Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JLink as upload tool #1029

Closed
wofei1314 opened this issue Sep 2, 2017 · 15 comments
Closed

JLink as upload tool #1029

wofei1314 opened this issue Sep 2, 2017 · 15 comments
Labels
Milestone

Comments

@wofei1314
Copy link

wofei1314 commented Sep 2, 2017

I have sad this page
http://docs.platformio.org/en/latest/plus/debugging.html#custom

But I didn't add Jlink successful.

My platformio ide version is 0.7.2

I want to use PIO Debug my stm32 project with Jlink debug tool ...

I try to modify platformio.ini like this:
[env:jlink_debug_and_upload]
platform = ststm32
framework = stm32cube
board = nucleo_f411re
debug_tool = custom
debug_server =
JLinkGDBServerCL
-singlerun
-if
SWD
-select
USB
-port
2331
-device
STM32F411RE

And when I update firmware to mcu,

`[09/02/17 23:20:02] Processing jlink_debug_and_upload (platform: ststm32; debug_server: JLinkGDBServerCL, -singlerun, -if,
SWD, -select, USB, -port, 2331, -device, STM32F411RE; debug_tool: custom; board: nucleo_f411re; framework: stm32cube)

Verbose mode can be enabled via -v, --verbose option
Collected 0 compatible libraries
Looking for dependencies...
No dependencies
Uploading .pioenvs\jlink_debug_and_upload\firmware.bin
st-flash 1.3.12
017-09-02T23:20:04 WARN src\usb.c: Couldn't find any ST-Link/V2 devices
*** [upload] Error -1
`

PS:I had add the JlinkGDBServerCL.exe path to my system environment,I can use powershell run JlinkGDBServerCL.exe successful.

Configuration

Operating system:WIN10 64bit

PlatformIO Version (platformio --version):0.7.2

@ivankravets
Copy link
Member

Could you try this workaround?

http://docs.platformio.org/en/latest/plus/debugging.html#j-link-as-debugger-and-uploader

If it works, we will think how to integrate J-Link to our development platforms where user will use something like that:

[env:myenv]
...
debug_tool = jlink
upload_protocol = jlink

@medovarsky medovarsky mentioned this issue Oct 2, 2017
@ivankravets ivankravets changed the title How to add Jlink debug tool JLink as upload tool Nov 29, 2017
@ivankravets ivankravets modified the milestones: 3.6.0, 3.5.0 Nov 29, 2017
@ivankravets ivankravets modified the milestones: 3.5.0, 3.x.x Dec 18, 2017
@ivankravets ivankravets modified the milestones: 3.x.x, 3.5.1 Jan 8, 2018
@ivankravets ivankravets modified the milestones: 3.5.1, 3.5.2 Jan 17, 2018
@fadh3r
Copy link

fadh3r commented Feb 10, 2018

with this settings in platformio.ini

upload_protocol = jlink
debug_tool = custom
debug_server =
    JLinkGDBServerExe
    -singlerun
    -if
    SWD
    -select
    USB
    -port
    2331
    -device
    STM32F103C8
    -telnetport
    2333

output is:

AVAILABLE: blackmagic, jlink, jlink, serial, stlink
CURRENT: upload_protocol = jlink
Uploading .pioenvs/genericSTM32F103C8/firmware.bin
2018-02-11T00:48:23 WARN usb.c: Couldn't find any ST-Link/V2 devices
st-flash 1.4.0
*** [upload] Error 255

@fadh3r
Copy link

fadh3r commented Feb 10, 2018

but when I push Debug button uploading finished fine

@fadh3r
Copy link

fadh3r commented Feb 11, 2018

my extra_script.py

Import("env")

env.AddPreAction(
    "upload",
     env.VerboseAction(" ".join([
         "echo",
         "'h\\nloadfile $BUILD_DIR/firmware.hex\\nr\\nq\\n'",
         ">$BUILD_DIR/aux.jlink"
     ]), "Creating auxiliary files"))

env.Replace(
    UPLOADHEXCMD=
    'JLinkExe -device STM32F103C8 -speed 4000 -if swd -autoconnect 1 -CommanderScript $BUILD_DIR/aux.jlink'
)

@fadh3r
Copy link

fadh3r commented Feb 11, 2018

So in my case I solved this issue with customizing extra_script.py

Import("env")

env.AddPreAction(
    "upload",
     env.VerboseAction(" ".join([
         "echo -e",
         "'h\\nloadbin $BUILD_DIR/firmware.bin 0x8000000\\nr\\nq\\n'",
         ">$BUILD_DIR/aux.jlink",
     ]), "Creating auxiliary files"))

