Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
Page Index Toggle Pages: [1] 2  Send TopicPrint
Very Hot Topic (More than 25 Replies) Can I debug nrf51822 through STLink ? (Read 6525 times)
entretoize1
Junior Member
**
Offline


Posts: 20
Joined: Dec 4th, 2020
Can I debug nrf51822 through STLink ?
Dec 4th, 2020 at 12:05pm
Print Post  
Hello, I started an arduino project for the NRF51822 using Waveshare BLE400 board and STLink v2 programmer.
I'm using 4 nets to connect the board to the stlink and the stlink is connected through USB.
I can program it with Visual studio 2019 and Visual Micro, it works fine.

I tried to run with debugging but it doesn't work, maybe I need to connect more pins or do something more.
First, is it possible ?

Thanks
  
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2174
Joined: Feb 13th, 2019
Re: Can I debug nrf51822 through STLink ?
Reply #1 - Dec 4th, 2020 at 12:26pm
Print Post  
If the programming works, then the debugging should be workable.

Would it be possible to attach the full build log with the properties shown at the top of the page, so we can understand your environment more accurately?
  
Back to top
 
IP Logged
 
entretoize1
Junior Member
**
Offline


Posts: 20
Joined: Dec 4th, 2020
Re: Can I debug nrf51822 through STLink ?
Reply #2 - Dec 4th, 2020 at 12:37pm
Print Post  
Sure here it is :

Code
Select All
Compiling 'BlinkVS' for 'Waveshare BLE400'
ld.exe: warning: changing start of section .heap by 4 bytes
ld.exe: warning: changing start of section .stack_dummy by 4 bytes
ld.exe: warning: changing start of section .heap by 4 bytes
ld.exe: warning: changing start of section .stack_dummy by 4 bytes
ld.exe: warning: changing start of section .heap by 4 bytes
ld.exe: warning: changing start of section .stack_dummy by 4 bytes
Program size: 52 260 bytes (used 34% of a 151 552 byte maximum) (1,60 secs)

Uploading 'BlinkVS' to 'Waveshare BLE400' using 'ST-Link V2'
Open On-Chip Debugger 0.10.0-dev-00254-g696fc0a (2016-04-10-10:13)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
debug_level: 0
0x4000
adapter speed: 1000 kHz
nrf51.cpu: target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0xc1000000 pc: 0x000006d0 msp: 0x000007c0
** Programming Started **
auto erase enabled
nrf51.cpu: target state: halted
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000001e msp: 0x000007c0
wrote 53248 bytes from file \Debug/BlinkVS.ino.hex in 2.742226s (18.963 KiB/s)
** Programming Finished **
** Verify Started **
nrf51.cpu: target state: halted
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000002e msp: 0x000007c0
verified 52468 bytes in 0.360806s (142.011 KiB/s)
	The upload process has finished.
** Verified OK **
** Resetting Target **
shutdown command invoked
 



I forgot to mention the error I receive :
Code
Select All
Unable to start debugging. The value of miDebuggerPath is invalid 

« Last Edit: Dec 4th, 2020 at 12:41pm by entretoize1 »  
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2174
Joined: Feb 13th, 2019
Re: Can I debug nrf51822 through STLink ?
Reply #3 - Dec 4th, 2020 at 12:46pm
Print Post  
Thanks, we will look into adding support for the same debuggers as shown on the programmer menu.

We will update when this is available, or if there are any manual work arounds available in the interim.
  
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2174
Joined: Feb 13th, 2019
Re: Can I debug nrf51822 through STLink ?
Reply #4 - Dec 4th, 2020 at 2:27pm
Print Post  
If you follow the steps below, this should get the debugging running for your project, before it is added to the software:

1) Right Click project in Solution Explorer > Add > Add Custom GDB Debugger (Advanced)
2) Replace the contents of the file with the code below, and save it
3) Select vMicro > Debugger > Debug: Hardware
4) Select vMicro > Debugger > Hardware Debugger: Manual/Custom
5) Build and Upload the project
6) Try Debug > Attach to Process

