From 7a4f0bac85cda8a9b5ad85e06d5ca17c5c3c5949 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Fri, 18 May 2018 23:31:29 +0200 Subject: [PATCH] kaleidoscope-builder: Do not hardcode the max program size Instead of hardcoding the max program size, pick it out of boards.txt, like we pick the device VID and PID. Signed-off-by: Gergely Nagy --- bin/kaleidoscope-builder | 3 +-- etc/kaleidoscope-builder.conf | 11 +++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) 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" \