Skip to content

Commit c328f64

Browse files
committed
Update Dockerfile and docs
1 parent beb7264 commit c328f64

File tree

7 files changed

+49
-27
lines changed

7 files changed

+49
-27
lines changed

Firmware/Dockerfile

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ubuntu:latest
1+
FROM ubuntu:latest AS upstream
22

33
ARG DEBIAN_FRONTEND=noninteractive
44

@@ -84,6 +84,9 @@ RUN arduino-cli lib install "SparkFun Apple Accessory Arduino Library"@3.0.9
8484
RUN arduino-cli lib install "SparkFun Authentication Coprocessor Arduino Library"@1.0.0
8585
RUN arduino-cli lib install "SparkFun Toolkit"@1.0.6
8686

87+
# Copy RTK_Everywhere into /work and build deployment image
88+
FROM upstream AS deployment
89+
8790
# Create work directory
8891
WORKDIR /work
8992
ADD . .
@@ -119,7 +122,7 @@ RUN cp RTKEverywhere.csv "/root/.arduino15/packages/esp32/hardware/esp32/${CORE_
119122

120123
# Compile Sketch
121124
WORKDIR /work/RTK_Everywhere
122-
CMD arduino-cli compile --fqbn "esp32:esp32:esp32":DebugLevel=${DEBUG_LEVEL},PSRAM=enabled \
125+
RUN arduino-cli compile --fqbn "esp32:esp32:esp32":DebugLevel=${DEBUG_LEVEL},PSRAM=enabled \
123126
./RTK_Everywhere.ino \
124127
--build-property build.partitions=RTKEverywhere \
125128
--build-property upload.maximum_size=4055040 \
@@ -132,3 +135,8 @@ CMD arduino-cli compile --fqbn "esp32:esp32:esp32":DebugLevel=${DEBUG_LEVEL},PSR
132135
\"-DFIRMWARE_VERSION_MINOR=${FIRMWARE_VERSION_MINOR}\" \
133136
\"-DENABLE_DEVELOPER=${ENABLE_DEVELOPER}\"" \
134137
--export-binaries
138+
139+
# Copy the compile output. List the files
140+
FROM deployment AS output
141+
COPY --from=deployment /work/RTK_Everywhere/build/esp32.esp32.esp32 /
142+
CMD echo $(ls /*.*)

docs/firmware_compile.md

Lines changed: 39 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,6 @@ Installing the correct version of the ESP32 core and of each required Arduino li
2222

2323
Here is a step-by-step guide for how to install Docker and compile the firmware from scratch:
2424

25-
### Install Docker Desktop
26-
27-
* Head to [Docker](https://www.docker.com/) and create an account. A free "Personal" account will cover occasional compilations of the firmware
28-
* Download and install [Docker Desktop](https://docs.docker.com/get-started/get-docker/) - there are versions for Mac, Windows and Linux. You may need to restart to complete the installation.
29-
* Run the Desktop and sign in
30-
* On Windows, you may see an error saying "**WSL needs updating** Your version of Windows Subsystem for Linux (WSL) is too old". If you do:
31-
* Open a command prompt
32-
* Type `wsl --update` to update WSL. At the time of writing, this installs Windows Subsystem for Linux 2.6.1
33-
* Restart the Docker Desktop
34-
* If you are using Docker for the first time, the "What is a container?" and "How do I run a container?" demos are useful
35-
* On Windows, you may need to give Docker Desktop permission to access to your Network
36-
* You can Stop the container and Delete it when you are done
37-
3825
### Clone, fork or download the RTK Everywhere Firmware repo
3926

4027
To build the RTK Everywhere Firmware, you obviously need a copy of the source code.
@@ -67,9 +54,24 @@ For the real Wild West experience, you can also download a copy of the `release_
6754

6855
[![Download ZIP - release candidate](./img/CompileSource/Download_Zip.png)](https://github.com/sparkfun/SparkFun_RTK_Everywhere_Firmware/archive/refs/heads/release_candidate.zip "Download ZIP (release_candidate branch)")
6956

57+
### Install Docker Desktop
58+
59+
* Head to [Docker](https://www.docker.com/) and create an account. A free "Personal" account will cover occasional compilations of the firmware
60+
* Download and install [Docker Desktop](https://docs.docker.com/get-started/get-docker/) - there are versions for Mac, Windows and Linux. You may need to restart to complete the installation.
61+
* Run the Desktop and sign in
62+
* On Windows, you may see an error saying "**WSL needs updating** Your version of Windows Subsystem for Linux (WSL) is too old". If you do:
63+
* Open a command prompt
64+
* Type `wsl --update` to update WSL. At the time of writing, this installs Windows Subsystem for Linux 2.6.1
65+
* Restart the Docker Desktop
66+
* If you are using Docker for the first time, the "What is a container?" and "How do I run a container?" demos are useful
67+
* On Windows, you may want to give Docker Desktop permission to access to your Network, so it can access (e.g.) HTML ports
68+
* You can Stop the container and Delete it when you are done
69+
* You may want to prevent Docker from running when your machine starts up
70+
* Uncheck "Start Docker Desktop when you sign in to your computer" in the Desktop settings
71+
7072
### Running the Dockerfile to create an Image
7173

72-
* Make sure you have Docker Desktop running
74+
* **Make sure you have Docker Desktop running.** You don't need to be logged in, but it needs to be running.
7375
* Open a Command Prompt and `cd` into the SparkFun_RTK_Everywhere_Firmware folder
7476
* Check you are in the right place. Type `dir` and hit enter. You should see the following files and folders:
7577

@@ -117,39 +119,51 @@ docker build -t rtk_everywhere_firmware --progress=plain .
117119
docker build -t rtk_everywhere_firmware --progress=plain --no-cache .
118120
```
119121

120-
Building the Image is slow, taking several minutes. But you should only need to do it once - unless you make any changes to the Dockerfile.
122+
Building the full Image from scratch is slow, taking several minutes. But you should only need to do it once - unless you make any changes to the Dockerfile.
121123

122-
### Compile the firmware by running the Image
124+
* When you make changes to the source code and want to recompile, use:
123125

124-
In Docker Desktop, in the Images tab, you should now be able to see an Image named `rtk_everywhere_firmware`. We now need to Run that image to compile the firmware. Click the triangular Run icon under Actions:
126+
```
127+
docker build -t rtk_everywhere_firmware --no-cache-filter deployment .
128+
```
129+
130+
This uses the cache for the `upstream` stage and avoids recreating the full ubuntu machine. But it ignores the cache for the `deployment` stage, ensuring the code is recompiled.
131+
132+
### Access the firmware by running the Image
133+
134+
In Docker Desktop, in the Images tab, you should now be able to see an Image named `rtk_everywhere_firmware`. We now need to Run that Image to access the firmware binary. Click the triangular Run icon under Actions:
125135

126136
![Docker image ready to run](./img/CompileSource/Docker_Image.png)
127137

128-
Running the Image will create a Container for the arduino-cli code compilation. The Container name is random, because we didn't define one in the **Optional settings**. It is running the final line of the Dockerfile `CMD arduino-cli compile ...`. Let it run. As the compilation progresses, you will see messages appear in the Logs tab. When the compilation is complete, the Container will stop and you should see:
138+
Running the Image will create a Container, through which we can access the output of the arduino-cli code compilation.
139+
140+
By default, the Container name is random. To avoid this, we define one in the **Optional settings** :
129141

130-
![Container code compilation is complete](./img/CompileSource/Container_compilation_complete.png)
142+
![Docker Container - named rtk_everywhere](./img/CompileSource/Docker_Container.png)
131143

132-
You can recompile your code at any time by running the image again. (You don't need to recreate the image each time - unless you've changed the Dockerfile.)
144+
Run the Container and you should see:
133145

134-
Make a note of the container name. We will need it to extract the firmware binary from the container. In the above screenshot, the container is called **reverent_jackson**
146+
![Container is complete](./img/CompileSource/Container_compilation_complete.png)
135147

136-
In the Command Prompt, type the following (replace **reverent_jackson** with your container name):
148+
In the Command Prompt, type the following :
137149

138150
```
139-
docker cp reverent_jackson:/work/RTK_Everywhere/build/esp32.esp32.esp32/RTK_Everywhere.ino.bin .
151+
docker cp rtk_everywhere:/RTK_Everywhere.ino.bin .
140152
```
141153

142154
Hey presto! A file called `RTK_Everywhere.ino.bin` appears in the current directory. That's the firmware binary we are going to upload to the ESP32.
143155

156+
1[Firmware binary](./img/CompileSource/Firmware_binary.png)
157+
144158
If you need the `.elf` file so you can debug code crashes with me-no-dev's [ESP ExceptionDecoder](https://github.com/me-no-dev/EspExceptionDecoder):
145159

146160
```
147-
docker cp reverent_jackson:/work/RTK_Everywhere/build/esp32.esp32.esp32/RTK_Everywhere.ino.elf .
161+
docker cp rtk_everywhere:/RTK_Everywhere.ino.elf .
148162
```
149163

150164
If you want the files to appear in a more convenient directory, replace the single `.` with a folder path.
151165

152-
The Container compilation is fast, taking around 2 minutes 20 seconds for a full compile. Running the same `arduino-cli compile` command directly in a Command Prompt takes around 3 minutes.
166+
Delete the `rtk_everywhere` container afterwardds, to save disk space, and so you can reuse the same container name next time.
153167

154168
## Compiling on Windows (Deprecated)
155169

-135 KB
Binary file not shown.
104 KB
Loading
101 KB
Loading
7.73 KB
Loading
79.2 KB
Loading

0 commit comments

Comments
 (0)