Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 21 Next »

x-boot (external boot code) serves as the first-stage boot-loader, residing in storage devices such as eMMC, NAND flash, or SD cards. It is loaded into the system SRAM by i-boot, as DRAM is not yet ready during this phase. As it operates in SRAM, its overall size, including code, data, and stack, must not exceed the capacity of the system SRAM. The primary objective of x-boot is to initialize the DDR SDRAM controller and PHY, conduct calibration on the PHY and signals, and once calibrated, make the DRAM ready for use.

Subsequently, x-boot loads the images of TF-A (BL31), OP-TEE (BL32), and U-Boot (BL33) from a storage device into DRAM. The CPU (core 0) then switches itself from 32-bit mode to 64-bit by triggering a software reset. It proceeds to awaken other cores (core 1, 2, 3) and transitions them to 64-bit mode. Finally, all cores execute TF-A.

Contents

Features

  1. Output log at UART0 (set at 115,200 bps by i-boot).

  2. Support loading firmware of DDR3, DDR4, or LPDDR4 from boot devices.

  3. Support initialization of DDR controller and PHY.

  4. Support 1D and 2D training of PHY and signals for DDR3, DDR4, and LPDDR4 SDRAM.

  5. Support loading images of TF-A (BL31), OP-TEE (BL32), and U-Boot (BL33) from boot devices.

  6. Support secure boot:

    • Verify digital signature of fip (including TF-A and OP-TEE) and U-Boot images.

    • Decrypt fip image.

  7. Support warm-boot:

    • Switch CA55 to 64-bit mode and jump to run TF-A.

  8. Support reading and writing OTP bits using Sunplus OTPTool through UART0.

Flow

The x-boot initiation begins with the "_start" subroutine, written in assembly code, responsible for initializing the C execution environment. The process then proceeds to execute the "xboot_main" subroutine, which serves as the main C function within x-boot.

image-20240125-055235.png

The "xboot_main()" subroutine begins with the "init_cdata" subroutine for initializing C global data. It is followed by the "init_uart()" subroutine to initialize all UARTs and the "init_hw()" subroutine for hardware initialization. Finally, the sequence progresses to run the "boot_flow()" subroutine.

image-20240125-055327.png

The "boot_flow()" subroutine starts by initializing the DDR SDRAM controller and PHY, followed by PHY training. It then initializes the controller of the boot device, which is recorded in the C structure g_bootinfo. Subsequently, it loads the fip (firmware image package) image and U-Boot image from the respective partitions within the boot device, storing them in DRAM. Finally, the process advances to execute the "boot_uboot()" subroutine.

image-20240125-055100.png

The "boot_uboot()" subroutine begins by verifying the images of fip and U-Boot. Upon successful verification, it moves the TF-A and OP-TEE images from the load position to the dedicated location in DRAM. Subsequently, it executes the “go_a32_to_a64()” subroutine.

In the “go_a32_to_a64()” subroutine, it configures the CPU reset vector to the entry-point of the a64up module for all cores and triggers a warm-reset to switch itself (core 0) to 64-bit (aarch64) mode.

After the warm-reset, CPU core 0 operates in the a64up module at 64-bit mode. It then wakes up cores 1, 2, and 3, switching them to 64-bit (aarch64) mode by triggering a warm-reset (in i-boot). Following the warm-reset, cores 1, 2, and 3 operate in the a64up mode at 64-bit mode. Subsequently, all cores make a jump to TF-A (BL31).

image-20240125-055619.png

The flow chart below illustrates the process from i-boot's reset vector to the jump to TF-A for all cores

image-20240122-104526.png

Source files

The source files for x-boot are located in the "boot/xobot/" directory under the project's top folder. The entry point for x-boot is the label "_start" in the assembly file "arch/arm/sp7350/start.S". Notably, "_start" is situated at an offset of 32 bytes within the x-boot module, with the initial 32-byte space reserved for a header. The "_start" subroutine initializes the C execution environment and subsequently jumps to the C main function, the "xboot_main()" subroutine in the "xboot.c" file. The "xboot.c" file serves as the top-level control file for x-boot, governing the entire flow of operations.

The table below lists and explains the main files and folders in x-boot:

Files or folders

Descriptions

adc/

Contains subroutines for ADC.

arch/arm/sp7350

Houses CPU-relevant codes, including:

  • a64up module

  • CPU and cache-related codes

  • MMU table page creating codes

  • Linker script file: boot.ld

  • Start-up file: start.S

bin/

Output folder

common/

Contains common code, such as verifying images.

configs/

Contains defconfig files for boards.

cpio/

Contains CPIO codes.

