okay this should probably go in a bug report or get reported upstream but that is hard sometimes because it takes a lot of work to report and is sometimes murky who to report to and I feel like a bother when there are 8 million issues already. hoping this ends up in search results
I wanted to flash new marlin firmware 2.1.2.5 to get linear advance on an artillery sidewinder x2. I'm on linux fedora 40. I downloaded vs code with the auto build marlin extension and platformio version 6.1.16.
Build was successful but then hit an error when trying to flash/upload. using lsub I observe the stm32 device vendor id : product id (vid:pid) 0483:5740 and later when in bootloader mode 0483:df11.
Bus 001 Device 017: ID 0483:5740 STMicroelectronics Virtual COM Port <- example when not in bootloader mode
The error from platformio which uses openocd (tool-openocd @ 3.1200.0 (12.0)) was
embedded:startup.tcl:28: Error: Can't find scripts/interface/stlink.cfg
I enabled debug logs for openocd with
diff --git a/buildroot/share/PlatformIO/boards/marlin_Artillery_Ruby.json b/buildroot/share/PlatformIO/boards/marlin_Artillery_Ruby.json
index e1c8333800..41e702f76a 100644
--- a/buildroot/share/PlatformIO/boards/marlin_Artillery_Ruby.json
+++ b/buildroot/share/PlatformIO/boards/marlin_Artillery_Ruby.json
@@ -21,6 +21,7 @@
"stlink": {
"server": {
"arguments": [
+ "-d3",
"-f",
"scripts/interface/stlink.cfg",
which let me see
Debug: 11 2 configuration.c:33 add_script_search_dir(): adding /home/andrew/.var/app/com.visualstudio.code/config/openocd
Debug: 12 2 configuration.c:33 add_script_search_dir(): adding /home/andrew/.openocd
Debug: 13 2 configuration.c:33 add_script_search_dir(): adding /home/andrew/.platformio/packages/tool-openocd/bin/../openocd/site
Debug: 14 2 configuration.c:33 add_script_search_dir(): adding /home/andrew/.platformio/packages/tool-openocd/bin/../openocd/scripts
Debug: 15 2 command.c:155 script_debug(): command - ocd_find scripts/interface/stlink.cfg
User : 16 2 command.c:608 command_run_line(): embedded:startup.tcl:28: Error: Can't find scripts/interface/stlink.cfg
and it looks like platformio is passing the search dirs but they aren't quite right, I think they should not be ../openocd/site
but rather ../openocd
(and maybe normalized). Anyways to work around that I did
ln -sf ~/.platformio/packages/tool-openocd/openocd ~/.openocd
then re-running upload I got
Debug: 124 2 stlink_usb.c:3693 stlink_open(): stlink_open
Debug: 125 2 stlink_usb.c:3705 stlink_open(): transport: 4 vid: 0x0483 pid: 0x3744 serial:
Debug: 126 2 stlink_usb.c:3705 stlink_open(): transport: 4 vid: 0x0483 pid: 0x3748 serial:
Debug: 127 2 stlink_usb.c:3705 stlink_open(): transport: 4 vid: 0x0483 pid: 0x374b serial:
Debug: 128 2 stlink_usb.c:3705 stlink_open(): transport: 4 vid: 0x0483 pid: 0x374d serial:
Debug: 129 2 stlink_usb.c:3705 stlink_open(): transport: 4 vid: 0x0483 pid: 0x374e serial:
Debug: 130 2 stlink_usb.c:3705 stlink_open(): transport: 4 vid: 0x0483 pid: 0x374f serial:
Debug: 131 2 stlink_usb.c:3705 stlink_open(): transport: 4 vid: 0x0483 pid: 0x3752 serial:
Debug: 132 2 stlink_usb.c:3705 stlink_open(): transport: 4 vid: 0x0483 pid: 0x3753 serial:
Debug: 133 2 stlink_usb.c:3705 stlink_open(): transport: 4 vid: 0x0483 pid: 0x3754 serial:
Error: 134 7 stlink_usb.c:3374 stlink_usb_usb_open(): open failed
Debug: 135 7 hla_layout.c:36 hl_layout_open(): failed
Debug: 136 7 command.c:544 run_command(): Command 'transport init' failed with error code -4
User : 137 7 command.c:608 command_run_line(): in procedure 'program'
Debug: 138 7 command.c:544 run_command(): Command 'init' failed with error code -4
Debug: 139 7 command.c:155 script_debug(): command - echo ** OpenOCD init failed **
User : 140 7 command.c:685 handle_echo(): ** OpenOCD init failed **
Debug: 141 7 command.c:155 script_debug(): command - shutdown error
User : 142 7 server.c:758 handle_shutdown_command(): shutdown command invoked
Debug: 143 7 command.c:544 run_command(): Command 'shutdown' failed with error code -4
interestingly the vid:pid iit shows trying don't match the 0483:5740, but even when adding that to the stlink.cfg script I still got the same error
diff --git a/tmp/stlink.cfg b/.platformio/packages/tool-openocd/openocd/scripts/interface/stlink.cfg
index b686a81..e4906b7 100644
--- a/tmp/stlink.cfg
+++ b/.platformio/packages/tool-openocd/openocd/scripts/interface/stlink.cfg
@@ -8,7 +8,7 @@
adapter driver hla
hla_layout stlink
hla_device_desc "ST-LINK"
-hla_vid_pid 0x0483 0x3744 0x0483 0x3748 0x0483 0x374b 0x0483 0x374d 0x0483 0x374e 0x0483 0x374f 0x0483 0x3752 0x0483 0x3753 0x0483 0x3754
+hla_vid_pid 0x0483 0x3744 0x0483 0x3748 0x0483 0x374b 0x0483 0x374d 0x0483 0x374e 0x0483 0x374f 0x0483 0x3752 0x0483 0x3753 0x0483 0x3754 0x0483 0x5740
I also tried udev rules if it was a permission thing like:
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="5740", \
MODE:="0666", \
SYMLINK+="artillery_%n"
which should populate /dev/artillery_1
when plugged in, but no difference.
I tried M997 to put marlin into bootloader mode, but after issuing the command I didn't see any difference (though I only knew later that there would/should be difference in product id when actually in bootloader mode) in lsusb. I also tried
~/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-objcopy -O binary .pio/build/Artillery_Ruby/firmware.elf firmware.bin
to then copy over to the sd card but no avail.
I tried the stm32cube programmer thing but that was dreadful. Did require udev rules and once in bootloader mode did let me upload/download but I wasn't confident in what I was doing there so I at least dumped the firmware and confirmed it wasn't an elf so it would require an objcopy transformation I think.
Anyways what worked was to jumper BOOT0 to 3v3 on the motherboard (opening the bottom panel is a bit of a pain; I actually wired in a switch and routed the cable through the gap by the usb port so I wouldn't have to open it again. I used a jst-xhp connector that I trimmed down to fit through the gap.
Okay so jumper/switch on/closed and then turn it on, lsusb should show 0483:df11, then this change (hail mary from looking at other stm32 board json file in marlin)
diff --git a/buildroot/share/PlatformIO/boards/marlin_Artillery_Ruby.json b/buildroot/share/PlatformIO/boards/marlin_Artillery_Ruby.json
index e1c8333800..ee520a6ad8 100644
--- a/buildroot/share/PlatformIO/boards/marlin_Artillery_Ruby.json
+++ b/buildroot/share/PlatformIO/boards/marlin_Artillery_Ruby.json
@@ -45,7 +45,7 @@
"disable_flushing": false,
"maximum_ram_size": 65536,
"maximum_size": 262144,
- "protocol": "stlink",
+ "protocol": "dfu",
"protocols": [
"stlink",
"dfu",
worked first try. Then power down, remove jumper / open switch and power up, should have new firmware.
Can't say this was fun or enlightening but the big win was keeping my cool. Hope this helps you or future me