AIoT Yocto BSP & Boot Architecture

This section describes the system booting architecture and the BSP images information at each boot stage.

The BSP(board support package) has the following booting architecture:

../../_images/sw_yocto_boot-bootflow.png

AIoT Yocto BSP Boot Architecture

MediaTek SoC ROM code

The MediaTek SoC ROM code will try to boot from different medias:

  • eMMC

  • USB

  • UFS (MT8395 only)

The AIoT Yocto only allows to boot from eMMC and UFS. USB is only used as part of the image flashing process but cannot be used alone to boot to a Linux userspace.

eMMC Boot

When booting the SoC will chose which media to boot from. If the eMMC boot is chosen, the bootrom will look at the first boot partition to look for a second stage bootloader.

In case the ROM code fails to find a valid boot partition or valid second stage bootloader, it will automatically go into USB Boot.

UFS Boot

MT8395 provides support to boot from UFS storage. However, the prebuilt i1200-demo image does not provide such support because MT8395 P1V6 (i1200-DEMO) board does not have UFS storage.

Please refer to the mt8395-evb-ufs in meta-mediate-bsp layer to know how to configure for UFS booting.

USB Boot

In AIoT Yocto, the ROM code USB boot is used only for flashing.

BL2 (TF-A)

The second stage bootloader is based on Trusted Firmware A (TF-A). The AIoT Yocto BSP ships pre-built binaries for second stage bootloaders.

BL2 first initializes the hardware:

  • Initialize the system timer

  • Initialize and turn on the PLLs

  • Initialize the PMIC wrap component in order to be able to talk to the PMIC

  • Sends a baseband power-up signal to the PMIC to notify him of a successful power up.

  • Initialize the DDR

  • Initialize the eMMC

Once the hardware is initialized, BL2 will read 4MB of memory stored at bootloaders partition of the eMMC. The offset of bootloaders partition can be retrieved by TF-A API get_partition_entry(partition_name). The API provide the entry of bootloaders partition to find the fip.bin file. This partition section should contains the fip.bin file.

Firmware Image Package (FIP) is a packaging format used by TF-A to package firmware images. In AIoT Yocto the FIP contains BL31, BL32, BL33 and optionally some certificates when secure boot is enabled.

BL2 will read the fip package and execute each of the binary it contains.

BL31 (TF-A)

BL31 is provided by TF-A and provides the PSCI routines. Unlike BL2 which won’t get used anymore once BL33 is loaded, BL31 will stay in DDR until a power off or a reboot.

Once BL31 is finished to initialize, it will jump back to BL2.

Source repository: https://gitlab.com/mediatek/aiot/bsp/trusted-firmware-a

BL32 (OP-TEE)

BL32 is the secure OS that runs in TrustZone. AIoT Yocto BSP is using by default OP-TEE trusted OS.

Like BL31, OP-TEE OS stays in DDR until a power off or a reboot.

Source repository: https://gitlab.com/mediatek/aiot/bsp/optee-os

BL33 (U-Boot)

U-Boot is the third and last stage bootloader in the AIoT Yocto boot architecture. It is used to load and boot the kernel from the kernel partition.

In AIoT Yocto the kernel must be encapsulated into a Flattened Image Tree (FIT) image. The FIT image contains the kernel binary, a Device Tree Blob (DTB), and optionally some Device Tree Blob Overlay (DTBO).

The DTBOs are used to provide optional features to a board, for instance for cameras, display, or any daughter board. U-Boot looks at its boot_conf environment variable in order to know which (if any) overlay it must load and merge to the main DTB. To merge a DTBO you need to change boot_conf as following format:

boot_conf=#conf-[platform_dtb_name]#conf-[feature1_dtbo_name]#conf-[feature2_dtbo_name]

For example if you would like to add a DTBO used for DSI panel support to AIoT-i350-EVK(dtbo name: panel-startek-kd070fhfid015.dtbo).

boot_conf=#conf-mediatek_mt8365-evk.dtb#conf-panel-startek-kd070fhfid015.dtbo

There are 2 methods that developers can configure boot_conf to merge DTBOs by U-Boot in AIoT Yocto.

  1. modify it during the Yocto build system by setting the following variable:

KERNEL_DEVICETREE_OVERLAYS_AUTOLOAD += "panel-startek-kd070fhfid015.dtbo"
  1. modify it with using aiot-tools

aiot-flash --load-dtbo panel-startek-kd070fhfid015.dtbo

Besides, it is possible to set the boot_conf variable from the U-Boot shell, target Linux system, or the u-boot-initial-env file directly. There are several ways to modify boot_conf.

  • Writing to the u-boot-initial-env file presented in the deploy image folder before flashing image. (Not recommended because it may be overwritten by bitbake later on)

  • In the U-Boot shell:

setenv boot_conf "you-boot-env-var"; saveenv
  • In the target Linux system:

fw_setenv boot_conf "you-boot-env-var"

U-Boot can also be used to flash (via fastboot), or to boot the kernel and/or rootfs using an USB connection. Please refer to the boards documentation in order to know which features are supported for your specific board.

Source repository: https://gitlab.com/mediatek/aiot/bsp/u-boot

Linux

The Linux kernel is the main OS running. It will load the root filesystem (rootfs) and starts running the init process.

The following versions of Linux are currently supported on AIoT Yocto:

Kernel Version and Branches

Kernel version

Branch name

v5.4

mtk-v5.4

v5.10

mtk-v5.10

By default the latest Linux release will be built, if you wan to use an older supported kernel you can set the PREFERRED_VERSION_linux-mtk variable in your local.conf.

For example if you want to use the v5.4 branch you can set:

PREFERRED_VERSION_linux-mtk = "5.4%"

Partition Layout

The AIoT image flash tool aiot-flash flash the wic image file which includes partition layout (MBR_EMMC) and the content of all partition images start from mmc0 directly. Users can still flash specific image by specifying partition name in aiot-flash command parameters.

The partition layout of AIoT Yocto is described as the matrix below.

Partition Layout

Partition name

Image name

Notes

mmc0

MBR_EMMC

Partition layout for EMMC. Not built as an individual image file in AIoT Yocto.

mmc0boot0

bl2.img

BL2 (TF-A)

mmc0boot1

u-boot-env.bin

U-boot environment variables

bootloaders

fip.bin

fip.bin includes BL31 (TF-A), BL32 (OP-TEE), and BL33 (U-Boot) images

kernel

fitImage

Linux

rootfs

ROOTFS

Rootfs partition. Not built as an individual image file in AIoT Yocto.

home

HOME

Home partition. Not built as an individual image file in AIoT Yocto.