December 24, 2022

ATF - arm trusted firmware

For several years I have done my best to try to ignore this. It has always been just some "mysterious nuisance" when building U-Boot.

But it is just software, and the basic idea is this. ATF is a "hypervisor" (which makes it better than a supervisor). It runs at the highest and most privileged level, hence it needs to be the first thing booted by the on chip bootrom. Once it gets itself running and happy, it then will load and start U-Boot at a less privileged level. U-Boot could then load an operating system at an even less privileged level, but as far as I know it does not.

Orange Pi 4 (Rockchip 3399) -- ATF (ARM trusted firmware)

This page is sort of a copy of the following (a mess I should tidy up someday). This page focuses on ATF from the start, while the following was a tangent that popped up when I was working on the RK3399.

The documentation calls it an EL3 `Secure Monitor`.
There is a nice PDF file and plenty of documentation from ARM. The PDF file is 636 pages.

The exciting part is that it is all open source and not all that gigantic. It took me perhaps 5 minutes to clone the sources and then build them for the RK3399. The process goes like this:

git clone --depth 1 https://github.com/ARM-software/arm-trusted-firmware.git
cd arm-trusted-firmware
make realclean
make CROSS_COMPILE=aarch64-linux-gnu- PLAT=rk3399
cd ..
Here is a log of the build process: The PDF document is wonderfully informative and accessible, with information about both Rockchip and Allwinner chips.

Allwinner H5

"What about the Allwinner H5?" I find myself asking. It turns out that the answer is right there in the 636 page PDF (that I should just make time to read). It says "to build for machines with an A64 or H5 SOC" use:
make CROSS_COMPILE=aarch64-linux-gnu- PLAT=sun50i_a64 DEBUG=1 bl31
Apparently the Allwinner H5 needs only bl31!

The innocent reader should know that the H5 is also known as the sun50i, specifically the sun50iw2p1.

The "plat" directory in the ATF code shows:

common  sun50i_a64  sun50i_h6  sun50i_h616  sun50i_r329
Using grep to search for the string "H5" reveals (in sun50i_a64/sunxi_power.c) various tests on SUNXI_SOC_H5. In the file plat/allwinner/common/include/sunxi_def.h we see:
#define SUNXI_SOC_A64                   0x1689
#define SUNXI_SOC_H5                    0x1718
#define SUNXI_SOC_H6                    0x1728
#define SUNXI_SOC_H616                  0x1823
#define SUNXI_SOC_R329                  0x1851
The above is sort of a menu of available Allwinner SOC.
Have any comments? Questions? Drop me a line!

Tom's electronics pages / tom@mmto.org