rp2040: add make flash support

This adds `make flash` support for the rp2040 target. Flashing is
performed using a custom `rp2040_flash` tool that uses the PICOBOOT
protocol. Root is not required.

The user specifies the serial device of the rp2040 they wish to flash as
the device. This device is reset into bootsel mode and `rp2040_flash`
is invoked on the original USB device path.

If the device is already in bootloader mode, the user can specify
'first' as `FLASH_DEVICE` which will simply invoke `rp2040_flash` with
no bus/address options.

Signed-off-by: Lasse Dalegaard <dalegaard@gmail.com>
This commit is contained in:
Lasse Dalegaard
2022-01-03 23:28:54 +01:00
committed by KevinOConnor
parent 8a3727ef74
commit 7c0559c6e6
10 changed files with 1124 additions and 7 deletions

View File

@@ -43,10 +43,11 @@ $(OUT)klipper.uf2: $(OUT)klipper.elf $(OUT)lib/rp2040/elf2uf2/elf2uf2
@echo " Creating uf2 file $@"
$(Q)$(OUT)lib/rp2040/elf2uf2/elf2uf2 $< $@
lib/rp2040_flash/rp2040_flash:
@echo " Building rp2040_flash"
$(Q)make -C lib/rp2040_flash rp2040_flash
# Flash rules
flash: $(OUT)klipper.uf2
@echo "Error: Flashing not supported on rp2040."
@echo "Place target board in bootloader mode (hold bootsel button"
@echo "during powerup), mount the device as a usb drive, and copy"
@echo "$< to the device."
@exit -1
flash: $(OUT)klipper.uf2 lib/rp2040_flash/rp2040_flash
@echo " Flashing $< to $(FLASH_DEVICE)"
$(Q)$(PYTHON) ./scripts/flash_usb.py -t $(CONFIG_MCU) -d "$(FLASH_DEVICE)" $(OUT)klipper.uf2