Giuseppe Modugno

_RODATA() works only on arrays

Discussion created by Giuseppe Modugno on Feb 20, 2018
Latest reply on Feb 20, 2018 by LPCX support

#include <cr_section_macros.h>

static __RODATA(Flash_SN) const uint32_t sn_flash = 0x01020304;

 

It doesn't work, the linker put sn_flash variable in the main flash block (see below my memory layout). I need to write something similar to:

 

#include <cr_section_macros.h>

static __RODATA(Flash_SN) const uint8_t sn_flash[] = { 0x01, 0x02, 0x03, 0x04 };

 

What is the reason to this behaviour?

 

This is the memory layout in linking script auto-generated by MCUXpresso:

 

MEMORY
{
  /* Define each memory region */
  MFlash512 (rx) : ORIGIN = 0x4000, LENGTH = 0x7bff0 /* 507888 bytes (alias Flash) */
  Flash_SN (rx) : ORIGIN = 0x7fff0, LENGTH = 0x8 /* 8 bytes (alias Flash2) */
  Flash_MAC (rx) : ORIGIN = 0x7fff8, LENGTH = 0x8 /* 8 bytes (alias Flash3) */
  RamLoc32 (rwx) : ORIGIN = 0x10000000, LENGTH = 0x8000 /* 32K bytes (alias RAM) */
  RamAHB32 (rwx) : ORIGIN = 0x2007c000, LENGTH = 0x8000 /* 32K bytes (alias RAM2) */
}

 

MFlash512 starts from 0x4000 because I have a bootloader at the beginning of the Flash.

Outcomes