Skip to content

Commit 1dcebc7

Browse files
committed
Add Dockerfile and compile_with_dockerfile.bat
This makes local compilation a whole lot easier - using the correct core and library versions
1 parent 0ed4448 commit 1dcebc7

File tree

4 files changed

+112
-52
lines changed

4 files changed

+112
-52
lines changed

.github/workflows/non-release-build.yml

Lines changed: 16 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -44,70 +44,35 @@ jobs:
4444
echo "DEBUG_LEVEL=debug" >> "$GITHUB_ENV"
4545
fi
4646
47-
- name: Setup Arduino CLI
48-
uses: arduino/setup-arduino-cli@v1
49-
50-
- name: Start config file
51-
run: arduino-cli config init --additional-urls "https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json,https://espressif.github.io/arduino-esp32/package_esp32_dev_index.json"
52-
53-
- name: Update core index
54-
run: arduino-cli core update-index
55-
56-
- name: Update library index
57-
run: arduino-cli lib update-index
58-
59-
- name: Install platform
60-
run: arduino-cli core install esp32:esp32@${{ env.CORE_VERSION }}
61-
62-
- name: Get IDF version
47+
- name: Run Dockerfile and copy files
6348
run: |
64-
cd /home/runner/.arduino15/packages/esp32/tools/esp32-arduino-libs
65-
IDF_VERSION=$(ls | grep idf-release)
66-
echo "ESP_IDF=${IDF_VERSION}" >> "$GITHUB_ENV"
67-
68-
- name: Get Known Libraries
69-
run: arduino-cli lib install
70-
71-
72-
"SparkFun Qwiic OLED Arduino Library"@1.0.13
73-
"SparkFun Toolkit"@0.9.2
74-
# "SparkFun SiT5358 DCTCXO Arduino Library"@1.0.0
75-
# "SparkFun SiT5811 OCXO Arduino Library"@1.0.0
76-
# "SparkFun STP3593LF OCXO Arduino Library"@1.0.0
77-
78-
- name: Enable external libs
79-
run: arduino-cli config set library.enable_unsafe_install true
80-
81-
- name: Get Libraries
82-
run: arduino-cli lib install --git-url
83-
https://github.com/sparkfun/SparkFun_SiT5358_DCTCXO_Arduino_Library.git
84-
https://github.com/sparkfun/SparkFun_SiT5811_OCXO_Arduino_Library.git
85-
https://github.com/sparkfun/SparkFun_STP3593LF_OCXO_Arduino_Library.git
86-
87-
- name: Copy custom app3M_fat9M_16MB.csv
88-
run:
89-
cp Firmware/app3M_fat9M_16MB.csv /home/runner/.arduino15/packages/esp32/hardware/esp32/${{ env.CORE_VERSION }}/tools/partitions/app3M_fat9M_16MB.csv
90-
91-
- name: Compile Sketch
92-
run: arduino-cli compile --fqbn "esp32:esp32:esp32":DebugLevel=${{ env.DEBUG_LEVEL }} ./Firmware/GNSSDO_Firmware/GNSSDO_Firmware.ino
93-
--build-property build.partitions=app3M_fat9M_16MB
94-
--build-property upload.maximum_size=3145728
95-
--build-property "compiler.cpp.extra_flags=-MMD -c \"-DFIRMWARE_VERSION_MAJOR=$FIRMWARE_VERSION_MAJOR\" \"-DFIRMWARE_VERSION_MINOR=$FIRMWARE_VERSION_MINOR\""
96-
--export-binaries
49+
cd ./Firmware
50+
docker build -t gnssdo_firmware --no-cache \
51+
--build-arg CORE_VERSION=${{ env.CORE_VERSION }} \
52+
--build-arg FIRMWARE_VERSION_MAJOR=${{ env.FIRMWARE_VERSION_MAJOR }} \
53+
--build-arg FIRMWARE_VERSION_MINOR=${{ env.FIRMWARE_VERSION_MINOR }} \
54+
--build-arg DEBUG_LEVEL=${{ env.DEBUG_LEVEL }} \
55+
.
56+
docker create --name=gnssdo_image rtk_firmware:latest
57+
mkdir ./build
58+
docker cp gnssdo_image:/GNSSDO_Firmware.ino.bin ./build
59+
docker cp gnssdo_image:/GNSSDO_Firmware.ino.elf ./build
60+
docker container rm gnssdo_image
9761
9862
- name: Create artifact name
9963
run: |
10064
echo "ARTIFACT=${{ env.FILENAME_PREFIX }}${{ env.FILE_ENDING_UNDERSCORE }}" >> $GITHUB_ENV
10165
10266
- name: Create artifact directory
10367
run: |
104-
cd Firmware/GNSSDO_Firmware/build/esp32.esp32.esp32/
68+
cd ./Firmware/build/
10569
mkdir ${{ env.ARTIFACT }}
10670
mv GNSSDO_Firmware.ino.bin ${{ env.ARTIFACT }}
71+
mv GNSSDO_Firmware.ino.elf ${{ env.ARTIFACT }}
10772
10873
- name: Upload artifact directory to action - avoid double-zip
10974
uses: actions/upload-artifact@v4
11075
with:
11176
name: ${{ env.ARTIFACT }}
112-
path: Firmware/GNSSDO_Firmware/build/esp32.esp32.esp32/${{ env.ARTIFACT }}
77+
path: ./Firmware/build/${{ env.ARTIFACT }}
11378
retention-days: 7

