As part of our DSbD technology project we’re looking at porting some of our code from our ARWAIN project to run on the Morello FVP. Our ARWAIN project is a UK government funded project developing indoor localisation tech for the Fire and Rescue Service. Part of this is a wearable IoT device that takes inputs from various sensor and fuses them via a Neural Network to calculate the path the wearer has taken as well as their activity. Security for this device is going to be a key issue, especially when we start looking at other applications such as the Police and Defence Sector. Running our code on DSbD enabled technology will go a long way towards ensuring the security of our system.
How are we going to start?
Firstly we need to make sure we can cross-compile standard C++ code into Cheri compatible binaries, so far for this project we have only worked with native C code which I covered in the Some Working Examples blog post. Once we have confirmed this works we can then move onto looking at the next stages.
Initial teething issues with running a hello_world C++ examples:
The compiler was unable to find the IOSTREAM system header file, this caused the basic app to refuse to compile. To fix this we had to install the libcxx standard library, which can be achieved with the below steps, note you can change the riscv64-purecap to the type of system you want to test with. Run python3 cheribuild.py –list-targets for options.
Run python3 cheribuid.py libunwind-riscv64-purecap (This is a dependency of libcxxrt which we install next.)
Run python3 cheribuild.py libcxxrt-riscv64-purecap (This is a dependency of the main libcxx package)
Run python3 cheribuild.py libcxx-riscv64-purecap (This is the main package for the C++ library)
Once those were installed the code was able to be compiled with the below command, this is
./cheri/output/sdk/bin/clang++ -g -O2 –sysroot=./cheri/output/rootfs-riscv64-purecap -target riscv64-unknown-freebsd -static -fuse-ld=lld -mno-relax -march=rv64gcxcheri -mabi=l64pc128d -Wall -Wcheri -G0 ./cheri/testcode/cxx_helloworld/hello_world.cxx
Initial Changes that were required
To start the porting process we need to look at the libraries currently used in our application. This is important because there is a currently a small number of libraries that have been ported to Cheri and will work with the BSD distribution used for testing Cheri code. It is also important to note we use a ZeroMQ library which allows us to connect to a stand-alone Python script.
We have had to remove the below libraries:
ZeroMQ This library has not been compiled with Cheri support as of yet, also because the lack of Python support currently we will not need this for testing.
I2C This library controls physical device connections and communication on the i2C bus. As above this has not be ported yet and this code will run a virtual machine as the Morello hardware is currently not available.
We do we have to do?
To get around the missing libraries we will need to mock the data in and out of the library, this will allow us to keep the same data flow and actions. This includes mocking the data from our main sensor as that was previously using I2C to communicate, mocking the output/input of any of the Python scripts we are using to.