From 65802e041d91cef34d884c1f9b0fe19e2ac70e34 Mon Sep 17 00:00:00 2001 From: Krzysztof Foltman Date: Sat, 20 Jun 2015 20:09:30 +0100 Subject: [PATCH 1/3] stm32: do not do mass erase on *every* flash operation :) --- stm32.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/stm32.rb b/stm32.rb index 9652f43..a1ff652 100644 --- a/stm32.rb +++ b/stm32.rb @@ -136,10 +136,6 @@ def lock_flash def flash_op(&block) self.unlock_flash - @flash.CR.MER = true - if @bank2 - @flash.CR.MER1 = true - end yield Log(:stm32, 4){ "waiting for flash transaction to be completed" } self.wait_for_flash From 604440e271e9e9cbbcf9c8243d8043d43d656ef1 Mon Sep 17 00:00:00 2001 From: Krzysztof Foltman Date: Sat, 20 Jun 2015 20:30:24 +0100 Subject: [PATCH 2/3] stm32: fix bit range order --- stm32.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stm32.rb b/stm32.rb index a1ff652..610d0f3 100644 --- a/stm32.rb +++ b/stm32.rb @@ -94,7 +94,7 @@ class FlashController bool :PG, [0x00, 0], :desc => "Programming" bool :SER, [0x00, 1], :desc => "Sector Erase" bool :MER, [0x00, 2], :desc => "Mass Erase, bank 1" - unsigned :SNB, [0x00, 3..6], :desc => "Sector Number (within bank)" + unsigned :SNB, [0x00, 6..3], :desc => "Sector Number (within bank)" unsigned :SNBANK, [0x00, 7], :desc => "Sector Number Bank (F42x/F43x only)" enum :PSIZE, [0x01, 1..0], { 8 => 0b00, # 1.8-2.1V From f73726e0c1ca6cc5e8ff2eeec269b8ba9b799ed7 Mon Sep 17 00:00:00 2001 From: Krzysztof Foltman Date: Sat, 20 Jun 2015 21:06:46 +0100 Subject: [PATCH 3/3] stm32: use block writes to speed up programming --- stm32.rb | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/stm32.rb b/stm32.rb index 610d0f3..0d81f54 100644 --- a/stm32.rb +++ b/stm32.rb @@ -167,6 +167,10 @@ def mass_erase end @flash.CR.STRT = true end + @flash.CR.MER = false + if @bank2 + @flash.CR.MER = false + end end def sector_erase(sector_no, sector_bank) @@ -179,6 +183,7 @@ def sector_erase(sector_no, sector_bank) end @flash.CR.STRT = true end + @flash.CR.SER = false end def range_erase(addr, size) @@ -205,10 +210,13 @@ def program_section(addr, data) self.flash_op do @flash.CR.PG = true pos = 0 - data.each do |w| - @dap.write(addr + pos, w) - pos += 4 + maxlen = 64 + unit = 4 + while pos < data.length + @dap.write(addr + pos * unit, data[pos..pos + maxlen - 1]) + pos += maxlen end + @flash.CR.PG = false end end end