3.1.1.1. General Information

3.1.1.1.1. Getting the U-Boot Source Code

The easiest way to get access to the U-boot source code is by downloading and installing the Processor SDK Linux. Once installed, the U-Boot source code is included in the SDK’s board-support directory. For your convenience the sources also includes the U-Boot’s git repository including commit history.
Alternatively, U-Boot sources can directly be fetched from GIT.
The GIT repo URL, branch and commit id can be found in the U-Boot section of the release notes.

3.1.1.1.2. Build U-Boot

Note

The following commands are intended to be run from the root of the U-Boot tree unless otherwise specified. The root of the U-Boot tree is the top-level directory and can be identified by looking for the “MAINTAINERS” file.

Several prebuilt images are required from the TI Processor SDK for building U-Boot on K3 based platforms. Go here to download and install the SDK.

TI-u-boot is included in the SDK in <path to tisdk>/board-support. Ensure that the u-boot version matches the U-Boot.

Getting Security Dev Tool

$ git clone git://git.ti.com/security-development-tools/core-secdev-k3.git -b master
$ export TI_SECURE_DEV_PKG=`pwd`/core-secdev-k3

Setting the tool chain path

We strongly recommend using the toolchain that came with the Linux Core release that corresponds to this U-Boot release. For e.g:

export PATH=$HOME/gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf/bin:$PATH
export PATH=$HOME/gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu/bin:$PATH

Compiling R5 and ARM64 images

Use the following table to determine what defconfig to use to configure with:

Board SD Boot eMMC Boot UART boot OSPI boot
AM64X EVM am64x_evm_r5_defconfig am64x_evm_a53_defconfig am64x_evm_r5_defconfig am64x_evm_a53_defconfig am64x_evm_r5_defconfig am64x_evm_a53_defconfig am64x_evm_r5_defconfig am64x_evm_a53_defconfig
AM64X SK am64x_evm_r5_defconfig am64x_evm_a53_defconfig   am64x_evm_r5_defconfig am64x_evm_a53_defconfig am64x_evm_r5_defconfig am64x_evm_a53_defconfig
AM64X HS EVM am64x_hs_evm_r5_defconfig am64x_hs_evm_a53_defconfig am64x_hs_evm_r5_defconfig am64x_hs_evm_a53_defconfig am64x_hs_evm_r5_defconfig am64x_hs_evm_a53_defconfig am64x_hs_evm_r5_defconfig am64x_hs_evm_a53_defconfig

on GP

R5
$ make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabihf- am64x_evm_r5_defconfig O=<output directory>/r5
$ make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabihf- O=<output directory>/r5
$ cd ../k3-image-gen-<version>
$ make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabihf- SOC=am64x SBL=<output directory>/r5/spl/u-boot-spl.bin SYSFW_PATH=<path to tisdk>/board-support/prebuilt-images/ti-sci-firmware-am64x-gp.bin

A53
$ make ARCH=arm CROSS_COMPILE=aarch64-none-linux-gnu- am64x_evm_a53_defconfig O=<output directory>/a53
$ make ARCH=arm CROSS_COMPILE=aarch64-none-linux-gnu- ATF=<path to tisdk>/board-support/prebuilt-images/bl31.bin TEE=<path to tisdk>/board-support/prebuilt-images/bl32.bin  O=<output directory>/a53

on HS

R5
$ make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabihf- am64x_hs_evm_r5_defconfig O=<output directory>/r5
$ make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabihf- O=<output directory>/r5
$ cd ../k3-image-gen-<version>
$ make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabihf- SOC=am64x HS=1 SBL=<output directory>/r5/spl/u-boot-spl.bin SYSFW_HS_PATH=<path to tisdk>/board-support/prebuilt-images/ti-sci-firmware-am64x-hs-enc.bin SYSFW_HS_INNER_CERT_PATH=<path to tisdk>/board-support/prebuilt-images/ti-sci-firmware-am64x-hs-cert.bin

Sign OPTEE and ATF binaries
$ $TI_SECURE_DEV_PKG/scripts/secure-binary-image.sh bl31.bin bl31.bin.signed
$ $TI_SECURE_DEV_PKG/scripts/secure-binary-image.sh bl32.bin bl32.bin.signed

A53
$ make ARCH=arm CROSS_COMPILE=aarch64-none-linux-gnu- am64x_hs_evm_a53_defconfig O=<output directory>/a53
$ make ARCH=arm CROSS_COMPILE=aarch64-none-linux-gnu- ATF=<path to tisdk>/board-support/prebuilt-images/bl31.bin.signed TEE=<path to tisdk>/board-support/prebuilt-images/bl32.bin.signed  O=<output directory>/a53

