Skip to content

Commit 95f8312

Browse files
committed
Update COMPILE_BINARY - to include Dockerfile and compile_with_docker.bat
1 parent a3e9557 commit 95f8312

File tree

5 files changed

+126
-38
lines changed

5 files changed

+126
-38
lines changed

COMPILE_BINARY.md

Lines changed: 126 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,125 @@
11
# OpenLog Artemis : How To Compile The OLA Firmware Binary
22

3-
These are _abbreviated_ instructions on how to compile the OLA firmware. It's more of an aide-memoire really... Sorry about that.
3+
* [Using Docker](#using-docker)
4+
* [How SparkFun does it](#how-sparkfun-does-it)
5+
* [Using Arduino IDE (Deprecated)](#using-arduino-ide-deprecated)
46

5-
## Install Arduino IDE
7+
## Using Docker
8+
9+
Installing the correct version of the Apollo3 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 core or library installed, or forgot to patch the core correctly... It is much easier to sandbox the firmware compilation using an environment like [Docker](https://www.docker.com/).
10+
11+
Docker is open-source. It is our new favourite thing!
12+
13+
Here is a step-by-step guide for how to install Docker and compile the firmware from scratch:
14+
15+
### Clone, fork or download the OpenLog_Artemis repo
16+
17+
To build the OpenLog_Artemis firmware, you obviously need a copy of the source code.
18+
19+
If you are familiar with Git and GitHub Desktop, you can clone the OpenLog_Artemis repo directly into GitHub Desktop:
20+
21+
![Clone OpenLog_Artemis with GitHub Desktop](./img/CompileSource/Clone_Repo_To_GitHub_Desktop.png)
22+
23+
If you want to _contribute_ to OpenLog_Artemis, and already have a GitHub account, you can Fork the repo:
24+
25+
![Fork OpenLog_Artemis](./img/CompileSource/Fork_Repo.png)
26+
27+
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.
28+
29+
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:
30+
31+
[![Download ZIP](./img/CompileSource/Download_Zip.png)](https://github.com/sparkfun/OpenLog_Artemis/archive/refs/heads/main.zip "Download ZIP (main branch)")
32+
33+
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...
34+
35+
[![Download ZIP - release candidate](./img/CompileSource/Download_Zip.png)](https://github.com/sparkfun/OpenLog_Artemis/archive/refs/heads/release_candidate.zip "Download ZIP (release_candidate branch)")
36+
37+
### Install Docker Desktop
38+
39+
* **(Optional)** Head to [Docker](https://www.docker.com/) and create an account. A free "Personal" account will cover occasional compilations of the firmware
40+
* 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.
41+
* Run the Desktop
42+
* You don't _need_ to have an account and you don't _need_ to be signed in
43+
* You only need to be signed in if you want to store or share your Container on Docker Hub
44+
* If you don't sign in, Docker Desktop will run in Personal mode - which will cover local compilations of the firmware
45+
* 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:
46+
* Open a command prompt
47+
* Type `wsl --update` to update WSL. At the time of writing, this installs Windows Subsystem for Linux 2.6.1
48+
* Restart the Docker Desktop
49+
* 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_
50+
* On Windows, you may want to give Docker Desktop permission to access to your Network, so it can access (e.g.) HTML ports
51+
* You can Stop the container and Delete it when you are done
52+
* You may want to prevent Docker from running when your machine starts up
53+
* Uncheck "Start Docker Desktop when you sign in to your computer" in the Desktop settings
54+
55+
### Using Docker to create the firmware binary
56+
57+
* **Make sure you have Docker Desktop running.** You don't need to be signed in, but it needs to be running.
58+
* Open a Command Prompt and `cd` into the OpenLog_Artemis folder
59+
* Check you are in the right place. Type `dir` and hit enter. You should see the following files and folders:
60+
61+
```
62+
.gitattributes
63+
.github
64+
.gitignore
65+
ADDING_SENSORS.md
66+
Binaries
67+
CHANGELOG.md
68+
COMPILE_BINARY.md
69+
CONTRIBUTING.md
70+
Firmware
71+
```
72+
73+
* `cd Firmware` and then `dir` again. You should see:
74+
75+
```
76+
compile_with_docker.bat
77+
Dockerfile
78+
Extras
79+
OpenLog_Artemis
80+
Test Sketches
81+
```
82+
83+
* The file that does most of the work is the `Dockerfile`. You can run the Dockerfile manually to create a container and image, from which you can extract the firmware binary.
84+
85+
* But, if you're short on time, simply run `compile_with_docker.bat`. It does everything for you:
86+
87+
![Output of the compile batch file](./img/CompileSource/compile_me_batch_file.png)
88+
89+
* Hey presto! You have your newly compiled firmware binary!
90+
91+
You can then use the [SparkFun Artemis Uploader App](https://github.com/sparkfun/Artemis-Firmware-Upload-GUI) to upload the binary onto the Artemis. See [UPGRADE](./UPGRADE.md) for more instructions.
92+
93+
On Linux, you will need to convert `compile_with_docker.bat` into a shell script. Or run each of the four docker commands manually to: build the image, create the container, extract the firmware binary, and delete the container:
94+
95+
```
96+
docker build -t openlog_artemis_firmware --progress=plain --no-cache-filter deployment .
97+
docker create --name=openlog_artemis_container openlog_artemis_firmware:latest
98+
docker cp openlog_artemis_container:/OpenLog_Artemis.ino.bin .
99+
docker container rm openlog_artemis_container
100+
```
101+
102+
## How SparkFun does it
103+
104+
At SparkFun, we use GitHub Actions and a Workflow to compile each release of the OpenLog Artemis firmware. We run the [compilation workflow](https://github.com/sparkfun/OpenLog_Artemis/blob/main/.github/workflows/build-for-release.yml) directly on GitHub. A virtual ubuntu machine installs the [Arduino CLI](https://github.com/arduino/arduino-cli/releases), installs the Apollo3 Arduino core, patches the core in a couple of places, installs all the required libraries at the required version, and generates the firmware binary for the Artemis. That binary is either uploaded as an Artifact (by [non-release-build](https://github.com/sparkfun/OpenLog_Artemis/blob/main/.github/workflows/non-release-build.yml)) or pushed to the [Binaries Folder](https://github.com/sparkfun/OpenLog_Artemis/tree/main/Binaries) (by [compilation workflow](https://github.com/sparkfun/OpenLog_Artemis/blob/main/.github/workflows/build-for-release.yml)).
105+
106+
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.
107+
108+
You can then download the firmware binary and use the [SparkFun Artemis Uploader App](https://github.com/sparkfun/Artemis-Firmware-Upload-GUI) to upload the binary onto the Artemis. See [UPGRADE](./UPGRADE.md) for more instructions.
109+
110+
## Using Arduino IDE (Deprecated)
111+
112+
We strongly suggest using Docker to compile the binary, it is **much** easier.
113+
114+
These are _abbreviated_ instructions on how to compile the OLA firmware using Arduino IDE. It's more of an aide-memoire really... Sorry about that.
115+
116+
### Install Arduino IDE
6117

7118
Tested version: 1.8.19
8119

9120
(IDE version 2 has not been tested)
10121

11-
## Add Apollo3 To The Additional Boards Manager URLs
122+
### Add Apollo3 To The Additional Boards Manager URLs
12123

13124
Open `File \ Preferences`
14125

@@ -26,15 +137,15 @@ Click OK
26137

27138
Close and re-open the IDE
28139

29-
## Install the Apollo3 Board Package
140+
### Install the Apollo3 Board Package
30141

31142
Open `Tools \ Board \ Boards Manager`
32143

33144
Enter `Apollo3` in the search box
34145

35146
Install the SparkFun Apollo3 Boards. Tested version: 2.2.1
36147

37-
## Install All The Required Libraries
148+
### Install All The Required Libraries
38149

39150
Copy and paste the following into an empty sketch. Click on each link in turn to install the libraries via the Library Manager:
40151

@@ -72,25 +183,26 @@ Copy and paste the following into an empty sketch. Click on each link in turn to
72183
// http://librarymanager/All#SparkFun_KX13X
73184
// http://librarymanager/All#SparkFun_LPS28DFW_Arduino_Library
74185
// http://librarymanager/All#SparkFun_VEML7700
186+
// http://librarymanager/All#SparkFun_TMP102
75187
```
76188

77-
### Blue Robotics MS5837
189+
#### Blue Robotics MS5837
78190

79191
Please manually download and install the latest version of the Blue Robotics MS5837 library from:
80192

81193
https://github.com/bluerobotics/BlueRobotics_MS5837_Library/archive/refs/heads/master.zip
82194

83195
(Version 1.1.1 - available through the Arduino Library Manager - is not the latest version...)
84196

85-
## Download the OLA Firmware Zip
197+
### Download the OLA Firmware Zip
86198

87199
Open this link in a web browser to download a complete Zip of the OLA firmware repo:
88200

89201
https://github.com/sparkfun/OpenLog_Artemis/archive/refs/heads/main.zip
90202

91203
Unzip it (Extract All files)
92204

93-
## Copy the OLA Source Code
205+
### Copy the OLA Source Code
94206

95207
Navigate to the `Firmware` sub-folder
96208

@@ -100,7 +212,7 @@ Copy the entire `OpenLog_Artemis` folder from the Zip file into your `Arduino` f
100212
C:\Users\<Your_User>\Documents\Arduino\OpenLog_Artemis
101213
```
102214

103-
## Patch the Apollo3 Core
215+
### Patch the Apollo3 Core
104216

105217
The Apollo3 core (2.2.1) requires patching - using code kindly provided by Paulvha. For more information, open [this link](https://github.com/sparkfun/OpenLog_Artemis/issues/117#issuecomment-1085881142) in a web browser.
106218

@@ -121,42 +233,18 @@ Unzip it (Extract All files)
121233

122234
Follow the instructions contained in `uart_power_3.odt`
123235

124-
In summary: replace the following five files with the ones from `UartPower3.zip` :
236+
In summary: replace the following six files with the ones from `UartPower3.zip` :
125237

126238
```
127239
C:\Users\<Your_User>\AppData\Local\Arduino15\packages\SparkFun\hardware\apollo3\2.2.1\cores\arduino\mbed-bridge\core-extend\HardwareSerial.h
128240
C:\Users\<Your_User>\AppData\Local\Arduino15\packages\SparkFun\hardware\apollo3\2.2.1\cores\arduino\mbed-bridge\core-implement\HardwareSerial.cpp
129241
C:\Users\<Your_User>\AppData\Local\Arduino15\packages\SparkFun\hardware\apollo3\2.2.1\cores\mbed-os\drivers\UnbufferedSerial.h
130242
C:\Users\<Your_User>\AppData\Local\Arduino15\packages\SparkFun\hardware\apollo3\2.2.1\cores\mbed-os\targets\TARGET_Ambiq_Micro\TARGET_Apollo3\device\serial_api.c
131243
C:\Users\<Your_User>\AppData\Local\Arduino15\packages\SparkFun\hardware\apollo3\2.2.1\variants\SFE_ARTEMIS_ATP\mbed\libmbed-os.a
132-
```
133-
134-
## Update Apollo3 SPI.cpp
135-
136-
Open the following file:
137-
138-
```
139244
C:\Users\<Your_User>\AppData\Local\Arduino15\packages\SparkFun\hardware\apollo3\2.2.1\libraries\SPI\src\SPI.cpp
140245
```
141246

142-
Search for `::end`
143-
144-
Replace `::end` with:
145-
146-
```
147-
void arduino::MbedSPI::end() {
148-
if (dev) {
149-
delete dev;
150-
dev = NULL;
151-
}
152-
}
153-
```
154-
155-
Save the updated file
156-
157-
The extra code prevents badness when the Artemis goes into deep sleep
158-
159-
## Enable ICM29048 DMP Support
247+
### Enable ICM29048 DMP Support
160248

161249
Open the following file:
162250

@@ -172,7 +260,7 @@ Uncomment the following line (29):
172260

173261
Save the updated file
174262

175-
## Compile / Upload the Code
263+
### Compile / Upload the Code
176264

177265
Re-open the Arduino IDE
178266

@@ -191,7 +279,7 @@ If you have the OLA connected via USB, you can click the `Upload` (Right-Arrow)
191279
If you want to be able to swap between firmware versions more quickly, use the `Sketch \ Export compiled Binary` to create a binary which
192280
you can upload with the `Artemis Firmware Upload GUI`. See [UPGRADE.md](./UPGRADE.md) for more details.
193281

194-
## Board Versions
282+
### Board Versions
195283

196284
If you are compiling for the Red (SparkFun) OLA: leave the hardware version defines as:
197285

@@ -207,7 +295,7 @@ If you have an original Black (SparkX) OLA - way to go! Change those lines to:
207295
#define HARDWARE_VERSION_MINOR 4
208296
```
209297

210-
## No Power Loss Protection
298+
### No Power Loss Protection
211299

212300
To disable the sleep-on-power-loss functionality, uncomment this line:
213301

55.3 KB
Loading

img/CompileSource/Download_Zip.png

1.24 KB
Loading

img/CompileSource/Fork_Repo.png

14.6 KB
Loading
87.6 KB
Loading

0 commit comments

Comments
 (0)