Arch is a bit… weird, in that it has /usr/share/arduino/hardware/archlinux-arduino instead of /usr/share/arduino/hardware/arduino. They do this because they use their own avr-gcc, and not the one shipped with Arduino. There are two ways to get around this issue:
Install stock Arduino somewhere, and use that.
Create an /usr/share/arduino/hardware/arduino symlink pointing to archlinux-arduino, and use something like the following command:
I’m not sure if the ARDUINO_LOCAL_LIB_PATH is required… if I remember correctly, that should point to a path where the hardware/keyboardio/avr stuff is (the parent of that path).
ls: cannot access ‘/home/hatten/.arduino15/packages/keyboardio/hardware/avr/*’: No such file or directory
BOARD_HARDWARE_PATH=“/home/hatten/Arduino/hardware” /home/hatten/Arduino/hardware/keyboardio/avr/libraries/Kaleidoscope/bin//kaleidoscope-builder build-all
Building output/Model01-Firmware/Model01-Firmware (0.0.0-gv1.13-55-g8ab1) …
open /usr/share/arduino/hardware/tools: no such file or directory
make: *** [/home/hatten/Arduino/hardware/keyboardio/avr/build-tools/makefiles//rules.mk:75: build-all] Error 1
Didn’t help much (did I do it wrong?). I changed ARDUINO_TOOLS_PATH and got further, but it doesn’t seem to respect AVR_SIZE_PATH.
$ find /usr/share/arduino/ -name tools
/usr/share/arduino/tools
$ make ARDUINO_BUILDER_PATH="/usr/bin/arduino-builder" \
ARDUINO_PATH="/usr/share/arduino"\
ARDUINO_LOCAL_LIB_PATH="../arduino-local" \
AVR_GCC_PREFIX="/usr" \
ARDUINO_TOOLS_PATH="/usr/share/arduino/tools" \
AVR_SIZE_PATH="avr-size"
ls: cannot access '/home/hatten/.arduino15/packages/keyboardio/hardware/avr/*': No such file or directory
BOARD_HARDWARE_PATH="/home/hatten/Arduino/hardware" /home/hatten/Arduino/hardware/keyboardio/avr/libraries/Kaleidoscope/bin//kaleidoscope-builder build-all
Building output/Model01-Firmware/Model01-Firmware (0.0.0-gv1.13-55-g8ab1) ...
/home/hatten/Arduino/hardware/keyboardio/avr/libraries/KeyboardioScanner/twi.c: In function '__vector_36':
/home/hatten/Arduino/hardware/keyboardio/avr/libraries/KeyboardioScanner/twi.c:446:47: warning: this statement may fall through [-Wimplicit-fallthrough=]
twi_masterBuffer[twi_masterBufferIndex++] = TWDR;
^
/home/hatten/Arduino/hardware/keyboardio/avr/libraries/KeyboardioScanner/twi.c:447:3: note: here
case TW_MR_SLA_ACK: // address sent, ack received
^~~~
- Size: firmware/Model01-Firmware/Model01-Firmware-0.0.0-gv1.13-55-g8ab1.elf
/home/hatten/Arduino/hardware/keyboardio/avr/libraries/Kaleidoscope/bin//kaleidoscope-builder: line 15: /usr/share/arduino/tools/avr/bin/avr-size: No such file or directory
awk: cmd. line:1: (FILENAME=- FNR=1) fatal: division by zero attempted
make: *** [/home/hatten/Arduino/hardware/keyboardio/avr/build-tools/makefiles//rules.mk:75: build-all] Error 2
$ which avr-size
/usr/bin/avr-size
setting AVR_SIZE_PATH to /usr/bin/avr-size gives the same error.
Huh, interesting. Can you try adding VERBOSE=1 to the command-line? That should get rid of the post-processing that appears to fail.
If that doesn’t fix it, if you could add a set -x to the top of /home/hatten/Arduino/hardware/keyboardio/avr/libraries/Kaleidoscope/bin//kaleidoscope-builder, and send me the output, that would be a huge help in tracking down where the issue lies.
$ make flash
ls: cannot access ‘/home/test/.arduino15/packages/keyboardio/hardware/avr/*’: No such file or directory
BOARD_HARDWARE_PATH=“/home/test/Arduino/hardware” /home/test/Arduino/hardware/keyboardio/avr/libraries/Kaleidoscope/bin//kaleidoscope-builder flash
Building output/Model01-Firmware/Model01-Firmware (0.0.0-gv1.13-57-ge6f5-dirty) …
fork/exec {runtime.tools.avr-gcc.path}/bin/avr-g++: no such file or directory
make: *** [/home/test/Arduino/hardware/keyboardio/avr/build-tools/makefiles//rules.mk:75: flash] Error 1
So I tried the extended make invocation suggested above:
$ make ARDUINO_BUILDER_PATH=“/usr/bin/arduino-builder”
ARDUINO_PATH=“/usr/share/arduino”
ARDUINO_LOCAL_LIB_PATH=“…/arduino-local”
AVR_GCC_PREFIX=“/usr”
ARDUINO_TOOLS_PATH=“”
AVR_SIZE_PATH=“avr-size” flash
ls: cannot access ‘/home/test/.arduino15/packages/keyboardio/hardware/avr/*’: No such file or directory
BOARD_HARDWARE_PATH=“/home/test/Arduino/hardware” /home/test/Arduino/hardware/keyboardio/avr/libraries/Kaleidoscope/bin//kaleidoscope-builder flash
Building output/Model01-Firmware/Model01-Firmware (0.0.0-gv1.13-57-ge6f5-dirty) …
/home/test/Arduino/hardware/keyboardio/avr/libraries/KeyboardioScanner/twi.c: In function ‘__vector_36’:
/home/test/Arduino/hardware/keyboardio/avr/libraries/KeyboardioScanner/twi.c:446:47: warning: this statement may fall through [-Wimplicit-fallthrough=]
twi_masterBuffer[twi_masterBufferIndex++] = TWDR;
^
/home/test/Arduino/hardware/keyboardio/avr/libraries/KeyboardioScanner/twi.c:447:3: note: here
case TW_MR_SLA_ACK: // address sent, ack received
^~~~
Press ENTER when ready…
stty: invalid argument ‘/dev/ttyACM1’
Try ‘stty --help’ for more information.
make: *** [/home/test/Arduino/hardware/keyboardio/avr/build-tools/makefiles//rules.mk:75: flash] Error 1
That’s a success, although it doesn’t look like it. The build environment works in general, the missing device node is a different problem. (Other hardware was assigned ttyACM1, my Model01 got ttyACM3. Gonna figure out how to point the arduino tools to that device node after diner.)
We’ve just been discussing this on #keyboardio on Freenode.
The issue is our hopelessly naive code that goes looking for device ports. (While you may see @algernon’s name in the git blame, it’s because he moved my horrible hack from elsewhere.)
It looks like right now our load-order for local customizations of the builder config have the system config being loaded last, so you wouldn’t even be able to properly override them, at least not yet. I’m so sorry this isn’t easy yet. But it’s now high on our list to rework.
I’ve just been testing exactly that, overwriting the default:
make ARDUINO_BUILDER_PATH=“/usr/bin/arduino-builder” ARDUINO_PATH=“/usr/share/arduino” ARDUINO_LOCAL_LIB_PATH=“…/arduino-local” AVR_GCC_PREFIX=“/usr” ARDUINO_TOOLS_PATH=“” AVR_SIZE_PATH=“avr-size” MONITOR_PORT=“/dev/ttyACM3” flash
I’ve also (incrementally) tried a few other ways of pointing “make” into the right direction. This is my latest attempt:
make … ARDUINO_PORT=“/dev/ttyACM3” MONITOR_PORT=“/dev/ttyACM3” FORCE_MONITOR_PORT=true DEVICE_PATH=“/dev/ttyACM3” flash
That code snippet explains why it didn’t work. I was searching the source for the line that defines ttyACM1, but hadn’t found it yet. Thanks very much.
Maybe you could do something like they do here:
Autodetection of the right port would of course be great, but in the meantime I’d settle for pointing make the right way via MONITOR_PORT or something similar.
There’s an additional wrinkle when you’re trying to flash a device – you need two different ports. The first is the port of the running device, so you can trigger the reboot into a bootloader. The second is the port that shows up when you’re in the bootloader. These are often, but not always the same.
We’ve got a couple ways we’re looking at fixing this, but it looks like doing the autodetection is unlikely to be dramatically more work than untangling the current code to make it easy to override.
I hadn’t gotten around to that wrinkle yet, thanks for the heads up.
I’ve noticed that the udev rules to avoid ModemManager’s interference (that many Linux users probably will need anyway) already creates a unique symlink for the Model01:
Maybe this could be used to set DEVICE_PATH? Unless the bootloader shows up with a different idVendor or idProduct, that symlink should be pretty reliable.
FWIW, there’s a very nice solution that avoids all these issues: detecting the device by vendor id & product id. The downside is, that this needs a bit of compiled code.
My current plan is to create a flasher application in node + Electron, package it for all platforms, and cross fingers. I’ve had great success with avrgirl before (it can detect both the running device, and the programmable mode too), so here’s hoping that this would fix our flashing issues once and for all, at the cost of some Electron bloat. (The same feature will be implemented in Chrysalis too - it actually already is implemented there.)
Worst case, I wasted an hour or so. Best? Flashing ~solved cross platform.
That is indeed part of the plan for Linux. (We have two different Device Ids. One for the bootloader and one for the running firmware, but both are known in advance.)
As an Arch user who is affected by this but has zero Arduino experience I was wondering if this issue could be circumvented by running from a Virtualbox Ubuntu guest? Is it too fiddly to enable flashing from the guest operating system?
@algernon’s suggestion to just use stock Arduino worked. I followed the instructions on the wiki to install Arduino manually on Linux with the Arch-specific part and it flashes without problems. I added a small fix to that wiki page though, an argument was missing from the Arch command.
After following along with the tips shared in this thread, I ran into the following error with Arch packaged version of Arduino IDE (1:1.8.5-1):
Found upload port: /dev/ttyACM0
___REMOVE___/bin/avrdude -C___REMOVE___/etc/avrdude.conf -v -patmega32u4 -cavr109 -P/dev/ttyACM0 -b57600 -D -Uflash:w:/tmp/arduino_build_609953/Model01-Firmware.ino.hex:i
java.io.IOException: Cannot run program "___REMOVE___/bin/avrdude": error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
at java.lang.Runtime.exec(Runtime.java:620)
at java.lang.Runtime.exec(Runtime.java:485)
at processing.app.helpers.ProcessUtils.exec(ProcessUtils.java:11)
at cc.arduino.packages.Uploader.executeUploadCommand(Uploader.java:129)
at cc.arduino.packages.uploaders.SerialUploader.uploadUsingPreferences(SerialUploader.java:207)
at cc.arduino.UploaderUtils.upload(UploaderUtils.java:78)
at processing.app.SketchController.upload(SketchController.java:713)
at processing.app.SketchController.exportApplet(SketchController.java:686)
at processing.app.Editor$DefaultExportHandler.run(Editor.java:2168)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.io.IOException: error=2, No such file or directory
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(UNIXProcess.java:247)
at java.lang.ProcessImpl.start(ProcessImpl.java:134)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
... 10 more
An error occurred while uploading the sketch
I was able to work around this issue by downgraded Arduino AVR board to 1.6.19 (from 1.6.20) within Arduino IDE -> Tools -> Board -> Board Manager… -> search for ‘avr board’ -> click on Arduino AVR board -> use drop down to select 1.6.19 -> Install. I am not sure why the error was occurring or why downgrading fixed this issue. I just wanted to share the work around if others ran into this issue.
I made a custom make.sh just to make life a bit easier in the Model01-Firmware that just packages the recommendations made together (I use fish so that just makes life easier)
lhl@ono4 ~/A/Model01-Firmware> ./make.sh
ls: cannot access '/home/lhl/.arduino15/packages/keyboardio/hardware/avr/*': No such file or directory
BOARD_HARDWARE_PATH="/home/lhl/Arduino/hardware" /home/lhl/Arduino/hardware/keyboardio/avr/libraries/Kaleidoscope/bin//kaleidoscope-builder flash
Building output/Model01-Firmware/Model01-Firmware (0.0.0-gv1.13-57-ge6f5) ...
/home/lhl/Arduino/hardware/keyboardio/avr/libraries/KeyboardioScanner/twi.c: In function '__vector_36':
/home/lhl/Arduino/hardware/keyboardio/avr/libraries/KeyboardioScanner/twi.c:446:47: warning: this statement may fall through [-Wimplicit-fallthrough=]
twi_masterBuffer[twi_masterBufferIndex++] = TWDR;
^
/home/lhl/Arduino/hardware/keyboardio/avr/libraries/KeyboardioScanner/twi.c:447:3: note: here
case TW_MR_SLA_ACK: // address sent, ack received
^~~~
Press ENTER when ready...
Connecting to programmer: .
Found programmer: Id = "CATERIN"; type = S
Software Version = 1.0; No Hardware Version given.
Programmer supports auto addr increment.
Programmer supports buffered memory access with buffersize=128 bytes.
Programmer supports the following devices:
Device code: 0x44
I get an error using the Arduino IDE (it complains about finding avr-g++) but I’ve confirmed that I can just edit the Model01-Firmware.ino file directly and the make fwill push the code over. Sweet.
Sorry to bump an old thread, but I’ve got mine building and flashing on my Arch laptop now too. I have it all wrapped up in a Makefile, so feel free to take what you need! https://github.com/Olical/keyboards/tree/master/model01
I managed to flash my keyboardio model 1 on Archlinux only with the Archlinux Arduino packages. I also use the upstream avr-gcc packaged by Archlinuxwithout any symlink in /usr/share/arduino/hardware.
Here is my conf:
max@host % pwd
/home/max/Documents/personnel/keyboardio/flash
max@host % tree --noreport -L 3
.
├── hardware
│ └── keyboardio
│ └── avr
└── Model01-Firmware
└── …
max@host % cd hardware/keyboardio/avr
max@host % git diff
diff --git a/boards.txt b/boards.txt
index d36402a..75a36e0 100644
--- a/boards.txt
+++ b/boards.txt
@@ -33,6 +33,6 @@ model01.build.pid=0x2301
model01.build.usb_product="Model 01"
model01.build.usb_manufacturer="Keyboardio"
model01.build.board=AVR_MODEL01
-model01.build.core=arduino:arduino
+model01.build.core=archlinux-arduino:arduino
model01.build.variant=model01
model01.build.extra_flags={build.usb_flags} '-DKALEIDOSCOPE_HARDWARE_H="Kaleidoscope-Hardware-Model01.h"'
diff --git a/libraries/Kaleidoscope b/libraries/Kaleidoscope
--- a/libraries/Kaleidoscope
+++ b/libraries/Kaleidoscope
@@ -1 +1 @@
-Subproject commit fe71904441b6f02698ac59b53efae0c159bbb772
+Subproject commit fe71904441b6f02698ac59b53efae0c159bbb772-dirty
max@host % cd libraries/Kaleidoscope
max@host % git diff
diff --git a/etc/kaleidoscope-builder.conf b/etc/kaleidoscope-builder.conf
index b337973..472e0fe 100644
--- a/etc/kaleidoscope-builder.conf
+++ b/etc/kaleidoscope-builder.conf
@@ -1,5 +1,15 @@
# -*- shell-script -*-
+# perso for Archlinux packages
+ARDUINO_PATH=/usr/share/arduino
+ARDUINO_TOOLS_PATH=/usr/share/arduino/tools
+AVR_SIZE=/usr/bin/avr-size
+AVR_NM=/usr/bin/avr-nm
+AVR_OBJDUMP=/usr/bin/avr-objdump
+AVRDUDE=/usr/bin/avrdude
+AVRDUDE_CONF=/etc/avrdude.conf
+AVR_GCC_PREFIX=/usr
+
## NEEDS: LIBRARY, SKETCH, ROOT, SOURCEDIR
## Should be included when the current directory is the dir of the Sketch.
max@host % cd /home/max/Documents/personnel/keyboardio/flash/Model01-Firmware
max@host % make SKETCHBOOK_DIR=/home/max/Documents/personnel/keyboardio/flash flash
BOARD_HARDWARE_PATH="/home/max/Documents/personnel/keyboardio/flash/hardware" /home/max/Documents/personnel/keyboardio/flash/hardware/keyboardio/avr/libraries/Kaleidoscope/bin//kaleidoscope-builder flash
Building output/Model01-Firmware/Model01-Firmware (0.0.0-gv1.22-3-gb745) ...
…
Press ENTER when ready...
Connecting to programmer: .
Found programmer: Id = "CATERIN"; type = S
Software Version = 1.0; No Hardware Version given.
Programmer supports auto addr increment.
Programmer supports buffered memory access with buffersize=128 bytes.
Programmer supports the following devices:
Device code: 0x44