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_update.md
+172-3Lines changed: 172 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -273,9 +273,178 @@ As of writing, no additional releases of the NEO-D9S firmware have been made.
273
273
274
274
## Compiling Source
275
275
276
-
### Windows
276
+
This is information about how to compile the RTK Firmware from source. This is for advanced users who would like to modify the functionality of the RTK products.
277
+
278
+
*[How SparkFun does it](#how-sparkfun-does-it)
279
+
*[Using Docker](#using-docker)
280
+
*[Compiling on Windows (Deprecated)](#compiling-on-windows-deprecated)
281
+
*[Compiling on Ubuntu 20.04 (Deprecated)](#compiling-on-ubuntu-2004-deprecated)
282
+
283
+
## How SparkFun does it
284
+
285
+
At SparkFun, we use GitHub Actions and a Workflow to compile each release of RTK Firmware. We run the [compilation workflow](https://github.com/sparkfun/SparkFun_RTK_Firmware/blob/main/.github/workflows/compile-rtk-firmware.yml) directly on GitHub. A virtual ubuntu machine installs the [Arduino CLI](https://github.com/arduino/arduino-cli/releases), installs the correct ESP32 Arduino core, patches the core in a couple of places, installs all the required libraries at the required version, converts the embedded HTML and Bootstrap JavaScript to binary zip format, and generates the firmware binary for the ESP32. That binary is either uploaded as an Artifact (by [non-release-build](https://github.com/sparkfun/SparkFun_RTK_Firmware/blob/main/.github/workflows/non-release-build.yml)) or pushed to the [SparkFun RTK Firmware Binaries](https://github.com/sparkfun/SparkFun_RTK_Firmware_Binaries) repo (by the [compilation workflow](https://github.com/sparkfun/SparkFun_RTK_Firmware/blob/main/.github/workflows/compile-rtk-firmware.yml)).
286
+
287
+
You are welcome to clone or fork this repo and do the exact same thing yourself. But you may need a paid GitHub Pro account to run the GitHub Actions, especially if you keep your clone / fork private.
288
+
289
+
If you run the [compilation workflow](https://github.com/sparkfun/SparkFun_RTK_Firmware/blob/main/.github/workflows/compile-rtk-firmware.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_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.
290
+
291
+
You can then use the [SparkFun RTK Firmware Uploader](https://github.com/sparkfun/SparkFun_RTK_Firmware_Uploader) to upload the binary onto the ESP32.
292
+
293
+
## Using Docker
294
+
295
+
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 Server.h... It is much easier to sandbox the firmware compilation using an environment like [Docker](https://www.docker.com/).
296
+
297
+
Here is a step-by-step guide for how to install Docker and compile the firmware from scratch:
298
+
299
+
### Clone, fork or download the RTK Firmware repo
300
+
301
+
To build the RTK Firmware, you obviously need a copy of the source code.
302
+
303
+
If you are familiar with Git and GitHub Desktop, you can clone the RTK Firmware repo directly into GitHub Desktop:
304
+
305
+
<figuremarkdown>
306
+

307
+
<figcaptionmarkdown>
308
+
Clone RTK Firmware with GitHub Desktop
309
+
</figcaption>
310
+
</figure>
311
+
312
+
If you want to _contribute_ to the RTK Firmware, and already have a GitHub account, you can Fork the repo:
Clone your fork to your local machine, make changes, and send us a Pull Request. This is exactly what the SparkFun Team do when developing the code. Please use the `release_candidate` branch for any such changes. We are very unlikely to merge anything directly into `main`, unless it is (e.g.) docs corrections or improvements.
322
+
323
+
If you don't want to do either of those, you can simply Download a Zip copy of the repo instead. You will receive a complete copy as a Zip file. You can do this from the green **Code** button, or click on the icon below to download a copy of the main (released) branch:
324
+
325
+
[](https://github.com/sparkfun/SparkFun_RTK_Firmware/archive/refs/heads/main.zip"Download ZIP (main branch)")
326
+
327
+
For the real Wild West experience, you can also download a copy of the `release_candidate` code branch. This is where the team is actively changing and testing the code, before it becomes a full release. The code there will _usually_ compile and will _usually_ work, but we don't guarantee it! We may be part way through implementing some breaking changes at the time of your download...
328
+
329
+
[](https://github.com/sparkfun/SparkFun_RTK_Firmware/archive/refs/heads/release_candidate.zip"Download ZIP (release_candidate branch)")
330
+
331
+
### Install Docker Desktop
332
+
333
+
* Head to [Docker](https://www.docker.com/) and create an account. A free "Personal" account will cover occasional compilations of the firmware
334
+
* 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.
335
+
* Run the Desktop and sign in
336
+
* 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:
337
+
* Open a command prompt
338
+
* Type `wsl --update` to update WSL. At the time of writing, this installs Windows Subsystem for Linux 2.6.1
339
+
* Restart the Docker Desktop
340
+
* If you are using Docker for the first time, the "What is a container?" and "How do I run a container?" demos are useful
341
+
* On Windows, you may want to give Docker Desktop permission to access to your Network, so it can access (e.g.) HTML ports
342
+
* You can Stop the container and Delete it when you are done
343
+
* You may want to prevent Docker from running when your machine starts up
344
+
* Uncheck "Start Docker Desktop when you sign in to your computer" in the Desktop settings
345
+
346
+
### Running the Dockerfile to create an Image
347
+
348
+
***Make sure you have Docker Desktop running.** You don't need to be logged in, but it needs to be running.
349
+
* Open a Command Prompt and `cd` into the SparkFun_RTK_Firmware folder
350
+
* Check you are in the right place. Type `dir` and hit enter. You should see the following files and folders:
351
+
352
+
```
353
+
.gitattributes
354
+
.github
355
+
.gitignore
356
+
docs
357
+
Firmware
358
+
Graphics
359
+
Issue_Template.md
360
+
License.md
361
+
README.md
362
+
```
363
+
364
+
*`cd Firmware` and then `dir` again. You should see:
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.
398
+
399
+
* 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.
406
+
407
+
### Access the firmware by running the Image
408
+
409
+
In Docker Desktop, in the Images tab, you should now be able to see an Image named `rtk_firmware`. We now need to Run that Image to access the firmware binary. Click the triangular Run icon under Actions:
410
+
411
+

412
+
413
+
Running the Image will create a Container, through which we can access the output of the arduino-cli code compilation.
414
+
415
+
By default, the Container name is random. To avoid this, we define one in the **Optional settings** :
416
+
417
+

418
+
419
+
Run the Container and you should see:
420
+
421
+

422
+
423
+
In the Command Prompt, type the following :
424
+
425
+
```
426
+
docker cp rtk_container:/RTK_Surveyor.ino.bin .
427
+
```
428
+
429
+
Hey presto! A file called `RTK_Surveyor.ino.bin` appears in the current directory. That's the firmware binary we are going to upload to the ESP32.
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):
434
+
435
+
```
436
+
docker cp rtk_container:/RTK_Surveyor.ino.elf .
437
+
```
438
+
439
+
If you want the files to appear in a more convenient directory, replace the single `.` with a folder path.
440
+
441
+
Delete the `rtk_container` 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:
442
+
443
+
```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.```
444
+
445
+
### Compiling on Windows (Deprecated)
277
446
278
-
The SparkFun RTK firmware is compiled using Arduino (currently v1.8.15). To compile:
447
+
The SparkFun RTK Firmware is compiled using Arduino (currently v1.8.15). To compile:
0 commit comments