This is the bare metal program running on both the i.MX53 QSB to test the TrustZone Secure-Normal World Transition and QEMU, without software interruptions.
The board will boot a bare-metal program to keep switching between secure and normal world.
As for QEMU, the serial console will only display “Hello World!”.
Based on:
i.MX53 QSB - https://github.com/finallyjustice/imx53qsb-code/tree/master/trustzone-smc
QEMU - https://balau82.wordpress.com/2010/02/28/hello-world-for-bare-metal-arm-using-qemu/
Follow the setup on the Hello World Demo tutorial.
This is very important in order to successfully compile code with the ARM Toolchain, for the board's SD card image deployment and finally, to execute it.
For QEMU download and compile follow this link.
Or simply:
Download QEMU:
$ git clone https://git.linaro.org/virtualization/qemu-tz.git --branch qemutz
Build the QEMU (from the QEMU root directory):
$ ./configure --target-list=arm-softmmu $ make
It's possible that it will require the installation of additional libs like zlib.
To solve this problem follow this link.
Note: Both the board and QEMU constantly require the arm toolchain, therefore copy the path to the arm-none-eabi- into the Makefile, avoiding the constant use of export.
For this tutorial the path used is /usr/local/gcc-arm-none-eabi-5_2-2015q4/bin/arm-none-eabi- .
The Makefile provided in this tutorial already contains this toolchain path.
In this tutorial we want to use the same C source file for both the i.MX53 QSB and QEMU.
Both the board and QEMU will require the following files:
- Linker file (.ld)
- Assembly file (.S)
These files are distinct, although very similar in functioning method.
As for the C source file, it will be the same for both.
Besides these files, the board also requires additional files provided in the original code reference displayed above.
To summarise the required files:
- i.MX53 QSB requires: imx53.ld, imx53_entry.S, config.h, imximage.cfg, mxc_serial.c, mxc_serial.h and libgcc.a
- QEMU requires: qemu.ld and qemu_entry.S
- Both: main.c
In the end we want to have one imx53.imx and one qemu.img, that will run in the board and QEMU, respectively.
To ease the compile process, I combined everything into one Makefile.
Through this Makefile you can both compile and run for the board or QEMU separately or together.
Compile for both: make all
Compile separately: make qemu.img or imx53.img
Run/Deploy: make run-qemu or make run-imx (deploys onto the SD card).
For QEMU, the output is shown in the console, as for the i.MX53 QSB, using minicom (see the Hello World Demo tutorial) you can receive the output in the serial port designated.