Got it. Went thru the process, seemed to go OK. Now gotta either wait for the programmer or decide to use another XIAO as per your suggestion. But probably not tonight.
The XIAO does not go into bootloader mode. Reset or double reset results in a fast LED blink. Hope that doesn’t prevent this reload from working.
My first post, which hasn’t showed up yet, describes what led up to the Com port on 2 XIAO going bad. Still don’t understand why that was. A glitch is understandable but not twice.
I have also made XIAO bricks several times. When I checked this flash memory using ST-Link, the boot loader start address “0x00-0xff” was overwritten with the data “0xff”. I think there was a problem with the sketch I uploaded. For safety, the bootloader part must be protected from overwriting, but XIAO shipped from Seeed is not protected. However, rewriting protects the bootloader area, so the same trouble no longer occurs. (However, the problem with sketches trying to overwrite the bootloader area must be resolved)
PS: Your post is not showing up in the forums. I found it using the search function.
So what is the root cause of sketches overwriting the bootloader area ? Doesn’t selecting Xiao as the device type define memory areas ? Are you suggesting that writing memory areas unintentionally (for instance overwriting array bounds) is at play ?
Which post are not showing up ? Those that describe how I bricked the part ? I’ve been assuming they have not been cleared cause I’m a new member.
Seems that just having an infinite loop in my setup code is enough to make the USB port malfunction. These are horrible boards to develop code on. Constantly having to reset and set the port again in the IDE.
I’ve used several different Arduino and ESP boards on many projects over the last couple of years. None have been as misbehaved. This is only my second project with a Xiao and I’m on high alert. I may have done something silly here but the number of cases of unexplained ‘bricks’ from many others is a concern. Haven’t seen similar things in these numbers on other forums with other boards.
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.