summaryrefslogtreecommitdiff
path: root/members/arm/android/images/armv8-android-juno-lsk/HOWTO_getsourceandbuild.txt
blob: 8a6453c82971556bf15b85bd4371770549866594 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
h2. License

The use of Juno software is subject to the terms of the Juno "End User License Agreement":https://releases.linaro.org/14.09/members/arm/android/images/armv8-android-juno-lsk/#tabs-5.

h1. Accessing Source Code

h2. Linaro Android Source Code

Run the "linaro_android_build_cmds.sh":https://releases.linaro.org/14.09/members/arm/android/images/armv8-android-juno-lsk/linaro_android_build_cmds.sh script, it will download the entire source code for both Android and the kernel and attempt to build it.

The pinned and source manifests can be found here:

* "Pinned Manifest":https://releases.linaro.org/14.09/members/arm/android/images/armv8-android-juno-lsk/pinned-manifest.xml ("?":https://wiki.linaro.org/Platform/Android/ReproduceABuildExactly)
* "Source Manifest":https://releases.linaro.org/14.09/members/arm/android/images/armv8-android-juno-lsk/source-manifest.xml

h2. Compiling Linaro Android RootFS+Kernel

The following simple steps download, install and compile a complete Linaro Android distribution

* Download and install Ubuntu 12.04 64 bit or newer ("download":http://www.ubuntu.com)
* Install the following packages:

bc. sudo apt-get update
sudo apt-get install zip curl flex bison build-essential git-core gnupg gperf zlib1g-dev libx11-dev x11proto-core-dev \
gcc-multilib g++-multilib libc6-dev-i386 ia32-libs lib32z-dev gcc-4.5 g++-4.5 cpp-4.5 gcc-4.5-multilib g++-4.5-multilib \
uuid-dev openjdk-7-jdk ant lib32ncurses5-dev xsltproc
sudo update-alternatives --config java
sudo update-alternatives --config javac
sudo update-alternatives --config javadoc

* Accept the EULA and download the Mali graphics (vendor.tar.bz2) libraries from "here":https://releases.linaro.org/14.09/members/arm/android/images/armv8-android-juno-lsk/vendor.tar.bz2
* Download the Android building script for this release from "here":https://releases.linaro.org/14.09/members/arm/android/images/armv8-android-juno-lsk/linaro_android_build_cmds.sh or from the list of artifacts listed above.

* Run the script

bc. chmod a+x linaro_android_build_cmds.sh
./linaro_android_build_cmds.sh -o $PWD/vendor.tar.bz2 -t

h3. Installing Android on your board

* Insert a USB drive and note the assigned @'/dev/sdX'@ or @'/dev/mmcblk0'@

bc. dmesg | less

Look for a line that looks like the following at the end of the log

@[288582.790722] sdc: sdc1 sdc2 sdc3 sdc4 <sdc5 sdc6 >@

Or, if your machine uses '/dev/mmcblkX', you may see a line line this:

@[10770.938042]  mmcblk0: p1 p2 p3 p4 < p5 p6 >@

*WARNING:* In the next step, make sure you use /dev/"whatever you see above". *You can erase your hard drive* with the wrong parameter.

* Create media

bc. cd android/out/target/product/juno
sudo linaro-android-media-create --mmc /dev/sdX --dev vexpress --boot boot.tar.bz2 --system system.tar.bz2 --userdata userdata.tar.bz2

* Insert the USB drive into your board and reboot it

p. You must configure UEFI exach time you create a new disk image.


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:

| *Filename* | *Image Type* | *Image Name* |
|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/BL33_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/BL33_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. Download the "firmware image artefacts":https://wiki.linaro.org/ARM/Juno?action=AttachFile&do=get&target=juno-firmware-beta-0.8.1.zip and extract to a working directory (hereafter referred to as @"<path to prebuilt binary>"@).

4. 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/arm-trusted-firmware/build/juno/release/bl32.bin .
$ cp $JUNO_ROOT_DIR/edk2/Build/ArmJuno/RELEASE_GCC48/FV/BL33_AP_UEFI.fd  bl33.bin

If you wish to use the pre-built ARM trusted firmware and UEFI EDK2 images instead of building them from source, then the last four lines of the above block can independently be replaced with the following:

bc. $ cp <path to prebuilt binary>/bl2.bin .
$ cp <path to prebuilt binary>/bl31.bin .
$ cp <path to prebuilt binary>/bl32.bin .
$ cp <path to prebuilt binary>/bl33.bin .


5. 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";

6. 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


h2. Installing the binaries

Please refer to the section titled "Firmware update" on the "Binary Image Installation tab":https://releases.linaro.org/14.09/members/arm/android/images/armv8-android-juno-lsk/#tabs-2.