@@ -39,8 +39,8 @@ The on-disk partition layout will be:
39
39
index | name | size | format | notes
40
40
------|------------|---------|--------|-----------------------------------------------
41
41
1 | boot | 10M | raw | Must cover disk bytes 1024 onwards as we'll directly write the bootloader here.
42
- 2 | proof | 512KB | ext4 | EXT4 filesytem for storing a serialised proof bundle
43
- 3 | firmware | 64MB+ | ext4 | EXT4 filesystem containing the bootable firmware image, armory boot config, and DTD file .
42
+ 2 | proof | 512KB | ext4 | EXT4 filesystem for storing a serialised proof bundle
43
+ 3 | firmware | 64MB+ | ext4 | EXT4 filesystem containing the bootable firmware image, armory boot config, etc .
44
44
45
45
### Preparing the SD Card
46
46
@@ -80,7 +80,7 @@ Model: Generic- Micro SD/M2 (scsi)
80
80
Disk /dev/sdc: 15931539456B
81
81
Sector size (logical/physical): 512B/512B
82
82
Partition Table: msdos
83
- Disk Flags:
83
+ Disk Flags:
84
84
85
85
Number Start End Size Type File system Flags
86
86
1 512B 10240511B 10240000B primary lba
@@ -108,9 +108,9 @@ To compile the bootloader itself, run the following command in the `bootloader`
108
108
directory:
109
109
110
110
``` bash
111
- # Note that START_KERNEL corresponds to the offset of the firmware partition,
111
+ # Note that START_KERNEL corresponds to the offset of the firmware partition,
112
112
# and START_PROOF is the offset of the proof partition
113
- make CROSS_COMPILE=arm-none-eabi- TARGET=usbarmory imx BOOT=uSD START_KERNEL=10753536 START_PROOF=10240512 LEN_KERNEL=89246720
113
+ make CROSS_COMPILE=arm-none-eabi- TARGET=usbarmory imx BOOT=uSD START_KERNEL=10753536 START_PROOF=10240512 LEN_KERNEL=89246720
114
114
```
115
115
116
116
If successful, this will create a few files - the one we're interested in is
@@ -130,7 +130,8 @@ $ sudo dd if=armory-boot.imx of=/dev/myscard bs=512 seek=2 conv=fsync,notrunc
130
130
Firmware images
131
131
---------------
132
132
133
- Currently, the bootloader can only chain to a Linux kernel.
133
+ Currently, the bootloader can only chain to either a Linux kernel, or a
134
+ bare-metal ELF unikernel (only tested with tamago-example thus far).
134
135
135
136
There are some invariants which must hold for this chain to work:
136
137
1 . The ` firmware ` partition MUST be located at the precise offset mentioned
@@ -140,18 +141,45 @@ There are some invariants which must hold for this chain to work:
140
141
following contents:
141
142
* ` armory-boot.conf ` - a JSON file which tells the bootloader which files
142
143
to load
143
- * a valid ARM linux Kernel image
144
- * a valid DTB file
145
- Note that the ` armory-boot.conf ` file also contains SHA256 hashes of the
146
- kernel and DTB files, and these MUST be correct.
144
+ * Either:
145
+ * to boot a Linux Kernel:
146
+ * a valid ARM linux Kernel image
147
+ * a valid DTB file
148
+ * to boot ELF unikernel:
149
+ * a valid ARM bare-metal ELF binary/unikernel
147
150
151
+ Note that the ` armory-boot.conf ` file also contains SHA256 hashes of
152
+ all files referenced, and these MUST be correct.
153
+
154
+ To aid in the creation of valid firmware images, use the
155
+ ` [cmd/usb_armory/image_builder/build.sh](/binary_transparency/firmware/cmd/usb_armory/image_builder/build.sh) `
156
+ script, e.g.:
157
+
158
+ ``` bash
159
+ $ ./cmd/usb_armory/image_builder/build.sh -u ./testdata/firmware/usb_armory/example/tamago-example -o /tmp/armory.ext4
160
+
161
+ /tmp/armory.ext4: Writing to the journal is not supported.
162
+ Created image in /tmp/armory.ext4:
163
+ -rw-rw-r-- 1 al al 13M Nov 30 10:39 /tmp/armory.ext4
164
+
165
+ ```
166
+
167
+ For now, this image can be written to the target partition using ` dd ` , e.g.:
168
+
169
+ ``` bash
170
+ $ sudo dd if=/tmp/armory.ext of=/dev/my_sdcard3 bs=1M conf=fsync
171
+ ```
172
+
173
+ TODO(al): consider updating ` flash_tool ` with support for writing these images.
174
+
175
+ ### Linux
148
176
149
177
> :frog : The [ Armory Debian Base Image] ( https://github.com/f-secure-foundry/usbarmory-debian-base_image/releases )
150
178
> is a good source for the kernel (zImage) and dtb files.
151
179
>
152
180
> You can decompress and mount the image to access the files like so:
153
181
> ``` bash
154
- > # decompress image
182
+ > # decompress image
155
183
> $ xz -d usbarmory-mark-two-usd-debian_buster-base_image-20200714.raw.xz
156
184
> # mount image with loopback:
157
185
> # note the offset parameter below - the raw file is a complete disk image, this
@@ -170,7 +198,7 @@ There are some invariants which must hold for this chain to work:
170
198
> -rwxr-xr-x 1 root root 6726952 Oct 20 17:13 zImage-5.4.72-0-usbarmory
171
199
> ` ` `
172
200
173
- An example ` armory-boot.conf` file is:
201
+ An example ` armory-boot.conf` file configured to boot a Linux kernel is:
174
202
175
203
` ` ` json
176
204
{
@@ -188,6 +216,24 @@ An example `armory-boot.conf` file is:
188
216
189
217
TODO(al): Consider wrapping this up into a script.
190
218
219
+ ### ELF unikernel
220
+
221
+ > :frog : A good sample unikernel is the
222
+ > [ tamago-example] ( https://github.com/f-secure-foundry/tamago-example )
223
+ > application.
224
+
225
+ An example ` armory-boot.conf ` file configured to boot an ELF unikernel is:
226
+
227
+ ``` json
228
+ {
229
+ "unikernel" : [
230
+ " /boot/tamago-example" ,
231
+ " aceb3514d5ba6ac591a7d5f2cad680e83a9f848d19763563da8024f003e927c7"
232
+ ]
233
+ }
234
+ ```
235
+
236
+
191
237
Booting
192
238
-------
193
239
@@ -211,3 +257,12 @@ Dentry cache hash table entries: 65536 (order: 6, 262144 bytes, linear)
211
257
...
212
258
```
213
259
260
+
261
+ Firmware Measurement
262
+ --------------------
263
+
264
+ The 'firmware measurement' hash for the USB Armory is defined to be the SHA256
265
+ hash of the raw bytes of the ` ext4 ` ** filesystem image** stored in the
266
+ 'firmware' partition of the SD Card.
267
+
268
+ Note that this _ may well_ be a different size than the partition itself.
0 commit comments