2014年9月17日 星期三

[Banana Pi] [A20] Boot Process

===murmur begin===
    As a firmware engineer, I am interested in checking boot process in the beginning of development. The time spent will usually get times of reward soon, mostly during board bring up.

    However, Allwinner provides few documentation (in public), all I can find are

- A20 User Manual 2013-03-22
- A20 Product Brief
- A20 Datasheet

    All of them don't describe boot procedure clearly. poor Allwinner!

====murmur end===

    A20 User's manual says "After power on, the system will try to boot from SDC0, NAND, SDC2, SPI0, and USB, respectively. In Banana Pi, there is no NAND and the default boot device is SD0.
    According to BROM, linux-sunxi-org, the boot sequence of A20 (probably A10, A13, A31 as well) is as follows:

    BROM(FEL, 0xffff0000) -> BROM(0xffff4000, magic eGON.BRM at 0xffff4004) -> boot0 -> boot1 -> uboot


Note that according to here,

linux-sunxi u-boot is fully SPL enabled which means it supports booting directly on the bare metal with no help from the Allwinner bootloaders. U-Boot SPL fully replaces Allwinner boot0 & boot1.

[BROM]

    BROM in A20 is at the address 0xFFFF0000, After power up, arm core will fetch the first instruction at 0xFFFF0000 and execute it. The BROM is actually split up into two parts. FEL mode and eGON.BRM. FEL mode is at the start, at 0xffff0000 followed by eGON.BRM at 0xffff4000.

    At 0xffff0000 is the reset vector which jumps to 0xffff0028. There it loads 0xffff4000 into the program counter to be executed next.

    The extraction of BROM and diassemble can be found at github.

 [SD]

      Load 4k data from sdcard slot 0 beginning at offset 8k to the internal sram, check if the data has a magic string(eGON.BT0), if so, it's a boot0 head. Get boot0 size from the boot0 head, and load the whole boot0. If the checksum of boot0 is ok, will jump to boot0. Any of above is wrong, will jump to FEL.




SD Card Layout


start size usage
0 8KB Unused, available for partition table etc.
8 24KB Initial SPL loader
32 512KB u-boot
544 128KB environment
672 352KB reserved
1024 - Free for partitions

[TBD]
1. screenshot of memdump of boot codes 
2. details of files output for boot0 and u-boot

[Reference]
- BROM, linux-sunxi-org
- Bootable SD card, linux-sunxi-org
- Allwinner Bootloader
- 全志A1X启动步骤




沒有留言:

張貼留言