Try to be a little smart at guessing where _start is located in flash, instead
of relying on a binutils bug. Reported by: dim
This commit is contained in:
parent
a4ab528826
commit
71407681fd
@ -159,7 +159,7 @@ _startC(void)
|
|||||||
#if defined(FLASHADDR) && defined(LOADERRAMADDR)
|
#if defined(FLASHADDR) && defined(LOADERRAMADDR)
|
||||||
unsigned int pc;
|
unsigned int pc;
|
||||||
|
|
||||||
__asm __volatile("adr %0, _start\n"
|
__asm __volatile("mov %0, pc\n"
|
||||||
: "=r" (pc));
|
: "=r" (pc));
|
||||||
if ((FLASHADDR > LOADERRAMADDR && pc >= FLASHADDR) ||
|
if ((FLASHADDR > LOADERRAMADDR && pc >= FLASHADDR) ||
|
||||||
(FLASHADDR < LOADERRAMADDR && pc < LOADERRAMADDR)) {
|
(FLASHADDR < LOADERRAMADDR && pc < LOADERRAMADDR)) {
|
||||||
@ -173,11 +173,13 @@ _startC(void)
|
|||||||
*/
|
*/
|
||||||
unsigned int target_addr;
|
unsigned int target_addr;
|
||||||
unsigned int tmp_sp;
|
unsigned int tmp_sp;
|
||||||
|
uint32_t src_addr = (uint32_t)&_start - PHYSADDR + FLASHADDR
|
||||||
|
+ (pc - FLASHADDR - ((uint32_t)&_startC - PHYSADDR)) & 0xfffff000;
|
||||||
|
|
||||||
target_addr = (unsigned int)&_start - PHYSADDR + LOADERRAMADDR;
|
target_addr = (unsigned int)&_start - PHYSADDR + LOADERRAMADDR;
|
||||||
tmp_sp = target_addr + 0x100000 +
|
tmp_sp = target_addr + 0x100000 +
|
||||||
(unsigned int)&_end - (unsigned int)&_start;
|
(unsigned int)&_end - (unsigned int)&_start;
|
||||||
memcpy((char *)target_addr, (char *)pc,
|
memcpy((char *)target_addr, (char *)src_addr,
|
||||||
(unsigned int)&_end - (unsigned int)&_start);
|
(unsigned int)&_end - (unsigned int)&_start);
|
||||||
/* Temporary set the sp and jump to the new location. */
|
/* Temporary set the sp and jump to the new location. */
|
||||||
__asm __volatile(
|
__asm __volatile(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user