PlatformIO Community

Need help getting STLINK talking to/programming an SKR1.4T 3D Printer CPU

I am using Visual Studio + Platform IO to config and compile MARLIN for my 3D printer. That part is working fine - I can compile & build xxx.bin files for my SKR 1.4 Turbo board (LPC1768 CPU). However, the board still runs but has stopped reading the SD card (Bad SD socket or boot loader?) so I can’t use the normal update-from-SD-card method. SKR 1.4T does have a “SWD connector” that should support STLINK V2 programmer. I bought a STLINK V2 (clone) and am trying to get Platform IO to update via the SDLINK method.

I have already downloaded and installed STLINK drivers and Windows 10 seems to be happy when STLINK is plugged in (Win10 IDs STLINK module and claims it’s driver is installed and okay). I have also added “upload_protocol = stlink” to the platformio.ini file but no joy.

After checking the discussions on this group, I found some info and I tried:
C:\Users\xxxx.platformio\packages\tool-openocd\bin>openocd.exe -f scripts\interface\stlink.cfg -c “reset_config none separate” -f s

Here’s what I get back:

xPack OpenOCD, 64-bit Open On-Chip Debugger 0.10.0+dev (2019-07-17-11:28)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
embedded:startup.tcl:26: Error: Can’t find scripts\interface\stlink.cfg in procedure ‘script’
at file “embedded:startup.tcl”, line 26

This seems to say that I have the OpenOCD program installed but seem to be missing the stlink.cfg file. Where to I get that? Any help is appreciated.

If you want to invoke it from the shell you might need to give it a -s <path to scripts folder> switch, aka -s C:\Users\<user>\.platformio\packages\tool-openocd\scripts for example, as the first argument.

However, this is a manual method.

What is the output there? Can you post the log of a “Verbose Upload” (or pio run -t upload -v equivalently)?

1 Like

Hi - Thanks for your response - Since my first post a couple of days ago, I now have got STLINK up and running and connected successfully to my SKR 1.4 T (LPC1769 CPU) printer board. I found that I had not provided valid paths while attempting the diagnostic openocd run. I now have success:

Here’s a snap shot of my DOS command openocd testing:

  Microsoft Windows [Version 10.0.18363.836]
(c) 2019 Microsoft Corporation. All rights reserved.


C:\Users\MyUserName> cd .platformio\packages\tool-openocd


C:\Users\MyUserName\.platformio\packages\tool-openocd> bin\openocd.exe -f scripts\interface\stlink.cfg -c "reset_config none separate" -f scripts\target\lpc17xx.cfg

xPack OpenOCD, 64-bit Open On-Chip Debugger 0.10.0+dev (2019-07-17-11:28)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
none separate

Info : auto-selecting first available session transport "hla_swd". To override use 'transport select <transport>'.
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : clock speed 10 kHz
Info : STLINK V2J29S7 (API v2) VID:PID 0483:3748
Info : Target voltage: 3.199481
Info : lpc17xx.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : Listening on port 3333 for gdb connections

So it appears that I’m now good on STLINK front.

I have added: “upload_protocol = stlink” to [env:LPC1768] but when I compile MARLIN, I receive this message: Warning! Unkown upload protol stlink

An “upload” to the SKR doesn’t work. In looking through your previous responses to a similar 1.3/1.4 question, you mentioned creating a special openocd programming script to do the flash. I have hunted around for more info on this topic but success escapes me. I’ve never used STLINK or openocd so I’m still in the steep part of the learning curve. Thanks!

PS C:\Users\EdAndrews\Documents\3D_PRINTER\Marlin-2.0.x\Marlin-2.0.x> pio run -t upload -v

