From 895ff5b5d47970154d9d2d7051eae2be8872228f Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Wed, 17 Jan 2024 20:02:30 +0300 Subject: added Makefile for arduino-cli * Upload works on FreeBSD via Linuxator but only if Linux-like device names will be created. This can be achived by installing linux-compatible-tty.conf. * Alternatively, it would also be possible to manually invoke avrdude. --- .gitignore | 2 +- Makefile | 33 +++++++++++++++++++++++++++++++++ linux-compatible-tty.conf | 20 ++++++++++++++++++++ 3 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 Makefile create mode 100644 linux-compatible-tty.conf diff --git a/.gitignore b/.gitignore index b03bcec..796b96d 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -build-leonardo +/build diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..28c58e7 --- /dev/null +++ b/Makefile @@ -0,0 +1,33 @@ +#DEVICE := /dev/ttyACM1 +# FreeBSD (via Linuxator). +# This requires installation of the linux-compatible-tty.conf devd script. +# Without this, `arduino-cli upload` will not work. +# You can however manually invoke avrdude on FreeBSD if everything fails. +DEVICE := /dev/ttyACM0 + +FQBN := arduino:avr:leonardo + +ARDUINO_CLI := arduino-cli +#ARDUINO_CLI := ~/arduino-ide_2.2.1_Linux_64bit/resources/app/lib/backend/resources/arduino-cli + +all: compile + +install-deps: + $(ARDUINO_CLI) core install arduino:avr + $(ARDUINO_CLI) lib install DistanceSensor + $(ARDUINO_CLI) lib install MIDIUSB + @echo 'You have to install https://github.com/tttapa/Control-Surface manually.' + +# For the legacy arduino-build that runs natively on FreeBSD. +# Not all libraries are compatible, though. +# Especially Control-Surface apparently needs a v2 core. +# arduino-builder -compile -hardware /usr/local/arduino/hardware -tools /usr/local/arduino/hardware/tools/ -tools /usr/local/arduino/tools-builder/ -core-api-version 10618 -libraries ~/Arduino/libraries -fqbn arduino:avr:leonardo -prefs "compiler.cpp.extra_flags=-DARDUINO_API_VERSION=1" -verbose shmotbox.ino +compile: + $(ARDUINO_CLI) compile --fqbn $(FQBN) . + +# You may have to run this as root, but this will require installing +# the arduino:avr core into the root account as well. +# It therefore makes sense to have $(DEVICE) accessible as a regular user. +# On FreeBSD you have to be in the dialer group. +upload: + $(ARDUINO_CLI) upload -p $(DEVICE) --fqbn $(FQBN) . diff --git a/linux-compatible-tty.conf b/linux-compatible-tty.conf new file mode 100644 index 0000000..086aa50 --- /dev/null +++ b/linux-compatible-tty.conf @@ -0,0 +1,20 @@ +# This FreeBSD devd-script creates Linux-like TTY device nodes under /compat/ubuntu/dev/. +# This fixes `arduino-cli upload`. + +notify 100 { + match "system" "DEVFS"; + match "subsystem" "CDEV"; + match "type" "CREATE"; + match "cdev" "cuaU[0-9]+"; + + action "ln -s $cdev /compat/ubuntu/dev/`echo $cdev | sed 's/^cuaU/ttyACM/'`"; +}; + +notify 100 { + match "system" "DEVFS"; + match "subsystem" "CDEV"; + match "type" "DESTROY"; + match "cdev" "cuaU[0-9]+"; + + action "rm /compat/ubuntu/dev/`echo $cdev | sed 's/^cuaU/ttyACM/'`"; +}; -- cgit v1.2.3