summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2024-01-17 20:02:30 +0300
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2024-01-17 20:02:30 +0300
commit895ff5b5d47970154d9d2d7051eae2be8872228f (patch)
tree8d06a6b049491243d13b0f08bd12cb03c9344ace
parent30a4bc671d5a9e84fff60f4cd485dc070d5724a8 (diff)
downloadshmotbox-895ff5b5d47970154d9d2d7051eae2be8872228f.tar.gz
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.
-rw-r--r--.gitignore2
-rw-r--r--Makefile33
-rw-r--r--linux-compatible-tty.conf20
3 files changed, 54 insertions, 1 deletions
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/'`";
+};