Discussion:
Interacting with the linker scripts in the STM32F4 BSP
Mr. Andrei Chichak
2014-07-14 22:53:03 UTC
Permalink
I have a block of parameters that I want to place in FLASH memory at a known location, say the last block of FLASH so that I can read and write it later. (these processors don’t have EEPROM but you can use a page of FLASH as an adequate replacement for internal configuration parameter storage at the cost of halting the bus until the writes complete)

It needs to be on a page boundary, because the FLASH is erased in 2K pages.

Since gcc doesn’t allow syntax like:

static volatile const PARAM_T fu @ 0x000FF800;
static volatile const PARAM_T fu __attribute__((at(0x000FF800)))
or
static volatile const PARAM_T fu __at__ 0x000FF800

I have to use the linker script to push the structure to the target location. The STM32F4 BSP has a set of scripts but there is a lot of existing thought that I don’t want to violate.


Is it possible to add a project specific linker script so that I can place a struct at a particular FLASH location without triggering the .unexpected_sections portion of linkcmds.base? I’ve tried a few things, but the trick escapes me.

Thanks,
Andrei



Typical lame attempt:



typedef struct {
uint8_t filler[2048];
} PARAM_PAGE_T;

static volatile PARAM_PAGE_T flashParamsPage __attribute__((section(".params"))) ;



MEMORY {
PARAM_INT : ORIGIN = 0x000FF800, LENGTH = 2k
}

SECTIONS {
.params : {
*(.params)
} > PARAM_INT
}
Mr. Andrei Chichak
2014-07-16 19:58:57 UTC
Permalink
No go,

This is actually being used with an STM32F373 with 256K of FLASH so I used:


MEMORY {
PARAM_INT : ORIGIN = 0x0003F800, LENGTH = 2k
}

SECTIONS {
.params : {
*(.params)
} > PARAM_INT
}

INCLUDE linkcmds.base


and adding this to the command line using the -T option I get

/Users/andreichichak/development/rtems/4.11/bin/arm-rtems4.11-gcc -B/Users/andreichichak/development/rtems/4.11/arm-rtems4.11/stm32f37x/lib/ -specs bsp_specs -qrtems -march=armv7-m -mthumb -L/Users/andreichichak/Documents/workspace/libstm32f373/lib -T ../project.linkcmds -o “TruckSensor.exe" ./src/adc.o ./src/cantask.o ./src/errorlogger.o ./src/flash.o ./src/gpio.o ./src/init.o ./src/led.o ./src/machine.o ./src/monitor.o ./src/pressure.o ./src/system_stm32f37x.o -llibstm32f373

/Users/andreichichak/development/rtems/4.11/lib/gcc/arm-rtems4.11/4.8.2/../../../../arm-rtems4.11/bin/ld:linkcmds.base:64: warning: redeclaration of memory region `UNEXPECTED_SECTIONS’

linkcmds.base:295 cannot move location counter backwards (from 0000000020001188 to 0000000020000000)

collect2: error: ld returned 1 exit status
make: *** [TruckSensor.exe] Error 1


It looks like the regular linkcmds.base is being executed twice.


Thanks,
Andrei
Post by Mr. Andrei Chichak
MEMORY {
PARAM_INT : ORIGIN = 0x000FF800, LENGTH = 2k
}
SECTIONS {
.params : {
*(.params)
} > PARAM_INT
}
Use the above and add (plus the base memory regions)
INCLUDE linkcmds.base
or
INCLUDE linkcmds.name_of_bsp
at the bottom.
--
Sebastian Huber, embedded brains GmbH
Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone : +49 89 189 47 41-16
Fax : +49 89 189 47 41-09
PGP : Public key available on request.
Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
_______________________________________________
users mailing list
http://lists.rtems.org/mailman/listinfo/users
--------------------
Andrei Chichak

'62 Morris Mini Traveller w/ 1275 'S engine
'97 Volvo 855 374,000 km
’99 VW Golf 130,000 km

Finnish: Terho Virtanen
Elvish: Tuor Vardamir

Loading...