Hi,
I have run into some issues while porting a C++ project from the MSP430 to the MSP432 with the initialization of global objects.
To be more specific, I have taken the uart example project from the MSPGCC examples folder and I am using the startup_msp432p401r_gcc.c and system_msp432p401r_gcc.c files (the latter is nearly empty, as I initialize most of the System later, I also threw away SystemCoreClockUpdate() since it seems to be never called). I have taken the compiler flags for the gcc arm compiler and included them in my own build script.
The C++ projects consists of many classes with only static members, so afaik these should be initialized in _start() (also called _mainCRTStartup() in newlib and the TI example). One of these classes contains an event queue, which is just an array filled with a certain struct. When the array is initialized, the compiler calls the constructor of each struct and somehow one of these constructor calls causes a jump into a not-executable region of the memory thereby resulting in a Usage Fault.
My guess is that some of the global initialization routines end up somewhere else in the flash and are maybe not copied correctly into RAM? But to be honest I am totally lost here, so I would be very grateful for any input.
I also looked into the examples provided by ARM (which are bundled with the arm-gcc toolchain) and they specifically mention that most of their Makefiles are not compatible with C++ global constructors/destructors. They provide one which is compatible with C++ and the difference seems to be that the C++ version defines __NO_SYSTEM_INIT, whereas the C version defines __STARTUP_CLEAR_BSS and __START=main . I have however not seen these macros in the TI examples and defining __NO_SYSTEM_INIT didn't help.
However both examples from ARM differ in their linkscripts, specifically the C++ version has a lot of lines with KEEP( ... ) (where ... is e.g. *(.init_array), *(.fini_array), *(.preinit_array), etc). I guess this might have some influence, but the differences between the ARM linkscripts and the TI linkscript are rather non-trivial. If someone is more fond of them, I would be grateful for any advice what these sections are and where to correctly include them (or whether they are needed at all on the MSP432).
Thanks in advance,
Dan


