Zephyr startup crash with CONFIG_CODE_DATA_RELOCATION

I'm trying to create a minimal executable that has a structure placed at a specific address in flash.  It looks like CONFIG_CODE_DATA_RELOCATION is needed to do this.  However, when I add CONFIG_CODE_DATA_RELOCATION to my prj.conf, the executable crashes in the Zephyr startup code.  Specifically in xip.c:49 here:
#ifdef CONFIG_CODE_DATA_RELOCATION
extern void data_copy_xip_relocation(void);

data_copy_xip_relocation(); // <-- crashes here
#endif /* CONFIG_CODE_DATA_RELOCATION */
The executable does not crash if CONFIG_CODE_DATA_RELOCATION is not defined.
My project doesn't use XIP, so not sure why the above code is like that or why it is crashing.  Any thoughts?
The repository with the code is [email protected]:denisbohm/firefly-zephyr.git and the folder is applications/blinky.
Parents
  • Hi Denis

    It shouldn't be necessary to use the CONFIG_CODE_DATA_RELOCATION configuration if what you need is to store some data at a specific location in flash. 

    Unfortunately there is no easy way to do this in Zephyr, but the fw_info module in the nrf repository is doing something similar in order to access data stored at a specific location in the flash. 

    The struct being stored is called m_firmware_info, and can be found in fw_info.c line 29

    In order for this to work you also need a custom linker script, in this case called fw_info.ld

    And then you also need to use the zephyr_linker_sources Cmake function in CamekeLists.txt, shown here

    Could you try to do something similar?

    Best regards
    Torbjørn

  • Hi Torbjørn,

    OK, thanks for looking into that.  I am using a custom linker script now while I was trying to figure out if CONFIG_CODE_DATA_RELOCATION would work.  The downside to the custom linker script is that I have to copy the one from Zephyr and just add one include at the right place for my customizations.  So each Zephyr release, I'll have to revisit that linker script.  Would be great if that linker script had config options for allowing the user to include their own snippets at various common places...  (CONFIG_CODE_DATA_RELOCATION has config include at the same place in the linker script that I added my include.  Maybe that include could be made more generic so that it can be used without CONFIG_CODE_DATA_RELOCATION.)

Reply
  • Hi Torbjørn,

    OK, thanks for looking into that.  I am using a custom linker script now while I was trying to figure out if CONFIG_CODE_DATA_RELOCATION would work.  The downside to the custom linker script is that I have to copy the one from Zephyr and just add one include at the right place for my customizations.  So each Zephyr release, I'll have to revisit that linker script.  Would be great if that linker script had config options for allowing the user to include their own snippets at various common places...  (CONFIG_CODE_DATA_RELOCATION has config include at the same place in the linker script that I added my include.  Maybe that include could be made more generic so that it can be used without CONFIG_CODE_DATA_RELOCATION.)

Children
No Data
Related