env.Replace(
    UPLOADCMD = 'JLinkExe -device STM32F103C8 -speed 4000 -if swd -autoconnect 1 -CommanderScript $BUILD_DIR/aux.jlink'
)

UPLOADCMD is not UPLOADHEXCMD like in example in Advanced Scripting

@ivankravets
Copy link
Member

@ju-mpe-r could you re-test with the latest upstream version? http://docs.platformio.org/en/latest/platforms/ststm32.html#stable-and-upstream-versions

Please remove all extra scripts and lines.

Just use

[env:xxx]
upload_protocol = jlink
debug_tool = jlink

All should work out of the box.

@ivankravets
Copy link
Member

@fadh3r
Copy link

fadh3r commented Feb 27, 2018

@ivankravets
with transport select swd in .platformio/packages/tool-openocd/scripts/interface/jlink.cfg works fine :)

@ivankravets
Copy link
Member

@ju-mpe-r I've just fixed that and you don't need to modify openOCD scripts. Could you try the upstream version?

@jourjine
Copy link

[env:upstream]
platform = https://github.com/platformio/platform-ststm32.git
board = bluepill_f103c8
framework = arduino
upload_protocol = jlink
debug_tool = jlink
debug_port =localhost:2331

Cloning into 'C:\Users\Jourjine.platformio\platforms_tmp_installing-erzqj2-package'...
fatal: unable to access 'https://github.com/platformio/platform-ststm32.git/': error setting certificate verify locations:
CAfile: C:/Program Files/Git/mingw64/libexec/ssl/certs/ca-bundle.crt
CApath: none
Error: VCS: Could not process command ['git', 'clone', '--recursive', '--depth', '1', 'https://github.com/platformio/platform-ststm32.git', 'C:\Users\Jourjine\.platformio\platforms\_tmp_installing-erzqj2-package']

mistake path - C:/Program Files/Git/mingw64/libexec/ssl/certs/ca-bundle.crt
correct path - C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt

@ivankravets
Copy link
Member

@jourjine you have broken Git tool in a system. Try to reinstall it or use platform = ststm32

ivankravets added a commit that referenced this issue Mar 13, 2018
@fadh3r
Copy link

fadh3r commented Mar 21, 2018

@ivankravets yes, it's working fine right now. Thank you.

@fadh3r
Copy link

fadh3r commented Mar 21, 2018

@ivankravets, I was wrong. Successful result was with my extra_script.py in platformio.ini, but without it, I've got this:

Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
swd
Warn : Transport "swd" was already selected
swd
adapter speed: 1000 kHz
adapter_nsrst_delay: 100
none separate
cortex_m reset_config sysresetreq
Error: Failed to claim interface: LIBUSB_ERROR_BUSY.
Error: Failed to open device: unspecified error.
Error: No J-Link device found.
Error: No Valid JTAG Interface Configured.
*** [upload] Error 255```

@ivankravets
Copy link
Member

@ju-mpe-r could you close VSCode, disconnect J-Link and start again?
Of course, without extra script.

@fadh3r
Copy link

fadh3r commented Mar 22, 2018

@ivankravets working! Thank you!

AVAILABLE: blackmagic, dfu, jlink, serial, stlink
CURRENT: upload_protocol = jlink
Uploading .pioenvs/genericSTM32F103C8/firmware.elf
GNU MCU Eclipse 64-bits Open On-Chip Debugger 0.10.0+dev-00392-gbe9ef0b0 (2018-01-12-14:56)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
swd
adapter speed: 1000 kHz
adapter_nsrst_delay: 100
none separate
cortex_m reset_config sysresetreq
Info : J-Link STLink V2 compiled Jun 26 2017 10:34:41
Info : Hardware version: 1.00
Info : VTarget = 3.300 V
Info : clock speed 1000 kHz
Info : SWD DPIDR 0x1ba01477
Info : stm32f1x.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : Listening on port 3333 for gdb connections
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x08008410 msp: 0x20005000
** Programming Started **
auto erase enabled
Info : device id = 0x20036410
Info : flash size = 64kbytes
wrote 50176 bytes from file .pioenvs/genericSTM32F103C8/firmware.elf in 2.738250s (17.895 KiB/s)
** Programming Finished **
** Verify Started **
verified 49644 bytes in 0.752215s (64.450 KiB/s)
** Verified OK **
** Resetting Target **
shutdown command invoked

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants