XIAO looses its Ports

Creator,
Your post will not appear on the pages below.
https://forum.seeedstudio.com/
However, if you use the search function to search for “xiao port”, you will find two posts.
https://forum.seeedstudio.com/search?q=xiao%20port


Managing memory boundaries seems to be the programmer’s responsibility. The link below is an example of a sketch that will definitely make a brick.

trouble getting the st-link to be recognized

I didn’t remember very clearly, but you might have to install the device driver “WinUSB” in order to use ST-Link with OpenOCD.
Although it is not an English site, the following will be helpful.

I found a driver and re ran with these results :

Licensed under GNU GPL v2
libusb1 09e75e98b4d9ea7909e8837b7a3f00dda4589dc3
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
Info : clock speed 400 kHz
Info : STLINK V2J17S4 (API v2) VID:PID 0483:3748
Info : Target voltage: 3.122449
Info : at91samd21g18.cpu: Cortex-M0+ r0p1 processor detected
Info : at91samd21g18.cpu: target has 4 breakpoints, 2 watchpoints
Info : starting gdb server for at91samd21g18.cpu on 3333
Info : Listening on port 3333 for gdb connections
target halted due to debug-request, current mode: Thread
xPSR: 0x81000000 pc: 0x00000288 msp: 0x20002dd8
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x00000288 msp: 0x20002dd8
** Programming Started **
Info : SAMD MCU: SAMD21G18A (256KB Flash, 32KB RAM)
Error: SAMD: NVM programming error
Error: Failed to erase row containing 00000000
Error: SAMD: failed to erase sector 0 at 0x00000000
Error: failed erasing sectors 0 to 38
embedded:startup.tcl:1029: Error: ** Programming Failed **
in procedure ‘script’
at file “embedded:startup.tcl”, line 26
in procedure ‘program’ called at file “XIAO_openocd.cfg”, line 15
in procedure ‘program_error’ called at file “embedded:startup.tcl”, line 1094
at file “embedded:startup.tcl”, line 1029

C:\XIAO_bootloader>

Also loaded STM 32 ST-Link utility hopeing to get some clarification. Is that utility proper for this application. It’s having some trouble too. Loaded but won’t run. Missing msf140.dll.

Please try using the following files.

source [find interface/stlink.cfg]
transport select hla_swd
 
set CHIPNAME at91samd21g18
source [find target/XIAO_at91samdXX.cfg]
 
# did not yet manage to make a working setup using srst
#reset_config srst_only
reset_config  srst_nogate
#reset_config trst_only
 
adapter_nsrst_delay 100
adapter_nsrst_assert_width 100
 
init
targets
reset halt

at91samd bootloader 0
program bootloader-XIAO_m0-v3.7.0-33-g90ff611-dirty.bin verify
at91samd bootloader 8192
reset
shutdown

