To build NuttX for Arm64 or RISC-V we need to install these Build Prerequisites...
- "Install Prerequisites"
- Arm64 or RISC-V Toolchain
## Install prerequisites
sudo apk add \
bison flex gettext texinfo \
gperf automake libtool gperf \
binutils-dev picocom u-boot-tools util-linux \
patch autoconf gcc-aarch64-none-elf newlib-aarch64-none-elf
## Install genromfs
git clone https://github.com/chexum/genromfs
pushd genromfs
make
sudo make install
popd
But on Alpine Linux, compiling kconfig-frontends
may fail with an aclocal-1.15
error.
Here's the fix...
pushd /tmp
git clone https://bitbucket.org/nuttx/tools.git
cd tools
cd kconfig-frontends
./configure --enable-mconf --disable-nconf --disable-gconf --disable-qconf
sudo ln -s /usr/bin/aclocal /usr/local/bin/aclocal-1.15
sudo ln -s /usr/bin/automake /usr/local/bin/automake-1.15
make
sudo make install
popd
Installing the RISC-V Toolchain on Alpine Linux requires a few more steps...
## Download xPack GNU RISC-V Embedded GCC Toolchain for 64-bit RISC-V
wget https://github.com/xpack-dev-tools/riscv-none-elf-gcc-xpack/releases/download/v13.2.0-2/xpack-riscv-none-elf-gcc-13.2.0-2-linux-x64.tar.gz
tar xf xpack-riscv-none-elf-gcc-13.2.0-2-linux-x64.tar.gz
## Add to PATH
export PATH=$PWD/xpack-riscv-none-elf-gcc-13.2.0-2/bin:$PATH
## Add glibc-to-musl compatibility, because xPack GCC was compiled for glibc
## From https://github.com/sgerrand/alpine-pkg-glibc
sudo wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub
wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.35-r1/glibc-2.35-r1.apk
sudo apk add glibc-2.35-r1.apk
## Test gcc:
## gcc version 13.2.0 (xPack GNU RISC-V Embedded GCC x86_64)
riscv-none-elf-gcc -v
This works great with Alpine Linux Containers on Rancher Desktop and VSCode Remote Containers...
But Alpine Linux uses musl
instead of glibc
. Will we have problems later?
Some tools will fail with musl
! (Like Nim Compiler)
We can use a Debian Bookworm Container instead (like for running Nim)...