Exception in BSP initialization code when debugging a project with Segger Ozone – KBA234662
Background: In the case of debugging a CM4 application from an .elf file that contains images for both CM0+ and CM4 cores, Ozone by default extracts the SP value from the first vector table it finds, which is usually part of the CM0+ application. As a result, the cores use the same memory area as the stack and the CM0+ core overwrites the contents of the stack to the CM4 core.
Solution: There are two possible solutions.
Do not set the SP value in the debug project creation wizard at all. In this case, setting the SP value will be performed by the application that is running on the CM0+ core just before it starts the application on the CM4 core. For a newly created project, select the "Do not set" option in the "Initial Stack Pointer" section. For existing projects, find the _SetupTarget function in the project file and comment out the setting of the initial value of the "SP" register in it.
If the name of the symbol that contains the value of the top of the stack is known, it can be specified in the debug project creation wizard. However, the name of such a symbol depends on the compiler and is often not obvious. For example, for ModusToolbox™ projects compiled with GCC, this symbol is named "__StackTop". For a newly created project, select the "Location" option and specify the symbol name in the "Initial Stack Pointer" section. For existing projects, find the _SetupTarget function in the project file, and then change the way the SP register value is retrieved so that it is retrieved by known symbol's name.