Phriction Trusted Firmware Mbed TLS Mbed TLS Testing Testing on Linux with Qemu History Version 1 vs 2
Version 1 vs 2
Version 1 vs 2
Edits
Edits
- Edit by gilles-peskine-arm, Version 2
- Nov 16 2021 10:46 AM
- ·show how to test on foreign architectures on Linux
- Edit by gilles-peskine-arm, Version 1
- Nov 16 2021 10:45 AM
- ·show how to
Original Change | Most Recent Change |
Edit Older Version 1... | Edit Current Version 2... |
Content Changes
Content Changes
== Preparing Ubuntu for building and testing with Qemu ==
Add other targets to your package sources in a new file `/etc/apt/sources.list.d/ubuntu-foreign.list`. Note that ordinary Ubuntu mirrors only have PC builds, so you need a `ports` mirror. For example:
```
deb [arch=arm64,armhf,ppc64,s390x] http://fr.ports.ubuntu.com/ubuntu-ports focal main restricted universe multiverse
deb [arch=arm64,armhf,ppc64,s390x] http://fr.ports.ubuntu.com/ubuntu-ports focal-security main restricted universe multiverse
deb [arch=arm64,armhf,ppc64,s390x] http://fr.ports.ubuntu.com/ubuntu-ports focal-updates main restricted universe multiverse
```
Then install `libc6-dev` for the desired architectures.
```
sudo apt-get update
sudo apt-get install libc6-dev:arm64 libc6-dev:armhf libc6-dev:ppc64 libc6-dev:s390x
```
== Testing with Qemu-user on Linux ==
=== Cmake build ===
For example for aarch64:
```
mkdir build-aarch64
cd build-aarch64
CC=clang CFLAGS="--target=aarch64-linux-gnu" cmake -DCMAKE_BUILD_TYPE=Release ..
make -j2
cd tests
qemu-aarch64 -L /usr/aarch64-linux-gnu ./test_suite_mpi
```
=== mbedtls-prepare-build ===
With [[https://github.com/ARMmbed/mbedtls-docs/blob/main/tools/bin/mbedtls-prepare-build | mbedtls-prepare-build]]:
```
mbedtls-prepare-build -d build-aarch64 --cc=clang --cflags='-O2 -target aarch64-linux-gnu' --qemu-ld-prefix=aarch64-linux-gnu
make -C build-aarch64 test
```
This page shows how to test Mbed TLS on Linux for CPUs you don't have, assuming the target CPU can also run Linux.
== Preparing Ubuntu for building and testing with Qemu ==
Add other targets to your package sources in a new file `/etc/apt/sources.list.d/ubuntu-foreign.list`. Note that ordinary Ubuntu mirrors only have PC builds, so you need a `ports` mirror. For example:
```
deb [arch=arm64,armhf,ppc64,s390x] http://fr.ports.ubuntu.com/ubuntu-ports focal main restricted universe multiverse
deb [arch=arm64,armhf,ppc64,s390x] http://fr.ports.ubuntu.com/ubuntu-ports focal-security main restricted universe multiverse
deb [arch=arm64,armhf,ppc64,s390x] http://fr.ports.ubuntu.com/ubuntu-ports focal-updates main restricted universe multiverse
```
Then install `libc6-dev` for the desired architectures.
```
sudo apt-get update
sudo apt-get install libc6-dev:arm64 libc6-dev:armhf libc6-dev:ppc64 libc6-dev:s390x
```
== Testing with Qemu-user on Linux ==
=== Cmake build ===
For example for aarch64:
```
mkdir build-aarch64
cd build-aarch64
CC=clang CFLAGS="--target=aarch64-linux-gnu" cmake -DCMAKE_BUILD_TYPE=Release ..
make -j2
cd tests
qemu-aarch64 -L /usr/aarch64-linux-gnu ./test_suite_mpi
```
=== mbedtls-prepare-build ===
With [[https://github.com/ARMmbed/mbedtls-docs/blob/main/tools/bin/mbedtls-prepare-build | mbedtls-prepare-build]]:
```
mbedtls-prepare-build -d build-aarch64 --cc=clang --cflags='-O2 -target aarch64-linux-gnu' --qemu-ld-prefix=aarch64-linux-gnu
make -C build-aarch64 test
```
This page shows how to test Mbed TLS on Linux for CPUs you don't have, assuming the target CPU can also run Linux.
== Preparing Ubuntu for building and testing with Qemu ==
Add other targets to your package sources in a new file `/etc/apt/sources.list.d/ubuntu-foreign.list`. Note that ordinary Ubuntu mirrors only have PC builds, so you need a `ports` mirror. For example:
```
deb [arch=arm64,armhf,ppc64,s390x] http://fr.ports.ubuntu.com/ubuntu-ports focal main restricted universe multiverse
deb [arch=arm64,armhf,ppc64,s390x] http://fr.ports.ubuntu.com/ubuntu-ports focal-security main restricted universe multiverse
deb [arch=arm64,armhf,ppc64,s390x] http://fr.ports.ubuntu.com/ubuntu-ports focal-updates main restricted universe multiverse
```
Then install `libc6-dev` for the desired architectures.
```
sudo apt-get update
sudo apt-get install libc6-dev:arm64 libc6-dev:armhf libc6-dev:ppc64 libc6-dev:s390x
```
== Testing with Qemu-user on Linux ==
=== Cmake build ===
For example for aarch64:
```
mkdir build-aarch64
cd build-aarch64
CC=clang CFLAGS="--target=aarch64-linux-gnu" cmake -DCMAKE_BUILD_TYPE=Release ..
make -j2
cd tests
qemu-aarch64 -L /usr/aarch64-linux-gnu ./test_suite_mpi
```
=== mbedtls-prepare-build ===
With [[https://github.com/ARMmbed/mbedtls-docs/blob/main/tools/bin/mbedtls-prepare-build | mbedtls-prepare-build]]:
```
mbedtls-prepare-build -d build-aarch64 --cc=clang --cflags='-O2 -target aarch64-linux-gnu' --qemu-ld-prefix=aarch64-linux-gnu
make -C build-aarch64 test
```