AM275 FreeRTOS SDK  11.00.00
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Understanding the bootflow and bootloaders

Introduction

Booting user defined applications on a SOC involves multiples steps as listed below,

  • Firstly, there are multiple steps involved to convert a user application, created using a compiler+linker toolchain, into a binary format that is suitable to be booted by the SOC
  • Next, we need to flash this binary to the EVM flash
  • Finally, when the SOC is powered on, the previously flashed binary is executed.
  • After powering on the EVM, the bootflow takes place mainly in two steps
    • ROM boot, in which the ROM bootloader boots a secondary bootloader or an SBL
    • SBL boot in which the secondary bootloader boots the application
  • Note, that a system application itself can consist of multiple CPU specific application binaries that all collaborate together to realize the overall system goal.

This section details these steps and gives an overview of the bootloaders to understand the process better.

Additional References

See also these additional pages for more details and examples about the boot flow,

Preparing the application for boot

Note
To see the exact sequence of steps in which applications and secondary bootloader (SBL) are converted from compiler generated .out files to boot images, see the makefile makefile_ccs_bootimage_gen that is included in every example and secondary bootloader (SBL) CCS project.
If you are using makefile based build, then see the file named makefile in the example folder.

Shown below are the different steps that are done to convert the compiler+linker generated application .out into a format suitable for flashing and booting

  • For each CPU, the compiler+linker toolchain is used to create the application .out "ELF" file which can be loaded and run via CCS
  • The below "post build" steps are then used to convert the application .out into a "flash" friendly format called mcelf image

MCELF Image

  • The mcelf image generator script genimage.py takes each individual core's .out file as input and combines them to form a .mcelf file.
  • This .mcelf file contains metadata and segments along with information like segment type, load address, size, alignment.
  • The .mcelf file is then flashed to the board.

Post build steps MCELF

Flashing the application for boot

  • Once the application image (.mcelf) is created one needs to copy or flash these to a supported boot media so that the application can start executing once the SOC is powered ON
  • When flashing the application we also need to flash a bootloader or SBL image.
  • See Flashing Tools for detailed steps that are done to flash a user application

Booting the application

After a SBL and application image is flashed, shown below is the high level boot flow, after the SOC is powered on.

HIGH LEVEL BOOTFLOW

ROM Boot

  • As soon as the EVM is powered ON, the ROM bootloader or RBL starts running. The RBL is the primary bootloader.
  • Depending on which boot mode is selected on the EVM, the RBL will load the secondary bootloader or SBL from a boot media (OSPI flash, SD card or via UART).
  • Rest of the booting is done by the SBL.
  • The RBL expects the image it boots (SBL in our case) to always be signed. Refer Booting Tools for more information on signing scripts.

SBL Boot

  • The SBL is essentially an example application of the bootloader library.
  • We call it a secondary bootloader because it is booted by the RBL, which is the primary bootloader.
  • An SBL typically does a bunch of SOC specific initializations and proceeds to the application loading.
  • Depending on the type of SBL loaded, SBL looks for the multicore elf image (refer Booting Tools for more on multicore elf image) of the application binary at a specified location in a boot media.

SBL BOOT

Booting MCELF application

SBL looks for the multicore elf image (refer Booting Tools for more on multicore elf image) of the application binary at a specified location in a boot media.

  • If the mcelf file is found, it is parsed into multiple loadable segments. These are then loaded into individual CPUs.
  • The Note segment of the MCELF image will have information regarding the core on which each segment that application binary needs to be loaded
  • The SBL uses this information to initialize each core, loads the segments to specified addresses, and then releases the core from reset. Now the core will start running.

SBL Boot for MCELF

Secondary Bootloaders

Depending on the boot media from which we load the application binary, we have multiple SBLs like sbl_ospi,sbl_uart etc. A bare minimum SBL called the sbl_null is also included which aids the users to load their applications via CCS.

SBL NULL

  • The sbl_null is a secondary bootloader which doesn't load any application binary, but just does the SOC initialization and puts all the cores in WFI (Wait For Interrupt) mode.
  • This is referred to as the SOC initialization binary, refer Flash SOC Initialization Binary for more on this.

SBL SD

  • The sbl_sd is a secondary bootloader which reads the application image file from the SD card and then moves on to core initialization and other steps
  • To boot an application using the sbl_sd, the application image needs to be copied to the SD card as a file named "app_{core_name} for R5 cores or dsp_{core_name} for C7x cores".Thus image name can be as follows for each core
CORE IMAGE NAME
r5fss0-0 app_r50_0
r5fss0-1 app_r50_1
r5fss1-0 app_r51_0
r5fss1-1 app_r51_1
c75ss0-0 app_dsp0_0
c75ss1-0 app_dsp0_1

Make sure that the SD card is formatted to have a FAT partition.

  • Follow the steps in the above referred page to partition the SD card. For a complete boot from SD card, both the sbl_sd binary and the application image binary has to be present as files in the SD card. You have to rename the sbl_sd appimage as 'tiboot3.bin'.
      copy file to SD card => ${SDK_INSTALL_PATH}/tools/boot/sbl_prebuilt/am275x-evm/sbl_sd.release.tiimage
      rename in SD card as => tiboot3.bin
    
  • Similarly you can copy any application image file to the SD card and rename in the SD card as per the above naming convention so that the SBL can pick it up.

SBL OSPI

  • The sbl_ospi is a secondary bootloader which reads and parses the application image from a location in the OSPI flash and then moves on to core initialization and other steps
  • To boot an application using the sbl_ospi, the application image needs to be flashed at a particular location in the OSPI flash memory.
  • This location or offset is specified in the SysConfig of the sbl_ospi application. Currently this is 0x80000. In most cases you wouldn't need to change this.
  • To flash an application (or any file in fact) to a location in the OSPI flash memory, follow the steps mentioned in Basic steps to flash files

SBL UART

  • The sbl_uart is a secondary bootloader which receives the multicore application image metadata via UART and then does the parsing to identify the required program segments.It then requests the program segments to host by specifying its offset and length and receives and stores it directly at load address of program segments.
  • To boot an application using the sbl_uart, you can refer to UART Bootloader Python Script subsection. Detailed steps on the usage is mentioned in the same subsection.

Preparing the SBL for boot

The SBL is like any other application, created using the same compiler and linker toolchain. However the steps to convert the application .out into a bootable image are different for SBL as listed below

  • After building, the SBL application .out file is first converted to a binary format .bin using the GCC objcopy tool.
    • This copies the loadable sections from the .out into a binary image stripping all symbol and section information.
    • If there are two loadable sections in the image which are not contiguous then objcopy fills the gaps with 0xFF.
    • It is highly recommended to keep all loadable sections together within a SBL application.
  • This .bin file is then signed using the Signing Scripts to create the final .tiimage bootable image.
    • A default key is used for this.
    • This is a ROM bootloader requirement and is needed even on a non-secure device.
  • This .tiimage file can then be flashed or copied to a boot image using the Flashing Tools