Unable to load code to custom device

I’m very new to PlatformIO IDE (on VS Code) and only discovered it because the MCU manufacturer I’m trying to use, provides a framework for it.

I’m starting with the provided examples from the manufacturer for the specific dev board(s) I have but I’m running into problems loading the compiled code to the device.
Terminal output is as follows:

 *  Executing task: platformio run --target upload 

Processing genericAT32F407VGT7 (platform: arterytekat32; board: genericAT32F407VGT7; framework: at32firmlib)
------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/arterytekat32/genericAT32F407VGT7.html
PLATFORM: ArteryTek AT32 (1.0.2) > AT32F407VGT7 (96K/224K RAM. 1024K Flash)
HARDWARE: AT32F407VGT7 240MHz, 96KB RAM, 1MB Flash
DEBUG: Current (atlink) External (atlink, atlink_dap_v2, cmsis-dap, jlink, stlink)
PACKAGES: 
 - framework-at32firmlib @ 2.0.1 
 - tool-openocd-at32 @ 0.1100.220911 (11.0) 
 - toolchain-gccarmnoneeabi @ 1.70201.0 (7.2.1)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 1 compatible libraries
Scanning dependencies...
Dependency Graph
|-- at32f403a_407_board
Building in release mode
Checking size .pio/build/genericAT32F407VGT7/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   0.1% (used 76 bytes from 98304 bytes)
Flash: [          ]   0.3% (used 2712 bytes from 1048576 bytes)
Configuring upload protocol...
AVAILABLE: atlink, atlink_dap_v2, cmsis-dap, jlink, stlink
CURRENT: upload_protocol = atlink
Uploading .pio/build/genericAT32F407VGT7/firmware.elf
Open On-Chip Debugger 0.11.0-00006-gbec841d-dirty (2022-09-11-22:29)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
debug_level: 1

swd
Error: unable to find a matching CMSIS-DAP device
Error: No Valid JTAG Interface Configured.
*** [upload] Error 255

Does anyone have any suggestions on how I might fix this?

Well does that dev board you’re working with have a CMSIS-DAP style debugger on board, physically?

When you open the Windows device manager or lsusb, do you see any CMSIS-DAP device?

Did you maybe connect a different SWD probe to the target, like an ST-Link?

I’m on Linux, so no Device Manager, I don’t see anything helpful with lsusb. I don’t know for a fact that it has a CMSIS device on board, but it has it listed as an option in the debug options, although AT-Link is listed as the default.

DEBUG: Current (atlink) External (atlink, atlink_dap_v2, cmsis-dap, jlink, stlink)

I’m guessing the configuration needs to be changed, but I have no idea where to do that for PIO.

I need you to post the link to your exact dev board, or a closeup photo thereof.

Also, unplug the board. Open a new terminal, execute sudo dmesg -w, enter your password and then press enter once. Plug the board back in. What new lines did appear in the log?

I’m evaluating two boards AT32-START-407 and AT32-START-437, but starting with the 407 first.

Info for the 407 at:
雅特力科技 Artery :: Usher in a new era of 32-bit microcontrollers Has basic MCU info
https://www.arterychip.com/download/AT-START/AT_START_F407_V1.2_EN.zip Contains PDFs with more detailed info, including photos of the board.

Same for the 437 at:
雅特力科技 Artery :: Usher in a new era of 32-bit microcontrollers and https://www.arterychip.com/download/AT-START/AT_START_F437_V1.1.zip

I’m beginning to think it might be easier to use protocol_command with the custom atlink command, but that would entail setting up a separate non-standard method which I would prefer to avoid.

EDIT: Ooops forgot to say. The sudo dmesg -w produced nothing new to the screen.

Well then something is wrong, if you have the “AT-START-F407” board, then there’s supposed to be an “AT-LINK EZ” on board, implemented in a separate AT32F304 chip. There are two USB connectors on the board, one USB Micro-B for the AT-LINK EZ (“CN6”) and another USB Micro-B “CN1” that connects to the F407.

  1. Are you sure you have the USB cable plugged into CN6, not CN1?
  2. Is R37 and R38 populated on the board?
  3. Have you made sure that the USB cable has power and data lines? (Charge-only cables exist)

grafik

1 Yes
2 Yes
3 hmmm, no idea. Do not even remember where the cable came from. I’ve ordered a new one from Amazon and will let you know Monday/Tuesday when it arrives.

Received the new USB cable today. It appears the old one is indeed power only, as I now get output from the dmesg -W command:

[ 399.166335] hid-generic 0003:2E3C:F000.0006: hiddev98,hidraw4: USB HID v1.00 Device [Artery Technology CMSIS-DAP] on usb-0000:0a:00.1-5/input2
[ 399.306197] cdc_acm 1-5:1.0: ttyACM0: USB ACM device
[ 399.306219] usbcore: registered new interface driver cdc_acm
[ 399.306220] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters

Loading code to the board now works.

Many thanks for your help.