Skip to content

Commit 9093c05

Browse files
committed
Refine RPi4 README and fix GIFs
1 parent 03f80ac commit 9093c05

21 files changed

+68
-64
lines changed

rpi4-ws/README.md

Lines changed: 61 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,14 @@ Start by setting the root folder path:
88
export ROOT=`realpath .`
99
```
1010

11-
# Setup firmware compnents
11+
# Setup firmware components
1212

1313
Some fimware components need to downloaded and built. Follow these steps:
1414

15+
```sh
16+
export ROOT=`pwd`
17+
```
18+
1519
```sh
1620
cd rpi4-ws
1721
export RPI4_WS=`pwd`
@@ -37,29 +41,36 @@ cd $RPI4_WS
3741
---
3842
## Prepare SDCard
3943

40-
In this example the sdcard is `/dev/mmcblk0` and the partitions are `/dev/mmcblk0p1`, `/dev/mmcblk0p2`, etc.
41-
42-
### i) Make sure all partitions are unmounted
44+
In this example the sdcard is `/dev/sdb` and the partitions are `/dev/sdb1`, `/dev/sdb2`, etc.
4345

46+
### i) Start by checking which SD card you have
4447
```sh
45-
umount /dev/mmcblk0*
48+
lsblk -o NAME,RM,SIZE,MODEL | grep 1
4649
```
50+
![SDcard](./img/.gif/SDcard.gif)
4751

48-
### ii) Delete all partitions
52+
### ii) Make sure all partitions are unmounted
4953

5054
```sh
51-
sudo fdisk /dev/mmcblk0
55+
umount /dev/<your SD card>*
5256
```
57+
![unmountSD](./img/.gif/unmountSD.gif)
58+
### iii) Delete all partitions
5359

60+
```sh
61+
sudo fdisk /dev/<your SD card>
62+
```
5463
Then run the commands:
5564

5665
* Press `d` until there are no more partitions (if it asks you for the partition, press `return` for the default)
5766
* Press `w` write changes and exit
5867

59-
### iii) Create partition
68+
![SDdelpart](./img/.gif/SDdelpart.gif)
69+
70+
### iv) Create partition
6071

6172
```sh
62-
sudo fdisk /dev/mmcblk0
73+
sudo fdisk /dev/<your SD card>
6374
```
6475

6576
Then run the commands:
@@ -76,30 +87,32 @@ Then run the commands:
7687
* type `c` for W95 FAT32 (LBA)
7788
* `w` to write changes and exit
7889

90+
![SDcreatepart](./img/.gif/SDcreatepart.gif)
7991

80-
### iv) Format partition
81-
92+
### v) Format partition
8293
Format the created partition to a fat filesystem:
83-
8494
```sh
85-
sudo mkfs.fat /dev/mmcblk0p1 -n boot
95+
sudo mkfs.fat /dev/<your SD card>1 -n boot
8696
```
8797

8898
Remove and insert the sd card to automatically mount it.
8999

90-
---
100+
![SDformat](./img/.gif/SDformat.gif)
91101

102+
---
92103
# Copy Firmware Files to SDCard
93-
copy the firmware and bao's final image to it:
104+
copy the firmware and CROSSCON Hypervisor's final image to it:
94105

95106
```sh
96-
export SDCARD=/media/$USER/boot
107+
cd $RPI4_WS
108+
SDCARD=/media/$USER/boot
97109

98-
cp -vr firmware/boot/* $SDCARD
110+
cp -vr firmware/boot/start* $SDCARD
99111
cp -v config.txt $SDCARD
100112
cp -v bin/bl31.bin $SDCARD
101113
cp -v bin/u-boot.bin $SDCARD
102114
```
115+
![SDcopyfw](./img/.gif/SDcopyfw.gif)
103116

104117
---
105118
# Build Components
@@ -113,7 +126,7 @@ cd $ROOT
113126
cd optee_os
114127

