diff --git a/Rakefile b/Rakefile index 037b670..688d6e7 100644 --- a/Rakefile +++ b/Rakefile @@ -198,6 +198,16 @@ task :flash => APPLICATION+".bin" do |t| sh "dfu-util --device 1209:4356 --download #{t.source}" end +desc "remove STM32F1 protection using SWD" +task :remove_protection do + case SWD_ADAPTER + when "STLINKV2" + sh "#{OOCD} --file interface/#{OOCD_INTERFACE}.cfg --file target/#{OOCD_TARGET}.cfg --command 'init' --command 'reset init' --command 'stm32f1x unlock 0' --command 'reset init' --command 'flash protect 0 0 last off' --command 'reset init' --command 'stm32f1x options_write 0 SWWDG NORSTSTNDBY NORSTSTOP' --command 'reset init' --command 'stm32f1x mass_erase 0' --command 'shutdown'" + when "BMP" + sh "#{GDB} --eval-command='target extended-remote #{BMP_PORT}' --eval-command='set confirm off' --eval-command='monitor swdp_scan' --eval-command='attach 1' --eval-command='monitor option erase' --eval-command='monitor erase_mass' --eval-command='kill' --eval-command='quit'" + end +end + desc "flash bootloader using SWD" task :flash_bootloader => BOOTLOADER+".hex" do |t| case SWD_ADAPTER