Intro to Raspberry Pi Pico and RP2040 - C/C++ Part 2: Debug with Picoprobe | Digi-Key Electronics

Поделиться
HTML-код
  • Опубликовано: 16 май 2021
  • In the previous video ( • Intro to Raspberry Pi ... ), we showed you how to configure VS Code to create simple C programs using the Pico SDK. This time, we install OpenOCD and GDB in order to provide step-through debugging of programs on the Raspberry Pi Pico.
    You can read a written version of this tutorial here: www.digikey.com/en/maker/proj...
    Note that you will need a second Raspberry Pi Pico device to act as the debugger.
    We will program one Pico with the picoprobe firmware to act as the debugger. That device will be connected to the target device (which will run the blink program we created in the first tutorial) over SWD. We can use VS Code as a graphical debugger environment, which will call functions in GDB. GDB will send commands to OpenOCD, which runs as a server in the background. OpenOCD communicates with the picoprobe firmware over USB in order to control the target Pico.
    You will need to build the Pico-specific version of OpenOCD by following the guide in Appendix A of the Pico Getting Started Guide (datasheets.raspberrypi.org/pi.... If you are on Windows, you can also follow the guide here (shawnhymel.com/2168/how-to-bu...) to build OpenOCD or download the pre-compiled executable here (bit.ly/pico-tools-windows).
    To start, you will need to download and build the picoprobe firmware (github.com/raspberrypi/picopr.... Upload the picoprobe.uf2 file to the debugger Pico after you put it into bootloader mode.
    If you are on Windows, you will need to install the libusb-win32 driver using Zadig (zadig.akeo.ie/).
    From there, you can install the Cortex-Debug and C/C++ extensions in VS Code. These will allow you to run OpenOCD and GDB in the background while giving you graphical tools to step through lines of code and peek at memory values.
    Product Links:
    www.digikey.com/en/products/d...
    Related Videos:
    Intro to MicroPython - Maker.io Tutorial - • Intro to MicroPython -...
    Intro to Raspberry Pi Pico and RP2040:
    Part 1: VS Code and Blink - • Intro to Raspberry Pi ...
    Part 2: Debug with Picoprobe - • Intro to Raspberry Pi ...
    Part 3: How to Use PIO - • Intro to Raspberry Pi ...
    Related Project Links:
    www.digikey.com/en/maker/proj...
    Related Videos:
    Intro to MicroPython - Maker.io Tutorial - • Intro to MicroPython -...
    Intro to Raspberry Pi Pico and RP2040 - C/C++ Part 1: VS Code and Blink - • Intro to Raspberry Pi ...
    Intro to Raspberry Pi Pico and RP2040 - C/C++ Part 2: Debug with Picoprobe - • Intro to Raspberry Pi ...
    Related Articles:
    Introduction to MicroPython - www.digikey.com/en/maker/blog...
    Raspberry Pi Pico and RP2040 - MicroPython Part 1 - www.digikey.com/en/maker/proj...
    Learn more:
    Maker.io - www.digikey.com/en/maker
    Digi-Key’s Blog - TheCircuit www.digikey.com/en/blog
    Connect with Digi-Key on Facebook / digikey.electronics
    And follow us on Twitter / digikey
  • НаукаНаука

Комментарии • 66

  • @ProTimax
    @ProTimax Год назад +18

    Words can't describe how beginner unfriendly developing for pi-pico is. Thanks for the tutorial!
    Edit. For anyone trying to build openocd on M1 macs, do:
    # export PATH="/opt/homebrew/opt/texinfo/bin:$PATH"
    instead of:
    # export PATH="/usr/local/opt/texinfo/bin:$PATH"
    As you can see the path changed.
    I spend too much time on this and it could obiously be avoided if we got binaries instead of forcing us to build everything...

  • @saustin98
    @saustin98 Год назад +2

    Shawn, there is absolutely no way on earth I could have gotten this working without your excellent detailed help!!! You seem to anticipate most of the glitches that pop up, and prepare us for that.
    THANK YOU!

  • @YoutubeBorkedMyOldHandle_why
    @YoutubeBorkedMyOldHandle_why 2 года назад +7

    I am truly shocked that there are only 12 comments here.
    You sir, have done an Awesome job explaining this.
    I'd be lying if I said I made it through without a hitch. There were a few times that my output didn't even vaguely resemble yours. But I did finally make it through and can now move on to more serious work with the pico.
    THANK YOU!

    • @gautombose4172
      @gautombose4172 2 года назад

      Just wondering how many followers have got PART 2 working.

  • @bertbrecht7540
    @bertbrecht7540 3 года назад +4

    This is a very valuable series for me. It will be particularly practical once the Pico is out of the perpetual backorder phase and the 2040 ecosystem grows, which no doubt it will.

    • @audiodiwhy2195
      @audiodiwhy2195 2 года назад +1

      Shawn's videos and publications are super useful! As a advanced hobbyist trying to get my skills closer to those of a "real EE", his work is Invaluable.

  • @mark-theeverydayimagineer6163
    @mark-theeverydayimagineer6163 Год назад

    Thank you for making the effort to put the material together, its always good to watch your stuff because it gets to the point and provides info that may not be in the manuals.
    Cant say that this wasn't without pains for me, mostly because the repos changed, but that I could still get around. The achilles heel was when openocd couldn't detect the target.
    After reinstalling both, checking hardware etc. the solution was one config entry in
    src/interface/cmsis-dap.cfg adding adapter speed 5000 to what little config there actually is. And now we're good to go.

  • @alperenalperen2458
    @alperenalperen2458 9 месяцев назад

    It's amazing that it's the only tutorial on the internet that works for debugging pico

  • @DavidHolman-uk9wn
    @DavidHolman-uk9wn Год назад

    THIS IS A GEM! Awesome setup of arguably the best set of tools for one of the best/popular microcontrollers.

  • @BS-my2ky
    @BS-my2ky Год назад +1

    Wow, this is super cool! Digikey is so lucky to have Shawn.

  • @AhmadAsmndr
    @AhmadAsmndr 2 года назад +3

    Thank you very much. It was very hard and difficult to build the tools, but at the end it works like a magic. I think that the tools Build tutorials need to be updated and add some more details to it spacially the part after building Openocd the pico tool and libusb.

  • @MsieurSmiley
    @MsieurSmiley Год назад

    Thanks for the tutorial.
    I had a little trouble with the linux installation on your site and more specificaly regarding the building of openocd. I found out I was missing the package pkg-config.
    I don't know if others experienced this problem but though i'd share. It's all written in the readme

  • @glugblub7524
    @glugblub7524 2 года назад +1

    thanks bro that is exactly what i need as im way too lazy to read

  • @skf957
    @skf957 3 года назад +4

    Good things should not come too easily. Thanks for presenting this about as simply as it could be.
    During January I went through the hell of getting the Pico SDK setup on w10 and VSC. It works, but I don't know how! Anyway - sub'd.

    • @ShawnHymel
      @ShawnHymel 3 года назад +1

      Yeah...the setup on Windows is not fun at all :-/

    • @audiodiwhy2195
      @audiodiwhy2195 2 года назад +1

      I just got done setting up Ubuntu 20.04, VSC, and step debugging with both terminal and VSC. It all works. It was a pain to get it all working, but it's amazing what you can do with free software and a $4 dev board.

  • @galatei11
    @galatei11 Год назад

    Good tutorial. You should also mention that for the serial to be present and to be able to connect to it with Serial terminal, you need both PICOs to be connected via USB to the PC.
    There's also a serial monitor extension for VSCode, which can be used instead of Putty, or any other serial term.

    • @peterwilbrink718
      @peterwilbrink718 8 месяцев назад

      Is that true? I think it's not necessary, because he redirects UART @ 14:52

  • @pabcet
    @pabcet 2 года назад +1

    Perfect , all works, thanks a lot

  • @MuhammadDaudkhanTV100
    @MuhammadDaudkhanTV100 3 года назад +1

    Really good to hear

  • @fotonical
    @fotonical Год назад +1

    Great tutorial

  • @sebastianabrilvera5080
    @sebastianabrilvera5080 2 года назад

    Thanks for the video!!! I have a question that I still can't solve, how can I set in visual code a different RP2040 based board, such as the adafruit feather. Thank you very much.

  • @aerosynth3544
    @aerosynth3544 2 года назад +3

    Seems awfully complicated to set up compared to other IDEs I've used in the past like for the STM32, SAM, Kinetis, etc. How about using a commercial SWD debugger like J-Link which comes with OpenOCD.

    • @gautombose4172
      @gautombose4172 2 года назад

      Exactly. The problem is you have to pay if you use Keil, IAR (if your code gets over 32k). STM32 CUBE IDE is free but does not support rpi pico. Shame really.

  • @bennguyen1313
    @bennguyen1313 Год назад

    In order to debug non-Pi devices (ex. stm32), would you just need to change the launch json file to point to the target's svd and cfg files?
    I understand openocd uses the universal arm protocol 'CMSIS-DAP', but is it necessary to modify or rebuild openocd/msys2 tool whenever you debug a different Arm device (cortex m0m3m7)?
    BTW, George Hotz has a great 2016 video where he shows a different way to debug.. he made a qemu-based tool (qira) that allows for 'timeless' debugging!

  • @FreemanPascal
    @FreemanPascal 2 года назад

    Shawn, if I want to code for and debug the USB port on the target Pico. How do I do this? Plugging the usb into the second Pico seems to cause the Picoprobe to hang. I have tried removing the power between the two boards did not help. Any suggestions?

  • @FruchtcocktailUndCo
    @FruchtcocktailUndCo 3 года назад +5

    Any tips on the debugger showing assembly instead of my C source code? 🙈
    Your Videos are perfect.

    • @ShawnHymel
      @ShawnHymel 3 года назад +2

      I'm glad you enjoy them! Viewing assembly is a great question--I have not tried it yet. I'm guessing that you can use arm-gcc to generate an assembly file (with the instructions written out) and then view it with something like this extension: marketplace.visualstudio.com/items?itemName=dseight.disasexpl. I have no idea if that will work though--let me know if you try it!

    • @gautombose4172
      @gautombose4172 2 года назад

      OMG. You are kidding. C/c++ on RPI PICO are extremely fast. Why would you want to work in assembly ? Perhaps you could furnish an example of your application.

    • @robinmattheussen2395
      @robinmattheussen2395 Год назад +1

      ​@@gautombose4172 The question is not about WRITING assembly, the question was about SHOWING the instructions that the compiler generated while debugging. This can be very useful in embedded programming.
      @Frucht Cocktail The easiest way that I can think of is the `layout asm` command during an interactive GDB session. Keep in mind that you need to be in GDB TUI mode for this to work, and I'm pretty sure that TUI mode is not supported by GDB on Windows, which you might be using considering the Windows-centric nature of this video. It obviously works out of the box on most platforms. You can also use richer graphical GDB frontends, like gdbgui, if you like.

    • @TheCustomFHD
      @TheCustomFHD 6 месяцев назад +1

      Ive read stuff about "-g" in a cmakelists or something

  • @bitdecay7773
    @bitdecay7773 2 года назад

    I'm not seeing the message print out to putty. I made sure I'm using the correct COM port (COM4) and the baud rate of 115200. I changed the CMakeLists.txt file and set uart to 1 and usb to 0. I double checked that my connections are correct; the target board is flashed correctly. I'm not sure what else to check, printing the message was working before using picoprobe, using usb.

    • @kilinw
      @kilinw 2 года назад

      Hello, I wonder did you solve this problem? I also encounter this problem but I can't find any way to solve it.

  • @yahmk3978
    @yahmk3978 2 года назад

    Tnak you!

  • @Cptnbond
    @Cptnbond 3 года назад +1

    Now we only waiting for an easy to use and setup debug probe like ST-Link from raspberry folks, please.

    • @gautombose4172
      @gautombose4172 2 года назад

      Raspberry PI does not have a native IDE. The same problem was experienced with STM32 boards, before STM32CUBEIDE came long.

  • @user-jr6zs2nx7z
    @user-jr6zs2nx7z Год назад

    nice video. i have some problems first, when i debugging rp2040, it shows me only assembly code(i have added compile option -g on CmakeList.txt) second, does not possible to view the memory periodic data? anyone help thanks

  • @sindbadoo
    @sindbadoo 2 года назад

    Is it possible to use Atmel ICE-C to debug?

  • @dw4_
    @dw4_ 2 года назад

    When using breakpoints, the code sometimes stops at assembly code instead of the source code. This seems to happen at random and I can’t change it back.
    Any ideas? Thanks for the tutorial

    • @ShawnHymel
      @ShawnHymel 2 года назад +1

      What is the assembly code? For me, it's usually a hard fault, which means that I have a runtime error somewhere.

    • @dw4_
      @dw4_ 2 года назад +2

      @@ShawnHymel I've fixed it now, I was missing a '-g' when defining the optimization level. Thanks for responding though!

  • @filipsevcik1102
    @filipsevcik1102 10 месяцев назад

    Hello I’m new to this and I have a question. When I connect Pico with picoprobe firmware to pc I don’t see the Pico in Ports part of device manager, but in libusb-win32 devices. Does anyone know the reason? Thank you for your answers.

  • @ismaeelm7091
    @ismaeelm7091 2 года назад

    I got an error in Vscode when I want to debug "Failed to launch OpenOCD GDB Server: Error: spawn openocd.exe ENOENT" I was wondering if someone could help.

    • @audiodiwhy2195
      @audiodiwhy2195 2 года назад

      Did you check the "terminal" tab in VSCODE (terminal > new terminal) and then look to the right and click on gdb-server? What does it say? You might have a path issue with one of your .json files, but the terminal information might help.

  • @CanchezAK
    @CanchezAK 6 месяцев назад

    I try this and it's didn't work((( I use MinGW for build my projects, when i try to connect gdb into vs code, I have a lot of errors. Vs code try to compile project with tools, that I havn't, and I don't know, how i can change it. Vs code is very unfriendly IDE(((

  • @angelsoria1068
    @angelsoria1068 Год назад

    Thanks a lot for the tutorials !
    All was going fine until the debug part. When I try to debug I get an error: SERVER CONSOLE DEBUG: GDBServerConsole: onBackendConnect: gdb-server program client error Error: read ECONNRESET
    Some people recommends to downgrade Cortex Debug to v 1.4.4 but it doesn't work for me.
    Any idea ?
    Thanks again !!!

    • @robakers6127
      @robakers6127 Год назад

      Yeah, I have been fighting this issue for a week now. I am sooo. close, I found that I had that error until I when back and followed the written directions word for word. Now the problem is VS code wasnts to read from ports 50001 and 50002, and when I run it in bash it wants to read from 6666 and 4444, so still stuck. I was stuck and found it weird that I had to copy a couple of files from tcl/tartget tp src/target. I kept getting messages they could not be found until I moved those over. so still struggleing.
      the content of these are awesome. I am finding that things are changing so quickly, things that worked 65 months ago needs a little tweaking.
      Good luck

    • @robakers6127
      @robakers6127 Год назад

      ok...I know I postesd this a just 2 hours ago, but just got it working. I kept noticing that with I used picotool info, the description of hte RP2040 was different that what was posted. ....then got clued into another post with the problem, where the person uninstallted the devices from windows before they got it working (they were on UNIX, and I wasn't so I couldn't redo what they posted). So I did that no problem (unstalled the usbs - both).Then..... it occurred to me that I had both PICOs together for debugging. So I disconnected the picos, Flashed nuked them seperately, and the reconnected them like in the instruction.
      Then another post, made me think the PICO was a little slow, I needed to give it a minnute or two beween all the changes and I did. Actuallt for the first time after the nuke, about 20- or 30 seconds I saw the light flash a few times).
      Then rebooted my machine, then re-setup the connections on my breadboard. (The magic happened)... whola.......the darn thing are glowing green, and I can do everything in the instructions.... (BTW - Nice debugger)
      Learned a few things:
      1- The instructions are fast and furious, slow down and read every line. There were a few small things in the detail that screwed me up
      2 - Give the Pico time to execute
      3 -Nuke the boards seperately and unconnected to each other.
      Still confused on why I had to copy a couple of the files from tcl/target to src/target... but at the end of the day it worked. yea! Good luck

  • @Acky0078
    @Acky0078 2 года назад

    Well well, the programming is so easy and everything but setting up a working IDE environment was very painful, even on linux. Why don't they just publish binary release of the c/c++ SDK or precompiled libraries so I can include them like a normal sane person using any IDE of my choice, like codeblocks which, to my knowledge, does not use cmake? Can anyone share some meaningful info please?

  • @user-rd8nh6kg8j
    @user-rd8nh6kg8j 2 года назад

    can rp2040 able to bitmanipulation or bit wise things in c

    • @audiodiwhy2195
      @audiodiwhy2195 2 года назад

      Yes, all the bit manipulation in C works for me.

  • @vuhoangdung
    @vuhoangdung 2 года назад +4

    too much work, i will just use printf then 😅

  • @nelsonamador5412
    @nelsonamador5412 Год назад

    There is not libusb driver compatibility anymore for windows instead of that it's necessary winusb, try to update because this can damage windows then you will need to restore the PC

  • @robertbox5399
    @robertbox5399 10 месяцев назад

    I drifted off at a third of the way through. Nothing bad about this video but the process of even doing C on a Pico is soul destroying. Why is it so hard?

  • @gautombose4172
    @gautombose4172 2 года назад

    "Intro to Raspberry Pi Pico and RP2040 - C/C++ Part 1" is excellent.
    I have everything working as per PART 1. Well Done Sir for PART 1 demonstration.
    However, PART2 .. (the Debug Part) ..is extremely difficult.
    Now I am working with a 64 bit Windows 10 Laptop.
    In theory, I should not have any problem, if I follow step by step.
    But I am getting stuck. Why ? Because, I am finding, the most difficult bits in PART 2
    is a bit rushed. I am getting Error message. Please help.
    A presentation of the directory structure. will help me a lot.

  • @tubeDude48
    @tubeDude48 2 года назад +1

    Dude! You go waaay to fast!!

  • @cernejr
    @cernejr 2 года назад

    In practice, what are the pros and cons of using a RaspberryPi vs. a Pico for debugging? 1) Cost. Anything else?

    • @audiodiwhy2195
      @audiodiwhy2195 2 года назад +1

      My bench is crowded and I didn't want to Xwindows to a RPi. The picoprobe can be thrown in a box with my atmel ice, stlink etc. --so, (small) size matters......

  • @gautombose4172
    @gautombose4172 2 года назад

    Your openocd.exe only runs in Windows 10 (64 bit version). Picotool.exe in windows10 (64bit version) says libgcc_s_seh_1.dll was not found. There has to be a simpler debugger like STM32CUBEIDE. Looking forward to a better/alternative solution to debug RPI PICO.

  • @RSC2194
    @RSC2194 2 года назад +1

    raspberry pico is garbage, It cost nothing to put a USB-serial converter

    • @galatei11
      @galatei11 Год назад

      you can just connect it yourself! what is the problem?

  • @PoiSonSonic
    @PoiSonSonic 2 года назад

    @Digi-Key I've been trying to launch the picotool.exe and I get an error "Entry point not found" The procedure entry point _ZNSt7__cxx1118basic_stringstreamlcSt11char_tratslcESalcEEC1Ev could not be located in the dynamic link library C:\picotool.exe
    And it's virtually impossible to compile, due to libusb missing. :( What to do?

  • @thebarry1232
    @thebarry1232 Год назад

    I can follow the whole tutorial command for command but the second I run the vs code debug session I get the following problem
    embedded:startup.tcl:26: Error: Can't find interface/picoprobe.cfg
    in procedure 'script'
    at file "embedded:startup.tcl", line 26
    the terminal did run the following command:
    "C:/VSARM/sdk/pico/openocd/src/openocd.exe" -c "gdb_port 50000" -c "tcl_port 50001" -c "telnet_port 50002" -s "C:/VSARM/skd/pico/openocd/tcl" -f "c:/Users/name of user/.vscode/extensions/marus25.cortex-debug-1.6.2/support/openocd-helpers.tcl" -f interface/picoprobe.cfg -f target/rp2040.cfg
    it list: Open On-Chip Debugger 0.11.0-g4f2ae61 (2022-08-20-14:26)
    I did try running the same command on a git bash this give the same problem. i also tyed to strip the command form the tcl stuff and turning the -f in to full paths.
    system win10
    is there anyone with the same issue that fixed it or someone that has experience with these kind of errors.

  • @audiodiwhy2195
    @audiodiwhy2195 2 года назад

    I have Ubuntu 20.04. make -j4 throws an error when running make -j4 (17:42 of video) I am dead in the water. Anyone have any ideas how to get what is on page 60 of "getting started" (datasheets.raspberrypi.com/pico/getting-started-with-pico.pdf) to compile from source w Ubuntu 20.04?

    • @MerinKumar
      @MerinKumar 6 месяцев назад

      i have the same error on ubuntu 22.04, did you get it resolved ?