Upload to mbed via cmsis-dap

Is it possible to upload the code to mbed boards via cmsis-dap instead of using the virtual usb storage,
like st-link on stm32 boards?

Hi @sstaub
I’m not sure, but it may be possible to flash boards with CMSIS-DAP interface via openocd package.
Which board are you trying to program?

Hi Valeros,
I’m using a NXP LPC1768 with mbed, I want to upload to a lpcxpresso 1769 board from embedded artists which is has a CMSIS-DAP interface (but no mbed interface). It is generally possible to run the code which is made with mbed, only for ethernet I have to change a file because there is a different phy.

I don’t have any board with cmsis-dap interface, but we can try next approach:

  • Create a new file cmsis_dap_upload.py in your project folder with next content:
from os.path import join
from SCons.Script import DefaultEnvironment

env = DefaultEnvironment()

env.Replace(
    UPLOADER=join("$PIOPACKAGES_DIR", "tool-openocd", "bin", "openocd"),
    UPLOADERFLAGS=[
        "-d2", "-s",
        join("$PIOPACKAGES_DIR", "tool-openocd",
             "share", "openocd", "scripts"),
        "-f", join("interface", "cmsis-dap.cfg"),
        "-f", join("target", "lpc17xx.cfg"),
        "-c", "\"telnet_port", "disabled;",
        "program", "{{$SOURCES}}",
        "verify", "reset", "0x00000000;", "shutdown\""
    ],
    UPLOADCMD='"$UPLOADER" $UPLOADERFLAGS'
)
  • Add a new option extra_script to your platformio.ini:
[env:lpc1768]
platform = nxplpc
framework = mbed
board = lpc1768
extra_script = cmsis_dap_upload.py
  • Try to upload the firmware via platformio run -t upload

I have changed the platform and framework to nxplpc and mbed, because I can’t build with ststm32 and spl.
Build is ok, but when I do the cmd “platformio run -t upload” nothing happens. When I use the
upload button i get following errors:

Try to define upload_port = /dev/null in platformio.ini.

get following error

Please fix typo. Need = instead of : between upload_port and /dev/null.

It seems that is maybe a bug, the in platformio is “=” but the output is “:”

Please update cmsis_dap_upload.py and try to upload via platformio run -t upload_dap:

from os.path import join
from SCons.Script import DefaultEnvironment

env = DefaultEnvironment()

env.Replace(
    UPLOADER=join("$PIOPACKAGES_DIR", "tool-openocd", "bin", "openocd"),
    UPLOADERFLAGS=[
        "-d2", "-s",
        join("$PIOPACKAGES_DIR", "tool-openocd",
             "share", "openocd", "scripts"),
        "-f", join("interface", "cmsis-dap.cfg"),
        "-f", join("target", "lpc17xx.cfg"),
        "-c", "\"telnet_port", "disabled;",
        "program", join(env.subst("$BUILD_DIR"), "firmware.bin"),
        "verify", "reset", "0x00000000;", "shutdown\""
    ],
    UPLOADCMD='"$UPLOADER" $UPLOADERFLAGS'
)

upload_dap = env.Alias(["upload_dap"], "$SOURCES", "$UPLOADCMD")
AlwaysBuild(upload_dap)

Hmmm, nothing happens with cmd “platformio run -t upload_dap” no output window.

Do you have package tool-openocd in PlatformIO home directory /home/user/.platformio/packages?

No this missing, how to download and install?

Download it for your OS from here and extract to /home/user/.platformio/packages/tool-openocd

It seems that it is a hardware problem with the board and also using it with a mac. I will try it when i get a new revised board. Thank you.