115128
OPTEE_DIR="./"
116-
export O="$OPTEE_DIR/optee-aarch64"
129+
export O="$OPTEE_DIR/optee-rpi4"
117130
CC="aarch64-none-elf-"
118131
export CFLAGS=-Wno-cast-function-type
119132
PLATFORM="rpi4"
@@ -155,7 +168,7 @@ make -C $OPTEE_DIR \
155168

156169

157170
OPTEE_DIR="./"
158-
export O="$OPTEE_DIR/optee2-aarch64"
171+
export O="$OPTEE_DIR/optee2-rpi4"
159172
SHMEM_START="0x08200000"
160173
TZDRAM_START="0x20100000"
161174

@@ -190,8 +203,8 @@ make -C $OPTEE_DIR \
190203
DEBUG=1 -j16
191204

192205
cd $ROOT
193-
194206
```
207+
![COMPoptee](./img/.gif/COMPoptee.gif)
195208

196209
## Step 2: Linux file system
197210
We will first build an incomplete filesystem to benefit fom buildroot building the appropriate linux toolchains.
@@ -222,6 +235,7 @@ make O=build-aarch64/ -j`nproc`
222235

223236
cd $ROOT
224237
```
238+
![COMPlinuxbefore](./img/.gif/COMPlinuxbefore.gif)
225239

226240
## Step 3: Build OP-TEE Clients
227241
Build the optee client application library and tee supplicant for both OP-TEEs.
@@ -231,11 +245,11 @@ cd optee_client
231245
git checkout master
232246
make CROSS_COMPILE=aarch64-none-linux-gnu- WITH_TEEACL=0 O=out-aarch64
233247
git checkout optee2
234-
make CROSS_COMPILE=aarch64-none-linux-gnu- WITH_TEEACL=0 O=out2-aarch64 CFG_TEE_FS_PARENT_PATH=/data/tee2
248+
make CROSS_COMPILE=aarch64-none-linux-gnu- WITH_TEEACL=0 O=out2-aarch64
235249

236250
cd $ROOT
237251
```
238-
252+
![COMPopteeclient](./img/.gif/COMPopteeclient.gif)
239253
## Step 4: Build OP-TEE xtest
240254
Build the OP-TEE xtest test suite.
241255
``` sh
@@ -248,7 +262,7 @@ export TA_CROSS_COMPILE=$BUILDROOT/host/bin/aarch64-linux-
248262
export ARCH=aarch64
249263
export PLATFORM=plat-vexpress
250264
export PLATFORM_FLAVOR=qemu_armv8a
251-
export TA_DEV_KIT_DIR=`pwd`/../optee_os/optee-aarch64/export-ta_arm64
265+
export TA_DEV_KIT_DIR=`pwd`/../optee_os/optee/export-ta_arm64
252266
export TEEC_EXPORT=`pwd`/../optee_client/out-aarch64/export/usr/
253267
export OPTEE_CLIENT_EXPORT=`pwd`/../optee_client/out-aarch64/export/usr/
254268
export CFG_TA_OPTEE_CORE_API_COMPAT_1_1=y
@@ -270,7 +284,7 @@ make install
270284

