Recent

Author Topic: Using PICO Debug Probe  (Read 3820 times)

krolikbest

  • Full Member
  • ***
  • Posts: 246
Using PICO Debug Probe
« on: November 11, 2023, 07:36:08 pm »
Uploading a compiled file using picoprobe is already covered but this time I'd like to describe how to use PICO Debug Probe in Windows. Perhaps some finds it obvious, but for me to understand how to use it, it took me a little, so that's why I write it now.
The Pico Debug Probe comes with already uploaded firmware. After connection it to usb Windows should discover  it and report it under Device Manager. Not distinguishing then between releases https://github.com/raspberrypi/picoprobe/releases: debugprobe and picoprobe, constantly tried to use Zadig to configure newly discovered usb port in Windows. But Zadig is no longer required.
In order to upload your compiled program to the Pico it has to be:

1. Use a special Lazarus release to create and build your .elf program
2. Download and unack openocd. I use version 0.12, downloaded from https://www.raspberrypi.com/documentation/microcontrollers/debug-probe.html
3. open cmd in Administrator mode, navigate to your opencmd file (from previous step)
4. It could happen that in rp2040.cfg you have to change this line
Quote
source [find target/swj-dp.tcl]
as I did to
Quote
source [find scripts/target/swj-dp.tcl]
4.Then use something like
Code: Pascal  [Select][+][-]
  1. "path_to your openocd_file">openocd -f scripts/interface/cmsis-dap.cfg -f scripts/target/rp2040.cfg -c "adapter speed 5000" -c "program "path_to some_elf_file" verify reset exit"
  2.  

This is exactly what is described here:https://www.raspberrypi.com/documentation/microcontrollers/debug-probe.html
----------
If you did it in different way please share it.
« Last Edit: November 11, 2023, 08:19:02 pm by krolikbest »

nouzi

  • Sr. Member
  • ****
  • Posts: 296
Re: Using PICO Debug Probe
« Reply #1 on: November 12, 2023, 10:08:56 am »
Thank  @krolikbest
you can add this to wiki
My English is  bad
Lazarus last version free pascal last version
Lazarus trunk  free pascal trunk 
System : Linux mint  64bit  Windows 7 64bit

krolikbest

  • Full Member
  • ***
  • Posts: 246
Re: Using PICO Debug Probe
« Reply #2 on: November 12, 2023, 10:56:43 am »
Not yet until I know how to debug

dbannon

  • Hero Member
  • *****
  • Posts: 2786
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Using PICO Debug Probe
« Reply #3 on: November 12, 2023, 11:25:13 am »
krolikbest, just a few points in the interest of accuracy, especially if you intend to get this onto the wiki. (And thats a good idea !)

The Pico Debug Probe comes with already uploaded firmware.
You can also just use another Pico and load the Probe firmware onto it.

1. Use a special Lazarus release to create and build your .elf program
Hmm, I suspect thats a "special FPC release" ?   Michael required Lazarus main but that was two years ago, so what ever went into it then should be there now. And, good news, it seems that Michael's special code for FPC has now been merged into FPC so, you should be able to use that to build a Pico cross compiler. I have not tried it yet myself, just a query.

https://forum.lazarus.freepascal.org/index.php/topic,65136.msg496422.html#msg496422

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

krolikbest

  • Full Member
  • ***
  • Posts: 246
Re: Using PICO Debug Probe
« Reply #4 on: November 12, 2023, 12:41:31 pm »
Quote
You can also just use another Pico and load the Probe firmware onto it.
Yes, of course, but my goal was to use Pico Debug Probe (a special hardware).

Quote
Hmm, I suspect thats a "special FPC release" ?   Michael required Lazarus main but that was two years ago, so what ever went into it then should be there now. And, good news, it seems that Michael's special code for FPC has now been merged into FPC so, you should be able to use that to build a Pico cross compiler. I have not tried it yet myself, just a query.

https://forum.lazarus.freepascal.org/index.php/topic,65136.msg496422.html#msg496422

I used for that purpose (a great tool) fpcupdeluxe to instal Lazarus (trunk ver) in order to compile for Pico. It would be great to have merged crosscompiler into FPC though. So far (for Pico) I've been using MMBasic but obviously it's interpreter hence using Pico in industrial use it was rather like a toy than seriously.

krolikbest

  • Full Member
  • ***
  • Posts: 246
Re: Using PICO Debug Probe
« Reply #5 on: November 12, 2023, 05:39:15 pm »
Debugging and uploading using Pico Debug Probe (under Windows)

1. First what has to be done is to run gdb server. In order to run it simply write in terminal (in Administrator mode):
Quote
"path_to openocd">openocd -f interface/cmsis-dap.cfg -f target/rp2040.cfg -c "adapter speed 5000"
in my case I had slightly to change so it looks like:
Quote
"path_to openocd">openocd -f scripts/interface/cmsis-dap.cfg -f scripts/target/rp2040.cfg -c "adapter speed 5000"
Then gdb server should start.
2. Start Lazarus for Pico (well, that is my case)
3. Follow this instructionhttps://wiki.freepascal.org/ARM_Embedded_Tutorial_-_Raspberry_Pi_Pico_Debugging_the_onboard_LED, especially this:

Quote
First select 'GNU remote debugger (gdbserver)' and then select the gdb to use.

Here you have two choices, both are provided by FPCUPdeluxe in the installation directory.

First choice is to use gdb-multiarch for your platform, this allows you to debug arm or avr boards without the need to change the debugger.

The alternative is to use a gdb that is specific to arm-none-eabi, it is located in the fpcbootstrap/gdb/arm-embedded/ directory. On Windows this directory is pre-selected when you first open up the Debugger Backend Page.

Depending on your choice you either put 'auto' in the Architecture field, when you decide to use the debugger in the fpcbootrap directory leave the field empty.

Then set the 'Debugger_Remote_DownloadExe' entry to true and set Debugger_Remote_Hostname to localhost

Enter 3333 in the Debugger_Remote_Port field (the OpenOCD default port for debugging)

You will most likely also have to set EncodeCurrentPath to gdfeNone, when this field is set wrong you cannot download your code to the pico.

The last setting is to set all InternalExceptionBreakpoints to 'False'. This setting is very important, the pico has only 4 Hardware Breakpoints and when you waste three of them for this setting then it will be close to impossible to debug even a simple program because you run out of breakpoints.

Hit OK to close the IDE Options, you are now ready to debug!


4. In Lazarus open a program you want to compile and upload to the Pico.
5. Hit F9 - the process should start, I mean it should compile and upload your compiled program to the Pico.
This way is much better (in fact the best so far) than to compile a program and manually upload to the Pico what I described in my first post.

 

TinyPortal © 2005-2018