h2. License

The use of Juno software is subject to the terms of the Juno "End User License Agreement":https://releases.linaro.org/14.06/openembedded/juno-lsk/#tabs-5.

h2. Building the Linaro Kernel

h3. Prerequisites

* Ubuntu 12.04 64 bit system. You can download Ubuntu from ubuntu.com
* git

bc. sudo apt-get install build-essential git

* toolchain

bc. mkdir -p ~/bin
cd ~/bin
wget http://releases.linaro.org/13.11/components/toolchain/binaries/gcc-linaro-aarch64-linux-gnu-4.8-2013.11_linux.tar.xz
tar xf gcc-linaro-aarch64-linux-gnu-4.8-2013.11_linux.tar.xz
PATH=$PATH:~/bin/gcc-linaro-aarch64-linux-gnu-4.8-2013.11_linux/bin

h3. Get the Linaro Kernel Source

bc. git clone https://git.linaro.org/landing-teams/working/arm/kernel-release.git
cd kernel
git checkout <release tag>

h3. Create a kernel config

Do not use the arm64 defconfig, instead, build a config from the config fragments that Linaro provides:

bc. ARCH=arm64 scripts/kconfig/merge_config.sh \
linaro/configs/linaro-base.conf \
linaro/configs/distribution.conf \
linaro/configs/vexpress64.conf \

Note: the config fragments are part of the git repository and the source tarball.

h3. Build the kernel

To build the kernel Image and juno.dtb files, use the following command:

bc. make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- Image dtbs

h3. Install your kernel

Copy the kernel Image and the juno.dtb files to the BOOT partition on the USB drive created in the "Binary Installation tab":https://releases.linaro.org/14.06/openembedded/juno-lsk/#tabs-2.

bc. cp arch/arm64/boot/Image /media/BOOT/Image
cp arch/arm64/boot/dts/juno.dtb /media/BOOT/juno/juno.dtb


h1. Building Firmware From Source

h2. Prerequisites

The following tools and environment are required:


* Ubuntu desktop OS and the following packages. ARM have only tested with Ubuntu 12.04.02 (64-bit).
** `git` package to obtain source code
** `ia32-libs` package
** `build-essential` and `uuid-dev` packages for building the UEFI and Firmware Image Package (FIP) tool

* Baremetal GNU GCC tools. Can be downloaded from Linaro 
** "http://releases.linaro.org/13.11/components/toolchain/binaries/gcc-linaro-aarch64-none-elf-4.8-2013.11_linux.tar.xz":http://releases.linaro.org/13.11/components/toolchain/binaries/gcc-linaro-aarch64-none-elf-4.8-2013.11_linux.tar.xz

* The instructions on this page below assume that the environment variable $JUNO_ROOT_DIR  has been initialised to a working directory.

bc. $ export JUNO_ROOT_DIR=<path-to-working-dir>/<name-of-working-dir>


h2. SCP Firmware

The SCP Firmware is only available as a pre-built binary.

 

h2. ARM Trusted Firmware

The ARM trusted firmware consists of the following images:

|<b>Filename</b>|<b>Image Type</b>|<b>Image Name</b>|
|bl1.bin|BL1|ARM Trusted ROM image|
|bl2.bin|BL2|ARM Trusted Firmware|
|bl31.bin|BL3-1|EL3 runtime|
|bl32.bin (optional)|BL3-2|Test Secure Payload|

The bl2.bin, bl31.bin and bl32.bin images are inputs to the process of creating a Firmware Image Package.

h3. Obtaining sources

Clone the ARM Trusted Firmware repository from GitHub:

bc. $ cd $JUNO_ROOT_DIR
$ git clone https://github.com/ARM-software/arm-trusted-firmware.git
$ cd arm-trusted-firmware
$ git checkout v0.4-Juno-0.5

h3. Configuration

Set the compiler path

bc. $ export CROSS_COMPILE=<path-to-aarch64-gcc>/bin/aarch64-none-elf-

h3. Building

1. Change to the trusted firmware directory:

bc. $ cd $JUNO_ROOT_DIR/arm-trusted-firmware

2. Build the different firmware images:

bc. $ make PLAT=juno all

To build the optional bl3-2 Test Secure Payload component, use the following commands instead (the 'make realclean' is important):

bc. $ make realclean
$ make PLAT=juno SPD=tspd all

By default the preceding commands produce a release version of the build. To produce a debug version instead and make the build more verbose use:

bc. $ make PLAT=juno DEBUG=1 V=1 all

The build process creates products in a `build` directory tree, building the objects for each boot loader stage in separate sub-directories. The following boot loader binary files are created:

* @build/juno/<build-type>/bl1.bin@
* @build/juno/<build-type>/bl2.bin@
* @build/juno/<build-type>/bl31.bin@
* @build/juno/<build-type>/bl32.bin@     (if the 'SPD=tspd' flag is used)

