Re: Question about non-XIP boot


Benjamin Walsh <benjamin.walsh@...>
 

On Mon, Sep 19, 2016 at 11:19:47AM +0800, Tidy Jiang wrote:
Hi All,

I'm reading the boot code for cortex-m, but confused about
something, please help me.

Before jumping to C code:

void _PrepC(void)
{
relocate_vector_table();
enable_floating_point();
_bss_zero();
_data_copy();
_Cstart();
CODE_UNREACHABLE;
}

---------------------------------------------------------

#ifdef CONFIG_XIP
static inline void relocate_vector_table(void) { /* do nothing */ }
#else
static inline void relocate_vector_table(void)
{
/* vector table is already in SRAM, just point to it */
_scs_relocate_vector_table((void *)CONFIG_SRAM_BASE_ADDRESS);
}
#endif

-----------------------------------------------------------

In non-XIP mode, from my view, before relocate vector table to RAM,
we should copy the data from flash to RAM. But above code firstly
relocates and then copy data, why ?
In non-XIP mode, the image is supposed to already be in RAM, including
the data, so there is no data to copy from the flash. _data_copy() does
nothing in that case.

Join devel@lists.zephyrproject.org to automatically receive all group messages.