Dependent Project location

  • In case not use TI SDK and building U-Boot out of mainline, then k3-image-gen (For generating tiboot3.bin and sysfw.itb) project is located here
  • Linux Firmware (for device specific ti-dm and ti-sysfw binaries) project is located here. Images are under ti-dm and ti-sysfw folders

Building SYSFW

  • In case of building and generating sysfw.itb rather than downloading from prebuilt download location, below is the instructions on how to do it.

Target Images

Copy the below images to the boot partition of an SD card and boot. Instructions to format the SD card can be found here.

  • tiboot3.bin from <path to K3-image-gen> (This is combined image of tiboot3.bin and sysfw.itb)
  • tispl.bin, u-boot.img from <output directory>/a53
  • tiboot3.bin:

    +-----------------------+
    |        X.509          |
    |      Certificate      |
    | +-------------------+ |
    | |                   | |
    | |        R5         | |
    | |   u-boot-spl.bin  | |
    | |                   | |
    | +-------------------+ |
    | |                   | |
    | |     FIT header    | |
    | | +---------------+ | |
    | | |               | | |
    | | |   DTB 1...N   | | |
    | | +---------------+ | |
    | +-------------------+ |
    | |                   | |
    | |      FIT HEADER   | |
    | | +---------------+ | |
    | | |               | | |
    | | |   sysfw.bin   | | |
    | | +---------------+ | |
    | | |               | | |
    | | |  board config | | |
    | | +---------------+ | |
    | | |               | | |
    | | |   PM config   | | |
    | | +---------------+ | |
    | | |               | | |
    | | |   RM config   | | |
    | | +---------------+ | |
    | | |               | | |
    | | | Secure config | | |
    | | +---------------+ | |
    | +-------------------+ |
    +-----------------------+
    
  • tispl.bin

    +-----------------------+
    |                       |
    |       FIT HEADER      |
    | +-------------------+ |
    | |                   | |
    | |      A53 ATF      | |
    | +-------------------+ |
    | |                   | |
    | |     A53 OPTEE     | |
    | +-------------------+ |
    | |                   | |
    | |      A53 SPL      | |
    | +-------------------+ |
    | |                   | |
    | |   SPL DTB 1...N   | |
    | +-------------------+ |
    +-----------------------+
    

3.1.1.1.3. Boot Flow

On K3 architecture based devices, ROM supports boot only via MCU(R5). This means that bootloader has to run on R5 core. In order to meet this constraint, keeping safety in picture and to have faster boot time, the software boot architecture is designed as below:

