CM-T43: U-Boot: Building Images

From Compulab Mediawiki
Jump to: navigation, search

Overview

CM-T43 firmware consists of two components: Secondary Program Loader (SPL) and U-Boot. Both components are based on U-Boot source code. SPL is the bootstrap utility invoked by the CPU internal boot ROM code of the AM437x SoC. SPL performs minimal hardware initialization and loads U-Boot from the same boot device. U-Boot initializes hardware modules necessary for system boot and loads the operating system.

Building Firmware images for CM-T43

Getting U-Boot sources

There are various ways to get U-Boot sources that can be used as a baseline for CM-T43 SPL and U-Boot. For instance, a copy of the U-Boot mainline git tree can be created or a the sources snapshot can be downloaded. We assume that you have created /home/development/cm-t43/u-boot directory for CM-T43 U-Boot development.

Snapshot download

  • Download v2016.01 snapshot with your web browser.
  • Extract the downloaded archive u-boot-fa85e82.tar.gz
cd /home/development/cm-t43/u-boot
tar xvf /path/to/downloaded/u-boot-fa85e82.tar.gz
mv u-boot u-boot-cm-t43
This will create /home/development/cm-t43/u-boot/u-boot-cm-t43 directory containing U-Boot source code tree.
  • Apply the CM-T43 patch
cd /home/development/cm-t43/u-boot/u-boot-cm-t43
patch -p1 < /path/to/cm-t43-u-boot-package/u-boot/u-boot-v2016.01-cm-t43-1.patch

Git clone

  • Install git version control system.
  • Create a clone of U-Boot tree
cd /home/development/cm-t43/u-boot
git clone git://git.denx.de/u-boot.git u-boot-cm-t43
cd /home/development/cm-t43/u-boot/u-boot-cm-t43
  • Create a branch for CM-T43 development. The CM-T43 patches are generated vs. v2016.01 tag (fa85e826c16b9ce1ad302a57e9c4b24db0d8b930 commit) in the U-Boot tree. It is recommended to use exactly the same baseline to avoid merge conflicts.
git checkout -b cm-t43-dev v2016.01
  • Apply the CM-T43 patch
git apply /path/to/cm-t43-u-boot-package/u-boot/u-boot-v2016.01-cm-t43-1.patch

Building the firmware images

  • First, compile both SPL and U-Boot. The following commands create the MLO, MLO.byteswap, and u-boot.img binaries (along with other image types):
export ARCH=arm
export CROSS_COMPILE=arm-none-linux-eabi-
make mrproper
make cm_t43_defconfig && make
  • Create the combined image for SPI-flash installation by creating a 0xFF initialized 768KB cm-t43-firmware-sf file, and writing the MLO.byteswap, MLO, and u-boot.img data to the appropriate offsets within the cm-t43-firmware file. The MLO.byteswap file will be written into the first 3 64KB segments to allow the bootROM to find it in 3 different places, thus improving reliability. The non-byteswapped MLO will occupy the 4th 64KB segment, thus allowing the same cm-t43-firmware to be written into SD-card, for which the bootROM requires non-byteswapped data. Finally, u-boot.img is written to the 256KB offset, right at the end of the 4 MLO segments.
dd if=/dev/zero count=768 bs=1K | tr '\000' '\377' > cm-t43-firmware
dd if=MLO.byteswap of=cm-t43-firmware bs=1k seek=0 conv=notrunc
dd if=MLO.byteswap of=cm-t43-firmware bs=1k seek=64 conv=notrunc
dd if=MLO.byteswap of=cm-t43-firmware bs=1k seek=128 conv=notrunc
dd if=MLO of=cm-t43-firmware bs=1k seek=192 conv=notrunc
dd if=u-boot.img of=cm-t43-firmware bs=1k seek=256 conv=notrunc
  • You can now install the cm-t43-firmware file into the CM-T43 SPI flash or SD-card.

See also