Custom Launch JSON (STLinkv2 + NRF51x):
Code
Select All
{
// MI Debugger Properties for NRF52x ++ STLink V2 (Ext)

  "serverLaunchTimeout": 5000,
  "filterStdout": false,
  "filterStderr": true,
  "targetArchitecture": "arm",
  "stopAtEntry": false,
  "externalConsole": false,
  "MIMode": "gdb",
  "MIDebuggerServerAddress": "localhost:3333",
  "cwd": "$(buildPath)",
  "MIDebuggerPath": -arm-none-eabi\\5_2-2015q4\\bin\\arm-none-eabi-gdb.exe",
  "MIDebuggerArgs": "",
  "debugServerPath": "C:\\ProgramData\\vmicro\\tools\\openocd-0.10.0.20200213\\bin/openocd.exe",
  "debugServerArgs": "-d2 -s \"C:\\ProgramData\\vmicro\\tools\\openocd-0.10.0.20200213/scripts/\" -f \"interface/stlink.cfg\" -c \"transport select hla_swd\" -f \"target/nrf51.cfg\" -c \"init\"",
  "program": "$(program)",
  "logging": {
    "moduleLoad": false,
    "trace": false,
    "engineLogging": false,
    "programOutput": false,
    "exceptions": false,
    "traceResponse": false
  },
  "showDisplayString": true
} 



If there are any issues, please attach the output from the Output > Debug Window
« Last Edit: Dec 4th, 2020 at 2:33pm by Simon@Visual Micro »  
Back to top
 
IP Logged
 
entretoize1
Junior Member
**
Offline


Posts: 20
Joined: Dec 4th, 2020
Re: Can I debug nrf51822 through STLink ?
Reply #5 - Dec 5th, 2020 at 8:19am
Print Post  
Hello, thank you for the quick help, it seems to run however I have currently another issue that I think isn't related.

I have 4 NRF51822 modules, 2 stlink programmers, and a BLE400 board, I was using the same module with the same stlink each time, but the led on the board stopped lighting, after a flash, as I was testing different libraries I thought it was that, I tried to go back without success, then I tried another module, another stlink but nothing worked even if flash succeeds each time.
I supposed the board was broken, so I tried another more module without the board, the bluetooth worked before I flash but not after. I also tried to reflash the bootloader and a precompiled program with bluettoth feature, flashing succeed but the bluetooth doesn't work. I'm lost, but you'll probably won't be able to help.
Anyway thank you for your help, I'll come back if I come to a solution.
  
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2174
Joined: Feb 13th, 2019
Re: Can I debug nrf51822 through STLink ?
Reply #6 - Dec 7th, 2020 at 11:15am
Print Post  
No problem, we have added the debuggers to the in-built configurations in the latest forum version(20.09.10.19).

Are you able to flash the modules via Serial?

It may be a different bootloader is required depending on chip revision, or the SoftDevice Firmware needs to be updated/reflashed, though I dont have direct experience with this chips programming intricacies.
  
Back to top
 
IP Logged
 
entretoize1
Junior Member
**
Offline


Posts: 20
Joined: Dec 4th, 2020
Re: Can I debug nrf51822 through STLink ?
Reply #7 - Dec 8th, 2020 at 9:43am
Print Post  
I come back to you with more details, I tested to reflash my modules with the raspberry using OpenOCD, and it worked, them came back to life again. But when I retry with the arduino ide, the flash seems to work but the module gives no more signs of life after flash.

This is the opendocd outputs:

Code
Select All
> halt
target halted due to debug-request, current mode: Thread
xPSR: 0x61000000 pc: 0x0001d360 msp: 0x20007ff8

> nrf51 mass_erase
nRF51822-xxxx(build code: xx) 256kB Flash, 32kB RAM
Mass erase completed.
A reset or power cycle is required if the flash was protected before.
> flash write_image s130_nrf51_2.0.1_softdevice.hex
Flash write discontinued at 0x000007c0, next section at 0x00001000
not enough working area available(requested 34)
no working area available, falling back to slow memory writes
not enough working area available(requested 34)
no working area available, falling back to slow memory writes
wrote 108448 bytes from file s130_nrf51_2.0.1_softdevice.hex in 5.727901s (18.49 0 KiB/s)

