Firmware starts only after openocd init. How to factory reset nrf52840?
yejianfengblue opened this issue · 2 comments
I'm building the nrfmicro using an ebyte E73-2G4M08S1C nrf52840. My programmer is cmsis dap link. Openocd verson is 0.11.0.
I built two controllers successfully and they run firmware (blink and zmk) well. Another controller (the third one) which was built in the same way, but after I reconnect power, the nrfmicro controller starts firmware only after I connect cmsis dap link and run command
openocd -d2 -f interface/cmsis-dap.cfg -f target/nrf52.cfg -c init -c exit
I guess this is a software issue rather than soldering issue or hardware damage. I tried desoldering the e73 module and use a new PCB, and re-flash the bootloader but it does't help.
Is there a way to factory reset the nrf52840? So that I flash again from the beginning?
Below are what I did and how the controller behaves
- Unlock is fine
openocd -d2 -f interface/cmsis-dap.cfg -f target/nrf52.cfg -c "init" -c "nrf52.dap apreg 1 0x04 0x01" -c "exit"
############## unlock output omitted
openocd -d2 -f interface/cmsis-dap.cfg -f target/nrf52.cfg -c "init" -c "nrf52.dap apreg 1 0x04" -c "exit"
Open On-Chip Debugger 0.11.0
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
debug_level: 2
Info : auto-selecting first available session transport "swd". To override use 'transport select <transport>'.
Info : CMSIS-DAP: SWD Supported
Info : CMSIS-DAP: FW Version = 2.0.0
Info : CMSIS-DAP: Serial# = 205526554555
Info : CMSIS-DAP: Interface Initialised (SWD)
Info : SWCLK/TCK = 1 SWDIO/TMS = 1 TDI = 0 TDO = 0 nTRST = 0 nRESET = 1
Info : CMSIS-DAP: Interface ready
Info : clock speed 1000 kHz
Info : SWD DPIDR 0x2ba01477
Info : nrf52.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : starting gdb server for nrf52.cpu on 3333
Info : Listening on port 3333 for gdb connections
0x00000001
- Flash bootloader pca10056_bootloader-0.5.0-dirty_s140_6.1.1.hex successfully
openocd -d2 -c 'set WORKAREASIZE 0;' -f interface/cmsis-dap.cfg -f target/nrf52.cfg -c init -c "program ./pca10056_bootloader-0.5.0-dirty_s140_6.1.1.hex verify reset exit"
Open On-Chip Debugger 0.11.0
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
debug_level: 2
Info : auto-selecting first available session transport "swd". To override use 'transport select <transport>'.
Info : CMSIS-DAP: SWD Supported
Info : CMSIS-DAP: FW Version = 2.0.0
Info : CMSIS-DAP: Serial# = 205526554555
Info : CMSIS-DAP: Interface Initialised (SWD)
Info : SWCLK/TCK = 1 SWDIO/TMS = 1 TDI = 0 TDO = 0 nTRST = 0 nRESET = 1
Info : CMSIS-DAP: Interface ready
Info : clock speed 1000 kHz
Info : SWD DPIDR 0x2ba01477
Info : nrf52.cpu: hardware has 6 breakpoints, 4 watchpoints
Error: nrf52.cpu -- clearing lockup after double fault
Polling target nrf52.cpu failed, trying to reexamine
Info : nrf52.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : starting gdb server for nrf52.cpu on 3333
Info : Listening on port 3333 for gdb connections
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0xfffffffe msp: 0xfffffffc
** Programming Started **
Info : nRF52840-xxAA(build code: D0) 1024kB Flash, 256kB RAM
Info : Padding image section 0 at 0x00000b00 with 1280 bytes
Info : Flash write discontinued at 0x00025de8, next section at 0x000f4000
Warn : Adding extra erase range, 0x00025de8 .. 0x00025fff
Warn : not enough working area available(requested 34)
Warn : no working area available, falling back to slow memory writes
Info : Padding image section 2 at 0x000fc124 with 5852 bytes
Warn : Adding extra erase range, 0x000fd858 .. 0x000fdfff
Warn : not enough working area available(requested 34)
Warn : no working area available, falling back to slow memory writes
Warn : Adding extra erase range, 0x10001000 .. 0x10001013
Warn : Adding extra erase range, 0x1000101c .. 0x10001fff
Warn : not enough working area available(requested 34)
Warn : no working area available, falling back to slow memory writes
** Programming Finished **
** Verify Started **
Warn : not enough working area available(requested 52)
Warn : not enough working area available(requested 52)
Warn : not enough working area available(requested 52)
Warn : not enough working area available(requested 52)
Warn : not enough working area available(requested 52)
** Verified OK **
** Resetting Target **
shutdown command invoked
- Flash the blink.uf2 or zmk firmware
- The blink or zmk works as expected, until power is disconnected
- disconnect USB power and reconnect
- The blink or zmk firware doesn't start
- Connect cmsis dap link and run command
openocd -d2 -f interface/cmsis-dap.cfg -f target/nrf52.cfg -c init -c exit
- The blink or zmk works as expected, until power is disconnected
I don't know, haven't used openocd/cmsis dap link. Maybe study this https://github.com/joric/nrfmicro/wiki/Bootloader#flashing-the-bootloader-using-openocd
understand. thank you for reply anyway