... where @<build-type>@ is either `debug` or `release`.

To clean the ARM Trusted Firmware source tree (warning, this will remove the binaries too):

bc. $ make realclean

 

h2. UEFI

UEFI is a single bl33.bin image that is an input to the process of creating a Firmware Image Package.

h3. Obtaining sources

Clone the Juno UEFI Github repository:

bc. $ cd $JUNO_ROOT_DIR
$ git clone https://github.com/ARM-software/edk2.git -b juno
$ cd edk2
$ git checkout v1.0-rc0

 

h3. Configuration

1. Define the AArch64 GCC toolchain:

bc. $ export GCC48_AARCH64_PREFIX=<path-to-aarch64-gcc>/bin/aarch64-none-elf-

2. Configure Tianocore environment:

bc. $ cd $JUNO_ROOT_DIR/edk2
$ . edksetup.sh
$ make -C BaseTools

h3. Building

1. Change to the EDK2 directory:

bc. $ cd $JUNO_ROOT_DIR/edk2

2. To build DEBUG version of UEFI firmware:

bc. $ make -f ArmPlatformPkg/ArmJunoPkg/Makefile

The build produces the binary $JUNO_ROOT_DIR/edk2/Build/ArmJuno/DEBUG_GCC48/FV/BL32_AP_UEFI.fd that should be used as 'bl33.bin' when generating the Firmware Image Package binary.

To build RELEASE version of UEFI firmware:

bc. $ make -f ArmPlatformPkg/ArmJunoPkg/Makefile EDK2_BUILD=RELEASE

Use the release binary $JUNO_ROOT_DIR/edk2/Build/ArmJuno/RELEASE_GCC48/FV/BL32_AP_UEFI.fd as bl33.bin when generating the Firmware Image Package binary.

To clean EDK2 source tree:

bc. $ make -f ArmPlatformPkg/ArmJunoPkg/Makefile clean

 

h2. Packaging the binaries

ARM Trusted Firmware uses the Firmware Image Package (FIP) binary blob to load images into the system, so that the firmware can avoid managing lots of smaller images. The FIP will contain:

* BL2 and BL3-1 boot loader images
* Test Secure Payload (BL3-2 image - optional)
* UEFI firmware (BL3-3 image)
* SCP firmware (BL3-0 image)

Note: BL1 image is NOT part of the FIP.


h3. Building a FIP binary

The steps to create a FIP are as follows:

1. Build the 'fip_create' tool.

bc. $ cd $JUNO_ROOT_DIR/arm-trusted-firmware
$ make fiptool

2. Define the FIP environment. Specifically, include the FIP tool in the path.

bc. $ export PATH=$JUNO_ROOT_DIR/arm-trusted-firmware/tools/fip_create:$PATH

3. Gather the binary files (the following example is for release builds only).

bc. $ cd $JUNO_ROOT_DIR
$ mkdir fip
$ cd fip
$ cp <path to prebuilt binary>/bl30.bin .
$ cp $JUNO_ROOT_DIR/arm-trusted-firmware/build/juno/release/bl2.bin .
$ cp $JUNO_ROOT_DIR/arm-trusted-firmware/build/juno/release/bl31.bin .
$ cp $JUNO_ROOT_DIR/edk2/Build/ArmJuno/RELEASE_GCC48/FV/BL32_AP_UEFI.fd  bl33.bin

 

4. Create the FIP file:

bc. $ fip_create --dump          \
             --bl2 bl2.bin   \
             --bl30 bl30.bin \
             --bl31 bl31.bin \
             --bl32 bl32.bin \    (if the optional bl32 image is present)
             --bl33 bl33.bin \
             fip.bin

The previous command will display the FIP layout:

 
bc. Firmware Image Package ToC:
---------------------------
- Trusted Boot Firmware BL2: offset=0xD8, size=0x5268
- SCP Firmware BL3-0: offset=0x5340, size=0x9C64
- EL3 Runtime Firmware BL3-1: offset=0xEFA4, size=0x82A0
- Non-Trusted Firmware BL3-3: offset=0x17244, size=0xF0000
---------------------------
Creating "fip.bin";

5. Optional: the `fip_create` tool can be used in the exact same way to update individual images inside an existing FIP file. For example, to update the SCP Firmware BL3-0 image:

bc. $ fip_create --dump --bl30 new_bl30.bin fip.bin

The previous command will again display the FIP layout:

bc. Firmware Image Package ToC:
---------------------------
- Trusted Boot Firmware BL2: offset=0xD8, size=0x5268
- SCP Firmware BL3-0: offset=0x5340, size=0x9C64
file: 'new_bl30.bin'
- EL3 Runtime Firmware BL3-1: offset=0xEFA4, size=0x82A0
- Non-Trusted Firmware BL3-3: offset=0x17244, size=0xF0000
---------------------------
Updating "fip.bin"

For more details and options about the `fip_create` tool:

bc. $ fip_create --help