> flash write_image examples/ble_app_proximity_pca10028_s130.hex
Flash write discontinued at 0x000007c0, next section at 0x00001000
not enough working area available(requested 34)
no working area available, falling back to slow memory writes
Padding image section 1 at 0x0001afe0 with 32 bytes
not enough working area available(requested 34)
no working area available, falling back to slow memory writes
wrote 140004 bytes from file examples/ble_app_proximity_pca10028_s130.hex in 6.899047s (19.818 KiB/s)

>reset 






And the arduino ouput:

Code
Select All
/ld.exe: warning: changing start of section .heap by 4 bytes
/ld.exe: warning: changing start of section .stack_dummy by 4 bytes
/ld.exe: warning: changing start of section .heap by 4 bytes
/ld.exe: warning: changing start of section .stack_dummy by 4 bytes
/ld.exe: warning: changing start of section .heap by 4 bytes
/ld.exe: warning: changing start of section .stack_dummy by 4 bytes
Sketch uses 31596 bytes (20%) of program storage space. Maximum is 151552 bytes.
Open On-Chip Debugger 0.10.0-dev-00254-g696fc0a (2016-04-10-10:13)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
debug_level: 0
0x4000
adapter speed: 1000 kHz
nrf51.cpu: target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0xc1000000 pc: 0x000006d0 msp: 0x000007c0
** Programming Started **
auto erase enabled
nrf51.cpu: target state: halted
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000001e msp: 0x000007c0
wrote 32768 bytes from file C:\Users\Greg\AppData\Local\Temp\arduino_build_403686/Blink.ino.hex in 1.646549s (19.435 KiB/s)
** Programming Finished **
** Verify Started **
nrf51.cpu: target state: halted
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x2000002e msp: 0x000007c0
verified 31792 bytes in 0.217847s (142.517 KiB/s)
** Verified OK **
** Resetting Target **
shutdown command invoked 



In visual studio I can't program it anymore I receive the following error:

Code
Select All
The uploader process failed
Open On-Chip Debugger 0.10.0-dev-00254-g696fc0a (2016-04-10-10:13)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
debug_level: 0
embedded:startup.tcl:60: Error: Can't find interface/upload.protocol.cfg
in procedure 'script'
at file "embedded:startup.tcl", line 60
 

« Last Edit: Dec 8th, 2020 at 9:47am by entretoize1 »  
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2174
Joined: Feb 13th, 2019
Re: Can I debug nrf51822 through STLink ?
Reply #8 - Dec 8th, 2020 at 10:31am
Print Post  
Thanks, is the first output from the Raspberry Pi?

Can you please attach the full build and upload log from Visual Micro each time, with the vMicro > Uploader > Verbose also enabled (along with the settings at the top of the page)?
  
Back to top
 
IP Logged
 
entretoize1
Junior Member
**
Offline


Posts: 20
Joined: Dec 4th, 2020
Re: Can I debug nrf51822 through STLink ?
Reply #9 - Dec 8th, 2020 at 10:49am
Print Post  
Yes the first is with the raspberry.
The visual micro verbose logs are attached.

My settings :
Arduino 1.6/1.8
Waveshare BLE400
Debug: Hardware
No project + libraries optimizations
ST-link V2
  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2174
Joined: Feb 13th, 2019
Re: Can I debug nrf51822 through STLink ?
Reply #10 - Dec 8th, 2020 at 11:08am
Print Post  
Thanks, we can replicate the problem, and will update when the fixed release is available.

If you set the Uploader to STLinkv2 this will allow the debugging to work in the interim before the fix is released.
« Last Edit: Dec 8th, 2020 at 11:12am by Simon@Visual Micro »  
Back to top
 
IP Logged
 
entretoize1
Junior Member
**
Offline


Posts: 20
Joined: Dec 4th, 2020
Re: Can I debug nrf51822 through STLink ?
Reply #11 - Dec 8th, 2020 at 12:00pm
Print Post  
Ok, but the uploader is already set to ST-link V2
  
