1. Home
  2. Software Articles
  3. A8040 Software
  4. CEX7 ATF, U-Boot and Linux Kernel

CEX7 ATF, U-Boot and Linux Kernel


Below are details how to build ATF (ARM Trusted Firmware), U-Boot (boot loader) and Linux kernel for CEX7 (Based on Armada 8040) , and Buildroot (filesystem).

Building From Sources


You can either build or download a ready-to-use toolchain. An example of such toolchains are from Linaro website.
When writing this document the following toolchain was used:
Linaro updates it’s toolchain quite often and more frequent one can be downloaded from here:

Toolchains based on gcc 8 and later are released by ARM (Ltd) directly.

Download and extract the toolchain into some place; and as instructed below the CROSS_COMPILE environment variables needs to be set to the path of the toolchain prefex.
For instance if the toolchain was extracted under /opt/gcc-linaro-7.3.1-2018.05-x86_aarch64-linux-gnu/ then the CROSS_COMPILE needs to be set as follows –

export ARCH=arm64
export CROSS_COMPILE=/opt/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-
export ROOTDIR=`pwd`

Your CEx7 unit should come with a U-Boot in its on-board SPI storage. If that is not the case or you want to flash a different U-Boot following Building U-Boot .

Linux Kernel

Kernel sources are found on SolidRun’s github site – https://github.com/SolidRun/linux-stable/tree/linux-4.19.y-mvebu

To build from source; follow the following steps –

export ARCH=arm64
export CROSS_COMPILE=<your arm64 cross compiler path>
git clone https://github.com/SolidRun/linux-stable.git -b linux-4.19.y-mvebu
cd ./linux-stable
wget -O .config https://developer.solid-run.com/wp-content/uploads/2019/03/kernel-armada-CEX-defconfig.txt
make olddefconfig
#Building the source run 
make Image dtbs # create Image and dtb
CEx7 kernel device tree file
The result files are
$ROOTDIR/linux-stable/arch/arm64/boot/Image  # kernel image

Image file
armada-8040-cex.dtb file



Intention of the Buildroot filesystem is to provide the developers a quick page how to build mainline buildroot with CEx7 u-boot, ATF and kernel with simple root filesystem.

Grabbing source and building instructions

Getting the sources –

git clone https://github.com/buildroot/buildroot.git -b 2018.11.x
cd $ROOTDIR/buildroot
#Download this CEx7 buildroot config file
wget -O .config https://developer.solid-run.com/wp-content/uploads/2019/01/clearfog-cx-8k-buildroot.txt
make olddefconfig
#Building the source run

The result files are


Image file
rootfs.cpio.uboot file
armada-8040-cex.dtb file 

Create SD Card

First insert the target microSD into your computer running Linux and identify its canonical name in /dev, e.g. by reading through dmesg.

mkdir -p cex_disk/
mkdir -p cex_disk/extlinux/
cp buildroot/output/images/rootfs.cpio.uboot cex_disk/rootfs.cpio-cex
cp buildroot/output/images/armada-8040-cex.dtb cex_disk/armada-8040-cex.dtb
cp buildroot/output/images/Image cex_disk/Image
# Prepare the msdos partition
dd if=/dev/zero of=cex_disk/boot.part bs=1M count=99
mkdosfs cex_disk/boot.part
mcopy -i cex_disk/boot.part cex_disk/Image ::/Image
mcopy -i cex_disk/boot.part cex_disk/rootfs.cpio-cex ::/rootfs.cpio-cex
mcopy -i cex_disk/boot.part cex_disk/armada-8040-cex.dtb ::/armada-8040-cex.dtb
# Create extlinux.conf boot file
echo "label linux" > cex_disk/extlinux/extlinux.conf
echo "        kernel ../Image" >> cex_disk/extlinux/extlinux.conf
echo "        devicetree ../armada-8040-cex.dtb" >> cex_disk/extlinux/extlinux.conf
echo "        initrd ../rootfs.cpio-cex" >> cex_disk/extlinux/extlinux.conf
mmd -i cex_disk/boot.part ::/extlinux
mcopy -i cex_disk/boot.part cex_disk/extlinux/extlinux.conf ::/extlinux/extlinux.conf
# Create the whole disk image
dd if=/dev/zero of=cex_disk/disk.img bs=1M count=102
parted --script cex_disk/disk.img mklabel msdos mkpart primary 2MiB 101MiB
# Copy MSDOS partition over
dd if=cex_disk/boot.part of=cex_disk/disk.img bs=1M seek=2 conv=notrunc
echo "Disk image ready at cex_disk/disk.img"
#sdX is used as placeholder for the actual device name of your microSD on your system
sudo umount /dev/sdX
sudo dd if=$ROOTDIR/cex_disk/disk.img of=/dev/sdX conv=sync status=progress

