Loading...
 

Zephyr project on STM32

   Zephyr Workbench, a VSCode extension to manage Zephyr on STM32.
It enables users to easily create, develop, and debug Zephyr applications.
Main features:
  • Install host dependencies.
  • Import toolchain and SDK.
  • Create, configure, build and manage apps.
  • Debug STM32.
You can directly download it from the VSCode marketplace
For more details, visit the Zephyr Workbench

System Workbench for STM32


Move .rodata section in Linker

Hi all,

Not sure if this is the place to ask this, but I’m busy with a custom bootloader for the STM32F411RE (512K FLASH, 128K RAM) using OpenSTM32 eclipse IDE.

For the bootloader, its only function is to check a few CRC’s and copy data from one point to another, so a few flash writes. As such the actual code is very small.

I’m trying to keep it all in the first sector of flash, Sector 0 (0x08000000-0x08003FFF), 16KB.

In the linker file I reduced the size from 512K to 16K just to make sure its within size, and even though all the code could fit within 5K even (I looked at the map file), it ALWAYS tries to put the .rodata section at 0x08004000 (Sector 1), regardless of what I do in the linker. This is obviously outside my 16K boundary, so the build fails.

My linker just looks like this - snippets of it, very standard (I have a version number I’m putting at the end of the bootloader space):

VERSION_ADR = 0x08003FFC;
/* Specify the memory areas */
MEMORY
{
FLASH (rx)  : ORIGIN = 0x08000000, LENGTH = 16K
RAM (xrw)  : ORIGIN = 0x20000000, LENGTH = 128K
}

.version (VERSION_ADR):
{
KEEP(*(.version))
} > FLASH

/* Constant data goes into FLASH */
.rodata :
{
. = ALIGN(4);
*(.rodata) /* .rodata sections (constants, strings, etc.) */
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
. = ALIGN(4);
} > FLASH

The map output looks like this:

.fini 0x08000f60 0x8 c:/eclipse/plugins/fr.ac6.mcu.externaltools.arm-none.win32_1.3.0.201507241045/tools/compiler/bin/../lib/gcc/arm-none-eabi/4.9.3/armv7e-m/fpu/crtn.o
0x08000f68 . = ALIGN (0x4)
0x08000f68 _etext = .

.vfp11_veneer 0x08000f68 0x0
.vfp11_veneer 0x00000000 0x0 linker stubs

.v4_bx 0x08000f68 0x0
.v4_bx 0x00000000 0x0 linker stubs

.iplt 0x08000f68 0x0
.iplt 0x00000000 0x0 c:/eclipse/plugins/fr.ac6.mcu.externaltools.arm-none.win32_1.3.0.201507241045/tools/compiler/bin/../lib/gcc/arm-none-eabi/4.9.3/armv7e-m/fpu/crtbegin.o

.version 0x08003ffc 0x1
*(.version)
.version 0x08003ffc 0x1 src\main.o
0x08003ffc version

.rodata 0x08004000 0x318
0x08004000 . = ALIGN (0x4)
*(.rodata)
.rodata 0x08004000 0x10 HAL_Driver\Src\stm32f4xx_hal_rcc.o
0x08004000 APBAHBPrescTable
.rodata 0x08004010 0x300 src\crc.o
0x08004010 crc_tbl
0x08004110 crc_CCITT_Table
*(.rodata*)
.rodata.str1.4
0x08004310 0x4 c:/eclipse/plugins/fr.ac6.mcu.externaltools.arm-none.win32_1.3.0.201507241045/tools/compiler/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7e-m/fpu\libc.a(lib_a-impure.o)
.rodata._global_impure_ptr
0x08004314 0x4 c:/eclipse/plugins/fr.ac6.mcu.externaltools.arm-none.win32_1.3.0.201507241045/tools/compiler/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7e-m/fpu\libc.a(lib_a-impure.o)
0x08004314 _global_impure_ptr
0x08004318 . = ALIGN (0x4)

.rel.dyn 0x08004318 0x0
.rel.iplt 0x00000000 0x0 c:/eclipse/plugins/fr.ac6.mcu.externaltools.arm-none.win32_1.3.0.201507241045/tools/compiler/bin/../lib/gcc/arm-none-eabi/4.9.3/armv7e-m/fpu/crtbegin.o

.ARM.extab
*(.ARM.extab* .gnu.linkonce.armextab.*)

.ARM 0x08000f68 0x0
0x08000f68 __exidx_start = .
*(.ARM.exidx*)
0x08000f68 __exidx_end = .

.preinit_array 0x08000f68 0x0
0x08000f68 PROVIDE (__preinit_array_start, .)
*(.preinit_array*)
0x08000f68 PROVIDE (__preinit_array_end, .)

.init_array 0x08000f68 0x8
0x08000f68 PROVIDE (__init_array_start, .)
*(SORT(.init_array.*))
.init_array.00000
0x08000f68 0x4 c:/eclipse/plugins/fr.ac6.mcu.externaltools.arm-none.win32_1.3.0.201507241045/tools/compiler/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/armv7e-m/fpu\libc.a(lib_a-__call_atexit.o)
*(.init_array*)
.init_array 0x08000f6c 0x4 c:/eclipse/plugins/fr.ac6.mcu.externaltools.arm-none.win32_1.3.0.201507241045/tools/compiler/bin/../lib/gcc/arm-none-eabi/4.9.3/armv7e-m/fpu/crtbegin.o
0x08000f70 PROVIDE (__init_array_end, .)

.fini_array 0x08000f70 0x4
0x08000f70 PROVIDE (__fini_array_start, .)
*(SORT(.fini_array.*))
*(.fini_array*)
.fini_array 0x08000f70 0x4 c:/eclipse/plugins/fr.ac6.mcu.externaltools.arm-none.win32_1.3.0.201507241045/tools/compiler/bin/../lib/gcc/arm-none-eabi/4.9.3/armv7e-m/fpu/crtbegin.o
0x08000f74 PROVIDE (__fini_array_end, .)
0x08000f74 _sidata = LOADADDR (.data)

Anyone know how I can make the rodata section just follow on after the text section instead of defaulting to 0x08004000?

Never mind, I’m being stupid. It does this because of my VERSION being put at 0x08003FFE, then it aligns to 4 above that.

Stupid user error, apologies for the question.


France

Hi,

Yes, the order of output sections does matter: you’ve placed your .rodata section after the .version section, that is located in 0x3ff8, so with th econtent of the version, your .rodata section will go after that, which finish by being 0x4000...

Bernard (Ac6)


 

Newest Forum Posts

  1. Монтаж камина с грилем в Москве - установка и барбекю by KpddomErorb, 2025-05-10 18:28
  2. SPI on Nucleo_STMH533RE by royjamil, 2025-05-04 20:13
  3. SPI on Nucleo_STMH533RE by higginsa1, 2025-03-25 07:37
  4. SPI on Nucleo_STMH533RE by royjamil, 2025-03-23 11:31
  5. SPI on Nucleo_STMH533RE by higginsa1, 2025-03-23 09:33
  6. Configuring DMA for ADC in SW? by sam.hodgson, 2025-03-04 12:58
  7. Build a project in "release" mode by info@creosrl.it, 2025-02-20 18:12
  8. Build a project in "release" mode by info@creosrl.it, 2025-02-20 17:05
  9. Build a project in "release" mode by tang, 2025-02-20 10:36
  10. Build a project in "release" mode by info@creosrl.it, 2025-02-19 17:35

Last-Modified Blogs