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 <algernon@keyboard.io>
pull/264/head
Gergely Nagy 7 years ago
parent eb9164ddaa
commit 7a423ced8b

@ -10,10 +10,6 @@ LIBRARY="${LIBRARY:-${SKETCH}}"
######## Keyboard hardware definitions ######## 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}" BOARD="${BOARD:-model01}"
MCU="${MCU:-atmega32u4}" MCU="${MCU:-atmega32u4}"
if [ "${BOARD}" = "virtual" ]; then if [ "${BOARD}" = "virtual" ]; then
@ -32,8 +28,21 @@ fi
# Shamelessly stolen from git's Makefile # Shamelessly stolen from git's Makefile
uname_S=$(uname -s 2>/dev/null || echo not) 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_port() {
find_device_vid_pid
DIR=$(dirname "$(readlink -f "$0")") DIR=$(dirname "$(readlink -f "$0")")
DEVICE_PORT_PROBER="${DIR}/find-device-port-linux-udev" DEVICE_PORT_PROBER="${DIR}/find-device-port-linux-udev"
DEVICE_PORT="$(perl ${DEVICE_PORT_PROBER} ${VID} ${SKETCH_PID})" DEVICE_PORT="$(perl ${DEVICE_PORT_PROBER} ${VID} ${SKETCH_PID})"
@ -49,6 +58,7 @@ reset_device_cmd() {
MD5="md5sum" MD5="md5sum"
find_bootloader_ports() { find_bootloader_ports() {
find_device_vid_pid
DIR=$(dirname "$(readlink -f "$0")") DIR=$(dirname "$(readlink -f "$0")")
DEVICE_PORT_PROBER="${DIR}/find-device-port-linux-udev" DEVICE_PORT_PROBER="${DIR}/find-device-port-linux-udev"
DEVICE_PORT_BOOTLOADER="$(perl ${DEVICE_PORT_PROBER} ${VID} ${BOOTLOADER_PID})" DEVICE_PORT_BOOTLOADER="$(perl ${DEVICE_PORT_PROBER} ${VID} ${BOOTLOADER_PID})"

Loading…
Cancel
Save