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


Locating data in a specific ROM section

Hi,

thanks for your help, I read the web page and used your example but I can’t allocate the section where I’d like:

Here is what I did:

Linker script:


MEMORY
{
ROM_Code (rx) : ORIGIN = 0x8000000, LENGTH = 448K
ROM_Data (r) : ORIGIN = 0x8050000, LENGTH = 256K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
}

/* Sections */
SECTIONS
{

....................

._const_data :
{
. = ALIGN(4);
*(.rodata)
*(.rodata*)
*(.text) /* .text sections (code) */
*(.text*) /* .text* sections (code) */
} >ROM_Data

}


Then in C code:

  1. define FL_SIZEOF_FLASH_SECTOR 127000 // 128 K
  2. define FL_NB_SECT_REQ_FOR_CONST_DATA 2



//! @brief const structure
typedef union _block_const_data_u
{
unsigned char bulkFL_SIZEOF_FLASH_SECTOR;

struct {
struct
{
unsigned char _number 20;
} infos;
} data;
} _block_const_data_t;

//! @brief block allocating all const structures
typedef struct _global_const_data_s
{
_block_const_data_t block2;

} _global_const_data_t;

volatile const _global_const_data_t s_const_data attribute ((section (“_const_data”))) =
{
.block0.data.infos._number = “12345678901234567890”,
.block1.data.infos._number = “12345678901234567890”
};


>>>> I expect the s_const_data structure to be allocated in .rodata of _const_data sections defined in linker script but I have the following error at link stage:

c:/utils/eclipse/eclipse-cpp-luna-sr1-win32/eclipse/plugins/fr.ac6.mcu.externaltools.arm-none.win32_1.1.0.201503101257/tools/compiler/bin/../lib/gcc/arm-none-eabi/4.8.4/../../../../arm-none-eabi/bin/ld.exe: project.elf section `_const_data’ will not fit in region `RAM’
c:/utils/eclipse/eclipse-cpp-luna-sr1-win32/eclipse/plugins/fr.ac6.mcu.externaltools.arm-none.win32_1.1.0.201503101257/tools/compiler/bin/../lib/gcc/arm-none-eabi/4.8.4/../../../../arm-none-eabi/bin/ld.exe: region `RAM’ overflowed by 130856 bytes

>>>> So obvisouly something is not correctly interpreted by gcc linker.


>>>> Map file excerpt:

._const_data
0x08050000 0x0
0x08050000 . = ALIGN (0x4)
*(.rodata)
*(.rodata*)
*(.text)
*(.text*)


>>> Nothing is allocated in the .text nor .rodata parts of the section _const_data

>>> And further in the map file, definititely unexpected interpretation:

_const_data 0x20000448 0x3e030 load address 0x0800d530
0x20000448 PROVIDE (startconst_data, .)
_const_data
0x20000448 0x3e030 ./src/Middlewares/gmx/mem/flash/flash_hal/flash_hal.o
0x20000448 s__const_data
0x2003e478 PROVIDE (stopconst_data, .)
0x2003e478 . = ALIGN (0x4)



>>> Any ideas about what’s wrong ?

Thanks,
Regards,
Sylvain