summaryrefslogtreecommitdiff
path: root/util/stm32mon.c
diff options
context:
space:
mode:
authorCraig Hesling <hesling@chromium.org>2021-07-27 03:36:32 -0400
committerCommit Bot <commit-bot@chromium.org>2021-07-28 04:22:34 +0000
commit33bf14ac28e3c9470ef0ece01e8b305fb558d7bc (patch)
tree4cbad1ce990029928ee701ab8cdc514d79538003 /util/stm32mon.c
parentf5ef1ee7fa649a6bc87bf2d0157740a60014294d (diff)
downloadchrome-ec-33bf14ac28e3c9470ef0ece01e8b305fb558d7bc.tar.gz
util/stm32mon: Move read unprotect before reading values
The 3 read_* functions attempt to read from areas that are protected by RDP on the STM32F412. This results in many read failures before we get to the unprotect function. These are not needed before attempting the unprotect, so move them to after the unprotect sequence. The unwanted sequence looks like the following, every time: Waiting for the monitor startup ...Done. ChipID 0x441 : STM32F412 | 0%NACK Failed to get command READMEM ACK NACK Failed to get command READMEM ACK NACK Failed to get command READMEM ACK NACK Failed to get command READMEM ACK Cannot read 21 bytes from address 0x1FFF7A0FUnable to read flash size register (0x1FFF7A22). / 0%NACK Failed to get command READMEM ACK NACK Failed to get command READMEM ACK NACK Failed to get command READMEM ACK NACK Failed to get command READMEM ACK Cannot read 13 bytes from address 0x1FFF7A0FUnable to read unique device ID register (0x1FFF7A10). Ignoring non-critical failure. Bootloader v3.1, commands : GETCMD GETVER GETID READMEM GO WRITEMEM EXTERASE WP WU RP RU Unprotecting flash read... Now, the output looks like: Waiting for the monitor startup ...Done. ChipID 0x441 : STM32F412 Bootloader v3.1, commands : GETCMD GETVER GETID READMEM GO WRITEMEM EXTERASE WP WU RP RU Unprotecting flash read... Timeout Timeout Timeout Flash read unprotected. Waiting for the monitor startup ...Done. | 0%Flash size: 1024 KB / 0%Unique Device ID: 0x383939313138511900038016 Flash write unprotected. Waiting for the monitor startup ...Done. Erasing... Timeout Timeout Timeout Flash erased. Writing 1047992 bytes at 0x08000000 1047992 bytes written. Done. BRANCH=none BUG=b:143374692 TEST=make proj-bloonchipper -j ./test/run_device_tests.py --flasher=servo_micro --tests\ flash_write_protect # This sets RDP ./util/flash_ec --board=bloonchipper TEST=# Tried flash_fp_mcu on dratini(F412/SPI) and bard(H732/SPI). Signed-off-by: Craig Hesling <hesling@chromium.org> Change-Id: I9b9ba2ecd3797cb1a98d7bcd7b226cdbc7872217 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3054465 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'util/stm32mon.c')
-rw-r--r--util/stm32mon.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/util/stm32mon.c b/util/stm32mon.c
index a437949168..f293399714 100644
--- a/util/stm32mon.c
+++ b/util/stm32mon.c
@@ -1672,6 +1672,12 @@ int main(int argc, char **argv)
if (!chip)
goto terminate;
+ if (command_get_commands(ser, chip) < 0)
+ goto terminate;
+
+ if (flags & FLAG_READ_UNPROTECT)
+ command_read_unprotect(ser);
+
/*
* Use the actual size if we were able to read it since some chips
* have the same chip ID, but different flash sizes based on the
@@ -1693,11 +1699,6 @@ int main(int argc, char **argv)
*/
(void)read_package_data_register(ser, chip, &package_data_reg);
- if (command_get_commands(ser, chip) < 0)
- goto terminate;
-
- if (flags & FLAG_READ_UNPROTECT)
- command_read_unprotect(ser);
if (flags & FLAG_UNPROTECT)
command_write_unprotect(ser);