RUI3 initialize user settings section at compile time

Hello,

Is there any way to change the linker script to create a code section for placing a block with default device settings at the compiler time and read them by flash api.
Or another way to initialize the custom settings section used by the flash api at compile time? ?

Welcome to RAK forum @croman13n3c

I have no experience on modifying linker scripts. However, maybe you can use some macro definitions on code if you have custom settings needed that can be controlled at compile time.

I work with RAK3172 and made changes in linker script (define USERCFG memory region)

MEMORY
{
  BL     (rx)    : ORIGIN = 0x08000000, LENGTH = 24K    /* Bootloader */
  ROM    (rx)    : ORIGIN = 0x08006000, LENGTH = 196K   /* Application */
  USERCFG (rx)   : ORIGIN = 0x08037800, LENGTH = 28K    /* User configuration */
/*Originally RAM1 and RAM2 are the same size: 32K, but it is not enough size for stack*/
  RAM1   (xrw)   : ORIGIN = 0x20000000, LENGTH = 63K    /* Non-backup SRAM1 */
  RAM2   (xrw)   : ORIGIN = 0x2000FC00, LENGTH = 1K    /* Backup SRAM2 */
}

config_length = 2048;

and place section`s before RAM region

  .factoryConf : AT (0x00)
   {
        . = ALIGN (4);
        _factoryConf_begin = .;
        KEEP(*(.factoryConf  .factoryConf*))
        . = _factoryConf_begin + config_length;
        _factoryConf_end = .;
   } >USERCFG

   .reservedConf : AT (0x800)
   {
        . = ALIGN (4);
        reservedConf_begin = .;
        KEEP(*(.reservedConf  .reservedConf*))
        . = reservedConf_begin + config_length;
        reservedConf_end = .;
   } >USERCFG

   .userConf : AT (0x1000)
   {
        . = ALIGN (4);
        userConf_begin = .;
        KEEP(*(.userConf  .userConf*))
        . = userConf_begin + config_length;
        userConf_end = .;
   } >USERCFG

place const variable at custom section

volatile const CONFIG_t __attribute__((section (".userConf"))) userConfig =

according to map file all these sections placed at correct address.
But bootloader blocking to upload firmware with message:

[S] TRANSMISSION: block 0 (seq=1) sent

[S] ERROR: Expected ACK but got b'C' for block 1

Can bootloader block writing data to this address ?

Hi @croman13n3c ,

I am not familiar on the low level management of memory spaces of RAK3172 RUI3 implementation. I can try to support you by asking the R&D team. The way I understand it, you want to configure the USERCFG space.

image

However, linker script modification is not what we advise our customers but use the APIs we developed under RUI3 whenever possible.

Yes, modification of linker script is last method i prefer to use. But its only one way to place var`s at specific address of flash.
This needed to make struct with settings been initialized after flashing device

After that i can use flash api of RUI3 to save and load config.

Maybe I don’t get it why you can’t write using RUI3 flash api?

Device settings are load after boot.
If settings are not placed there at the time of programming the validation mechanism will generate a message that they are corrupted, because checksums do not match.
To fix these is necessary to add the operation to write them at the production stage (it’s not a necessary extra job).

But if they placed at offset of user settings (MCU_USER_DATA_NVM_ADDR 0x08037800 ) i can use api to manupulate them.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.