Firmware/Dockerfile

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
FROM ubuntu:latest AS upstream
2+
3+
ARG DEBIAN_FRONTEND=noninteractive
4+
5+
ARG CORE_VERSION=3.0.7
6+
7+
ARG FIRMWARE_VERSION_MAJOR=9
8+
ARG FIRMWARE_VERSION_MINOR=9
9+
10+
# ESP32 Core Debug Level
11+
# We use "none" for releases and "error" for release_candidate
12+
# You may find "verbose" useful while you are debugging your changes
13+
ARG DEBUG_LEVEL=error
14+
15+
# arduino-cli warnings: none default more all
16+
ARG WARNINGS=default
17+
18+
# Get curl and python3
19+
RUN apt-get update \
20+
&& apt-get install -y curl python3 python3-pip python3-venv \
21+
&& apt-get clean \
22+
&& rm -rf /var/lib/apt/lists/*
23+
24+
# Avoid the externally managed environment constraint
25+
RUN PYTHON_VER=$(ls /usr/lib | grep python3.) \
26+
&& echo "Python version: ${PYTHON_VER}" \
27+
&& rm /usr/lib/${PYTHON_VER}/EXTERNALLY-MANAGED
28+
29+
# Install Python dependencies - esptool needs pyserial
30+
#RUN python3 -m pip install --upgrade pip && \
31+
RUN pip install pyserial
32+
33+
# Setup Arduino CLI
34+
#RUN curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | BINDIR=/usr/local/bin sh
35+
RUN curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh
36+
37+
# Start config file
38+
RUN arduino-cli config init --additional-urls https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json,https://espressif.github.io/arduino-esp32/package_esp32_dev_index.json
39+
40+
# Update core index
41+
RUN arduino-cli core update-index
42+
43+
# Update library index
44+
RUN arduino-cli lib update-index
45+
46+
# Install platform
47+
RUN arduino-cli core install "esp32:esp32@${CORE_VERSION}"
48+
49+
# Get Known Libraries
50+
RUN arduino-cli lib install [email protected]
51+
RUN arduino-cli lib install [email protected]
52+
RUN arduino-cli lib install "SparkFun Qwiic OLED Arduino Library"@1.0.13
53+
RUN arduino-cli lib install "SparkFun Toolkit"@0.9.2
54+
#RUN arduino-cli lib install "SparkFun SiT5358 DCTCXO Arduino Library"@1.0.1
55+
#RUN arduino-cli lib install "SparkFun SiT5811 OCXO Arduino Library"@1.0.1
56+
#RUN arduino-cli lib install "SparkFun STP3593LF OCXO Arduino Library"@1.0.1
57+
58+
# Enable external libs
59+
RUN arduino-cli config set library.enable_unsafe_install true
60+
61+
# Get external libs
62+
RUN arduino-cli lib install --git-url https://github.com/sparkfun/SparkFun_SiT5358_DCTCXO_Arduino_Library.git
63+
RUN arduino-cli lib install --git-url https://github.com/sparkfun/SparkFun_SiT5811_OCXO_Arduino_Library.git
64+
RUN arduino-cli lib install --git-url https://github.com/sparkfun/SparkFun_STP3593LF_OCXO_Arduino_Library.git
65+
66+
# Copy GNSSDO_Firmware and build deployment image
67+
FROM upstream AS deployment
68+
69+
# Add the source files
70+
ADD . .
71+
72+
# Copy custom app3M_fat9M_16MB.csv
73+
RUN cp app3M_fat9M_16MB.csv "/root/.arduino15/packages/esp32/hardware/esp32/${CORE_VERSION}/tools/partitions/app3M_fat9M_16MB.csv"
74+
75+
# Compile Sketch
76+
RUN cd ./GNSSDO_Firmware \
77+
&& arduino-cli compile --fqbn "esp32:esp32:esp32":DebugLevel=${DEBUG_LEVEL} \
78+
--warnings ${WARNINGS} \
79+
./GNSSDO_Firmware.ino \
80+
--build-property build.partitions=app3M_fat9M_16MB \
81+
--build-property upload.maximum_size=3145728 \
82+
--build-property "compiler.cpp.extra_flags=-MMD -c \
83+
\"-DFIRMWARE_VERSION_MAJOR=${FIRMWARE_VERSION_MAJOR}\" \
84+
\"-DFIRMWARE_VERSION_MINOR=${FIRMWARE_VERSION_MINOR}\"" \
85+
--export-binaries
86+
87+
# Copy the compile output. List the files
88+
FROM deployment AS output
89+
COPY --from=deployment ./GNSSDO_Firmware/build/esp32.esp32.esp32 /
90+
CMD echo $(ls /*.*)

Firmware/GNSSDO_Firmware/compile_me.bat

Lines changed: 0 additions & 1 deletion
This file was deleted.

Firmware/compile_with_docker.bat

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
docker build -t gnssdo_firmware --no-cache-filter deployment .
2+
docker create --name=gnssdo_image gnssdo_firmware:latest
3+
docker cp gnssdo_image:/GNSSDO_Firmware.ino.bin .
4+
docker cp gnssdo_image:/GNSSDO_Firmware.ino.elf .
5+
docker cp gnssdo_image:/GNSSDO_Firmware.ino.bootloader.bin .
6+
docker container rm gnssdo_image

0 commit comments

Comments
 (0)