In this example sdX is used as placeholder for the actual device name of your microSD on your system.

connect the microSD card into CEx7 board and run 

Buildroot connecting settings

The root password in the Buildroot after generated image is
buildroot login: root
password: 123456


Building U-Boot

Your CEx7 unit should come with a U-Boot in its on-board SPI storage. If that is not the case or you want to flash a different U-Boot following below

Armada 8040 CEX7 board uses U-boot wrapper in ATF (ARM Trusted Firmware) in order to boot the board.
Following are build instructions where the target is to build flash-image.bin

Building U-Boot is as follows – make sure you have set your ARCH and CROSS_COMPILE environment variables as noted above

Download Source and Firmware

git clone https://github.com/SolidRun/u-boot.git -b v2018.11-solidrun
git clone https://github.com/SolidRun/mv-ddr-marvell.git -b mv_ddr-armada-18.09
git clone https://github.com/MarvellEmbeddedProcessors/atf-marvell.git -b atf-v1.5-armada-18.09
git clone https://github.com/MarvellEmbeddedProcessors/binaries-marvell.git -b binaries-marvell-armada-18.06
export ROOTDIR=`pwd`

CEx7 U-Boot device tree file

Make sure you have this command wget, tar, git, make, 7z, unsquashfs, dd, vim, mkfs.ext4, sudo, parted, mkdosfs, mcopy, dtc, ibssl-dev

You can install the package using the command below:
sudo apt install p7zip-full
sudo apt install device-tree-compiler
sudo apt install libssl-dev

cd $ROOTDIR/u-boot
make mvebu_cex-88f8040_defconfig

The result files are


Build U-Boot and generate the image – make sure you have set your ARCH and CROSS_COMPILE environment variables as noted above

cd $ROOTDIR/atf-marvell
export SCP_BL2=$ROOTDIR/binaries-marvell/mrvl_scp_bl2_mss_ap_cp1_a8040.img
export MV_DDR_PATH=$ROOTDIR/mv-ddr-marvell
export BL33=$ROOTDIR/u-boot/u-boot.bin

The result files are



Serial Connection
Connecting with PuTTY

This page will walk you through installing necessary serial connection software for Linux/Windows.

You can install the putty using the command below.

sudo apt install putty
Flashing U-Boot
Booting the board using UART xmodem

The CEx7 can be booted through UART xmodem. Even if the processor is indicated ( by default ) to boot from SPI.

The flash-image.bin that is built above is a ready to use xmodem protocol transferable image to Armada 8040 processor. But first the processor needs to be redirected from it’s default boot
This can be achieved by running the ‘download-serial.sh’ script

Connect your PC to your board by plugging the micro USB cable to a USB port on your laptop/computer and plugging the other end to MicroUSB port on CEx7, run PuTTY and select Serial under Connection type, and also set Speed to 115200. The next step Download and run the “download-serial.sh” script :

This script automates sending the magic pattern to halt normal boot of Armada 8040 processor and redirects it to boot the uart version of u-boot .

wget -O download-serial.sh http://www.solidrundev.com/tests/dev-yazan/download_serial/download-serial.sh
chmod +x download-serial.sh
./download-serial.sh /dev/ttyUSB0 $ROOTDIR/atf-marvell/build/a80x0_mcbin/release/flash-image.bin

Make sure the putty is active
Now reset or power cycle your CEx7 board and then press enter


That /dev/ttyUSB0 needs to be modified to your correct terminal emulation char device
Embedded in download-serial.sh a small C program that gets built every time the script runs and requires curses libraries.
wait to loading the U-Boot to your CEx7 board ( load u-boot to RAM memory )

From U-Boot to SPI Flash

This step requires U-Boot running on the target device first, e.g. loaded from UART. The flash-image.bin can then be loaded from either microSD, USB or network, and finally written to the SPI flash.
This sample covers the easiest case where flash-image.bin is available on a fat formatted partition on a USB drive:

# start USB stack
usb start
# scanning usb for storage devices... 1 Storage Device(s) found <-- indicates success
# load flash-image.bin to ram
load usb 0:1 $kernel_addr_r flash-image.bin
# u-boot will indicate how many btes were read. Make sure to verify the number!
# initialize spi flash
sf probe
# optionally erase
sf erase 0 0x800000
# finally write loaded file
sf write $kernel_addr_r 0 0x$filesize

When we should use the distro method ( allow use extlinux.conf file )
after first boot loader change the bootcmd variable on putty terminal using setenv command below

setenv bootcmd 'run distro_bootcmd'


Updated on June 27, 2021

Was this article helpful?

Related Articles

Please note - this website is no longer being updated, please visit our new developer center by clicking here