draminit/

Contains DRAM-related codes.

fat/

Contains codes for FAT file-system operations.

i2c/

Contains subroutines for I2C interface.

include/

Contains many constant definitions used in x-boot.

lib/

Contains images CRC verification codes.

nand/

Contains SPI-NAND and 8-bit NAND drivers.

otp/

Contains subroutines for accessing OTP.

romshare/

Contains the entry table for accessing secure functions in i-boot.

sdmmc/

Contains SD card and eMMC drivers.

tools/

Contains some utilities used by x-boot.

usb/

Contains USB2.0 and USB3.0 drivers.

warmboot/

Contains a concise version of x-boot for running during warm-boot.

Kconfig

Menu config file of x-boot.

Makefile

Make file of x-boot

xboot.c

Main C file of x-boot.

Driver specifications and features

x-boot incorporates a range of device drivers, each offering specific features to facilitate various operations. The following table outlines the detailed specifications and features of these drivers.

Drivers

Specification and features

8-bit NAND

  1. Supports loading U-Boot image from 8-bit NAND flash.

  2. Requires the first block of 8-bit NAND flash to contain the Sunplus Boot Profile Header.

  3. Supports reading 1K60 ECC sectors.

  4. U-Boot image should be stored in 1K60 sectors.

eMMC

  1. Supports loading U-Boot image from the eMMC device.

  2. U-Boot image should be stored in the User Data Area.

  3. Requires eMMC to contain the GUID Partition Table (GPT).

I2C driver

  1. Supports I2C master mode.

  2. Supports 100kHz and 400kHz speeds.

NVMEN (OTP)

  1. Supports read and write OTP.

SD card

  1. Supports loading U-Boot image from an SD card.

  2. U-Boot image should be stored at the root directory of the first partition of the SD card.

  3. File-name of the U-Boot image should be “u-boot.img.”

  4. Requires the first partition of the SD card to be in FAT32 or FAT16 format.

SPI-NAND

  1. Supports loading U-Boot image from SPI-NAND flash.

  2. Requires the first block of SPI-NAND flash to contain the Sunplus Boot Profile Header.

  3. Supports reading 1K60 ECC sectors.

  4. U-Boot image should be stored in 1K60 ECC sectors.

  5. Supports SPI-NAND flash mounted in X1 or X2 position.

USB2.0 Host

  1. Supports loading U-Boot image from a USB flash drive in the USB2.0 port.

  2. U-Boot image should be stored at the root directory of the first partition of the USB flash drive.

  3. File-name of the U-Boot image should be “u-boot.img.”

  4. Requires the first partition of the USB flash drive to be in FAT32 or FAT16 format.

  5. Supports high-speed read operation only

USB3.0 Host

  1. Supports loading U-Boot image from a USB flash drive in the USB3.0 port.

  2. U-Boot image should be stored at the root directory of the first partition of the USB flash drive.

  3. File-name of the U-Boot image should be “u-boot.img.”

  4. Requires the first partition of the USB flash drive to be in FAT32 or FAT16 format.

  5. Supports high-speed read operation only

SRAM Space Allocation

To facilitate program maintenance and data sharing, x-boot and i-boot utilize the same SRAM segment division and structure. The figure below illustrates the segmentation of SRAM into 9 segments, ordered from low to high addresses: xboot_buf, bootinfo, boothead, a64up, cdata, storage_buf, stack, bootcompat, and spacc_ram.

image-20240125-081732.png

Let's delve into the purpose of each segment:

  • xboot_buf: This segment houses the x-boot program, where it is loaded and executed.

  • bootinfo: Contains the bootinfo segment with the g_bootinfo structure, recording essential boot-related information.

  • boothead: The boothead segment stores the g_boothead array, used for GPT data in eMMC or header data in NAND flashes.

  • a64up: Dedicated to the a64up module, responsible for transitioning the CPU from 32-bit mode to 64-bit mode.

  • cdata: This is the C data segment, hosting global and static variables in C.

  • storage_buf: Reserved for device driver data related to boot devices like eMMC and NAND flash. Multiple boot device drivers share this space during a single boot, with only one boot device driver utilized per boot.

  • mmu_pgtbl: The page table of MMU.

  • stack: The stack segment where the stack for C is located.

  • bootcomp: CPU run control fields.

  • reserved: This segment is designated for warm-boot retention data.

During system boot, i-boot reads boot-related information from the boot switch and the OTP (One-Time Programmable) memory within the chip. This information is then stored in the C structure g_bootinfo. x-boot directly utilizes the data in the g_bootinfo structure to determine the boot mode and process.

  • No labels