Last edited 2 weeks ago

How to build bootloaders for Android

Applicable for STM32MP25x lines

Important
OpenSTDroid is validated against the ecosystem release v5.1.0 . It has not been ported yet on STM32 MPU ecosystem release v6. Visit the ecosystem release v5.1.0 wiki to access to user guide explaining how to port Android on top of STM32 MPU ecosystem release v5.

This article explains how to build the Android™ bootloader binaries (primary and secondary bootloaders on Arm® Cortex®-A processor) for a selected STM32 device. It is intended for Distribution Package users.

1. Prerequisites[edit | edit source]

The environment must be installed using the Distribution Package adapted to the selected microprocessor unit.

The environment setup must be carried out in accordance with the instructions provided here.

Additionally, the toolchain has to be installed using the following command:

bspsetup
Information
The bspsetup instruction only needs to be run once for each distribution.

2. Partition layout[edit | edit source]

The Trusted Firmware (TF-A) is used as the primary bootloader (FSBL-A on Arm® Cortex®-A processor) in the OpenSTDroid distribution. The TF-A binary file is part of the fsbla partition.

The Universal Bootloader (U-Boot) is used as the secondary bootloader (SSBL on Arm® Cortex®-A processor) in the OpenSTDroid distribution. The U-Boot binary file is part of the fip partition.

The binaries are available in device/stm/<STM32Series>-bootloader/prebuilt.

Information
For information on the complete partition layout for the corresponding development platform, refer to the STM32 MPU Flash mapping for Android article.

3. Load the bootloader sources[edit | edit source]

By default, the bootloader sources are not part of the OpenSTDroid distribution. To load the sources, execute the following instruction:

load_bootloader

It will load both the TF-A and U-Boot sources.

Information

The load_bootloader script uses the configuration file android_fsbl.config (resp. android_ssbl.config) available in the device/stm/<STM32Series>-bootloader/source/patch/<fsbl-version>/ (resp. .../<ssbl-version>/) directory.

The bootloader sources are located in:

  • TF-A: device/stm/<STM32Series>-bootloader/tf-a-<STM32Series>
  • U-Boot: device/stm/<STM32Series>-bootloader/u-boot-<STM32Series>

4. Build the bootloaders[edit | edit source]

To build both the FSBL-A and the SSBL, run:

build_bootloader
Warning
The build script is only compatible with x86_64 host machine. The arm64 host machine compatible version will arrive soon.

This instruction generates both the TF-A and the U-Boot for every available board, memory, and boot mode.

To get more details on available options, run:

build_bootloader -h

Hereafter, this is the result for version 1.10:

$ build_bootloader -h
Usage: build_bootloader [Options] [Mode Options] [Board Options]
 
  This script allows building the bootloaders source (TF-A and/or U-Boot)
 
Options:
  -h / --help: print this message
  -v / --version: get script version
  -i / --install: update prebuilt images
  -d/--debug: enable script debug traces
  --verbose: enable verbosity
 
  -p / --programmer: build dedicated programmer version (-i option forced)
  -g/--gdb: generate .elf files useful for debug purpose
  -t / --tools: generate fiptool, certtool, enctool for the HOST machine
 
Board options: (default = all possibilities)
  -b <name> / --board=<name>: set board name from following list = eval dk (default: all)
  -m <config> / --mem=<config>: set memory configuration from following list = sdcard emmc (default: all)

5. Integrate the bootloaders[edit | edit source]

To update prebuilt images, add -i option:

build_bootloader -i

To integrate the updated prebuilt images, execute from the root directory:

make -j

Then update associated partitions on your device. Refer to How to populate boards for Android.