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

Software reset and RAM

Hi!

I am using IAR compiler for my project

I declare global variable

__no_init u32 uPowernResetSignature;

in my code I assign value to this variable

uPowernResetSignature=0x11223344;

After that I perform software reset using

NVIC_SystemReset();

After that I check  uPowernResetSignature variable.

I expect to see value 0x11223344 because according to datasheet software reset should not change RAM.

I also expect that compiler will not init this variable because __no_init  declaration.

But after reset I see in debugger 0.

Can somebody explain why and help how to solve it?

Thank you

Parents
  • Hi,

    You are correct that on soft reset RAM does not change, and that the compiler will not initialize a __no_init variable.

    We did something similar to this in the DFU bootloader of nRF5 SDK v11, in order to allow the application to leave messages when rebooting into the bootloader. From <sdk folder>/examples/dfu/bootloader/dfu_ble_svc.c:

    __no_init static dfu_ble_peer_data_t m_peer_data     @ 0x20003F80;                               /**< This variable should be placed in a non initialized RAM section in order to be valid upon soft reset from application into bootloader. */
    __no_init static uint16_t            m_peer_data_crc @ 0x20003F80 + sizeof(dfu_ble_peer_data_t); /**< CRC variable to ensure the integrity of the peer data provided. */

    While I cannot explain why it did not work in your case, I have some suggestions for what to look at: Is uPowernResetSignature a global static variable? Are you sure the issue is not with the debugger? Does adding a fixed location help?

    You may also want to have a look at the linker file of the SDK 11 bootloader example (<sdk folder>/examples/dfu/bootloader/pca10040/dual_bank_ble_s132/iar/dfu_iar_nRF5x.icf),I think you may need this line in your linker file:

    do not initialize  { section .noinit };

    Please note that I am not an expert on this, and so others may have better tips for how to get it working.

    Regards,
    Terje

  • Thank you.

    this is already in link file.

    do not initialize  { section .noinit };

    But as I wrote my variables are not static. They are global variables. I will declare static and try again..

    But as I know static only restrict scope. Or I missed something? Can you advice?

    ABout debuger I will try without.

  • When I do it staitc

    __no_init static u32 uPowernResetSignature;

    In icf file

    initialize by copy { readwrite };
    do not initialize  { section .noinit };

    in map file appears .noinit section that was not before I add static

    "P2", part 2 of 3:                           0xa04
      .noinit             uninit   0x2000370c      0x4  SO_SystemOperations.o [1]
      CSTACK                       0x20003710    0x800  <Block>
        CSTACK            uninit   0x20003710    0x800  <Block tail>
      HEAP                         0x20003f10    0x200  <Block>
        HEAP              uninit   0x20003f10    0x200  <Block tail>
                                 - 0x20004110    0xa04

    But after software reset variable still become zero. Any ideas?

Reply
  • When I do it staitc

    __no_init static u32 uPowernResetSignature;

    In icf file

    initialize by copy { readwrite };
    do not initialize  { section .noinit };

    in map file appears .noinit section that was not before I add static

    "P2", part 2 of 3:                           0xa04
      .noinit             uninit   0x2000370c      0x4  SO_SystemOperations.o [1]
      CSTACK                       0x20003710    0x800  <Block>
        CSTACK            uninit   0x20003710    0x800  <Block tail>
      HEAP                         0x20003f10    0x200  <Block>
        HEAP              uninit   0x20003f10    0x200  <Block tail>
                                 - 0x20004110    0xa04

    But after software reset variable still become zero. Any ideas?

Children
Related