diff options
Diffstat (limited to 'doc/boot/u-boot.md')
| -rw-r--r-- | doc/boot/u-boot.md | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/doc/boot/u-boot.md b/doc/boot/u-boot.md new file mode 100644 index 0000000..f919c38 --- /dev/null +++ b/doc/boot/u-boot.md @@ -0,0 +1,57 @@ +# U-boot +U-boot is a bootloader, not a firmware standard like UEFI. + +## U-boot boot methods +### U-Boot's own boot protocol +- Loads a flat binary or uImage +- Passes device tree in X0 (or R2 on 32-bit) +- No UEFI involved at all + +### U-Boot as UEFI firmware +- U-boot builded with CONFIG_EFI_LOADER +- Loads and runs 3efi PE32+ applications +- Bastion kernel should work perfectly + +### booti/bootm commands +- Loads Linux-format Image with header +- Passes device tree pointer + +### Modify u-boot to run bastion kernel +Worst case + +## Easiest method +is using u-boot as uefi loader +For it i need to build u-boot with CONFIG_EFI_LOADER. +U-boot provides the same EFI_SYSTEM_TABLE, EFI_BOOT_SERVICES, GOP, memory map and ExitBootServices() that real UEFI firmware does. +A lot of ARM Linux platforms use it - they run GRUB(grubaa64.efi) from u-boot and then run kernel. + +## Not-easiest method +Use u-boot's own boot proto +Here's how it works: +- The kernel is loaded as a flat bin (or a uImage wrapper) +- CPU is en EL2 or EL1, MMU off, caches off +- X0 = physical address of the device tree blof (FDT) +- No memory map - we need to parse dt's /memory node +- No framebuffer setup - we need to configure it from dt +- No ExitBootServices - u-boot is already gone when we get control + +### Kernel image format +U-boot expects same as Linux's Image format - a flat binary with 64-byte header: +``` +// ARM64 Image header (at offset 0 of the binary) +struct arm64_image_header { + uint32_t code0; // Executable code (branch instruction) + uint32_t code1; // Executable code + uint64_t text_offset; // Image load offset from start of RAM + uint64_t image_size; // Effective image size (0 = unknown) + uint64_t flags; // Kernel flags + uint64_t res2; // Reserved + uint64_t res3; // Reserved + uint64_t res4; // Reserved + uint32_t magic; // Magic: 0x644D5241 ("ARM\x64") + uint32_t res5; // Reserved (used for PE offset if EFI stub) +}; +``` + +# Current state +Bastion kernel supports only UEFI boot loading and not support own u-boot protos |
