How to build bootloaders for Android

Revision as of 14:39, 2 August 2019 by Registered User (Created page with "== Article purpose == This article is intended to a Distribution Package user (see Which STM32MPU Embedded Software Package for Android better suits your needs|Which Packag...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

1. Article purpose[edit source]

This article is intended to a Distribution Package user (see Which Package better suits your needs for more information).

The Trusted Firmware (TF-A) is used as primary bootloader in the STM32MPU distribution for Android™.

The TF-A binary file is part of the FSBL partition.

The Universal Bootloader (U-Boot) is used as secondary bootloader in the STM32MPU distribution for Android™.

The U-Boot binary file is part of the SSBL partition.

The STM32MPU distribution for Android™ includes prebuilt bootloader binaries used to generate the partition images (FSBL and SSBL).

The binaries are available in device/stm/stm32mp1-bootloader/prebuilt.

This page explains how to rebuild the primary or/and the secondary bootloaders if needed.


2. Prerequisites[edit source]

The environment must be installed using the Distribution Package adapted to your selected microprocessor device. See the list of Android distribution Packages STM32MP1 Distribution Package for Android.

To be able to execute following instruction you need to work from your ST AOSP root directory STM32MP1 Distribution Package for Android, initialise your environment and then launch:

source build/envsetup.sh

lunch aosp-eval-userdebug.

3. Load the bootloader source[edit source]

By default, the bootloader sources are not part of the STM32MPU distribution for Android. To load the sources, execute the following command: load_bootloader

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

Info white.png Information

The load_bootloader script is using configuration files available in the device/stm/stm32mp1-bootloader/source/patch/<fsbl-xxx>

The bootloader sources can be find inside:

  • TF-A device/stm/stm32mp1-bootloader/tf-a-stm32mp1
  • U-Boot device/stm/stm32mp1-bootloader/u-boot-stm32mp1


4. Build bootloaders[edit source]

To build all bootloaders configuration, launch:

build_bootloader

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
  --verbose <level>: enable verbosity (1 or 2 depending on level of verbosity required)

Mode options (exclusive, default = both optee and trusted):
  -o/--optee: set optee mode for bootloaders
  or
  -t/--trusted: set trusted mode for bootloaders (non op-tee option)
  or
  -p/--programmer: build dedicated programmer version (-i option is mandatory)

Board options: (exclusive, default = all possibilities)
  -c/--current: build only for current configuration (board and memory)
  or
  -b/--board <name>: set board name = eval or disco (default: all)
  -m/--mem <name>: set memory configuration = sd or emmc (default: all), ignored if board = disco

5. Generate AOSP without bootloaders prebuilt[edit source]

In order to compile and generate the AOSP with your custom bootloader build you need to change the device/stm/stm32mp1/BoardConfigCommon.mk file and comment those lines:

TARGET_PREBUILT_PBL #FSBL, TF-A
TARGET_PREBUILT_SBL #SSBL, U-boot

Then you need to rebuild the AOSP:

make -j

6. Creates bootloaders prebuilts[edit source]

When you have compile your new bootloader and your change are valid, you can generate prebuilt images to simplify it's integration by doing:

build_bootloader -i