lpcware

M0APP issue

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by charchar on Tue Mar 24 11:51:37 MST 2015
I've been tracking down an issue that has to do with static initializer data for M0 code when using the M0APP mechanism.  Essentially the initializer data isn't being set, so for example, this program on the M0 side:

int foo=0x1234;

int main(void)
{
   printf("%x\n", foo);
}

will print random numbers.  Here's why ---

The M0 makefile does this:

arm-none-eabi-objcopy --target elf32-littlearm --verbose --strip-all --redefine-sym __vectors_start__=__vectors_start___core_m0app --keep-symbol __vectors_start___core_m0app --rename-section .text=".core_m0app" --rename-section .data=".core_m0app.data" --rename-section .data_RAM2=".core_m0app.data_RAM2" --rename-section .data_RAM3=".core_m0app.data_RAM3" --rename-section .data_RAM4=".core_m0app.data_RAM4" --rename-section .data_RAM5=".core_m0app.data_RAM5"

(or similar) to rename the sections so the M4 side can include them in its linker script:

    .data_RAM4 : ALIGN(4)
    {
       FILL(0xff)
       __core_m0app_START__ = .; /* start of slave image */
         KEEP(*(.core_m0app))
       __core_m0app_END__ = .; /* end of slave image */
       ASSERT(!(__core_m0app_START__ == __core_m0app_END__), "No slave code for _core_m0app");

But the line KEEP(*(.core_m0app)) fails to pick up the renamed data sections above --- e.g. .core_m0app.data doesn't match the wildcard, but

KEEP(*(.core_m0app*)) does.  (note the extra * inserted)

This one's particularly crazy-making because when attaching the debugger to the M0, the debugger typically reloads the program and the problem goes away (and it will work fine until the next cold reset).





Outcomes