271285
export O=`pwd`/out2-aarch64
272286
export DESTDIR=./to_buildroot-aarch64-2
273-
export TA_DEV_KIT_DIR=`pwd`/../optee_os/optee2-aarch64/export-ta_arm64
287+
export TA_DEV_KIT_DIR=`pwd`/../optee_os/optee2/export-ta_arm64
274288
export TEEC_EXPORT=`pwd`/../optee_client/out2-aarch64/export/usr/
275289
export OPTEE_CLIENT_EXPORT=`pwd`/../optee_client/out2-aarch64/export/usr/
276290
rm -rf `pwd`/out2-aarch64
@@ -285,6 +299,7 @@ find . -name "Makefile" -exec sed -i "s/optee2_armtz/optee_armtz/g" {} +
285299
mv $DESTDIR/bin/xtest $DESTDIR/bin/xtest2
286300
cd $ROOT
287301
```
302+
![COMPxtest](./img/.gif/COMPxtest.gif)
288303

289304
## Step 5: Compile Bitcoin Wallet Client and Trusted Application
290305
```sh
@@ -297,7 +312,7 @@ export HOST_CROSS_COMPILE=$BUILDROOT/host/bin/aarch64-linux-
297312
export TA_CROSS_COMPILE=$BUILDROOT/host/bin/aarch64-linux-
298313
export ARCH=aarch64
299314
export PLATFORM=plat-virt
300-
export TA_DEV_KIT_DIR=`pwd`/../optee_os/optee-aarch64/export-ta_arm64
315+
export TA_DEV_KIT_DIR=`pwd`/../optee_os/optee/export-ta_arm64
301316
export TEEC_EXPORT=`pwd`/../optee_client/out-aarch64/export/usr/
302317
export OPTEE_CLIENT_EXPORT=`pwd`/../optee_client/out-aarch64/export/usr/
303318
export CFG_TA_OPTEE_CORE_API_COMPAT_1_1=n
@@ -306,7 +321,6 @@ export DEBUG=0
306321
export CFG_TEE_TA_LOG_LEVEL=0
307322
export O=`pwd`/out-aarch64
308323

