diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c030dd6 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +FROM fedora:36 + +RUN dnf install -y \ + gcc-c++ \ + arm-none-eabi-gcc-cs \ + arm-none-eabi-gcc-cs-c++ \ + arm-none-eabi-binutils-cs \ + arm-none-eabi-newlib \ + libbsd-devel \ + cmake + +COPY docker_build.sh /build.sh +RUN chmod +x /build.sh + +ENTRYPOINT ["/bin/bash", "/build.sh"] diff --git a/README.md b/README.md index 11b7372..949120b 100644 --- a/README.md +++ b/README.md @@ -156,6 +156,25 @@ Note that the code uses `strlcpy()` also in the test code, which requires `libbs ``` 3. The firmware will be stored in file `build/src/RS41ng.elf` +### Building the firmware with Docker + +Using Docker to build the firmware is usually the easiest option, because it provides a stable Fedora Linux-based +build environment on any platform. It should work on Windows and Mac operating systems too. + +The Docker environment can also help address issues with the build process, including the `strlcpy()` errors observed on certain Linux distributions. + +1. Install Docker if not already installed +2. Set the current directory to the RS41ng source directory +3. Build the RS41ng compiler Docker image using the following command. It is necessary to build the Docker image only once. + ``` + docker build -t rs41ng_compiler . + ``` +4. Build the firmware using the following command. If you need to rebuild the firmware, simply run the command again. + ``` + docker run --rm -it -v $(pwd):/usr/local/src/RS41ng rs41ng_compiler + ``` +5. The firmware will be stored in file `build/src/RS41ng.elf` + ## Flashing the firmware Hardware requirements: diff --git a/docker_build.sh b/docker_build.sh new file mode 100644 index 0000000..2d16560 --- /dev/null +++ b/docker_build.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +# Script to compile RS41ng on any platform using Docker +# This script is copied into the Docker image when it is built. +# If you plan to change this script, please make sure to rebuild the Docker image. + +set -e # Exit if failed + +SOURCE_PATH="/usr/local/src/RS41ng" + +# Sanity check +if [ ! -d "${SOURCE_PATH}" ] +then + echo "Source directory does not exist, please run the Docker command given in README to mount the source directory" + exit 1 +fi + +# Build RS41ng +cd "${SOURCE_PATH}" +rm -rf build +mkdir -p build +cd build +cmake .. +make -j$(nproc) + +echo "RS41ng build complete"