none
Bootloader, global/static variables not initialized RRS feed

  • Question

  • Hi,

    we have trouble booting our ARM based board using Windows Embedded Compact 2013. Dependent on optimization settings and debug output, it sometimes works and sometimes not.

    Further investigations with Lauterbach debugger showed that some global/static variables were not initialized correctly. There is a sequence of "abcde...." lying around in the RAM, and the global/static variables are mapped to this area. Dependent on the settings mentioned above sometimes the variables are mapped to an already used area, sometimes to a free area.

    I can rule out accidentally overwriting this area by a wild pointer, as the "abcde...." is there immediately after download.

    Has somebody a hint how to prevent this problem?

    We are using:
    - Visual Studio 2015, Update 3
    - Platform Builder WEC 2013 Update 34
    - Development PC is Windows 7, 64 Bit
    - the Device is a board based in a NXP LS1021A, a Dual Core ARM Cortex-A7

    Regards,
    Oliver

    Friday, April 28, 2017 9:39 AM

Answers

All replies

  • Hi Oliver,

    Are you able to trace which variables are the problem? Hopefully, the sequence of "abcde" lying around in RAM should help you identify which values are getting changed by a controlled review of the settings you are changing.

    Sincerely,

    IoTGirl

    Friday, April 28, 2017 9:30 PM
    Moderator
  • Hi IoTGirl,

    thanks for your answer. It seems that this variables aren't initialized generally. We are in a very early stage of booting, our bootloader (FLDR, FirstLoader) contains assembler and C sources. But it doesn't contain a C runtime, which is usually responsible for initializing global/static variables.
    Do you have a hint for us what code we need to link and call that does this initialization? We had linked a bootcrt.lib, but we found out that it wasn't used, so we removed it.

    Regards,
    Oliver

    Thursday, May 4, 2017 6:12 AM
  • Hi Oliver,

    I believe that lib is critical... see https://social.msdn.microsoft.com/Forums/en-US/97849c50-39f9-4697-bf80-69da08c6a6c7/oal-startup-issue-in-wec-2013-beagleboardxm?forum=winembplatdev

    Are you starting with a BSP provided to you by NXP?

    Sincerely,

    IoTGirl

    Thursday, May 4, 2017 7:07 AM
    Moderator
  • Hi IoTGirl,

    I've put the lib back, but doesn't change the behavior. Removing it didn't produce a linker error. And we're not linking against fulllibc.lib or msvcrt.lib mentioned in your link. If one needs the bootcrt.lib, what function do we need to call from it, i.e. what function does the initialization of global/static variables?

    No, the BSP is not provided by NXP, we are using a BSP from DAB-embedded.

    Regards,
    Oliver

    Thursday, May 4, 2017 12:43 PM
  • Hi Oliver,

    What does DAB Embedded say about your experience? My assumption is they also started with a BSP from NXP and modified it.

    Sincerely,

    IoTGirl

    Thursday, May 4, 2017 3:41 PM
    Moderator
  • Oliver

    Your bootloader needs to call KernelRelocate (pTOC) which is done in BLCommon if you use it.
     



    Bruce Eitman (eMVP)
    Senior Engineer
    Bruce.Eitman AT Eurotech DOT com
    My BLOG http://geekswithblogs.net/bruceeitman
    I work for Eurotech

    • Marked as answer by OliSp Friday, May 5, 2017 6:33 AM
    Thursday, May 4, 2017 4:13 PM
    Moderator
  • Hi Bruce,

    thanks for your answer, that was the function we were looking for. As our FirstLoader doesn't use BLCommon, KernelRelocate was not called. I've added it to our code and now it is working.

    Regards,
    Oliver

    Friday, May 5, 2017 6:32 AM