Closed solvaholic closed 8 months ago
If you find yourself thinking a Makefile will help, check out sudar/Arduino-Makefile and Sudar's blog.
If you find yourself wanting to run builds in a container, check out some prior art: https://hub.docker.com/r/arduinoci/ci-arduino-esp32 https://hub.docker.com/r/domatic/arduino
Understand the sketch build process
I think that's sort of like:
cat Sketch/*.ino Sketch/*.pde > Sketch.cpp
#include <Arduino.h>
, if it's not already there#line
directives so compiler warnings and error swill make sense (neat!)Build and upload with
arduino-cli
I think I'd like to have arduino-cli
download and install libraries in my clone of this repo. And I'd like to control which configuration file it uses. Docs say arduino-cli
will use the config file specified by --config-file
option, or the one stored in directories.data
.
Can you guess where directories.data
is written? It seems like I'll need to either overwrite the default config file or specify a --config-file
each time I run arduino-cli
.
8052acab71 creates script/bootstrap.sh to set up the local arduino-cli
configuration file, arduino-cli.yaml.
Build and upload with
arduino-cli
f97260bde5 updates script/bootstrap.sh to install Arduino core and libraries. After that, this seems to do the trick:
cd ~/repos/arduino
./script/bootstrap.sh
_port=/dev/cu.usbserial-0001
_board=Heltec-esp32:esp32:wifi_kit_32
_sketch=esp32_hello
arduino-cli --config-file ./arduino-cli.yaml \
compile -b $_board $_sketch
arduino-cli --config-file ./arduino-cli.yaml \
board attach -p $_port -b $_board \
--board-options "UploadSpeed=115200" \
$_sketch
arduino-cli --config-file ./arduino-cli.yaml \
upload $_sketch
Build and upload with VS Code
Microsoft's extension looks like it should Just Work: https://github.com/microsoft/vscode-arduino
For me, however, it did not. In case I come back to it, or you're facing similar challenges, here are a few of the issues I was unable to pass:
arduino.path
and arduino.commandPath
, the extension failed to use my arduino-cli
arduino-cli
, it doesn't know about my installed core, libraries, and packagesUsing Arduino IDE costs me less time and attention than troubleshooting that mess.
Using Arduino IDE costs me less time and attention than troubleshooting that mess.
And maintaining my own build and upload scripts costs even less, so 5fdb9189ef introduces those. Now my environment is easily reproducible, I don't have to remember the steps, and I can work in my preferred editor.
I like the Arduino IDE, it makes all the steps super easy. For editing code, tho, I prefer using VS Code. I'd also like to lint, build, and test regardless of IDE, for example on a GitHub Actions runner. How to build a sketch and upload it, without using the Arduino IDE?