I have a 3d printer that uses the Marlin firmware. It’s an Alunar M508 (Prusa I3 Clone) and I maintain a build of Marlin for it that is tailored for that printer. Recently, I thought it would be fun to set up a Jenkins build agent that can build Arduino code. The agent is a docker image that is based off a base sshd image. Currently these are not available publicly, but I may change that in the future.
The base image is just a standard sshd server so so Jenkins can communicate to the agent.
The arduino agent installs arduino 1.8.5, and a few things like pip, gcc, etc. I also have some scripts that I put together that allow the build pipeline install Arduino Boards and Libraries. Like the board and library managers in the UI.
board-manager --name='Arduino AVR Boards' --version='latest' --packager='arduino'
That command will install the latest AVR boards and all the required dependencies. Additionally, to install a libarary, it would look like this:
library-manager --name='LiquidCrystal' --version='latest';
After I got all that setup and able to output the hex binaries from the arduino-builder, I thought it would be fun if I could trust that the build that came out flashes to a device successfully. I pulled out the extra Mega2560 board I have that I use for testing my builds of the firmware anyhow before I would flash it to the printer, and I plugged it in to my Docker Host. The Jenkins Arduino agent mounts that device so it can access it.
After the binaries are built, I run:
avrdude -p m2560 -c avrispmkII -P /dev/ttyACM0 -C /usr/local/etc/avrdude.conf -D -U flash:w:/path/to/build.hex:i
Which will write the binary to the device. After that is successful, I run some serial commands to actually read from the Firmware to validate that it is announcing / working as Marlin.
After that is successful, it will zip up the hex files, and it creates a Github release and uploads the file to the release.
You can find most of the “work” in the github repo in either the Jenkinsfile, or the .deploy scripts folder. I still have some issues to iron out, like making sure the serial port is available again after the push to the device. After I get that stuff wrapped up, I will see what I have to adjust to make the container images publicly available.