I know all of this is Doing It Wrong™ but I’d like to see how far I can get with it anyway. I’m only about 75% of the way to doing a successful build I got it to work, see below, but hopefully someone will find my rubber duck rambling useful.
Okay, so the distro has a pre-existing Arduino package (good!). But it’s 1.0.5, which is incredibly ancient - Kaleidoscope needs 1.6.10 or higher. But I’m in luck because people have already been working on a 1.8.5 package and it’s already available. So I’ve installed that and now have a generic AVR cross-compile toolchain set up, the Arduino IDE runs too but I’ll ignore that for the time being.
Let’s try to build the keyboard firmware:
cd kaleidoscope/Kaleidoscope/
make
# BOARD_HARDWARE_PATH="/home/ant/Arduino/hardware" /home/ant/Arduino/hardware/keyboardio/avr/libraries/Kaleidoscope/bin//kaleidoscope-builder build-all
# Building output/AppSwitcher/AppSwitcher (0.0.1-gfe71) ...
# /home/ant/Arduino/hardware/keyboardio/avr/libraries/Kaleidoscope/bin//kaleidoscope-builder: line 134: /usr/local/arduino/arduino-builder: No such file or directory
# make: *** [/home/ant/Arduino/hardware/keyboardio/avr/build-tools/makefiles//rules.mk:75: build-all] Error 127
Right, that won’t work because the build script assumes I did the sensible thing and followed the instructions. I can fix most of that by telling it where the binaries really live:
cat > ~/Arduino/rc
export ARDUINO_PATH="/usr/share/arduino"
export AVR_SIZE="/usr/bin/avr-size"
export AVR_NM="/usr/bin/avr-nm"
export AVR_OBJDUMP="/usr/bin/avr-objdump"
export AVRDUDE="/usr/bin/avrdude"
export AVRDUDE_CONF="/etc/avrdude.conf"
export ARDUINO_TOOLS_PATH="/usr/bin/"
^D
source ~/Arduino/rc
That gets me a different error, at least:
make
#...
# Building output/AppSwitcher/AppSwitcher (0.0.1-gfe71) ...
# open /usr/share/arduino/tools-builder: no such file or directory
# make: *** [/home/ant/Arduino/hardware/keyboardio/avr/build-tools/makefiles//rules.mk:75: build-all] Error 1
That’s coming from the -tools "${ARDUINO_PATH}/tools-builder"
in bin/kaleidoscope-builder
. But I don’t have/need that folder (all my tools are in $PATH
already).
What happens if I just delete the line entirely (from the repo I’m in and the other copy under ~/Arduino
)? This:
# Building output/AppSwitcher/AppSwitcher (0.0.1-gfe71-dirty) ...
# fork/exec /bin/avr-g++: no such file or directory
Time to figure out where that’s coming from…
ack 'avr-g\+\+' ~/kaleidoscope/
# Arduino-Boards/platform.txt
# 27:compiler.cpp.cmd=avr-g++
ack -o '.*compiler.cpp.cmd' ~/kaleidoscope/
# Arduino-Boards/platform.txt
# 27:compiler.cpp.cmd
# 57:recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd
# 86:recipe.preproc.includes="{compiler.path}{compiler.cpp.cmd
# 89:recipe.preproc.macros="{compiler.path}{compiler.cpp.cmd
ack 'compiler.path=' ~/kaleidoscope/
# Arduino-Boards/platform.txt
# 21:compiler.path={runtime.tools.avr-gcc.path}/bin/
That leads me back to ./etc/kaleidoscope-builder.conf
. I needed to set another thing:
echo 'export AVR_GCC_PREFIX="/usr"' >> ~/Arduino/rc && source ~/Arduino/rc
(and then a slight half hour detour because Gentoo doesn’t install avr-g++ by default, oops)
make
# Building output/AppSwitcher/AppSwitcher (0.0.1-gfe71-dirty) ...
# In file included from /home/ant/Arduino/hardware/keyboardio/avr/libraries/Kaleidoscope-Macros/src/Kaleidoscope-Macros.h:6:
# ,
# from /tmp/tmp.waMDUiSTff/sketch/Macros.h:22,
# from /tmp/tmp.waMDUiSTff/sketch/Macros.cpp:24:
# /tmp/tmp.waMDUiSTff/sketch/Macros.cpp: In function ‘const macro_t* macroAppSwitch(uint8_t)’:
# /home/ant/Arduino/hardware/keyboardio/avr/libraries/Kaleidoscope-Macros/src/MacroSteps.h:21:43: error: variable ‘__m’ with
# dynamic initialization put into program memory area
# #define MACRO(...) ({static const macro_t __m[] PROGMEM = { __VA_ARGS__, MACRO_ACTION_END }; &__m[0]; })
# ^
# /tmp/tmp.waMDUiSTff/sketch/Macros.cpp:38:12: note: in expansion of macro ‘MACRO’
# return MACRO(Dr(mod), D(Tab));
# ^~~~~
# (...bunch more lines like this...)
# exit status 1
# make: *** [/home/ant/Arduino/hardware/keyboardio/avr/build-tools/makefiles//rules.mk:72: build-all] Error 1
A scary-sounding GCC error! At least we’re getting somewhere interesting now, I think I’ve solved most of the self-inflicted environment problems, and this looks like actual bug report territory… so I’ll come back when I make more progress.