porting nRF52 project from IAR to ARMGCC

Hi. I have a working IAR project based on the nrf52 SDK \nordic\examples\ble_peripheral\ble_app_uart. i am attempting to port the project to ARMGCC using VSCode. I am at a stage in the port where all the files compile and link and I am at the main() stepping in and out of functions using the GDB. i come across a function "localtime" and have a HARDFAULT. I verified the input parameters are valid.

thanks in advance.

Barry

Parents
  • Hi I'm back after a while. I am trying to retain some data structure in RAM in my c file, I define 

    #if defined(__ICCARM__)  // IAR Compiler
    #pragma location = HITLESS_START_ADDRESS
    __no_init volatile HITLESS_STRUCTURE hitless_struct; 
     #elif defined(__GNUC__)  // GCC Compiler
    /**
     * @brief Fixed-location hitless structure (retains values across soft reset).
     */
    __attribute__((section(".persistent")))
    __attribute__((used))
    volatile HITLESS_STRUCTURE hitless_struct;
     #else

    in my linker file I define:

    SECTIONS
    {
      . = 0x20003324;
      hitless_struct = .;
      .persistent (NOLOAD) :
      {
        KEEP(*(.persistent))
      } > RAM
    }

    When debugging, the address is set as designated; however, after a soft reset, the data is not retained.

    I appreciate any help you can provide.

    Barry

  • You are manually setting location counter to 0x20003324 just before defining the .persistent section. This might place .persistent at 0x20003324. Also this section can be silently overridden by a startup code zeroing out the .bss sections if .persistent overlaps it.

    I suggest use simpler declaration in C code like below

    __attribute__((section(".noinit")))
    volatile HITLESS_STRUCTURE hitless_struct;
    

    Also this in your linker script to tell the startup code to skip initialization on this section.

    .noinit (NOLOAD) :
    {
      . = ALIGN(4);
      KEEP(*(.noinit))
    } > RAM
    

Reply
  • You are manually setting location counter to 0x20003324 just before defining the .persistent section. This might place .persistent at 0x20003324. Also this section can be silently overridden by a startup code zeroing out the .bss sections if .persistent overlaps it.

    I suggest use simpler declaration in C code like below

    __attribute__((section(".noinit")))
    volatile HITLESS_STRUCTURE hitless_struct;
    

    Also this in your linker script to tell the startup code to skip initialization on this section.

    .noinit (NOLOAD) :
    {
      . = ALIGN(4);
      KEEP(*(.noinit))
    } > RAM
    

Children
No Data
Related