Cleaned up and adjusted the Docker build environment

pull/11/head
Mikael Nousiainen 2022-08-23 22:31:58 +03:00
rodzic ac040f294b
commit 4236e6d31d
3 zmienionych plików z 27 dodań i 16 usunięć

Wyświetl plik

@ -1,4 +1,4 @@
FROM fedora:latest
FROM fedora:36
RUN dnf install -y \
gcc-c++ \

Wyświetl plik

@ -155,15 +155,22 @@ Note that the code uses `strlcpy()` also in the test code, which requires `libbs
### Building the firmware with Docker
Building with Docker can help address issues with the build process on some platforms, including the `strlcpy()` errors observed on certain Linux distributions.
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. Build the firmware using the following commands
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 .
docker run --rm -it -v $(pwd):/usr/src/rs41ng rs41ng_compiler
```
3. The firmware will be stored in this directory.
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

Wyświetl plik

@ -1,22 +1,26 @@
# Script to compile RS41ng on any platform
# 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
#!/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 "/usr/src/rs41ng" ]
if [ ! -d "${SOURCE_PATH}" ]
then
echo "Build directory does not exist, please run the command given in README to mount the source directory"
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 /tmp/
mkdir rs41ng_build && cd rs41ng_build
cmake /usr/src/rs41ng
cd "${SOURCE_PATH}"
rm -rf build
mkdir -p build
cd build
cmake ..
make -j$(nproc)
# Copy the binary, ELF and hex to the home directory
cp src/RS41ng.elf /usr/src/rs41ng
cp RS41ng.hex /usr/src/rs41ng
cp RS41ng.bin /usr/src/rs41ng
echo "RS41ng build complete"