Create a Docker container for building RS41ng (#11)

* Create a Docker container to build on any compatible platform

* Add newlines to the end of the newly-created files.

* Remove outdated IDE-suggested comment

* Cleaned up and adjusted the Docker build environment

Co-authored-by: Mikael Nousiainen <mikael.nousiainen@iki.fi>
pull/37/head
MrARM 2022-08-23 12:33:31 -07:00 zatwierdzone przez GitHub
rodzic b0602f8b18
commit 1b6ff19a95
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
3 zmienionych plików z 60 dodań i 0 usunięć

15
Dockerfile 100644
Wyświetl plik

@ -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"]

Wyświetl plik

@ -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:

26
docker_build.sh 100644
Wyświetl plik

@ -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"