Back to top
 
IP Logged
 
entretoize1
Junior Member
**
Offline


Posts: 20
Joined: Dec 4th, 2020
Re: Can I debug nrf51822 through STLink ?
Reply #12 - Dec 8th, 2020 at 12:04pm
Print Post  
Sorry I needed to set "enable programmer", but there's still a problem:

Code
Select All
Error during upload using programmer
The uploader process failed

The uploader process failed
The uploader returned an error
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
adapter speed: 1000 kHz
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : clock speed 950 kHz
Info : STLINK v2 JTAG v37 API v2 SWIM v7 VID 0x0483 PID 0x3748
Info : using stlink api v2
Info : Target voltage: 3.255209
Error: init mode failed (unable to connect to the target)
in procedure 'program'
in procedure 'init' called at file "embedded:startup.tcl", line 473
in procedure 'ocd_bouncer'
** OpenOCD init failed **
shutdown command invoked
 



I attached the ful log.
  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2174
Joined: Feb 13th, 2019
Re: Can I debug nrf51822 through STLink ?
Reply #13 - Dec 8th, 2020 at 1:30pm
Print Post  
Thanks for the update.

Please try the latest release from the board below (20.09.10.20) which should allow the debuggers to work independently of the uploader.
https://www.visualmicro.com/forums/YaBB.pl?board=VS_ARDUINO_EXT_RELEASES

If you encounter further issues please submit a new log file.
  
Back to top
 
IP Logged
 
entretoize1
Junior Member
**
Offline


Posts: 20
Joined: Dec 4th, 2020
Re: Can I debug nrf51822 through STLink ?
Reply #14 - Dec 10th, 2020 at 9:38am
Print Post  
I still have the error "embedded:startup.tcl:60: Error: Can't find interface/upload.protocol.cfg"
What can I do ?
  
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2174
Joined: Feb 13th, 2019
Re: Can I debug nrf51822 through STLink ?
Reply #15 - Dec 10th, 2020 at 10:00am
Print Post  
Can you confirm you have updated vMicro?

Also after upgrade, try re-selecting the board, and debugger, then retry the debug attach again, to ensure the new settings are pulled into the project.
  
Back to top
 
IP Logged
 
entretoize1
Junior Member
**
Offline


Posts: 20
Joined: Dec 4th, 2020
Re: Can I debug nrf51822 through STLink ?
Reply #16 - Dec 10th, 2020 at 12:43pm
Print Post  
Yes I updated,
I've been able to flash after reselecting the board and debugger.
But again I receive the following error when I try to debug while selecting "Debug: hardware":

Unable to start debugging. The value of miDebuggerPath is invalid

I attached the logs.
« Last Edit: Dec 10th, 2020 at 12:45pm by entretoize1 »  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2174
Joined: Feb 13th, 2019
Re: Can I debug nrf51822 through STLink ?
Reply #17 - Dec 10th, 2020 at 1:21pm
Print Post  
From the logs it cannot resolve the arm-none-eabi toolchain.

To use the xpack version of this, you can add a Local Board.txt to the project, and add the below entry:
Code
Select All
} 



If this does not work, please submit a new log with the vMicro > Compiler > Show Build Properties enabled as well as Verbose.
  
Back to top
 
IP Logged
 
entretoize1
Junior Member
**
Offline


Posts: 20
Joined: Dec 4th, 2020
Re: Can I debug nrf51822 through STLink ?
Reply #18 - Dec 10th, 2020 at 7:06pm
Print Post  
Still the same, see attached logs.
  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2174
Joined: Feb 13th, 2019
Re: Can I debug nrf51822 through STLink ?
Reply #19 - Dec 10th, 2020 at 9:53pm
Print Post  
Apologies, this is clearer now with the new log, the below entry will work around this until we release a fix shortly:

Code
Select All
runtime.tools.arm-none-eabi-gcc.path={runtime.tools.gcc-arm-none-eabi.path}
 



  
Back to top
 
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send TopicPrint