From 7a423ced8bd57715a96600c118593dfb6e8d781e Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Thu, 7 Dec 2017 17:22:50 +0100 Subject: [PATCH] kaleidoscope-builder: Pull VID, SKETCH_PID and BOOTLOADER_PID from boards.txt Instead of hardcoding defaults for `VID`, `SKETCH_PID`, and `BOOTLOADER_PID`, use `arduino-builder -dump-prefs` to pull these out of `boards.txt`. Signed-off-by: Gergely Nagy --- etc/kaleidoscope-builder.conf | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/etc/kaleidoscope-builder.conf b/etc/kaleidoscope-builder.conf index 015c187a..6f2e2025 100644 --- a/etc/kaleidoscope-builder.conf +++ b/etc/kaleidoscope-builder.conf @@ -10,10 +10,6 @@ LIBRARY="${LIBRARY:-${SKETCH}}" ######## Keyboard hardware definitions ######## -# These should be pulled from Arduino boards.txt -VID="${VID:-1209}" -BOOTLOADER_PID="${BOOTLOADER_PID:-2300}" -SKETCH_PID="${SKEYCH_PID:-2301}" BOARD="${BOARD:-model01}" MCU="${MCU:-atmega32u4}" if [ "${BOARD}" = "virtual" ]; then @@ -32,8 +28,21 @@ fi # Shamelessly stolen from git's Makefile uname_S=$(uname -s 2>/dev/null || echo not) +find_device_vid_pid() { + VPIDS=$(${ARDUINO_BUILDER} \ + -hardware "${ARDUINO_PATH}/hardware" \ + -hardware "${BOARD_HARDWARE_PATH}" \ + ${ARDUINO_TOOLS_PARAM} \ + -tools "${ARDUINO_PATH}/tools-builder" \ + -fqbn "${FQBN}" \ + -dump-prefs | grep "\.[vp]id=") + VID=${VID:-$(echo "${VPIDS}" | grep build.vid= | cut -dx -f2)} + SKETCH_PID=${SKETCH_PID:-$(echo "${VPIDS}" | grep build.pid= | cut -dx -f2)} + BOOTLOADER_PID=${BOOTLOADER_PID:-$(echo "${VPIDS}" | grep bootloader.pid= | cut -dx -f2)} +} find_device_port() { + find_device_vid_pid DIR=$(dirname "$(readlink -f "$0")") DEVICE_PORT_PROBER="${DIR}/find-device-port-linux-udev" DEVICE_PORT="$(perl ${DEVICE_PORT_PROBER} ${VID} ${SKETCH_PID})" @@ -49,6 +58,7 @@ reset_device_cmd() { MD5="md5sum" find_bootloader_ports() { + find_device_vid_pid DIR=$(dirname "$(readlink -f "$0")") DEVICE_PORT_PROBER="${DIR}/find-device-port-linux-udev" DEVICE_PORT_BOOTLOADER="$(perl ${DEVICE_PORT_PROBER} ${VID} ${BOOTLOADER_PID})"