309-
310324
rm -rf out-aarch64/
311325
## make sure we have things setup for first OP-TEE
312326
find . -name "Makefile" -exec sed -i "s/\-lteec2$/\-lteec/g" {} +
@@ -321,8 +335,6 @@ cp out-aarch64/*.ta to_buildroot-aarch64/lib/optee_armtz
321335
cp host/wallet to_buildroot-aarch64/bin/bitcoin_wallet_ca
322336
chmod +x to_buildroot-aarch64/bin/bitcoin_wallet_ca
323337

324-
325-
326338
## setup second OP-TEE
327339
export O=`pwd`/out2-aarch64
328340
export DESTDIR=./to_buildroot-aarch64-2
@@ -348,13 +360,12 @@ chmod +x to_buildroot-aarch64-2/bin/bitcoin_wallet_ca2
348360

349361
cd $ROOT
350362
```
363+
![COMPbw](./img/.gif/COMPbw.gif)
351364

352365
## Step 6: Compile Malicious Client and Trusted Application
353366
```
354367
cd malicous_ta
355-
356368
BUILDROOT=`pwd`/../buildroot/build-aarch64/
357-
358369
export CROSS_COMPILE=$BUILDROOT/host/bin/aarch64-linux-
359370
export HOST_CROSS_COMPILE=$BUILDROOT/host/bin/aarch64-linux-
360371
export TA_CROSS_COMPILE=$BUILDROOT/host/bin/aarch64-linux-
@@ -369,23 +380,17 @@ export DEBUG=0
369380
export CFG_TEE_TA_LOG_LEVEL=2
370381
export O=`pwd`/out-aarch64
371382
export aarch64_TARGET=y
372-
373-
374383
rm -rf out-aarch64/
375384
## make sure we have things setup for first OP-TEE
376385
find . -name "Makefile" -exec sed -i "s/\-lteec2$/\-lteec/g" {} +
377386
find . -name "Makefile" -exec sed -i "s/optee2_armtz/optee_armtz/g" {} +
378387
make clean
379388
make -j`nproc`
380-
381389
mkdir -p to_buildroot-aarch64/lib/optee_armtz
382390
mkdir -p to_buildroot-aarch64/bin
383-
384391
cp out-aarch64/*.ta to_buildroot-aarch64/lib/optee_armtz
385392
cp host/malicious_ca to_buildroot-aarch64/bin/malicious_ca
386393
chmod +x to_buildroot-aarch64/bin/malicious_ca
387-
388-
389394
## setup second OP-TEE
390395
export O=`pwd`/out2-aarch64
391396
export DESTDIR=./to_buildroot-aarch64-2
@@ -400,17 +405,14 @@ make -j`nproc`
400405
## undo changes
401406
find . -name "Makefile" -exec sed -i "s/\-lteec2/\-lteec/g" {} +
402407
find . -name "Makefile" -exec sed -i "s/optee2_armtz/optee_armtz/g" {} +
403-
404408
mkdir -p to_buildroot-aarch64-2/lib/optee2_armtz
405409
mkdir -p to_buildroot-aarch64-2/bin
406-
407410
cp out2-aarch64/*.ta to_buildroot-aarch64-2/lib/optee2_armtz
408411
cp host/malicious_ca to_buildroot-aarch64-2/bin/malicious_ca2
409412
chmod +x to_buildroot-aarch64-2/bin/malicious_ca2
410-
411-
412413
cd $ROOT
413414
```
415+
![COMPlinuxkernel](./img/.gif/COMPmalicious.gif)
414416

415417
## Step 7: Finalize Linux file system
416418
We have everything setup now, so build the final file system for Linux.
@@ -421,7 +423,7 @@ make O=build-aarch64/ -j`nproc`
421423

422424
cd $ROOT
423425
```
424-
426+
![COMPlinuxfinal](./img/.gif/COMPlinuxfinal.gif)
425427

426428
## Step 8: Build Linux
427429

@@ -437,14 +439,13 @@ make ARCH=arm64 O=build-aarch64 CROSS_COMPILE=`realpath ../buildroot/build-aarch
437439
cd $ROOT
438440
```
439441

440-
### Bind Linux Image and device tree
441-
442-
```sh
443-
cd rpi4-ws
442+
![COMPlinuxkernel](./img/.gif/COMPlinuxkernel.gif)
444443

445-
dtc -I dts -O dtb rpi4.dts > rpi4.dtb
444+
---
445+
### Step 9: Bind Linux Image and device tree
446446

447-
cd $ROOT
447+
```sh
448+
dtc -I dts -O dtb rpi4-ws/rpi4.dts > rpi4-ws/rpi4.dtb
448449
```
449450

450451
```sh
@@ -454,29 +455,36 @@ rm linux-rpi4.bin
454455
rm linux-rpi4.elf
455456
make \
456457
IMAGE=../linux/build-aarch64/arch/arm64/boot/Image \
457-
DTB=../rpi4-ws/rpi4.dtb \
458+
DTB=../rpi4-ws/rpi4-dt1.dtb \
458459
TARGET=linux-rpi4.bin \
459460
CROSS_COMPILE=aarch64-none-elf- \
460461
ARCH=aarch64
461462

462463
cd $ROOT
463464
```
465+
![COMPdt](./img/.gif/COMPdt.gif)
466+
464467

465468
### Simple Demo
466469
This demo instantiates a Linux VM and an OP-TEE VM.
467470
Insert the sdcard in your pc, and wait for it to mount the boot partition. The script expects it to be mount on `/media/$USER/boot`
468471
``` sh
469-
cd rpi4-ws
470-
471472
./build-demo-vtee.sh
472-
473-
cd $ROOT
474473
```
474+
![RUNsimpledemo](./img/.gif/RUNsimpledemo.gif)
475+
475476
#### Setup board
476477

477478
Insert the sd card in the board's sd slot.
478479

479-
Connect to the Raspberry Pi's UART using a USB-to-TTL adapter to connect to the Raspberry Pi's GPIO header UART pins. Use a terminal application such as `miniterm.py` from pyserial package. For example:
480+
Connect to the Raspberry Pi's UART using a USB-to-TTL adapter to connect to the Raspberry Pi's GPIO header UART pins.
481+
482+
- VCC (Pin 4 on RPI4) → Connect to VCC on the USB-to-TTL adapter. This provides power to the adapter.
483+
- GND (Pin 6 on RPI4) → Connect to GND on the adapter to establish a common ground.
484+
- TX (Pin 8 on RPI4) → Connect to RX on the adapter. This allows the RPI4 to send data to the adapter’s receive line.
485+
- RX (Pin 10 on RPI4) → Connect to TX on the adapter, enabling data reception from the adapter’s transmit line.
486+
487+
Use a terminal application such as `miniterm.py` from pyserial package. For example:
480488

481489
```
482490
miniterm.py /dev/ttyUSB0 115200
@@ -502,11 +510,7 @@ xtest -t regression
502510
### Demo 2
503511
This demo instantiates a Linux VM and two OP-TEE VMs.
504512
``` sh
505-
cd rpi4-ws
506-
507513
./build-demo-dual-vtee.sh
508-
509-
cd $ROOT
510514
```
511515

512516
After Linux finishes booting you may execute xtest in both OP-TEE VMs.

rpi4-ws/build-demo-dual-vtee.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ make -C CROSSCON-Hypervisor/ \
2424
CROSS_COMPILE=aarch64-none-elf- \
2525
-j`nproc`
2626

27-
cp -vr rpi4-ws/firmware/boot/start* $SDCARD
28-
cp -uv CROSSCON-Hypervisor/bin/rpi4/builtin-configs/rpi4-dual-vTEE/crossconhyp.bin $SDCARD
27+
cp -vr firmware/boot/start* $SDCARD
28+
cp -uv CROSSCON-Hypervisor/bin/rpi4/builtin-configs/rpi4-dual-vTEE/crossconhyp.bin /media/$USER/boot
2929

3030
umount /media/$USER/boot
3131

rpi4-ws/build-demo-vtee.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ make -C CROSSCON-Hypervisor/ \
2323
SDEES="sdSGX sdTZ" \
2424
CROSS_COMPILE=aarch64-none-elf- \
2525
-j`nproc`
26-
26+
export SDCARD=/media/$USER/boot
2727
cp -vr rpi4-ws/firmware/boot/start* $SDCARD
28-
cp -uv CROSSCON-Hypervisor/bin/rpi4/builtin-configs/rpi4-single-vTEE/crossconhyp.bin $SDCARD
28+
cp -uv CROSSCON-Hypervisor/bin/rpi4/builtin-configs/rpi4-single-vTEE/crossconhyp.bin /media/$USER/boot
2929

3030
umount /media/$USER/boot
3131

rpi4-ws/configs/rpi4-dual-vTEE/config.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include <config.h>
22

3-
VM_IMAGE(optee2_os_image, "../optee_os/optee2-aarch64/core/tee-pager_v2.bin");
3+
VM_IMAGE(optee2_os_image, "../optee_os/optee2-rpi4/core/tee-pager_v2.bin");
44

55
struct vm_config optee2_os = {
66
.image = {
@@ -140,7 +140,7 @@ struct vm_config linux = {
140140
}
141141
};
142142

143-
VM_IMAGE(optee_os_image, "../optee_os/optee-aarch64/core/tee-pager_v2.bin");
143+
VM_IMAGE(optee_os_image, "../optee_os/optee-rpi4/core/tee-pager_v2.bin");
144144

145145

146146
struct vm_config optee_os = {

rpi4-ws/configs/rpi4-single-vTEE/config.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ struct vm_config linux = {
8282
}
8383
};
8484

85-
VM_IMAGE(optee_os_image, "../optee_os/optee-aarch64/core/tee-pager_v2.bin");
85+
VM_IMAGE(optee_os_image, "../optee_os/optee-rpi4/core/tee-pager_v2.bin");
8686

8787

8888
struct vm_config optee_os = {

rpi4-ws/img/.gif/COMPbw.gif

619 KB
Loading

rpi4-ws/img/.gif/COMPdt.gif

145 KB
Loading
330 KB
Loading
887 KB
Loading
638 KB
Loading

0 commit comments

Comments
 (0)