Boot0

From linux-sunxi.org
Jump to navigation Jump to search

Overview

Boot0 is the secondary program-loader, it's loaded by BROM in the Boot Process.

  • The information is incomplete, in the short time I'll fill in the missing data

Structure of Boot0

Offset Name Size Notes
0x00 B_INS 4 Branch instruction to Code Starting Point
0x04 Magic 8 Ascii string "eGON.BT0" (No Null-terminated )
0x0c Checksum 4 Simple 4-bytes Checksum (Before calculate checksum this must be 0x5F0A6C39 )
0x10 Size 4 Size of Boot0, it's must be 8-KiB aligned in NAND and 512-Bytes aligned in MMC
0x14 Code - Code of SPL. The size depends on the processor and if it 's loaded from SPI, NAND or MMC
  • clarification: These aren't the official names

Boot0 Example (armhf GAS)

_start:
  b code
  .ascii "eGON.BT0"
  .word 0x5F0A6C39, aligned_len

code:
  bl reset
  ...
  ...

Boot0 Checksum Example "C"

...
...
  checksum = 0;
  while(read(fd, &word, 4))
    checksum += word;

  lseek(fd, CHECKSUM_OFFSET, SEEK_SET);
  write(fd, &checksum, 4);
...
...