19.1. Zephyr
Zephyr is an RTOS that has POSIX support. I think it works much like our Baremetal setup which uses Newlib and generates individual ELF files that contain both our C program’s code, and the Zephyr libraries.
TODO get a hello world working, and then consider further integration in this repo, e.g. being able to run all C userland content on it.
TODO: Cortex-A CPUs are not currently supported, there are some qemu_cortex_m0
boards, but can’t find a QEMU Cortex-A. There is an x86_64 qemu board, but we don’t currently have an x86 baremetal toolchain. For this reason, we won’t touch this further for now.
However, unlike Newlib, Zephyr must be setting up a simple pre-main runtime to be able to handle threads.
Failed attempt:
# https://askubuntu.com/questions/952429/is-there-a-good-ppa-for-cmake-backports wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | sudo apt-key add - sudo apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic-rc main' sudo apt-get update sudo apt-get install cmake git clone https://github.com/zephyrproject-rtos/zephyr pip3 install --user -U west packaging cd zephyr git checkout v1.14.1 west init zephyrproject west update export ZEPHYR_TOOLCHAIN_VARIANT=xtools export XTOOLS_TOOLCHAIN_PATH="$(pwd)/out/crosstool-ng/build/default/install/aarch64/bin/" source zephyr-env.sh west build -b qemu_aarch64 samples/hello_world
The build system of that project is a bit excessive / wonky. You need an edge CMake not present in Ubuntu 18.04, which I don’t want to install right now, and it uses the weird custom west
build tool frontend.