Skip to content

Commit

Permalink
fel-sdboot: Fix header corruption workaround
Browse files Browse the repository at this point in the history
Now that we have a better understanding of what's causing the issue
that prevented entering FEL sometimes, we can adjust the workaround
code to a proper solution.

Signed-off-by: Bernhard Nortmann <[email protected]>
  • Loading branch information
n1tehawk committed May 27, 2016
1 parent ce9cf33 commit 0ae03e9
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions fel-sdboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,21 @@ void _start(void)
unsigned int sctlr;

/*
* FEL mode fails to activate in an unpredictable way without
* this NOP padding. Minor changes in the code, such as checking
* the PC register (PC >= 0x10000) instead of SCTLR.V or doing
* jump instead of call to the FEL handler in the BROM sometimes
* break on A64 and sometimes break on A10/A13/A20. Trying to
* add DSB & ISB instructions and/or invalidating caches and
* BTB do not seem to make any difference. Only adding a bunch
* of NOP instructions in the beginning helps.
* In cases where insufficient padding is added by an old mksunxiboot,
* the _start entry point may be 0x20, which means that the instruction
* at 0x28 could get corrupted by the BROM - see
* https://patchwork.ozlabs.org/patch/622173/
*
* Apply a workaround to avoid (= skip over) that memory location.
* _main would be 0x30 in that particular case. With newer (properly
* fixed) versions of mksunxiboot, this code ends up at higher addresses
* and will be moot, but harmless.
*/
asm volatile(".rept 32 \n nop \n .endr");
asm volatile("b _main \n"
"nop \n"
"nop \n"
"nop \n"
"_main:");

asm volatile("mrc p15, 0, %0, c1, c0, 0" : "=r" (sctlr));

Expand Down

0 comments on commit 0ae03e9

Please sign in to comment.