lancaster-university / microbit-v2-samples

CODAL build tools and sample programs for the micro:bit v2.x
MIT License
68 stars 88 forks source link

Debugging Error: "Error erasing flash with vFlashErase packet" #36

Closed caemor closed 2 years ago

caemor commented 3 years ago

I tried #27 with the openocd option and always get a vFlashErase error, even when trying this with multiple different new micro:bit v2s. Same problem when trying to manually start openocd and gdb. Is there anything I am missing?

Alert Window:

Failed to launch gdb: error erasing flash with vFlashErase packet (from interpreter-exec console "load build/MICROBIT")

Error erasing flash with vFlashErase packet

Debug console:

debug console:
Please check TERMINAL tab (gdb-server) for output from openocd
Launching server: "openocd" "-c" "gdb_port 50000" "-c" "tcl_port 50001" "-c" "telnet_port 50002" "-s" "/microbit-v2-samples" "-f" "interface/cmsis-dap.cfg" "-f" "target/nrf52.cfg"
Launching GDB: "arm-none-eabi-gdb" "-q" "--interpreter=mi2"
Reading symbols from /microbit-v2-samples/build/MICROBIT...
done.
0xfffffffe in ?? ()
Program stopped, probably due to a reset and/or halt issued by debugger
Error erasing flash with vFlashErase packet

Terminal:

Resuming connection to gdb server...
SERVER CONSOLE DEBUG: onBackendConnect: gdb-server session connected
GNU MCU Eclipse 64-bits Open On-Chip Debugger 0.10.0+dev-00487-gaf359c18 (2018-05-12-19:25)
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>'.
adapter speed: 1000 kHz
cortex_m reset_config sysresetreq
Info : Listening on port 50001 for tcl connections
Info : Listening on port 50002 for telnet connections
Info : CMSIS-DAP: SWD  Supported
Info : CMSIS-DAP: Interface Initialised (SWD)
Info : CMSIS-DAP: FW Version = 0255
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 : Listening on port 50000 for gdb connections
Info : accepting 'gdb' connection on tcp/50000
Warn : Unknown device (HWID 0x000001a0)
undefined debug reason 7 - target needs reset
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0xfffffffe msp: 0xfffffffc
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0xfffffffe msp: 0xfffffffc
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0xfffffffe msp: 0xfffffffc
Error: The chip was not pre-programmed with SoftDevice stack and UICR cannot be erased separately. Please issue mass erase before trying to write to this region
Error: failed erasing sectors 0 to 0
Error: flash_erase returned -4
Error: nrf52.cpu -- clearing lockup after double fault
target halted due to debug-request, current mode: Handler HardFault
xPSR: 0x01000003 pc: 0xfffffffe msp: 0xffffffd8
Polling target nrf52.cpu failed, trying to reexamine
Info : nrf52.cpu: hardware has 6 breakpoints, 4 watchpoints
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0xfffffffe msp: 0xfffffffc
SERVER CONSOLE DEBUG: onBackendConnect: gdb-server session closed
GDB server session ended. This terminal will be reused, waiting for next session to start...
carlosperate commented 3 years ago

I'd try updating OpenOCD first, the version I've got is:

 $ openocd --version
xPack OpenOCD, x86_64 Open On-Chip Debugger 0.10.0+dev (2020-10-13-20:30)
Licensed under GNU GPL v2
For bug reports, read
    http://openocd.org/doc/doxygen/bugs.html
microbit-carlos commented 2 years ago

Hi @caemor, were you able to get this working?

caemor commented 2 years ago

Not on this version, but I had another system with a different version of openocd/gdb/gcc running where it was old enough but not too old to work for the microbit v2. So I think this was just a version incompatibility which should be fixed by #33