flash_usb: Pass -t $CONFIG_MCU to flash_usb on all targets

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2019-10-26 18:48:00 -04:00
parent 538d6ac3a2
commit 1a69f38e6e
5 changed files with 17 additions and 17 deletions

View File

@ -211,9 +211,9 @@ def flash_stm32f4(options, binfile):
sys.exit(-1)
MCUTYPES = {
'atsam3': flash_atsam3, 'atsam4': flash_atsam4, 'atsamd': flash_atsamd,
'lpc176x': flash_lpc176x, 'stm32f1': flash_stm32f1,
'stm32f4': flash_stm32f4, 'stm32f0': flash_stm32f4,
'sam3': flash_atsam3, 'sam4': flash_atsam4, 'samd': flash_atsamd,
'lpc176': flash_lpc176x, 'stm32f103': flash_stm32f1,
'stm32f4': flash_stm32f4, 'stm32f042': flash_stm32f4,
}
@ -235,12 +235,19 @@ def main():
options, args = opts.parse_args()
if len(args) != 1:
opts.error("Incorrect number of arguments")
if options.mcutype not in MCUTYPES:
opts.error("Not a valid mcu type")
flash_func = None
if options.mcutype:
for prefix, func in MCUTYPES.items():
if options.mcutype.startswith(prefix):
flash_func = func
break
if flash_func is None:
opts.error("USB flashing is not supported for MCU '%s'"
% (options.mcutype,))
if not options.device:
sys.stderr.write("\nPlease specify FLASH_DEVICE\n\n")
sys.exit(-1)
MCUTYPES[options.mcutype](options, args[0])
flash_func(options, args[0])
if __name__ == '__main__':
main()

View File

@ -49,9 +49,6 @@ lib/bossac/bin/bossac:
@echo " Building bossac"
$(Q)make -C lib/bossac bin/bossac
FLASH_TYPE-$(CONFIG_MACH_SAM3X) := atsam3
FLASH_TYPE-$(CONFIG_MACH_SAM4) := atsam4
flash: $(OUT)klipper.bin lib/bossac/bin/bossac
@echo " Flashing $< to $(FLASH_DEVICE)"
$(Q)$(PYTHON) ./scripts/flash_usb.py -t $(FLASH_TYPE-y) -d "$(FLASH_DEVICE)" $(OUT)klipper.bin
$(Q)$(PYTHON) ./scripts/flash_usb.py -t $(CONFIG_MCU) -d "$(FLASH_DEVICE)" $(OUT)klipper.bin

View File

@ -54,4 +54,4 @@ BOSSAC_OFFSET-$(CONFIG_MACH_SAMD51) := 0x4000
flash: $(OUT)klipper.bin lib/bossac/bin/bossac
@echo " Flashing $< to $(FLASH_DEVICE)"
$(Q)$(PYTHON) ./scripts/flash_usb.py -t atsamd -d "$(FLASH_DEVICE)" -s "$(BOSSAC_OFFSET-y)" $(OUT)klipper.bin
$(Q)$(PYTHON) ./scripts/flash_usb.py -t $(CONFIG_MCU) -d "$(FLASH_DEVICE)" -s "$(BOSSAC_OFFSET-y)" $(OUT)klipper.bin

View File

@ -32,4 +32,4 @@ $(OUT)klipper.bin: $(OUT)klipper.elf
# Flash rules
flash: $(OUT)klipper.bin
@echo " Flashing $< to $(FLASH_DEVICE)"
$(Q)$(PYTHON) ./scripts/flash_usb.py -t lpc176x -d "$(FLASH_DEVICE)" $(if $(NOSUDO),--no-sudo) $(OUT)klipper.bin
$(Q)$(PYTHON) ./scripts/flash_usb.py -t $(CONFIG_MCU) -d "$(FLASH_DEVICE)" $(if $(NOSUDO),--no-sudo) $(OUT)klipper.bin

View File

@ -49,13 +49,9 @@ $(OUT)klipper.bin: $(OUT)klipper.elf
$(Q)$(OBJCOPY) -O binary $< $@
# Flash rules
FLASH_TYPE-$(CONFIG_MACH_STM32F0) := stm32f0
FLASH_TYPE-$(CONFIG_MACH_STM32F1) := stm32f1
FLASH_TYPE-$(CONFIG_MACH_STM32F4) := stm32f4
flash: $(OUT)klipper.bin
@echo " Flashing $< to $(FLASH_DEVICE)"
$(Q)$(PYTHON) ./scripts/flash_usb.py -t $(FLASH_TYPE-y) -d "$(FLASH_DEVICE)" -s "$(CONFIG_FLASH_START)" $(if $(NOSUDO),--no-sudo) $(OUT)klipper.bin
$(Q)$(PYTHON) ./scripts/flash_usb.py -t $(CONFIG_MCU) -d "$(FLASH_DEVICE)" -s "$(CONFIG_FLASH_START)" $(if $(NOSUDO),--no-sudo) $(OUT)klipper.bin
serialflash: $(OUT)klipper.bin
@echo " Flashing $< to $(FLASH_DEVICE) via stm32flash"