You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/firmware_compile.md
+72-13Lines changed: 72 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,12 +14,14 @@ You are welcome to clone or fork this repo and do the exact same thing yourself.
14
14
15
15
If you run the [compilation workflow](https://github.com/sparkfun/SparkFun_RTK_Everywhere_Firmware/blob/main/.github/workflows/compile-rtk-everywhere.yml), it will compile the firmware and attempt to push the binary to the Binaries repo. This will fail as your account won't have the right permissions. The [non-release-build](https://github.com/sparkfun/SparkFun_RTK_Everywhere_Firmware/blob/main/.github/workflows/non-release-build.yml) is the one for you. The firmware binary will be attached as an Artifact to the workflow run. Navigate to Actions \ Non-Release Build, select the latest run of Non-Release Build, the binary is in the Artifacts.
16
16
17
-
You can then use the [SparkFun RTK Firmware Uploader](https://github.com/sparkfun/SparkFun_RTK_Firmware_Uploader) to upload the binary onto the ESP32.
17
+
You can then use (e.g.) the [SparkFun RTK Firmware Uploader](https://github.com/sparkfun/SparkFun_RTK_Firmware_Uploader) to upload the binary onto the ESP32.
18
18
19
19
## Using Docker
20
20
21
21
Installing the correct version of the ESP32 core and of each required Arduino library, is tedious and error-prone. Especially on Windows. We've lost count of the number of times code compilation fails on our local machines, because we had the wrong ESP32 core installed, or forgot to patch libbt or libmbedcrypto... It is much easier to sandbox the firmware compilation using an environment like [Docker](https://www.docker.com/).
22
22
23
+
Docker is open-source. It is our new favourite thing!
24
+
23
25
Here is a step-by-step guide for how to install Docker and compile the firmware from scratch:
24
26
25
27
### Clone, fork or download the RTK Everywhere Firmware repo
@@ -56,20 +58,20 @@ For the real Wild West experience, you can also download a copy of the `release_
56
58
57
59
### Install Docker Desktop
58
60
59
-
* Head to [Docker](https://www.docker.com/) and create an account. A free "Personal" account will cover occasional compilations of the firmware
61
+
***(Optional)**Head to [Docker](https://www.docker.com/) and create an account. A free "Personal" account will cover occasional compilations of the firmware
60
62
* 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
63
+
* Run the Desktop. If you don't sign in, it will run in Personal mode - which will cover occasional compilations of the firmware
62
64
* 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
65
* Open a command prompt
64
66
* Type `wsl --update` to update WSL. At the time of writing, this installs Windows Subsystem for Linux 2.6.1
65
67
* 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
68
+
* If you are using Docker for the first time, the "What is a container?" and "How do I run a container?" demos are useful - _but not essential_
67
69
* On Windows, you may want to give Docker Desktop permission to access to your Network, so it can access (e.g.) HTML ports
68
70
* You can Stop the container and Delete it when you are done
69
71
* You may want to prevent Docker from running when your machine starts up
70
72
* Uncheck "Start Docker Desktop when you sign in to your computer" in the Desktop settings
71
73
72
-
### Running the Dockerfile to create an Image
74
+
### Using Docker to create the firmware binary
73
75
74
76
***Make sure you have Docker Desktop running.** You don't need to be logged in, but it needs to be running.
75
77
* Open a Command Prompt and `cd` into the SparkFun_RTK_Everywhere_Firmware folder
@@ -90,14 +92,31 @@ For the real Wild West experience, you can also download a copy of the `release_
90
92
*`cd Firmware` and then `dir` again. You should see:
91
93
92
94
```
95
+
compile_with_docker.bat
93
96
Dockerfile
94
97
readme.md
95
98
RTKEverywhere.csv
96
99
RTKEverywhere_8MB.csv
100
+
RTK_Everywhere
97
101
```
98
102
99
-
* The file we will be using is the `Dockerfile`.
100
-
* Type:
103
+
* The file that does most of the work is the `Dockerfile`
104
+
105
+
* But, if you're short on time, run `compile_with_docker.bat`. It does everything for you:
106
+
107
+

108
+
109
+
* Hey presto! You have your newly compiled firmware binary!
110
+
111
+
You can then use (e.g.) the [SparkFun RTK Firmware Uploader](https://github.com/sparkfun/SparkFun_RTK_Firmware_Uploader) to upload the binary onto the ESP32.
112
+
113
+
### Running the Dockerfile manually
114
+
115
+
If you want to see and understand what's going on under the hood with the Dockerfile, Image and Container:
Building the full Image from scratch is slow, taking several minutes. You should only need to do it once - unless you make any changes to the Dockerfile.
123
142
124
-
* When you make changes to the source code and want to recompile, use:
143
+
***When you make changes to the source code and want to recompile, use:**
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
150
132
-
### Access the firmware by running the Image
151
+
### Access the firmware binary by running the Image
133
152
134
153
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:
135
154
@@ -161,12 +180,39 @@ If you need the `.elf` file so you can debug code crashes with me-no-dev's [ESP
If you want the files to appear in a more convenient directory, replace the single `.` with a folder path.
165
190
166
-
Delete the `rtk_everywhere` container afterwards, to save disk space and so you can reuse the same container name next time.
191
+
Delete the `rtk_everywhere` container afterwards, to save disk space and so you can reuse the same container name next time. If you forget, you will see an error:
192
+
193
+
```Conflict. The container name "/rtk_container" is already in use by container. You have to remove (or rename) that container to be able to reuse that name.```
194
+
195
+
***Remember:** when you make changes to the source code and want to recompile, use:
0 commit comments