[riot-notifications] [RIOT-OS/RIOT] boards/frdm: fix flashing from invalid state (#12261)

Francisco notifications at github.com
Fri Sep 20 09:15:09 CEST 2019


Tested on `frdm-k64f` using #11789, the following output are after I flashed an application that has `pm_set(0)` right at the start.

<details><summary>OPENOCD_RESET_USE_CONNECT_ASSERT_SRST=0 make -C tests/periph_pm BOARD=frdm-k64f flash -j3
</summary>

```
make: Entering directory '/home/francisco/workspace/RIOT/tests/periph_pm'
Building application "tests_periph_pm" for "frdm-k64f" with MCU "kinetis".

"make" -C /home/francisco/workspace/RIOT/boards/frdm-k64f
"make" -C /home/francisco/workspace/RIOT/core
"make" -C /home/francisco/workspace/RIOT/cpu/kinetis
"make" -C /home/francisco/workspace/RIOT/drivers
"make" -C /home/francisco/workspace/RIOT/cpu/cortexm_common
"make" -C /home/francisco/workspace/RIOT/drivers/periph_common
"make" -C /home/francisco/workspace/RIOT/cpu/cortexm_common/periph
"make" -C /home/francisco/workspace/RIOT/cpu/kinetis/periph
"make" -C /home/francisco/workspace/RIOT/sys
"make" -C /home/francisco/workspace/RIOT/sys/auto_init
"make" -C /home/francisco/workspace/RIOT/sys/isrpipe
"make" -C /home/francisco/workspace/RIOT/sys/newlib_syscalls_default
"make" -C /home/francisco/workspace/RIOT/sys/pm_layered
"make" -C /home/francisco/workspace/RIOT/sys/shell
"make" -C /home/francisco/workspace/RIOT/sys/stdio_uart
"make" -C /home/francisco/workspace/RIOT/sys/tsrb
   text	   data	    bss	    dec	    hex	filename
  20732	    240	   2820	  23792	   5cf0	/home/francisco/workspace/RIOT/tests/periph_pm/bin/frdm-k64f/tests_periph_pm.elf
/home/francisco/workspace/RIOT/dist/tools/openocd/openocd.sh flash /home/francisco/workspace/RIOT/tests/periph_pm/bin/frdm-k64f/tests_periph_pm.elf
### Flashing Target ###
/home/francisco/workspace/RIOT/tests/periph_pm/bin/frdm-k64f/tests_periph_pm.elf is not locked.
Open On-Chip Debugger 0.10.0+dev-00703-g92bb76a4-dirty (2019-07-19-14:27)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "swd". To override use 'transport select <transport>'.
Info : add flash_bank kinetis kx.pflash
adapter speed: 1000 kHz
none separate
cortex_m reset_config sysresetreq
srst_only separate srst_nogate srst_open_drain connect_deassert_srst
Info : CMSIS-DAP: SWD  Supported
Info : CMSIS-DAP: FW Version = 1.10
Info : CMSIS-DAP: Interface Initialised (SWD)
Info : SWCLK/TCK = 0 SWDIO/TMS = 1 TDI = 0 TDO = 0 nTRST = 0 nRESET = 1
Info : CMSIS-DAP: Interface ready
Info : clock speed 1000 kHz


/home/francisco/workspace/RIOT/tests/periph_pm/../../Makefile.include:600: recipe for target 'flash' failed
make: *** [flash] Error 1
make: Leaving directory '/home/francisco/workspace/RIOT/tests/periph_pm'


```
</details>

<details><summary>OPENOCD_RESET_USE_CONNECT_ASSERT_SRST=1 make -C tests/periph_pm BOARD=frdm-k64f flash -j3
</summary>

```

make: Entering directory '/home/francisco/workspace/RIOT/tests/periph_pm'
Building application "tests_periph_pm" for "frdm-k64f" with MCU "kinetis".

"make" -C /home/francisco/workspace/RIOT/boards/frdm-k64f
"make" -C /home/francisco/workspace/RIOT/core
"make" -C /home/francisco/workspace/RIOT/cpu/kinetis
"make" -C /home/francisco/workspace/RIOT/drivers
"make" -C /home/francisco/workspace/RIOT/cpu/cortexm_common
"make" -C /home/francisco/workspace/RIOT/drivers/periph_common
"make" -C /home/francisco/workspace/RIOT/cpu/cortexm_common/periph
"make" -C /home/francisco/workspace/RIOT/cpu/kinetis/periph
"make" -C /home/francisco/workspace/RIOT/sys
"make" -C /home/francisco/workspace/RIOT/sys/auto_init
"make" -C /home/francisco/workspace/RIOT/sys/isrpipe
"make" -C /home/francisco/workspace/RIOT/sys/newlib_syscalls_default
"make" -C /home/francisco/workspace/RIOT/sys/pm_layered
"make" -C /home/francisco/workspace/RIOT/sys/shell
"make" -C /home/francisco/workspace/RIOT/sys/stdio_uart
"make" -C /home/francisco/workspace/RIOT/sys/tsrb
   text	   data	    bss	    dec	    hex	filename
  20732	    240	   2820	  23792	   5cf0	/home/francisco/workspace/RIOT/tests/periph_pm/bin/frdm-k64f/tests_periph_pm.elf
/home/francisco/workspace/RIOT/dist/tools/openocd/openocd.sh flash /home/francisco/workspace/RIOT/tests/periph_pm/bin/frdm-k64f/tests_periph_pm.elf
### Flashing Target ###
/home/francisco/workspace/RIOT/tests/periph_pm/bin/frdm-k64f/tests_periph_pm.elf is not locked.
Open On-Chip Debugger 0.10.0+dev-00703-g92bb76a4-dirty (2019-07-19-14:27)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "swd". To override use 'transport select <transport>'.
Info : add flash_bank kinetis kx.pflash
adapter speed: 1000 kHz
none separate
cortex_m reset_config sysresetreq
srst_only separate srst_nogate srst_open_drain connect_deassert_srst
srst_only separate srst_nogate srst_open_drain connect_assert_srst
Info : CMSIS-DAP: SWD  Supported
Info : CMSIS-DAP: FW Version = 1.10
Info : CMSIS-DAP: Interface Initialised (SWD)
Info : SWCLK/TCK = 0 SWDIO/TMS = 1 TDI = 0 TDO = 0 nTRST = 0 nRESET = 1
Info : Connecting under reset
Info : CMSIS-DAP: Interface ready
Info : clock speed 1000 kHz
Info : SWD DPIDR 0x2ba01477
Info : MDM: Chip is unsecured. Continuing.
Info : kx.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : kx.cpu: external reset detected
Info : Listening on port 46373 for gdb connections
    TargetName         Type       Endian TapName            State       
--  ------------------ ---------- ------ ------------------ ------------
 0* kx.cpu             cortex_m   little kx.cpu             reset
Info : MDM: Chip is unsecured. Continuing.
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x0000073c msp: 0x1fff0200
auto erase enabled
Info : Kinetis MK64FN1M0xxx12 detected: 2 flash blocks
Info : 2 PFlash banks: 1024k total
wrote 24576 bytes from file /home/francisco/workspace/RIOT/tests/periph_pm/bin/frdm-k64f/tests_periph_pm.elf in 1.209991s (19.835 KiB/s)
Info : kx.cpu: external reset detected
Error: Failed to write memory and, additionally, failed to find out where
Warn : target was in unknown state when halt was requested
Error: error executing cortex_m crc algorithm
Error: Failed to read memory and, additionally, failed to find out where

/home/francisco/workspace/RIOT/tests/periph_pm/../../Makefile.include:600: recipe for target 'flash' failed
make: *** [flash] Error 1
make: Leaving directory '/home/francisco/workspace/RIOT/tests/periph_pm'

```
</details>

<details><summary><b>NOTE</b>: my diff</summary>


```
diff --git a/boards/common/frdm/dist/openocd-klx.cfg b/boards/common/frdm/dist/openocd-klx.cfg
index 5d7f29cb1..7970abc14 100644
--- a/boards/common/frdm/dist/openocd-klx.cfg
+++ b/boards/common/frdm/dist/openocd-klx.cfg
@@ -19,7 +19,7 @@ source [find target/klx.cfg]
 # The debug module is stopped in low leakage modes, we use connect_assert_srst
 # to hold the device in reset while connecting with OpenOCD to make sure that we
 # always get a connection even when the application uses low power modes.
-reset_config srst_only connect_assert_srst
+reset_config srst_only
 
 $_TARGETNAME configure -event gdb-attach {
   halt
diff --git a/boards/common/frdm/dist/openocd-kx.cfg b/boards/common/frdm/dist/openocd-kx.cfg
index 2e128dcb9..84bd6243e 100644
--- a/boards/common/frdm/dist/openocd-kx.cfg
+++ b/boards/common/frdm/dist/openocd-kx.cfg
@@ -16,7 +16,7 @@ source [find target/kx.cfg]
 # The debug module is stopped in low leakage modes, we use connect_assert_srst
 # to hold the device in reset while connecting with OpenOCD to make sure that we
 # always get a connection even when the application uses low power modes.
-reset_config srst_only connect_assert_srst
+reset_config srst_only
 
 $_TARGETNAME configure -event gdb-attach {
   halt
diff --git a/tests/periph_pm/main.c b/tests/periph_pm/main.c
index 4fe74b3bf..3f5705956 100644
--- a/tests/periph_pm/main.c
+++ b/tests/periph_pm/main.c
@@ -241,6 +241,8 @@ int main(void)
          "needed.");
 #endif
 
+    pm_set(0);
+
     /* run the shell and wait for the user to enter a mode */
     shell_run(shell_commands, line_buf, SHELL_DEFAULT_BUFSIZE);
```
</details>

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/12261#issuecomment-533438607
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190920/bac654e3/attachment.htm>


More information about the notifications mailing list