From ced714129ce7f924d3e2316704b3ce7decb7dfe0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?King=20K=C3=A9vin?= Date: Fri, 27 Nov 2020 16:39:11 +0100 Subject: [PATCH] Rakefile: add method to flash bootloader over DFU --- Rakefile | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Rakefile b/Rakefile index 8b6b436..464e861 100644 --- a/Rakefile +++ b/Rakefile @@ -204,11 +204,19 @@ OOCD_TARGET = "stm32f4x" # Black Magic Probe port BMP_PORT = ENV["BMP_PORT"] || "/dev/ttyACM0" +desc "flash application" +task :flash => :dfu_application + desc "flash application using USB DFU" -task :flash => APPLICATION+".bin" do |t| +task :dfu_application => APPLICATION+".bin" do |t| sh "dfu-util --device 1209:4356 --download #{t.source}" end +desc "flash application using USB DFU" +task :dfu_bootloader => BOOTLOADER+".bin" do |t| + sh "dfu-util --device 0483:df11 --cfg 1 --intf 0 --alt 0 --dfuse-address 0x08000000 --download #{t.source} --reset" +end + desc "remove STM32F4 protection using SWD" task :remove_protection do case SWD_ADAPTER @@ -220,7 +228,7 @@ task :remove_protection do end desc "flash bootloader using SWD" -task :flash_bootloader => BOOTLOADER+".hex" do |t| +task :swd_bootloader => BOOTLOADER+".hex" do |t| case SWD_ADAPTER when "STLINKV2" sh "#{OOCD} --file interface/#{OOCD_INTERFACE}.cfg --command 'transport select hla_swd' --file target/#{OOCD_TARGET}.cfg --command 'init' --command 'halt' --command 'reset init' --command 'flash erase_sector 0 0 last' --command 'flash write_image erase #{t.source}' --command 'reset' --command 'shutdown'" @@ -229,8 +237,10 @@ task :flash_bootloader => BOOTLOADER+".hex" do |t| end end +task :swd => :swd_application + desc "flash application using SWD" -task :flash_application => APPLICATION+".hex" do |t| +task :swd_application => APPLICATION+".hex" do |t| case SWD_ADAPTER when "STLINKV2" sh "#{OOCD} --file interface/#{OOCD_INTERFACE}.cfg --command 'transport select hla_swd' --file target/#{OOCD_TARGET}.cfg --command 'adapter speed 100' --command 'init' --command 'halt' --command 'reset init' --command 'flash write_image erase #{t.source}' --command 'reset' --command 'shutdown'"