Skip to content

Commit

Permalink
Merge pull request #42 from ssvb/20160506-fel-sdboot-for-a64
Browse files Browse the repository at this point in the history
Make fel-sdboot.sunxi usable on A64 and A80

This also fixes potential problems with older SoCs when using certain (cross-)toolchains. See the discussion of #42
  • Loading branch information
n1tehawk committed May 13, 2016
2 parents 938569f + b4d32f0 commit ce9cf33
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Binary file modified bin/fel-sdboot.sunxi
Binary file not shown.
21 changes: 20 additions & 1 deletion fel-sdboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,24 @@ dd if=fel-boot.sunxi of=/dev/sdX bs=1024 seek=8

void _start(void)
{
((void (*)(void))0xffff0020)();
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.
*/
asm volatile(".rept 32 \n nop \n .endr");

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

if (sctlr & (1 << 13)) /* SCTLR.V */
((void (*)(void))0xffff0020)();
else
((void (*)(void))0x00000020)();
}

0 comments on commit ce9cf33

Please sign in to comment.