This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

can we run soft device from RAM instead of flash?

 is there any way to run soft device from RAM instead of flash? which function we can use for this .i am using s140 for nrf52840.

Parents
  • Nope. SD must run from flash. Google: Static linking in C language.

    Note that there is next to nothing to save in current consumtion - SD runs often, but not for a long time.

  • ok thanks let see. and i have one issue .

    i am trying  to run our code from ram instead of flash in nrf52840. in linker file we create one section like this


    MEMORY
    {
    FLASH (rx) : ORIGIN = 0x26000, LENGTH = 0xda000
    RAM (rwx) : ORIGIN = 0x20003bb8, LENGTH = 0x9000
    NO_INIT (rwx) : ORIGIN = 0x20009000, LENGTH = 0x2400000
    }

    SECTIONS
    {
    }

    SECTIONS
    {
    .no_init (NOLOAD):
    {
    PROVIDE(__start_no_init_data = .);
    KEEP(*(SORT(.no_init*)))
    PROVIDE(__stop_no_init_data = .);
    } > NO_INIT
    }

    and use txn fxn

    __attribute__((used, long_call, section(".no_init"))) void main(void)

    {
    ble_init();

    }

    code is succesfully build but in jlink we dont see any print msg and nrf connect dont see my device name .  can u suggest me how can i run our main fxn in ram instead of flash

  • The .noinit section won't be populated with code - no initialization means random data (empty on POR).

    Try just using ".data" section. The startup code must copy your function from flash to RAM, this is always done for the data section.

    Note: Your NO_INIT section seems to be waaaaay bigger than available RAM, and it overlaps the actual RAM section. Both are not a good idea.

  • and can the application run from ram and linked with soft device ? because soft device run from flash so i am confused. can those be linked

  • and i am also using data section  but its give error

    s/main.c:38:(.data+0x2): relocation truncated to fit: R_ARM_THM_CALL against symbol `ble_init' defined in .text.ble_init section in _build/nrf52840_xxaa_Ble_Interface.c.o

  • The gcc ARM documentaion suggests using

    #pragma long_calls

    as workaround.

    ARM Cortex-M cannot use a single instruction to call functions outside a ±16MB range, and thus won't be able to call flash from RAM. Workaround is to put the address into a register and use this for the call (BLX).

  • as per your suggestion i am using like this  in bilnky example

    #pragma long_calls 


    __attribute__((used, long_calls, section(".data"))) int main(void)
    {
    /* Configure board. */
    bsp_board_init(BSP_INIT_LEDS);

    /* Toggle LEDs. */
    while (true)
    {
    for (int i = 0; i < LEDS_NUMBER; i++)
    {
    bsp_board_led_invert(i);
    nrf_delay_ms(500);
    }
    }

    but we get same error

    bilnkyoutsdh/Applications/main.c:66:(.data+0x6): relocation truncated to fit: R_ARM_THM_CALL against symbol `bsp_board_init' defined in .text.bsp_board_init section in _build/nrf52840_xxaa_boards.c.o
    bilnkyoutsdh/Applications/main.c:73:(.data+0x12): relocation truncated to fit: R_ARM_THM_CALL against symbol `bsp_board_led_invert' defined in .text.bsp_board_led_invert section in _build/nrf52840_xxaa_boards.c.o
    collect2.exe: error: ld returned 1 exit status

Reply
  • as per your suggestion i am using like this  in bilnky example

    #pragma long_calls 


    __attribute__((used, long_calls, section(".data"))) int main(void)
    {
    /* Configure board. */
    bsp_board_init(BSP_INIT_LEDS);

    /* Toggle LEDs. */
    while (true)
    {
    for (int i = 0; i < LEDS_NUMBER; i++)
    {
    bsp_board_led_invert(i);
    nrf_delay_ms(500);
    }
    }

    but we get same error

    bilnkyoutsdh/Applications/main.c:66:(.data+0x6): relocation truncated to fit: R_ARM_THM_CALL against symbol `bsp_board_init' defined in .text.bsp_board_init section in _build/nrf52840_xxaa_boards.c.o
    bilnkyoutsdh/Applications/main.c:73:(.data+0x12): relocation truncated to fit: R_ARM_THM_CALL against symbol `bsp_board_led_invert' defined in .text.bsp_board_led_invert section in _build/nrf52840_xxaa_boards.c.o
    collect2.exe: error: ld returned 1 exit status

Children
No Data
Related