diff --git a/bin/kaleidoscope-builder b/bin/kaleidoscope-builder index a67bab55..58e1b4b7 100755 --- a/bin/kaleidoscope-builder +++ b/bin/kaleidoscope-builder @@ -30,8 +30,7 @@ firmware_size () { ## This is a terrible hack, please don't hurt me. - algernon - MAX_PROG_SIZE=28672 - + find_max_prog_size output="$("$@" | grep "\\(Program\\|Data\\):" | sed -e 's,^, - ,' && echo)" PROGSIZE="$(echo "${output}" | grep "Program:" | cut -d: -f2 | awk '{print $1}')" diff --git a/etc/kaleidoscope-builder.conf b/etc/kaleidoscope-builder.conf index b3379734..4d5a8c23 100644 --- a/etc/kaleidoscope-builder.conf +++ b/etc/kaleidoscope-builder.conf @@ -26,6 +26,17 @@ fi # Shamelessly stolen from git's Makefile uname_S=$(uname -s 2>/dev/null || echo not) +find_max_prog_size() { + VPIDS=$(${ARDUINO_BUILDER} \ + -hardware "${ARDUINO_PATH}/hardware" \ + -hardware "${BOARD_HARDWARE_PATH}" \ + ${ARDUINO_TOOLS_PARAM} \ + -tools "${ARDUINO_PATH}/tools-builder" \ + -fqbn "${FQBN}" \ + -dump-prefs | grep "upload\.maximum_size=") + MAX_PROG_SIZE=${MAX_PROG_SIZE:-$(echo "${VPIDS}" | grep upload.maximum_size | cut -d= -f2)} +} + find_device_vid_pid() { VPIDS=$(${ARDUINO_BUILDER} \ -hardware "${ARDUINO_PATH}/hardware" \