Use openocd auto-erase when writing flash, and use sysresetreq to reset

According to its datasheet, LM4 doesn't support vectreset, but does
support sysresetreq.  Using sysresetreq properly resets all
peripherals and cleanly resets the LM4.

Auto-erase makes the flash command faster.

BUG=none
TEST=flash_link_ro, flash_link_a, flash_link, all with different images

Change-Id: I80b72de2ee0f42cee1b0f2f2a53062384d2c29aa
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/27416
This commit is contained in:
Randall Spangler
2012-07-13 14:08:35 -07:00
parent c1701c4f07
commit 1dc7241e3a
2 changed files with 7 additions and 8 deletions

View File

@@ -27,6 +27,9 @@ target create $_TARGETNAME cortex_m3 -chain-position $_CHIPNAME.cpu -variant lm3
# 12k working area at base of ram, not backed up
$_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size 0x3000
# Use system reset request, since LM4 doesn't support vectreset
cortex_m3 reset_config sysresetreq
# Ensure that the watchdog is properly disabled when doing flashing
$_TARGETNAME configure -event reset-init {
# Unlock watchdog0

View File

@@ -7,14 +7,10 @@
# Program internal flash
proc flash_lm4 {path offset size} {
set firstsect [expr {$offset / 1024}];
set lastsect [expr {($offset + $size) / 1024 - 1}];
reset init;
flash erase_sector internal $firstsect $lastsect;
# Note erase_sector silently fails sometimes; see crosbug.com/p/8632
# Dump a few words as a diagnostic for whether erase succeeded
mdw 0 16
flash write_image $path $offset;
#set firstsect [expr {$offset / 1024}];
#set lastsect [expr {($offset + $size) / 1024 - 1}];
reset halt;
flash write_image erase $path $offset;
reset
}