+------------------------------------------------------------------------+-----------------------+
|        DMSC            |      MAIN R50         |         A53           |   MAIN R51            |
+------------------------------------------------------------------------+-----------------------+
|    +--------+          |                       |                       |                       |
|    |  Reset |          |                       |                       |                       |
|    +--------+          |                       |                       |                       |
|         :              |                       |                       |                       |
|    +--------+          |   +-----------+       |                       |                       |
|    | *ROM*  |----------|-->| Reset rls |       |                       |                       |
|    +--------+          |   +-----------+       |                       |                       |
|    |        |          |         :             |                       |                       |
|    |  ROM   |          |         :             |                       |                       |
|    |services|          |         :             |                       |                       |
|    |        |          |   +-------------+     |                       |                       |
|    |        |          |   |  *R5 ROM*   |     |                       |                       |
|    |        |          |   +-------------+     |                       |                       |
|    |        |<---------|---|Load and auth|     |                       |                       |
|    |        |          |   | tiboot3.bin |     |                       |                       |
|    | Start  |          |   +-------------+     |                       |                       |
|    | SYSFW  |<---------|---|    Start    |     |                       |                       |
|    |        |          |   |    SYSFW    |     |                       |                       |
|    +--------+          |   +-------------+     |                       |                       |
|        :               |   |             |     |                       |                       |
|    +---------+         |   |   Load      |     |                       |                       |
|    | *SYSFW* |         |   |   system    |     |                       |                       |
|    +---------+         |   | Config data |     |                       |                       |
|    |         |<--------|---|             |     |                       |                       |
|    |         |         |   +-------------+     |                       |                       |
|    |         |         |         :             |                       |                       |
|    |         |         |         :             |                       |                       |
|    |         |         |         :             |                       |                       |
|    |         |         |   +-------------+     |                       |                       |
|    |         |         |   |  *R5 SPL*   |     |                       |                       |
|    |         |         |   +-------------+     |                       |                       |
|    |         |         |   |    DDR      |     |                       |                       |
|    |         |         |   |   config    |     |                       |                       |
|    |         |         |   +-------------+     |                       |                       |
|    |         |         |   |    Load     |     |                       |                       |
|    |         |         |   |  tispl.bin  |     |                       |                       |
|    |         |         |   +-------------+     |                       |                       |
|    |         |<--------|---| Start A53   |     |                       |                       |
|    |         |         |   +-------------+     |                       |                       |
|    |         |         |                       |     +-----------+     |                       |
|    |         |---------|-----------------------|---->| Reset rls |     |                       |
|    |         |         |                       |     +-----------+     |                       |
|    |  SYSFW  |         |                       |          :            |                       |
|    |Services |         |                       |     +-----------+     |                       |
|    |         |<--------|-----------------------|---->|*ATF/OPTEE*|     |                       |
|    |         |         |                       |     +-----------+     |                       |
|    |         |         |                       |          :            |                       |
|    |         |         |                       |     +-----------+     |                       |
|    |         |<--------|-----------------------|---->| *A53 SPL* |     |                       |
|    |         |         |                       |     +-----------+     |                       |
|    |         |         |                       |     |   Load    |     |                       |
|    |         |         |                       |     | u-boot.img|     |                       |
|    |         |         |                       |     +-----------+     |                       |
|    |         |         |                       |          :            |                       |
|    |         |         |                       |     +-----------+     |                       |
|    |         |<--------|-----------------------|---->| *U-Boot*  |     |                       |
|    |         |         |                       |     +-----------+     |                       |
|    |         |         |                       |     |  prompt   |     |                       |
|    |         |         |                       |     +-----------+     |                       |
|    |         |         |                       |     |  Load R5  |     |                       |
|    |         |         |                       |     |  Firmware |     |                       |
|    |         |         |                       |     +-----------+     |                       |
|    |         |<--------|-----------------------|-----|  Start R5 |     |      +-----------+    |
|    |         |---------|-----------------------|-----+-----------+-----|----->| R5 starts |    |
|    |         |         |                       |                       |      +-----------+    |
|    |         |         |                       |                       |                       |
|    +---------+         |                       |                       |                       |
|                        |                       |                       |                       |
+------------------------------------------------------------------------+-----------------------+

Here DMSC acts as master and provides all the critical services. R5/ARM64 requests DMSC to get these services done as shown in the above diagram.

3.1.1.1.4. U-Boot Environment

Please note that on many boards we modify the environment during system start for a variety of variables such as board_name and if unset, ethaddr. When we restore defaults some variables will become unset, and this can lead to other things not working such as findfdt that rely on these run-time set variables.

Restoring defaults

It is possible to reset the set of U-Boot environment variables to their defaults and if desired, save them to where the environment is stored, if applicable. It is also required to restore the default setting when u-boot version changes from an upgrade or downgrade. To do so, issue the following commands:

U-Boot # env default -f -a
U-Boot # saveenv

Networking Environment

When using a USB-Ethernet dongle a valid MAC address must be set in the environment. To create a valid address please read **this page**. Then issue the following command:

U-Boot # setenv usbethaddr value:from:link:above

You can use the printenv command to see if usbethaddr is already set.

Then start the USB subsystem:

U-Boot # usb start

The default behavior of U-Boot is to utilize all information that a DHCP server passes to us when the user issues the dhcp command. This will include the dhcp parameter next-server which indicates where to fetch files from via TFTP. There may be times however where the dhcp server on your network provides incorrect information and you are unable to modify the server. In this case the following steps can be helpful:

U-Boot # setenv autoload no
U-Boot # dhcp
U-Boot # setenv serverip correct.server.ip
U-Boot # tftp

Another alternative is to utilize the full syntax of the tftp command:

U-Boot # setenv autoload no
U-Boot # dhcp
U-Boot # tftp ${loadaddr} server.ip:fileName

3.1.1.1.5. Available RAM for image download

To know the amount of RAM available for downloading images or for other usage, use bdinfo command.

=> bdinfo
arch_number = 0x00000000
boot_params = 0x80000100
DRAM bank   = 0x00000000
-> start    = 0x80000000
-> size     = 0x7F000000
baudrate    = 115200 bps
TLB addr    = 0xFEFF0000
relocaddr   = 0xFEF30000
reloc off   = 0x7E730000
irq_sp      = 0xFCEF8880
sp start    = 0xFCEF8870
Early malloc usage: 890 / 2000

