@@ -8,10 +8,14 @@ Start by setting the root folder path:
88export ROOT=` realpath .`
99```
1010
11- # Setup firmware compnents
11+ # Setup firmware components
1212
1313Some fimware components need to downloaded and built. Follow these steps:
1414
15+ ``` sh
16+ export ROOT=` pwd`
17+ ```
18+
1519``` sh
1620cd rpi4-ws
1721export 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+ ```
5463Then 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
6576Then 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
8293Format 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
8898Remove 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
99111cp -v config.txt $SDCARD
100112cp -v bin/bl31.bin $SDCARD
101113cp -v bin/u-boot.bin $SDCARD
102114```
115+ ![ SDcopyfw] ( ./img/.gif/SDcopyfw.gif )
103116
104117---
105118# Build Components
@@ -113,7 +126,7 @@ cd $ROOT
113126cd optee_os
114127
115128OPTEE_DIR=" ./"
116- export O=" $OPTEE_DIR /optee-aarch64 "
129+ export O=" $OPTEE_DIR /optee-rpi4 "
117130CC=" aarch64-none-elf-"
118131export CFLAGS=-Wno-cast-function-type
119132PLATFORM=" rpi4"
@@ -155,7 +168,7 @@ make -C $OPTEE_DIR \
155168
156169
157170OPTEE_DIR=" ./"
158- export O=" $OPTEE_DIR /optee2-aarch64 "
171+ export O=" $OPTEE_DIR /optee2-rpi4 "
159172SHMEM_START=" 0x08200000"
160173TZDRAM_START=" 0x20100000"
161174
@@ -190,8 +203,8 @@ make -C $OPTEE_DIR \
190203 DEBUG=1 -j16
191204
192205cd $ROOT
193-
194206```
207+ ![ COMPoptee] ( ./img/.gif/COMPoptee.gif )
195208
196209## Step 2: Linux file system
197210We 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
223236cd $ROOT
224237```
238+ ![ COMPlinuxbefore] ( ./img/.gif/COMPlinuxbefore.gif )
225239
226240## Step 3: Build OP-TEE Clients
227241Build the optee client application library and tee supplicant for both OP-TEEs.
@@ -231,11 +245,11 @@ cd optee_client
231245git checkout master
232246make CROSS_COMPILE=aarch64-none-linux-gnu- WITH_TEEACL=0 O=out-aarch64
233247git 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
236250cd $ROOT
237251```
238-
252+ ![ COMPopteeclient ] ( ./img/.gif/COMPopteeclient.gif )
239253## Step 4: Build OP-TEE xtest
240254Build the OP-TEE xtest test suite.
241255``` sh
@@ -248,7 +262,7 @@ export TA_CROSS_COMPILE=$BUILDROOT/host/bin/aarch64-linux-
248262export ARCH=aarch64
249263export PLATFORM=plat-vexpress
250264export 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
252266export TEEC_EXPORT=` pwd` /../optee_client/out-aarch64/export/usr/
253267export OPTEE_CLIENT_EXPORT=` pwd` /../optee_client/out-aarch64/export/usr/
254268export CFG_TA_OPTEE_CORE_API_COMPAT_1_1=y
@@ -270,7 +284,7 @@ make install
270284
271285export O=` pwd` /out2-aarch64
272286export 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
274288export TEEC_EXPORT=` pwd` /../optee_client/out2-aarch64/export/usr/
275289export OPTEE_CLIENT_EXPORT=` pwd` /../optee_client/out2-aarch64/export/usr/
276290rm -rf ` pwd` /out2-aarch64
@@ -285,6 +299,7 @@ find . -name "Makefile" -exec sed -i "s/optee2_armtz/optee_armtz/g" {} +
285299mv $DESTDIR /bin/xtest $DESTDIR /bin/xtest2
286300cd $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-
297312export TA_CROSS_COMPILE=$BUILDROOT /host/bin/aarch64-linux-
298313export ARCH=aarch64
299314export 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
301316export TEEC_EXPORT=` pwd` /../optee_client/out-aarch64/export/usr/
302317export OPTEE_CLIENT_EXPORT=` pwd` /../optee_client/out-aarch64/export/usr/
303318export CFG_TA_OPTEE_CORE_API_COMPAT_1_1=n
@@ -306,7 +321,6 @@ export DEBUG=0
306321export CFG_TEE_TA_LOG_LEVEL=0
307322export O=` pwd` /out-aarch64
308323
309-
310324rm -rf out-aarch64/
311325# # make sure we have things setup for first OP-TEE
312326find . -name " Makefile" -exec sed -i " s/\-lteec2$/\-lteec/g" {} +
@@ -321,8 +335,6 @@ cp out-aarch64/*.ta to_buildroot-aarch64/lib/optee_armtz
321335cp host/wallet to_buildroot-aarch64/bin/bitcoin_wallet_ca
322336chmod +x to_buildroot-aarch64/bin/bitcoin_wallet_ca
323337
324-
325-
326338# # setup second OP-TEE
327339export O=` pwd` /out2-aarch64
328340export DESTDIR=./to_buildroot-aarch64-2
@@ -348,13 +360,12 @@ chmod +x to_buildroot-aarch64-2/bin/bitcoin_wallet_ca2
348360
349361cd $ROOT
350362```
363+ ![ COMPbw] ( ./img/.gif/COMPbw.gif )
351364
352365## Step 6: Compile Malicious Client and Trusted Application
353366```
354367cd malicous_ta
355-
356368BUILDROOT=`pwd`/../buildroot/build-aarch64/
357-
358369export CROSS_COMPILE=$BUILDROOT/host/bin/aarch64-linux-
359370export HOST_CROSS_COMPILE=$BUILDROOT/host/bin/aarch64-linux-
360371export TA_CROSS_COMPILE=$BUILDROOT/host/bin/aarch64-linux-
@@ -369,23 +380,17 @@ export DEBUG=0
369380export CFG_TEE_TA_LOG_LEVEL=2
370381export O=`pwd`/out-aarch64
371382export aarch64_TARGET=y
372-
373-
374383rm -rf out-aarch64/
375384## make sure we have things setup for first OP-TEE
376385find . -name "Makefile" -exec sed -i "s/\-lteec2$/\-lteec/g" {} +
377386find . -name "Makefile" -exec sed -i "s/optee2_armtz/optee_armtz/g" {} +
378387make clean
379388make -j`nproc`
380-
381389mkdir -p to_buildroot-aarch64/lib/optee_armtz
382390mkdir -p to_buildroot-aarch64/bin
383-
384391cp out-aarch64/*.ta to_buildroot-aarch64/lib/optee_armtz
385392cp host/malicious_ca to_buildroot-aarch64/bin/malicious_ca
386393chmod +x to_buildroot-aarch64/bin/malicious_ca
387-
388-
389394## setup second OP-TEE
390395export O=`pwd`/out2-aarch64
391396export DESTDIR=./to_buildroot-aarch64-2
@@ -400,17 +405,14 @@ make -j`nproc`
400405## undo changes
401406find . -name "Makefile" -exec sed -i "s/\-lteec2/\-lteec/g" {} +
402407find . -name "Makefile" -exec sed -i "s/optee2_armtz/optee_armtz/g" {} +
403-
404408mkdir -p to_buildroot-aarch64-2/lib/optee2_armtz
405409mkdir -p to_buildroot-aarch64-2/bin
406-
407410cp out2-aarch64/*.ta to_buildroot-aarch64-2/lib/optee2_armtz
408411cp host/malicious_ca to_buildroot-aarch64-2/bin/malicious_ca2
409412chmod +x to_buildroot-aarch64-2/bin/malicious_ca2
410-
411-
412413cd $ROOT
413414```
415+ ![ COMPlinuxkernel] ( ./img/.gif/COMPmalicious.gif )
414416
415417## Step 7: Finalize Linux file system
416418We have everything setup now, so build the final file system for Linux.
@@ -421,7 +423,7 @@ make O=build-aarch64/ -j`nproc`
421423
422424cd $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
437439cd $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
454455rm linux-rpi4.elf
455456make \
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
462463cd $ROOT
463464```
465+ ![ COMPdt] ( ./img/.gif/COMPdt.gif )
466+
464467
465468### Simple Demo
466469This demo instantiates a Linux VM and an OP-TEE VM.
467470Insert 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
477478Insert 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```
482490miniterm.py /dev/ttyUSB0 115200
@@ -502,11 +510,7 @@ xtest -t regression
502510### Demo 2
503511This 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
512516After Linux finishes booting you may execute xtest in both OP-TEE VMs.
0 commit comments