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

Wrong initialization value in static variables

Hi,

I'm developing a node based on the nRF52840-QIAA rev. B.

I'm using Eclipse Neon and GCC-toolchain for coding. Softdevice is S140 5.0.0.2 alpha and SDK is V14.2.

For Debugging I'm using an PCA10056 (nRF52840 PDK).

I'm always running into Error as soon as i try to interact with the softdevice. For example when calling nrf_sdh_enable_request().

While Debugging I've noticed that static variables like m_nrf_sdh_enabled (which is of type bool) don't seem to get initialized correctly.

Instead of "false", the value is an integer value. Depending on the configurations in sdk_config.h or the settings in the linker script for RAM start adress, this value changes.

Is this a Problem with the settings in linker script or what could it be?

Note: I'm using the default linkerscript provided in the examples library from ble_peripheral/ble_app_template 

Thanks for your help and advises!

Dominic

  • Hello,

    I do not have a solution for you problem, but hopefully someone here in the open forum have experienced the same and may help you.

    I would like to make a recommendation in general, because I see many issues using Eclipse, such as:

    • Issues to integrate toolchain in Eclipse
    • Issues setup debugging in Eclipse
    • Issues setup project settings in Eclipse

    Most of issues are caused by Eclipse is not natively support in nRF5 SDK, and there is no plan to do so.

    So instead, have you considered using SEGGER Embedded Studio (SES) for development?

    Latest nRF5 SDK releases do support SES and some of the advantages using SES are:

    • SDK examples are setup with SES projects ready to compile and run
    • Debugger is integrated
    • GCC compiler
    • Multi-platform (Linux, Windows, OSX)
    • No code limitations using nRF devices for development

    For more information, also check out: https://www.segger.com/products/development-tools/embedded-studio/

    Best regards,
    Kenneth

  • Hi Kenneth,

    Toolchain and Debugging are working fine with my Eclipse setup.

    I have some code which is executed before interfacing with the softdevice and this part is running fine and can be debugged without any Problems.

    Thanks for the hint about SES. I'll check this out as soon as possible. But I would still prefer to get the code working within Eclipse, as this IDE is used also for other Projects in our Company.

    Best regards,

    Dominic

  • Does anyone else have some hints or recommendations?

  • All static variables are located in .bss segment. By default in startup code you should erase .bss section of RAM before code start.

    FALSE value equal to 0, so I suppose your startup code has wrong init sequence. Please set the breakpoint at Reset_Handler address and check if _bss_start__ and __bss_end__ have the correct value. Also in .map file address of m_nrf_sdh_enabled shoul be between these values.

  • Hi ekrashtan,

    I tried to check your hints but when I set a breakpoint in the startup-file at the very beginning of the Reset_Handler, then this Breakpoint is never hit.

    Some lines below the Reset_Handler I saw this comment in the startup code:

    /* Call _start function provided by libraries.
     * If those libraries are not accessible, define __START as your entry point.
     */

    Could this be a Problem, if i don't set this correctly?

    __bss_start__ is at 0x200021fc

    __bss_end__ is at 0x200035dc

    m_nrf_sdh_enabled is at 0x20003368

    So this variable is located between bss_start and bss_end.

    RAM ORIGIN is set to 0x20002088 in linkerscript, as the correct address could only be known after the first enable of the softdevice as far as i know. This setting is made according to the ble_app_template from the sdk.

    Best regards 

    Dominic

Related