This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CPP added to project creates not working project?

Hi I'm just wondering why my project can not be started anymore. I just added some files on CPP sources to a pure C project.

Now I made some interface functions so the C code is able to call some of the CPP functions. But as I now load the project in the debugger it says constantly processor in reset or  a reset occured on the target system. See pics.

The Reset vector is in both working and not working program mapped to the same address... 00200031  ResetISR 

Additionally the Loader of the Debugger posts this message:

why is there suddenly some code which is mapped to an uncorrect memory section?


I just found out that the program starts to work uncorrectly on file boot.asm line 211

        ;*------------------------------------------------------
        ;* Perform all the required initializations when
        ;* _system_pre_init() returns non-zero:
        ;*   - Process BINIT Table
        ;*   - Perform C auto initialization
        ;*   - Call global constructors
        ;*------------------------------------------------------
        BL      PRE_INIT_RTN
        CMP     R0, #0
        BEQ     bypass_auto_init
        BL      AUTO_INIT_RTN
bypass_auto_init:

This line is BL AUTO_INIT_RTN seems to be that the constuructor of a global class instance is called there, but it is mapped maybe to a not working area...

It does not return on the new code from that line, in the old code it just goes on to bypass_auto_init (label)

  • Hello Andreas,
    Would be be possible to provide a reproducible test case? If you are willing to provide one but do not wish to post it publicly, send me a private message via E2E.

    Thanks
    ki
  • I try to setup a test project, but it is not compilable until now (too many include dependencies).
    At least for now I found out that the program works if I don't use a global instance of a class but instead use a local one.

    The comment in the asm file was a good hint that it is a problem with the constructor of the global instance. maybe I should create a class instance only on heap?
  • I really try to understand where the linker should put the constructor calls of global class instances.
    I added a test class of the same structure to the testprogram and it does work also with a global class instance. so maybe it is just a problem with the TI-startup code?
  • I found the error, it was simply a linker command file misconfiguration.

    if a global instance of a class is added to the project, it seems that the compiler generates a new section called .init_array


    if the linker command file is not configured correpondingly the section will be placed on the lowest possible address configured in the linker command file.

    In my case there was a second misconfiguration in the linker file so, a section was missing one digit of the address which was lying in nowhere land (so no Flash memory there)

    This triggered constantly resetting the processor!