klipper-flash: derive -s/--start for stm32 boards (#555064)

This commit is contained in:
Cabia Rangris
2026-08-24 14:56:07 +00:00
committed by GitHub

View File

@@ -17,12 +17,17 @@ let
field:
with builtins;
let
matches = match ''^[^#\r\n]*${field}="([a-zA-Z0-9_]+)".*$'' (readFile firmwareConfig);
lines = lib.splitString "\n" (readFile firmwareConfig);
matchLine = line: match ''${field}="?([a-zA-Z0-9_]+)"?.*'' (lib.trim line);
matched = lib.findFirst (line: matchLine line != null) null lines;
in
if matches != null then head matches else null;
if matched != null then head (matchLine matched) else null;
matchPlatform = getConfigField "CONFIG_BOARD_DIRECTORY";
matchBoard = getConfigField "CONFIG_MCU";
matchAvrdudeProtocol = getConfigField "CONFIG_AVRDUDE_PROTOCOL";
matchFlashApplicationAddress = getConfigField "CONFIG_FLASH_APPLICATION_ADDRESS";
# Only stm32's require -s/--start (flash_stm32f4 in scripts/flash_usb.py)
flashStartAddress = if matchPlatform == "stm32" then matchFlashApplicationAddress else null;
flashUsbSupportedBoards = [
"sam3"
"sam4"
@@ -69,7 +74,9 @@ writeShellApplication {
&& matchPlatform != null
then
''
${klipper}/lib/scripts/flash_usb.py -t ${matchBoard} -d ${flashDevice} ${klipper-firmware}/klipper.bin "$@"
${klipper}/lib/scripts/flash_usb.py -t ${matchBoard} -d ${flashDevice}${
lib.optionalString (flashStartAddress != null) " -s ${flashStartAddress}"
} ${klipper-firmware}/klipper.bin "$@"
''
else if matchPlatform == "avr" && matchAvrdudeProtocol != null && matchBoard != null then
''