Processing LPC1769 (platform: https://github.com/p3p/pio-nxplpc-arduino-lpc176x/archive/0.1.2.zip; board: nxp_lpc1769; build_flags: -DU8G_HAL_LINKS -IMarlin/src/HAL/LPC1768/include -IMarlin/src/HAL/LPC1768/u8g -fmax-errors=5 -g -D__MARLIN_FIRMWARE__ -fmerge-all-constants; lib_ldf_mode: off; lib_compat_mode: strict; extra_scripts: Marlin/src/HAL/LPC1768/upload_extra_script.py; src_filter: +<src/*> -<src/config> -<src/HAL> +<src/HAL/shared> +<src/HAL/LPC1768>; upload_protocol: stlink; lib_deps: Servo, LiquidCrystal, U8glib-HAL=https://github.com/MarlinFirmware/U8glib-HAL/archive/bugfix.zip, TMCStepper@>=0.6.1,<1.0.0, Adafruit NeoPixel=https://github.com/p3p/Adafruit_NeoPixel/archive/release.zip, SailfishLCD=https://github.com/mikeshub/SailfishLCD/archive/master.zip; framework: arduino; monitor_speed: 250000)
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

CONFIGURATION: https://docs.platformio.org/page/boards/nxplpc-arduino-lpc176x/nxp_lpc1769.html
PLATFORM: NXP Arduino LPC176x 0.1.1 (https://github.com/p3p/pio-nxplpc-arduino-lpc176x/archive/0.1.2.zip) > NXP LPC1769
HARDWARE: LPC1769 120MHz, 31.97KB RAM, 464KB Flash
DEBUG: Current (cmsis-dap) On-board (cmsis-dap) External (blackmagic, jlink)
PACKAGES:
 - framework-arduino-lpc176x 0.2.2
 - toolchain-gccarmnoneeabi 1.90201.191206 (9.2.1)
arm-none-eabi-g++ -o "C:\Users\EdAndrews\Documents\3D_PRINTER\Marlin-2.0.x\Marlin-2.0.x\Marlin\Marlin.ino.cpp" -x c++ -fpreprocessed -dD -E "C:\Users\EDANDR~1\AppData\Local\Temp\tmpmxkw83av"
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ off, Compatibility ~ strict
Platform incompatible library C:\Users\EdAndrews\.platformio\lib\NTPClient_ID551
Platform incompatible library C:\Users\EdAndrews\.platformio\packages\framework-arduino-lpc176x\libraries\__cores__\arduino\SPI
Platform incompatible library C:\Users\EdAndrews\.platformio\packages\framework-arduino-lpc176x\libraries\__cores__\arduino\SoftwareSerial
Platform incompatible library C:\Users\EdAndrews\.platformio\packages\framework-arduino-lpc176x\libraries\__cores__\arduino\Wire
More details about "Library Compatibility Mode": https://docs.platformio.org/page/librarymanager/ldf.html#ldf-compat-mode
Found 10 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <Servo> 1.0.0 (C:\Users\EdAndrews\.platformio\packages\framework-arduino-lpc176x\libraries\Servo)
|-- <LiquidCrystal> 1.0.0 (C:\Users\EdAndrews\.platformio\packages\framework-arduino-lpc176x\libraries\LiquidCrystal)
|-- <U8glib-HAL> 0.4.1 [https://github.com/MarlinFirmware/U8glib-HAL/archive/bugfix.zip] (C:\Users\EdAndrews\Documents\3D_PRINTER\Marlin-2.0.x\Marlin-2.0.x\.pio\libdeps\LPC1769\U8glib-HAL_ID1932)      
|-- <TMCStepper> 0.6.2 (C:\Users\EdAndrews\Documents\3D_PRINTER\Marlin-2.0.x\Marlin-2.0.x\.pio\libdeps\LPC1769\TMCStepper_ID5513)
|-- <Adafruit NeoPixel> 1.3.0 [https://github.com/p3p/Adafruit_NeoPixel/archive/release.zip] (C:\Users\EdAndrews\Documents\3D_PRINTER\Marlin-2.0.x\Marlin-2.0.x\.pio\libdeps\LPC1769\Adafruit NeoPixel)  
|-- <SailfishLCD> [https://github.com/mikeshub/SailfishLCD/archive/master.zip] (C:\Users\EdAndrews\Documents\3D_PRINTER\Marlin-2.0.x\Marlin-2.0.x\.pio\libdeps\LPC1769\SailfishLCD)
Building in release mode
Warning! Unknown upload protocol stlink

Unable to find destination disk (Autodetect Error)
Please select it in platformio.ini using the upload_port keyword (https://docs.platformio.org/en/latest/projectconf/section_env_upload.html) or copy the firmware (.pio/build/LPC1769/firmware.bin) manually to the appropriate disk

MethodWrapper(["checkprogsize"], [".pio\build\LPC1769\firmware.elf"])
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [======    ]  59.0% (used 19304 bytes from 32736 bytes)
Flash: [=====     ]  47.7% (used 226660 bytes from 475136 bytes)
.pio\build\LPC1769\firmware.elf  :

section               size        addr

.ram_isr_vector        256   268435456

.text               225548       16384

.ramcode                 0   268435712

.ARM.exidx               8      241932

.data                 1104   268435712

.bss                 17944   268436816

.heap                 2048   268454760

.stack_dummy          3072   268454760

.AHBSRAM0             9248   537378816

.ARM.attributes         41           0

.comment               102           0

.debug_info       22887617           0

.debug_abbrev       723390           0

.debug_loc          420396           0

.debug_aranges       22808           0

.debug_ranges       137216           0

.debug_line         839537           0

.debug_str          341457           0

.debug_frame         71512           0

.stab                   60           0

.stabstr               118           0

Total             25703482
===================================================================================== [SUCCESS] Took 12.28 seconds =====================================================================================

Environment               Status    Duration
------------------------  --------  ------------
mega2560                  IGNORED
mega1280                  IGNORED
rambo                     IGNORED
FYSETC_F6_13              IGNORED
FYSETC_F6_14              IGNORED
sanguino644p              IGNORED
sanguino1284p             IGNORED
melzi                     IGNORED
melzi_optiboot            IGNORED
at90usb1286_cdc           IGNORED
at90usb1286_dfu           IGNORED
DUE                       IGNORED
DUE_USB                   IGNORED
DUE_debug                 IGNORED
LPC1768                   IGNORED
LPC1769                   SUCCESS   00:00:12.282
STM32F103RC               IGNORED
STM32F103RC_fysetc        IGNORED
STM32F103RC_btt           IGNORED
STM32F103RC_btt_USB       IGNORED
STM32F103RC_btt_512K      IGNORED
STM32F103RC_btt_512K_USB  IGNORED
STM32F103RE               IGNORED
STM32F103RE_btt           IGNORED
STM32F103RE_btt_USB       IGNORED
STM32F4                   IGNORED
STM32F7                   IGNORED
ARMED                     IGNORED
STM32F103VE_GTM32         IGNORED
STM32F103VE_longer        IGNORED
mks_robin_mini            IGNORED
mks_robin_nano            IGNORED
mks_robin                 IGNORED
mks_robin_pro             IGNORED
mks_robin_lite            IGNORED
mks_robin_lite3           IGNORED
jgaurora_a5s_a1           IGNORED
STM32F103CB_malyan        IGNORED
chitu_f103                IGNORED
STM32F401VE_STEVAL        IGNORED
FLYF407ZG                 IGNORED
FYSETC_S6                 IGNORED
STM32F407VE_black         IGNORED
BIGTREE_SKR_PRO           IGNORED
BIGTREE_GTR_V1_0          IGNORED
BIGTREE_BTT002            IGNORED
teensy31                  IGNORED
teensy35                  IGNORED
esp32                     IGNORED
linux_native              IGNORED
SAMD51_grandcentral_m4    IGNORED
rumba32_f446ve            IGNORED
rumba32_mks               IGNORED
include_tree              IGNORED
====================================================================================== 1 succeeded in 00:00:12.282 ======================================================================================
PS C:\Users\EdAndrews\Documents\3D_PRINTER\Marlin-2.0.x\Marlin-2.0.x>

Yeah since Marlin uses an external platform here it doesn’t work like the PlatformIO provided ones (e.g. stm32). This platform does not handle the stlink protocol (refer here).

This looks good – your STLink is properly connected to the target chip.

You can still use advanced scripting to use a ST-Link upload.

For that, in the specific Marlin environment, use the directives

extra_scripts = extra_script.py
upload_protocol = custom
upload_flags =
    -f
    scripts/interface/stlink.cfg
    -f
    scripts/target/lpc17xx.cfg
    -c 
    "reset_config none separate"

(remove any previous upload_protocol directive in the environment) and create a new extra_script.py in the Marlin project folder (same level as the platformio.ini) with the content

Import("env")

platform = env.PioPlatform()

env.Prepend(
    UPLOADERFLAGS=["-s", platform.get_package_dir("tool-openocd") or ""]
)
env.Append(
    UPLOADERFLAGS=["-c", "program {{$SOURCE}} verify reset; shutdown"]
)
env.Replace(
    UPLOADER="openocd",
    UPLOADCMD="$UPLOADER $UPLOADERFLAGS"
)

Then check again with pio run -t upload -v / Verbose Upload that PlatformIO invokes the correct openocd command in the same way you did.

1 Like

Max - Thanks for your help…So here’s where I stand. Per your guidance, I generated the extra_script.py file (I actually called it StLinkUpLd_script.py) located in the SAME sub-directory as platformio.ini as follows:

Import("env")
platform = env.PioPlatform()
env.Prepend(
    UPLOADERFLAGS=["-s", platform.get_package_dir("tool-openocd") or ""])
env.Append(
    UPLOADERFLAGS=["-c", "program {{$SOURCE}} verify reset; shutdown"])
env.Replace(
    UPLOADER="openocd",
    UPLOADCMD="$UPLOADER $UPLOADERFLAGS"
)

Then I modified platformio.ini - The "[env: LPC1769} section now looks like this:

[env:LPC1769]
platform          = https://github.com/p3p/pio-nxplpc-arduino-lpc176x/archive/0.1.2.zip
board             = nxp_lpc1769
build_flags       = -DU8G_HAL_LINKS -IMarlin/src/HAL/LPC1768/include -IMarlin/src/HAL/LPC1768/u8g ${common.build_flags}
# debug options for backtrace
#  -funwind-tables
#  -mpoke-function-name
lib_ldf_mode      = off
lib_compat_mode   = strict
#vvvvvvvvvvvvvvvvvvvvvvvvv EWA 20200609 REMOVED THIS CODE
#extra_scripts     = Marlin/src/HAL/LPC1768/upload_extra_script.py
#^^^^^^^^^^^^^^^^^^^^^^^^^ EWA 20200609 REMOVED THIS CODE

#vvvvvvvvvvvvvvvvvvvvvvvvv EWA 20200609  Added for SKR1.4T via stlink & openOCD
extra_scripts    = StLinkUpLd_script.py
upload_protocol  = custom
upload_flags =
    -f
    scripts\interface\stlink.cfg
    -f
    scripts\target\lpc17xx.cfg
    -c 
    "reset_config none separate"
#^^^^^^^^^^^^^^^^^^^^^^^^^ EWA 20200609 Added for SKR1.4T via stlink & openOCD
src_filter        = ${common.default_src_filter} +<src/HAL/LPC1768>
lib_deps          = Servo
  LiquidCrystal
  U8glib-HAL=https://github.com/MarlinFirmware/U8glib-HAL/archive/bugfix.zip
  TMCStepper@>=0.6.1,<1.0.0
  Adafruit NeoPixel=https://github.com/p3p/Adafruit_NeoPixel/archive/release.zip
  SailfishLCD=https://github.com/mikeshub/SailfishLCD/archive/master.zip

So, now I get a “Warning! Unknown upload protocol custom” error like this:

Converting Marlin.ino
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ off, Compatibility ~ strict
Found 10 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <Servo> 1.0.0
|-- <LiquidCrystal> 1.0.0
|-- <U8glib-HAL> 0.4.1
|-- <TMCStepper> 0.6.2
|-- <Adafruit NeoPixel> 1.3.0
|-- <SailfishLCD>
Building in release mode
**Warning! Unknown upload protocol custom**
Compiling .pio\build\LPC1769\src\src\HAL\LPC1768\DebugMonitor.cpp.o
Compiling .pio\build\LPC1769\src\src\HAL\LPC1768\HAL.cpp.o
Compiling .pio\build\LPC1769\src\src\HAL\LPC1768\HAL_SPI.cpp.o

This feels like it could be PATH problem perhaps inside of StLinkUpLd_script.py but I haven’t yet resolved it. What stupid mistake have I make? TNX

Meh, turns out even that isn’t possible because that third-party platform doesn’t recognize custom upload protocols where it should just execute that commands.

I’m forking the platform and fixing the code…

Hm actually it also checks the env object.

Try setting

extra_scripts    = pre:StLinkUpLd_script.py

so that it definitely executes before the main builder script does (https://docs.platformio.org/en/latest/projectconf/advanced_scripting.html#launch-types).

Otherwise you can use

platform          = https://github.com/maxgerhardt/pio-nxplpc-arduino-lpc176x/archive/0.1.3.zip

for a version with a code fix in https://github.com/maxgerhardt/pio-nxplpc-arduino-lpc176x.

Geting closer… I now can compile without errors!!

Upload using the platformio ‘->’ upload-button yields the following error:
.
.
Uploading .pio\build\LPC1769\firmware.bin
’openocd’ is not recognized as an internal or external command,
operable program or batch file.
***** [upload] Error 1**
.
.

Sorry to be such a pain, but I gather that I need to specify the path to openocd but I don’t understand the syntax. Path + openocd command to me seems like it will be close to:
C:\Users\<user>\.platformio\packages\tool-openocd\bin\openocd

It may be possible that you don’t have tool-openocd in your C:\Users\<user>\.platformio\packages\tool-openocd. Is that the case?

If it is, it may be the case that the platform doesn’t declare the usage of that tool and thus it doesn’t get included in the path… Instead of writing

env.Replace(
    UPLOADER="openocd",
    UPLOADCMD="$UPLOADER $UPLOADERFLAGS"
)

try writing

# at the top 
from os import path

env.Replace(
    UPLOADER=path.join(platform.get_package_dir("tool-openocd"), "bin", "openocd"),
    UPLOADCMD="$UPLOADER $UPLOADERFLAGS"
)

So still have not uncovered the holy Grail…Tried several changes to StLinkUpLd_script.py

from os import pathImport("env")
platform = env.PioPlatform()
env.Prepend(
    UPLOADERFLAGS = ["-s", platform.get_package_dir("tool-openocd") or ""]
)
env.Append(
    UPLOADERFLAGS = ["-c", "program {{$SOURCE}} verify reset; shutdown"]
)
env.Replace(
    #vvv---Compiles & builds OK but generates: 'openocd' is not recognized as an internal or external command,... error
    #UPLOADER =  "openocd",

    #vvv---This kills the build & generates long error msg: (See below)...
    UPLOADER = path.join(platform.get_package_dir("tool-openocd"), "bin", "openocd"),
    #vvvv-- These don't work either...
    #UPLOADER = path.join("Users","EdAndrews",".platformio","packages","tool-openocd","bin","openocd.exe"),
    #UPLOADER = path.join(path,"tool-openocd","bin","openocd"),
    #^^^^^-- These don't work either...

    UPLOADCMD = "$UPLOADER $UPLOADERFLAGS"
)

When I run the “path,join(…” variant I get this build abort output error mess:

> Executing task in folder Marlin-2.0.x: C:\Users\EdAndrews\.platformio\penv\Scripts\platformio.exe run --target upload <

Processing LPC1769 (platform: https://github.com/p3p/pio-nxplpc-arduino-lpc176x/archive/0.1.2.zip; board: nxp_lpc1769; framework: arduino)
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
TypeError: expected str, bytes or os.PathLike object, not NoneType:
  File "C:\Users\EdAndrews\.platformio\penv\lib\site-packages\platformio\builder\main.py", line 166:
    env.SConscript(item, exports="env")
  File "C:\Users\EdAndrews\.platformio\packages\tool-scons\script\..\engine\SCons\Script\SConscript.py", line 597:
    return _SConscript(self.fs, *files, **subst_kw)
  File "C:\Users\EdAndrews\.platformio\packages\tool-scons\script\..\engine\SCons\Script\SConscript.py", line 286:
    exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
  File "C:\Users\EdAndrews\Documents\3D_PRINTER\Marlin-2.0.x\Marlin-2.0.x\StLinkUpLd_script.py", line 16:
    UPLOADER = path.join(platform.get_package_dir("tool-openocd"), "bin", "openocd"),
  File "C:\Users\EdAndrews\.platformio\python37\lib\ntpath.py", line 76:
    path = os.fspath(path)
====================================================================================== [FAILED] Took 1.44 seconds ======================================================================================

Environment               Status    Duration
------------------------  --------  ------------
mega2560                  IGNORED
mega1280                  IGNORED
rambo                     IGNORED
FYSETC_F6_13              IGNORED
FYSETC_F6_14              IGNORED
sanguino644p              IGNORED
sanguino1284p             IGNORED
melzi                     IGNORED
melzi_optiboot            IGNORED
at90usb1286_cdc           IGNORED
at90usb1286_dfu           IGNORED
DUE                       IGNORED
DUE_USB                   IGNORED
DUE_debug                 IGNORED
LPC1768                   IGNORED
LPC1769                   FAILED    00:00:01.440
STM32F103RC               IGNORED
STM32F103RC_fysetc        IGNORED
STM32F103RC_btt           IGNORED
STM32F103RC_btt_USB       IGNORED
STM32F103RC_btt_512K      IGNORED
STM32F103RC_btt_512K_USB  IGNORED
STM32F103RE               IGNORED
STM32F103RE_btt           IGNORED
STM32F103RE_btt_USB       IGNORED
STM32F4                   IGNORED
STM32F7                   IGNORED
ARMED                     IGNORED
STM32F103VE_GTM32         IGNORED
STM32F103VE_longer        IGNORED
mks_robin_mini            IGNORED
mks_robin_nano            IGNORED
mks_robin                 IGNORED
mks_robin_pro             IGNORED
mks_robin_lite            IGNORED
mks_robin_lite3           IGNORED
jgaurora_a5s_a1           IGNORED
STM32F103CB_malyan        IGNORED
chitu_f103                IGNORED
STM32F401VE_STEVAL        IGNORED
FLYF407ZG                 IGNORED
FYSETC_S6                 IGNORED
STM32F407VE_black         IGNORED
BIGTREE_SKR_PRO           IGNORED
BIGTREE_GTR_V1_0          IGNORED
BIGTREE_BTT002            IGNORED
teensy31                  IGNORED
teensy35                  IGNORED
esp32                     IGNORED
linux_native              IGNORED
SAMD51_grandcentral_m4    IGNORED
rumba32_f446ve            IGNORED
rumba32_mks               IGNORED
include_tree              IGNORED
================================================================================= 1 failed, 0 succeeded in 00:00:01.440 =================================================================================
The terminal process terminated with exit code: 1

Terminal will be reused by tasks, press any key to close it.

Still searching…Any other thoughts?

BTW, openocd.exe is located in the normal/expected directory location as you indicated.

I am going through the TCL crash course right now to see if I can get a little farther along. TNX.

Meh, platform.get_package_dir("tool-openocd") probably returns None becauase the platform does not declare the usage of the tool.

I would just hardcode a constant string at this point as an absolute path, like

  UPLOAD="/Users/EdAndrews/.platformio/packages/tool-openocd/bin/openocd"

btw if you start your path with /Users you’re a Mac user? Then the .exe part must be removed.

openocd is found and does start with a absolute path. However, the py script that is supposed to supply the uploader string doesn’t work Here’s the current StLinkUpLd_Script.py

Import("env")
> 
> platform = env.PioPlatform()
> 
> env.Prepend(
>     UPLOADERFLAGS = ["-s", platform.get_package_dir("tool-openocd") or ""]
> )
> 
> env.Append(
>     UPLOADERFLAGS = ["-c", "program {{$SOURCE}} verify reset; shutdown"]
>  )
> 
> env.Replace(

>     UPLOADER  = ["/Users/EdAndrews/.platformio/packages/tool-openocd/bin/openocd"],
     UPLOADCMD = "$UPLOADER $UPLOADERFLAGS"

> )

openocd runs but apparently UPLOADCMD is null. Here’s what I see.

> Executing task in folder Marlin-2.0.x: C:\Users\EdAndrews\.platformio\penv\Scripts\platformio.exe run --target upload <
>

Processing LPC1769 (platform: https://github.com/p3p/pio-nxplpc-arduino-lpc176x/archive/0.1.2.zip; board: nxp_lpc1769; framework: arduino)

> -----------------------------------------------------------
> 
> Verbose mode can be enabled via `-v, --verbose` option
> CONFIGURATION: https://docs.platformio.org/page/boards/nxplpc-arduino-lpc176x/nxp_lpc1769.html
> PLATFORM: NXP Arduino LPC176x 0.1.1 > NXP LPC1769
> HARDWARE: LPC1769 120MHz, 31.97KB RAM, 464KB Flash
> DEBUG: Current (cmsis-dap) On-board (cmsis-dap) External (blackmagic, jlink)
> PACKAGES:
>  - framework-arduino-lpc176x 0.2.2
>  - toolchain-gccarmnoneeabi 1.90201.191206 (9.2.1)
> Converting Marlin.ino
> LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
> LDF Modes: Finder ~ off, Compatibility ~ strict
> Found 10 compatible libraries
> Scanning dependencies...
> Dependency Graph
> |-- <Servo> 1.0.0
> |-- <LiquidCrystal> 1.0.0    
> |-- <U8glib-HAL> 0.4.1       
> |-- <TMCStepper> 0.6.2       
> |-- <Adafruit NeoPixel> 1.3.0
> |-- <SailfishLCD>
> Building in release mode
> Checking size .pio\build\LPC1769\firmware.elf
> Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
> RAM:   [======    ]  59.0% (used 19304 bytes from 32736 bytes)
> Flash: [=====     ]  47.7% (used 226676 bytes from 475136 bytes)
> Configuring upload protocol...
> AVAILABLE: blackmagic, cmsis-dap, custom, jlink, mbed
> CURRENT: upload_protocol = custom
> Uploading .pio\build\LPC1769\firmware.bin
> xPack OpenOCD, 64-bit Open On-Chip Debugger 0.10.0+dev (2019-07-17-11:28)
> Licensed under GNU GPL v2
> For bug reports, read
>         http://openocd.org/doc/doxygen/bugs.html
> Unexpected command line argument: none
> *** [upload] Error 1
> ===== [FAILED] Took 12.86 seconds ====================
> 
> Environment               Status    Duration
> ------------------------  --------  ------------
> mega2560                  IGNORED
> mega1280                  IGNORED
> rambo                     IGNORED
> FYSETC_F6_13              IGNORED
> FYSETC_F6_14              IGNORED
> sanguino644p              IGNORED
> sanguino1284p             IGNORED
> melzi                     IGNORED
> melzi_optiboot            IGNORED
> at90usb1286_cdc           IGNORED
> at90usb1286_dfu           IGNORED
> DUE                       IGNORED
> DUE_USB                   IGNORED
> DUE_debug                 IGNORED
> LPC1768                   IGNORED
> LPC1769                   FAILED    00:00:12.857
> STM32F103RC               IGNORED
> STM32F103RC_fysetc        IGNORED
> STM32F103RC_btt           IGNORED
> STM32F103RC_btt_USB       IGNORED
> STM32F103RC_btt_512K      IGNORED
> STM32F103RC_btt_512K_USB  IGNORED
> STM32F103RE               IGNORED
> STM32F103RE_btt           IGNORED
> STM32F103RE_btt_USB       IGNORED
> STM32F4                   IGNORED
> STM32F7                   IGNORED
> ARMED                     IGNORED
> STM32F103VE_GTM32         IGNORED
> STM32F103VE_longer        IGNORED
> mks_robin_mini            IGNORED
> mks_robin_nano            IGNORED
> mks_robin                 IGNORED
> mks_robin_pro             IGNORED
> mks_robin_lite            IGNORED
> mks_robin_lite3           IGNORED
> jgaurora_a5s_a1           IGNORED
> STM32F103CB_malyan        IGNORED
> chitu_f103                IGNORED
> STM32F401VE_STEVAL        IGNORED
> FLYF407ZG                 IGNORED
> FYSETC_S6                 IGNORED
> STM32F407VE_black         IGNORED
> BIGTREE_SKR_PRO           IGNORED
> BIGTREE_GTR_V1_0          IGNORED
> BIGTREE_BTT002            IGNORED
> teensy31                  IGNORED
> teensy35                  IGNORED
> esp32                     IGNORED
> linux_native              IGNORED
> SAMD51_grandcentral_m4    IGNORED
> rumba32_f446ve            IGNORED
> rumba32_mks               IGNORED
> include_tree              IGNORED
> ====== 1 failed, 0 succeeded in 00:00:12.857 =========

This is probably a NOOB question, but what do the env.Prepend (), env.Append(), and env.Replace() procedures do? Looks like string manipulation routines that aren’t behaving as expected…

Yeah okay the problem is that it definitely doesn’t like reset_config none seperate as an argument, and thinks those are seperate flags – -c needs that as one string arg.

Remove these two lines in the platformio.ini file and retry. If openocd cannot reset the board, edit the python script

to say

UPLOADCMD="$UPLOADER $UPLOADERFLAGS -c \"reset_config none separate\""

Max - tried your throughs and no mater what I use, I get “unexpected command line argument. In the following example, I set UPLOADERFLAGS = [”-c", “exit”] and still no joy.

Building in release mode
Checking size .pio\build\LPC1769\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [======    ]  59.0% (used 19304 bytes from 32736 bytes)
Flash: [=====     ]  47.7% (used 226676 bytes from 475136 bytes)
Configuring upload protocol...
AVAILABLE: blackmagic, cmsis-dap, custom, jlink, mbed
CURRENT: upload_protocol = custom
Uploading .pio\build\LPC1769\firmware.bin
xPack OpenOCD, 64-bit Open On-Chip Debugger 0.10.0+dev (2019-07-17-11:28)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
Unexpected command line argument: reset
*** [upload] Error 1

Also tried just program, just verify, just reset, just shutdown and all gave me command line errors argument errors. It is as through the Stlink command set (what ever that is) is not available or wasn’t initialized in openocd. I’m about ready to throw in the towl with this approach and toss this ‘bricked/not upgradable’ SKR board. It appears that this approach is ‘above my pay grade’ Thanks for trying.

Watching this. Same exact scenario here. Hoping for the best!

@Ed-EE-Eng Do you need to put 3.3v on ISP BOOT to get that to work? If so, are you just adding a jumper over R28?

Actually I think this is where it wrongly read reset as a seperate argument. Somehow it must be changed so that the commandline says openocd [..] -c "program {{$SOURCE}} verify reset; shutdown" and not openocd [..] -c program {{$SOURCE}} verify reset; shutdown. Verify that this is happening with pio run -t upload -v to see the used openocd invocation.