After booting, U-Boot relocates itself (along with its various reserved RAM areas) and places itself at end of available RAM (starting at relocaddr in bdinfo output above). Only the stack is located just before that area. The address of top of the stack is in sp start in bdinfo output and it grows downwards. Users should reserve at least about 1MB for stack, so in the example output above, RAM in the range of [0x80000000, 0xFCE00000] is safely available for use.

3.1.1.1.6. Device Trees

A note about device trees. Now all supported boards are required to use a device tree to boot. To facilitate this in supported platforms, a command in U-Boot environment findfdt is available that will set the fdtfile variable to the name of the device tree to use, as found with the kernel sources. In the Keystone-2 family devices (K2H/K/E/L/G), it is specified by name_fdt variable for each platform. The device tree is expected to be loaded from the same media as the kernel, and from the same relative path.

3.1.1.1.7. SRAM memory Layout during R5 SPL bootloader stage

The SRAM memory layout explains the memory used for Bootloader’s operation.

  • In SDK 08.00 release, USB DFU boot mode support has been added in AM64. For USB DFU boot mode there is a limitation on the load address of boot images to be less than 0x70001000. In order to overcome this limitation, the R5 SPL load address has been moved to 0x70000000. Given below is the SRAM memory layout in SDK 08.00 release, during R5 SPL bootloader stage.
┌──────────────────────────────────────┐0x70000000
│                                      │
│                                      │
│                                      │
│    SPL IMAGE (Max size 1.5 MB)       │
│                                      │
│                                      │
│                                      │
├──────────────────────────────────────┤0x7017FFFF
│                                      │
│           SPL STACK                  │
│                                      │
├──────────────────────────────────────┤0x70192727
│          GLOBAL DATA(216 B)          │
├──────────────────────────────────────┤0x701927FF
│                                      │
│       INITIAL HEAP (32 KB)           │
│                                      │
├──────────────────────────────────────┤0x7019A7FF
│                                      │
│          BSS  (20 KB)                │
├──────────────────────────────────────┤0x7019F7FF
│         EEPROM DATA (2 KB)           │
├──────────────────────────────────────┤0x7019FFFF
│                                      │
│                                      │
│            TF-A (123 KB)             │
│                                      │
│                                      │
├──────────────────────────────────────┤0x701BEBFB
│   BOOT PARAMETER INDEX TABLE (5124 B)│
├──────────────────────────────────────┤0x701BFFFF
│                                      │
│        UNALLOCATED  AREA(128 KB)     │
│                                      │
├──────────────────────────────────────┤0x701DFFFF
│                                      │
│      DMSC CODE AREA (128 KB)         │
│                                      │
└──────────────────────────────────────┘0x701FFFFF
  • In SDK 08.01 release, TF-A will be moved to 0x701c0000 and 128 KB will be reserved for it. Given below is the memory layout after making this change.
┌──────────────────────────────────────┐0x70000000
│                                      │
│                                      │
│                                      │
│    SPL IMAGE (Max size 1.5 MB)       │
│                                      │
│                                      │
│                                      │
├──────────────────────────────────────┤0x7017FFFF
│                                      │
│           SPL STACK                  │
│                                      │
├──────────────────────────────────────┤0x70192727
│          GLOBAL DATA(216 B)          │
├──────────────────────────────────────┤0x701927FF
│                                      │
│       INITIAL HEAP (32 KB)           │
│                                      │
├──────────────────────────────────────┤0x7019A7FF
│                                      │
│          BSS  (20 KB)                │
├──────────────────────────────────────┤0x7019F7FF
│         EEPROM DATA (2 KB)           │
├──────────────────────────────────────┤0x7019FFFF
│                                      │
│                                      │
│     UNALLOCATED AREA (123 KB)        │
│                                      │
│                                      │
├──────────────────────────────────────┤0x701BEBFB
│   BOOT PARAMETER INDEX TABLE (5124 B)│
├──────────────────────────────────────┤0x701BFFFF
│                                      │
│             TF-A (128 KB)            │
│                                      │
├──────────────────────────────────────┤0x701DFFFF
│                                      │
│      DMSC CODE AREA (128 KB)         │
│                                      │
└──────────────────────────────────────┘0x701FFFFF
  • In the last 128 KB of memory used by DMSC during run time, initial 80 KB gets freed after a security handover happens. The last 48 KB still will be used by DMSC.
  • For more details on Security handover see here .