C:\XIAO_bootloader>
C:\XIAO_bootloader>C:\OpenOCD\OpenOCD-20211118-0.11.0\bin\openocd -f XIAO_openocd.cfg
Open On-Chip Debugger 0.11.0 (2021-11-18) [https://github.com/sysprogs/openocd]
Licensed under GNU GPL v2
libusb1 09e75e98b4d9ea7909e8837b7a3f00dda4589dc3
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
DEPRECATED! use ‘adapter srst delay’ not ‘adapter_nsrst_delay’
DEPRECATED! use ‘adapter srst pulse_width’ not ‘adapter_nsrst_assert_width’
Info : clock speed 400 kHz
Info : STLINK V2J17S4 (API v2) VID:PID 0483:3748
Info : Target voltage: 3.114796
Info : at91samd21g18.cpu: Cortex-M0+ r0p1 processor detected
Info : at91samd21g18.cpu: target has 4 breakpoints, 2 watchpoints
Info : starting gdb server for at91samd21g18.cpu on 3333
Info : Listening on port 3333 for gdb connections
target halted due to debug-request, current mode: Thread
xPSR: 0x81000000 pc: 0x00000288 msp: 0x20002dd8
target halted due to debug-request, current mode: Thread
xPSR: 0x81000000 pc: 0x00000288 msp: 0x20002dd8
** Programming Started **
Info : SAMD MCU: SAMD21G18A (256KB Flash, 32KB RAM)
Error: SAMD: NVM programming error
Error: Failed to erase row containing 00000000
Error: SAMD: failed to erase sector 0 at 0x00000000
Error: failed erasing sectors 0 to 31
embedded:startup.tcl:1029: Error: ** Programming Failed **
in procedure ‘script’
at file “embedded:startup.tcl”, line 26
in procedure ‘program’ called at file “XIAO_openocd.cfg”, line 20
in procedure ‘program_error’ called at file “embedded:startup.tcl”, line 1094
at file “embedded:startup.tcl”, line 1029

C:\XIAO_bootloader>

My version of OpenOCD is old, but I reconfirmed that I am using ST-Link V2 made in China and can write the boot loader of XIAO. I’m not familiar with OpenOCD, but I think about your Error.

On the other hand, the “STM32 ST-LINK Utility”, which worked with the Chinese ST-Link V2, has stopped working. I will investigate this a little more. Of course, I can use it with STMicro genuine ST-Link.

OK I appreciate your help.

As a test, try the following for the directory structure of OpenOCD.

C: / OpenOCD / bin
/ drivers
/ share

C:\XIAO_bootloader>C:\OpenOCD\bin\openocd -f XIAO_openocd.cfg
Open On-Chip Debugger 0.11.0 (2021-11-18) [https://github.com/sysprogs/openocd]
Licensed under GNU GPL v2
libusb1 09e75e98b4d9ea7909e8837b7a3f00dda4589dc3
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
DEPRECATED! use ‘adapter srst delay’ not ‘adapter_nsrst_delay’
DEPRECATED! use ‘adapter srst pulse_width’ not ‘adapter_nsrst_assert_width’
Info : clock speed 400 kHz
Info : STLINK V2J17S4 (API v2) VID:PID 0483:3748
Info : Target voltage: 3.141401
Info : at91samd21g18.cpu: Cortex-M0+ r0p1 processor detected
Info : at91samd21g18.cpu: target has 4 breakpoints, 2 watchpoints
Info : starting gdb server for at91samd21g18.cpu on 3333
Info : Listening on port 3333 for gdb connections
target halted due to debug-request, current mode: Thread
xPSR: 0x61000000 pc: 0x00000288 msp: 0x20002dd8
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x00000288 msp: 0x20002dd8
** Programming Started **
Info : SAMD MCU: SAMD21G18A (256KB Flash, 32KB RAM)
Error: SAMD: NVM programming error
Error: Failed to erase row containing 00000000
Error: SAMD: failed to erase sector 0 at 0x00000000
Error: failed erasing sectors 0 to 31
embedded:startup.tcl:1029: Error: ** Programming Failed **
in procedure ‘script’
at file “embedded:startup.tcl”, line 26
in procedure ‘program’ called at file “XIAO_openocd.cfg”, line 20
in procedure ‘program_error’ called at file “embedded:startup.tcl”, line 1094
at file “embedded:startup.tcl”, line 1029

Looks the same.

I tried to make the versions of OpenOCD and WinUSB the same, I can write. Have you confirmed the connection between XIAO and ST-LINK?

c:\XIAO_bootloader>C:\OpenOCD\bin\openocd -f XIAO_openocd.cfg
Open On-Chip Debugger 0.11.0 (2021-11-18) [https://github.com/sysprogs/openocd]
Licensed under GNU GPL v2
libusb1 09e75e98b4d9ea7909e8837b7a3f00dda4589dc3
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
DEPRECATED! use 'adapter srst delay' not 'adapter_nsrst_delay'
DEPRECATED! use 'adapter srst pulse_width' not 'adapter_nsrst_assert_width'
Info : clock speed 400 kHz
Info : STLINK V2J37S7 (API v2) VID:PID 0483:3748
Info : Target voltage: 3.110597
Info : at91samd21g18.cpu: Cortex-M0+ r0p1 processor detected
Info : at91samd21g18.cpu: target has 4 breakpoints, 2 watchpoints
Info : starting gdb server for at91samd21g18.cpu on 3333
Info : Listening on port 3333 for gdb connections
target halted due to debug-request, current mode: Thread
xPSR: 0x81000000 pc: 0x00000288 msp: 0x20002dd8
target halted due to debug-request, current mode: Thread
xPSR: 0x81000000 pc: 0x00000288 msp: 0x20002dd8
** Programming Started **
Info : SAMD MCU: SAMD21G18A (256KB Flash, 32KB RAM)
** Programming Finished **
** Verify Started **
** Verified OK **
shutdown command invoked

Try updating the ST-Link firmware using the ST-LINK Utility.

Pretty comfortable that the 4 connections are solid and it reacts differently with swdi9 & swclk disconnected.
C:\XIAO_bootloader>c:\OpenOCD\bin\openocd -f XIAO_openocd.cfg
Open On-Chip Debugger 0.11.0 (2021-11-18) [https://github.com/sysprogs/openocd]
Licensed under GNU GPL v2
libusb1 09e75e98b4d9ea7909e8837b7a3f00dda4589dc3
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
DEPRECATED! use ‘adapter srst delay’ not ‘adapter_nsrst_delay’
DEPRECATED! use ‘adapter srst pulse_width’ not ‘adapter_nsrst_assert_width’
Info : clock speed 400 kHz
Info : STLINK V2J17S4 (API v2) VID:PID 0483:3748
Info : Target voltage: 3.110828
Error: init mode failed (unable to connect to the target)

Don’t have ST_Link Utility running due to missing .dll files. Is STM32 ST-Link the correct program ?

I downloaded v4.6.0 from the link below.

Looks like the same place I got it from except my version was in English. I’ll uninstall and reinstall. Same version number. Same problem. I found & installed the 2 dll files it said it needed then there is a message saying it can’t start correctly. This is a Win10 machine.

You can also update the firmware with the utility linked below.
My PC is also Windows 10 64bit.

Yes, that’s fine. Tells me old st-link fw. I think I updated FW on the ST-Link.

C:\XIAO_bootloader>C:\OpenOCD\bin\openocd -f XIAO_openocd.cfg
Open On-Chip Debugger 0.11.0 (2021-11-18) [https://github.com/sysprogs/openocd]
Licensed under GNU GPL v2
libusb1 09e75e98b4d9ea7909e8837b7a3f00dda4589dc3
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
DEPRECATED! use ‘adapter srst delay’ not ‘adapter_nsrst_delay’
DEPRECATED! use ‘adapter srst pulse_width’ not ‘adapter_nsrst_assert_width’
Info : clock speed 400 kHz
Info : STLINK V2J39S7 (API v2) VID:PID 0483:3748
Info : Target voltage: 3.111903
Info : at91samd21g18.cpu: Cortex-M0+ r0p1 processor detected
Info : at91samd21g18.cpu: target has 4 breakpoints, 2 watchpoints
Info : starting gdb server for at91samd21g18.cpu on 3333
Info : Listening on port 3333 for gdb connections
target halted due to debug-request, current mode: Thread
xPSR: 0x61000000 pc: 0x00000288 msp: 0x20002dd8
target halted due to debug-request, current mode: Thread
xPSR: 0x81000000 pc: 0x00000288 msp: 0x20002dd8
** Programming Started **
Info : SAMD MCU: SAMD21G18A (256KB Flash, 32KB RAM)
** Programming Finished **
** Verify Started **
** Verified OK **
shutdown command invoked

I think success here. But no joy via device manager

Rewriting the bootloader should bring XIAO back to life. Also, since the boot loader area is protected, I think that the same trouble will not occur again.

Device manager still doesn’t see either XIAO

Double reset is required.