Raspberry Pi Debugging with Visual Studio

Поділитися
Вставка
  • Опубліковано 16 лип 2024
  • Dave shows you how to single-step C++ code live in the Visual Studio debugger as it runs remotely on a Pi running Raspbian Linux.
    Don’t forget to check out my book on Autism and read the “Burgers with Bill Gates” sample chapter!
    amzn.to/3EUe321
    Discord: / discord
    ----
    IMPORTANT STEP THAT'S NOT SHOWN IN THE VIDEO: CONNECTION MANAGER in Visual Studio
    - To connect to the Pi, you must set up the Connection to it in Connection Manager as follows:
    - In the Debug-Options menu, under Cross Platform, open the Connection Manager. Add an SSH connection to your Pi using it’s hostname and your credentials, and it will verify that the connection works for you.
    - Here’s some additional info on the connection manager if needed:
    docs.microsoft.com/en-us/cpp/...
    ON THE PI:
    sudo apt update
    sudo apt upgrade
    sudo apt-get install openssh-server g++ gdb gdbserver wiringpi install make ninja-build rsync zip
    sudo groupadd gpio
    sudo usermod -a -G gpio YOURUSERNAME
    sudo grep gpio /etc/group
    sudo chown root.gpio /dev/gpiomem
    sudo chmod g+rw /dev/gpiomem
    --- If you need a source copy of WiringPi:
    Using WSL and your favorite Linux distribution:
    git clone github.com/zhaolei/WiringOP.git -b h3
    cd WiringOP
    chmod +x ./build
    sudo ./build
    --- More helpful info
    I found this page quite helpful and recommend it:
    dogfeatherdesign.com/2017/01/...
  • Наука та технологія

КОМЕНТАРІ • 208

  • @Emerald13
    @Emerald13 2 роки тому +128

    Definitely a vid on remote ESP32 w/ vscode!

  • @JeffGeerling
    @JeffGeerling 2 роки тому +52

    1:40 I had an excellent sleep last night, thanks!

    • @erroljoshua3429
      @erroljoshua3429 2 роки тому +1

      I thought I might find you in the comments.

    • @DavesGarage
      @DavesGarage  2 роки тому +11

      And a well deserved one! Sorry, I know this was pretty basic compared to compiling your own kernel to #define out the sections of the board you sawed off with a roto-tool, but I'm new to the Pi ;-)
      If you can think of a way to combine an ESP32 and a Pi, it might be fun to do a collab at some point... Right now, my biggest use of the Pi is as the master controller for a bunch of ESP32 Christmas lights: studio.ua-cam.com/users/videoHk7ByiVPACc/edit

    • @JeffGeerling
      @JeffGeerling 2 роки тому +5

      @@DavesGarage There are a few projects I have in mind... I've only used the 8266, never the ESP32 (yet), and I have my eye on a couple of the Pico boards with built-in WiFi too. So far though I'm completely backlogged with some really fun Pi CM4 builds enough that I don't get the time for microcontroller fun :(
      Hopefully that changes next year!

    • @makkam7575
      @makkam7575 2 роки тому +1

      @@DavesGarage Isn't red shirt jeff the one who sawed that poor raspberry pi? No but all jokes aside I was recently playing with github copilot and it's amazing. I made it write a simple code for my esp to read data from various sensors and make a post request containing some data. And a python server built on flask to save this data on a database running in a docker container. I also managed to run my python server on my android phone using termux and save the files on a .db file on the phone and it was so much fun to build.

    • @toucan221
      @toucan221 2 роки тому

      @@makkam7575 that sounds great, maybe one you will do a video for us all, thanks

  • @psyjax2
    @psyjax2 2 роки тому +148

    Joke's on you Dave, most bosses haven't coded in decades ;)

    • @DavesGarage
      @DavesGarage  2 роки тому +46

      Good point! But keep in mind I was a boss too, so there are many kinds 🙂

    • @blain20_
      @blain20_ 2 роки тому +4

      I once had a boss who enjoyed cracking software.

    • @BennyColyn
      @BennyColyn 2 роки тому +1

      And we're still cleaning up the mess they made.

    • @masternobody1896
      @masternobody1896 2 роки тому +2

      @@DavesGarage jokes on you most boss dont code. lol

    • @technowey
      @technowey 2 роки тому

      @@masternobody1896 - I've had several bosses that coded.

  • @sczygiel
    @sczygiel 2 роки тому +6

    Hello Dave! Post more tips and tricks on debugging, that is significant amount of effort when coding and looking for non obvious problems.
    I like this video very much!
    Also, you made huge progress and now you are natural friendly youtube fraggles. Its pleasure to watch you!

  • @technowey
    @technowey 2 роки тому +2

    You're an excellent teacher. You repeat things that are really important, but you don't repeat them too much.

  • @gbrls_yt
    @gbrls_yt 2 роки тому +1

    Hi Dave, amazing video! Really good to see you more relaxed on the camera. Just finished you book by the way, it was really informative and answered many questions !

  • @erichkohl9317
    @erichkohl9317 2 роки тому +1

    Dave I can't believe you just made this video. I bought a Freenove Ultimate Starter Kit for my Pi 3B+, and just the other day I completed the very first project, the one where you flash the LED on and off. For years I've wanted to learn more about how electronics works (outside of school), and this finally gives me the chance. Tip: Make sure your jumper wires are connected tight into the breadboard. The one I had leading back to ground was loose, so I had to wiggle it. Then it started working. :-D

  • @dwillingham
    @dwillingham 2 роки тому +2

    I used wiringPi way back in 2014 for some undergrad projects in my ECE program. Nice to see a much more refined workflow using Visual Studio and ssh to do things wirelessly!

  • @lucasthompson1650
    @lucasthompson1650 2 роки тому +13

    Wow, a Friendly Giant reference at the end. Someone’s showing their Canuckishness.
    PS Hello from Jasper avenue in “Siberia”

    • @DavesGarage
      @DavesGarage  2 роки тому +3

      Awesome! Stop by that little mall you have in town and treat yourself to something ;-)

  • @vincei4252
    @vincei4252 2 роки тому +2

    Thanks, Dave. Haven't used VS for work in almost 15 years as I'm in a 100% Linux shop. I'll add this to the list of things I want to play with bin 😁

  • @jameshorner2045
    @jameshorner2045 2 роки тому

    Thanks so much! I tried to get Wiringpi working last year, but had trouble. Looking forward to getting back into it

  • @dandanlec1996
    @dandanlec1996 2 роки тому +24

    Debbuger... what's a debugger?
    I just use c out for variables and c in for pauses

    • @Hazit90
      @Hazit90 2 роки тому +3

      🙃

    • @nobytes2
      @nobytes2 2 роки тому +1

      poor man debugger

  • @MikeNewmania
    @MikeNewmania 2 роки тому +1

    Wasn't expecting to be transported back to my childhood. Thanks for reminding me of the Friendly Giant.

  • @Swesen
    @Swesen 2 роки тому +5

    One of the most useful tips when working with a pi: In Raspberry Pi Imager press CTRL+SHIFT+X to bring up the advanced options. Lets you setup SSH, Wi-Fi, mDNS name, and you can save these settings so every pi from now on has these settings by default when flashed with Raspberry Pi Imager.

  • @Potts1966
    @Potts1966 2 роки тому +5

    I would absolutely love a video about debugging an ESP32 in the same way.

  • @RockuHD
    @RockuHD 2 роки тому +1

    I do this kind of debugging daily. I do this on game consoles. Attaching and launching on another pc. It's great!

  • @ScottLahteine
    @ScottLahteine 2 роки тому +2

    Great video! I've recently started doing remote debugging of STM32 with ST-Link, and there's truly no better way to dig deep into those tricky bugs than direct debugging. Before getting the ST-Link I was just printing things out to the serial console, just about the slowest and most tedious way to track down issues.

    • @beest_
      @beest_ 2 роки тому

      Did you buy a hardware debugger or did you manage it with software. I spent few days during a project deadline and just didn't have time to finish it. Any tips are appreciated

    • @VeritasEtAequitas
      @VeritasEtAequitas 10 місяців тому

      Printf doesn't help a stack out of memory causing a kernel panic reboot.

    • @MrHaggyy
      @MrHaggyy 7 місяців тому

      ST-Link or any other debugger for that matter are awesome. I use them to get memory snapshots while testing. Really useful when a problem could be caused by either software, hardware, electronics or mechanical.

  • @child_of_god_
    @child_of_god_ 2 роки тому

    Thanks for the tutorial, this opens up a new simpler possibility for me

  • @ShampooCell
    @ShampooCell 2 роки тому +1

    I love the font in your terminal!

  • @nevin3543
    @nevin3543 2 роки тому

    Great video, always nice learning new things. Had a pi when I was younger, would be cool to buy one and play around with it

  • @Nolekev
    @Nolekev 2 роки тому +3

    I recall using pigpio for all my pi gpio access needs. It was a pretty good library

  • @brett1354
    @brett1354 2 роки тому

    Love Studio's dark background and character-cell font you set up there.

  • @christopherleadholm6677
    @christopherleadholm6677 2 роки тому +3

    Thank you, Dave. Still working with the LED's, myself. This was a good C++ breakdown for me. Awesome!

  • @RadicalEdwardStudios
    @RadicalEdwardStudios 2 роки тому

    The first thing I noticed when I started working up a new project for a pi was that my VS community installation, which I may have pushed all the buttons on during installation, has a c++ raspberry pi project already in place ["Raspberry Pi Project", "A blinking LED app using WiringPi for Raspberry Pi."]. This sets things up quite nicely, including sorting out wiringPi. The little getting started bit also gives some nice instructions for setting up the remote.

  • @seanys
    @seanys 2 роки тому +2

    I enjoyed that Bill OReilly reference. 🤣

  • @nickoppen
    @nickoppen 2 роки тому +1

    Thanks for this video Dave. I'm developing on the pi A+ and it's as slow as a wet week but VS is way better than nano and native gdb.

  • @gregnewberry4813
    @gregnewberry4813 10 місяців тому

    Great video! Yes on a video to debug esp32 on VS Code! Love this channel!

  • @christopherguy1217
    @christopherguy1217 2 роки тому +1

    Yes to debugging an ESP32. Man this is going to make my work on a Pi much better.

  • @fpgaguy
    @fpgaguy 2 роки тому

    Bought your book - I think it's more stories so I should like. Also consider adding a short monetized amazon list for things you play with, etc. Besides sending .001 cents your way occasionally it also helps us by playing with discussed content vs debugging the different setup activities.

  • @davidjamgochian
    @davidjamgochian 2 роки тому +1

    Great video and reviews

  • @mranthonymills
    @mranthonymills 2 роки тому +7

    Absolutely interested in a similar setup for the ESP32! We have a work project that uses one of those, and we just use the vanilla ESP-IDF with VS Code to edit and printf debugging :)

  • @thatcreole9913
    @thatcreole9913 2 роки тому +1

    You sir. Just changed my life. Wow.

  • @everythingquads
    @everythingquads Рік тому

    This is a gamechanger for me. Brilliant!

  • @whatsyoursteezo
    @whatsyoursteezo 2 роки тому

    You are a hero and totally my favorite youtuber.

  • @MikelNaUsaCom
    @MikelNaUsaCom 2 роки тому

    few notes - microsoft code can also be installed on the pi, if you want to code locally on the pi. sql server can be installed on linux... haven't tried on the pi, but i've got it on a x86 version running on a NUC. Rasp pi just released a new version 2 w ... would like to see what you can do with that 64bit monster... .as they got 4 cores on a pi zero... anyways... keep up the good work! Thanks, Mike.

  • @rayroulstone3565
    @rayroulstone3565 2 роки тому +1

    Great video. Yes please on the ESP32 debug like a BOSS.

  • @gspier6454
    @gspier6454 2 роки тому

    thanks for this one Dave , very helpful ! =)

  • @Codeaholic1
    @Codeaholic1 2 роки тому +8

    I can magically do this over ssh with lldb. :-D I would DEFINITELY like to see this on an ESP32.

  • @kamran_aghlami
    @kamran_aghlami 2 роки тому

    Excellent content, thanks for sharing.

  • @gregaluise5727
    @gregaluise5727 2 роки тому

    Definitely a video on Esp32 debugging via Visual studio. And greetings to Jeff Geerling!

  • @Nik930714
    @Nik930714 2 роки тому +1

    I really could have used this a few years ago. I managed get similar results on an Eclipse based IDE and remote debugging. Or did i cross compile? I cant say i remember anymore. As much as i'm not a huge fan of Visual Studio, it is a lot better IDE than Eclipse.
    It was not for a PI, but for a custom Computer On a Module that run Linux. Very similar to the current Raspberry PI CM 4 modules.
    I will certainly use this video as a reference next time i need to get a similar project up and running. Thank you Dave.
    PS: The book started off great and i will read the rest of it while on vacation in the next couple of days. Cant wait for that.

  • @Gunbudder
    @Gunbudder 2 роки тому +3

    I knew this was possible, but never had the patience to figure out how to configure it

  • @DouglasFish
    @DouglasFish 2 роки тому

    Thanks for still doing videos

  • @ProjectKneepads
    @ProjectKneepads 2 роки тому +3

    "Let's try it live ... that's always advisable."
    lmao

  • @johankorten2797
    @johankorten2797 2 роки тому

    Very nice. Showing it for a PiCo would also be useful.

  • @toxicbloud
    @toxicbloud 2 роки тому

    Just what I need for my school project

  • @darthcabs
    @darthcabs 2 роки тому +1

    Hey, Dave, I'm curious to know what you heard during the 90s and early 00s about Linux inside Microsoft, if and when you heard something about Microsoft treating it like a competitor, or if it just ignored completely, if the employees experimented with Linux, if they took inspiration in some things from Linux distros, anyway, anything in that sense. Thanks and congrats for your channel!

  • @Ishpeck
    @Ishpeck 2 роки тому

    Neat. Visual Studio is almost as featureful as emacs now! :P

  • @MrJugsstein
    @MrJugsstein 2 роки тому

    Thanks Dave

  • @Aragubas
    @Aragubas 2 роки тому

    I knew visual studio was this powerfull, i learned programming with Visual Studio btw

  • @meggrobi
    @meggrobi 2 роки тому +1

    Another great Vid, would also like to see ESP32 version

  • @akelarsson3358
    @akelarsson3358 2 роки тому +1

    Hi Dave, yes Please, it would be very nice with a video on setting up and debugging ESP32 on VSC (-:

  • @D4v1ks
    @D4v1ks 2 роки тому

    Wish i knew this before, when i coded a LED spinning globe to display some bitmaps. Would had saved me a lot of time. :)

  • @larsgregersen
    @larsgregersen 2 роки тому

    Please let us know how you normally set up your build dependencis in Visual Studio, since I'm sure I'm missing a lot of great tricks there too.

  • @ooltimu
    @ooltimu 2 роки тому

    I used this while working on a Linux target at a past job. Eclipse was horrendous for the big project we were working on.

  • @leslieleslie336
    @leslieleslie336 4 місяці тому

    Great video! I have some question. at 9:01, how can i access the WiringPi libraries installed(by me) inside WSL debian? are you using WSL1 or WSL2? How do you create the $(LinuxIncludePath) macro inside visual studio to point to WSL's linux virtualmachine file system?
    My current idea is to pre-build & install libraries for raspberry pi inside the WSL debian system. Afterwards, when i build & debug in visual studio 2022, i include and link to WSL debian's linux include path. And it will do a remote-build on a raspbery pi , and i can debug from it as well. Is this approach the way?

  • @davidclift5989
    @davidclift5989 6 місяців тому

    Hi Dave just been watching this again. Is this possible with VS Code ? Studio code is a bit rich for my budget.

  • @drelephanttube
    @drelephanttube 2 роки тому

    Nice video. Do you have any info on the flame spiral looking thing in the top-right? Looks cool.

    • @DavesGarage
      @DavesGarage  2 роки тому

      Yup, search for tiki lamp on the channel!

  • @howard_yin
    @howard_yin 2 роки тому

    love your rolex submariner

  • @LamNgo-yy7og
    @LamNgo-yy7og 2 роки тому

    Me too with remote ESP32 w/ vscode. Thanks!

  • @thomasgalliker
    @thomasgalliker Рік тому

    Hi Dave. Cool video! Do you know if I can do such a thing with a c# console application and a raspberry pi 4?

  • @trickysoft
    @trickysoft 2 роки тому

    Wow, thanks, that has my limit of Linux in it, but well worth it.
    Now can you get bare metal c++ working in VS please :)

  • @mikeer5517
    @mikeer5517 10 місяців тому

    Great! How to use remote includes, libraries, such as SDL, zmq? I have some headers in /usr/lib /usr/local/lib /usr/include/SDL /usr/local/include, how i can use them?

  • @markpitts5194
    @markpitts5194 2 роки тому +1

    ESP32 like a boss debugging - YES PLEASE !

  • @Skrat2k
    @Skrat2k 2 роки тому +3

    Esp32 remote debug video would be handy

  • @charlesb4714
    @charlesb4714 Рік тому

    I think this a great and informative video --Thanks. I have tried for many hours to get this to work on Visual Studio 2022 with Nov-Dec update. It has a R P template for blink. I cannot get it to build. Would you consider a new video on this subject showing how to do this on Visual Studio 2022. I thought it would be easy but I cannot do it.
    Thanks

  • @isxckk.
    @isxckk. 8 місяців тому

    For everyone that is getting Severity Code Description Project File Line Suppression State
    Error -E or -x required when input is from standard input
    There is a stray " - " somewhere in your settings.
    For me it was at linker --> all options --> Additional options " - %(AdditionalOptions)" it should be "%(AdditionalOptions)"

  • @guilherme5094
    @guilherme5094 2 роки тому

    Nice!

  • @alexrossouw7702
    @alexrossouw7702 2 роки тому

    In-fact, more ESP32 stuff would be epic. I loved this video tho!

  • @christopherweeks89
    @christopherweeks89 2 роки тому

    Would love the esp32 vid!

  • @TokkanFX
    @TokkanFX 2 роки тому

    ESP32 debugging video would be nice please. Also have you played with the Pi pico yet?

  • @bayliner4387
    @bayliner4387 2 роки тому

    Yes, Please!!! Debugging on the ESP32 using VS-Code. Thanks

  • @nerminziric6691
    @nerminziric6691 4 місяці тому

    Nice, Great but I have one question: can you please give me how to type a path to the wiringPi library? Under vc++directories..it is not so clear on this video

  • @michaelsteliaros9037
    @michaelsteliaros9037 2 роки тому

    Is ESP32/VSCode debugging possible without a board with onboard jtag? If so, I'd love to know how... Both the heltec_wifi_kit_32 and the ttgo-lora32-v1 I've been playing with dont seem to want to play nice.

  • @MamaMia84oo7
    @MamaMia84oo7 Рік тому

    “Let’s do it live like Bill O’Reilly”. 😂😂😂😂😂 hehe

  • @KaziiTheAvali_inactive
    @KaziiTheAvali_inactive Рік тому

    i would love the vsc one cause i dont have access to visual studio due to linux.

  • @farhanyousaf5616
    @farhanyousaf5616 2 роки тому

    Hey Dave, what processor you flexing there? Also, I'm going for a Timmy run. Want something?

  • @YacineBougrinat
    @YacineBougrinat Рік тому

    Have you done something similar with VS Code? with python code

  • @chrisbadal5852
    @chrisbadal5852 2 роки тому

    Ok, so what if the code was built elsewhere?
    Could I still attach Visual Studio to a remote Linux process and debug it?

  • @timw1971
    @timw1971 2 роки тому

    Yes, Dave! Yes I really would like to debug an ESP32 remotely!
    Is it also possible for its little brother, the ESP8266?

  • @felipemonteiro4223
    @felipemonteiro4223 2 роки тому

    Does the visual studio code have a similar extension?

  • @nathantron
    @nathantron 2 роки тому +3

    In B4 he automates his truck and makes it self driving and first drives his truck with a laptop in debugger mode.

  • @joeltyler3427
    @joeltyler3427 2 роки тому +3

    7:59 The pi 3 is 64 bit capable. But the older ones are not.
    This list includes original pi, B+, Pi2, 1st gen zero's and other pi's that are based on them.

    • @DavesGarage
      @DavesGarage  2 роки тому +1

      Thanks!

    • @user-xr3rb6pn9m
      @user-xr3rb6pn9m 2 роки тому +1

      Did you specifically install a 64-bit version of Raspbian? Even though Pi3 and Pi4 have 64-bit processors, the default Raspbian image is 32-bit, for compatibility purposes (and 64-bit build is available as beta).

  • @bobhillier921
    @bobhillier921 2 роки тому +1

    Friendly Dave

  • @diandradeeke
    @diandradeeke 2 роки тому

    yes please show me how to debug the ESP32 like a BOSS with visual studio. i am very interested

  • @NinjaRunningWild
    @NinjaRunningWild 2 роки тому

    "Let's try it live. That's always advisable."
    😂🤣

  • @Gyannea
    @Gyannea 2 роки тому

    Went by the adding the include directories too fast - this was the part that killed me when trying to use the blinky project direct. Where are those $(xxxx) defined?

  • @popliviustefan
    @popliviustefan 2 роки тому

    Hi Dave!
    Great video!
    I am sure it saves a lot of people tine if they setup the workflow for remote debugging (I know it would have saved me time if I would have seen something like this about a year ago).
    But one thing that I still haven't figured is this: for more complicated projects, remote building is a pain (even on the 8GB pi4), plus I think it unnecessarily increases the wear and tear of the microSD.
    So what it would be nice to have is this: remote build the project on a linux box, then deploy, run and debug it on the Raspberry PI.
    I am pretty sure it is well within the capabilities of the Visual Studio to do this, but I didn't know how to set it up on the Visual Studio side, nor how to setup the linux box with the toolchain and all the necessary dependencies to build the project as on the PI.
    Do you have any insights about this?

    • @DavesGarage
      @DavesGarage  2 роки тому

      I know, it *should* cross compile on the fast PC, but I am not sure if that's possible!

  • @7heMech
    @7heMech 2 роки тому

    This was already streamed?

  • @fmasterofu
    @fmasterofu 2 роки тому

    yes please for the esp32 video

  • @rowdyriemer
    @rowdyriemer 2 місяці тому

    I used to really enjoy debugging through GDB. After debugging daily via visual studio for years now, I think I'd hate using GDB.

  • @typingcat
    @typingcat 2 роки тому

    Debugging like a boss: "Debug this by tomorrow or you will get fired."

  • @pichlalex
    @pichlalex 2 роки тому

    ESP32 debugging for everyone!

  • @virtualpilgrim8645
    @virtualpilgrim8645 2 роки тому +1

    Dave puts the curly braces on separate lines which I believe is the proper way. I read a number of books on programming styles and it is important that your code is readable because sooner or later somebody else is going to inherit your code and try to understand it. Fortunately, Visual Studio has a curly brace setting for both types of programmers.

  • @SergeyKucheryavy
    @SergeyKucheryavy 13 днів тому

    But how to build WiringPi on Windows to work with that includes and lib file? it's kind a blind spot totally not covered in video. Sad (

  • @thembijan
    @thembijan 2 роки тому

    I would like to see an esp-32 debug

  • @jesperkock5969
    @jesperkock5969 Рік тому

    Please do a ESP32 setup tutorial, that would be awesome 🙂

  • @snoopyjc
    @snoopyjc 2 роки тому

    I do code for the PI in python

  • @matoatlantis
    @matoatlantis 2 роки тому

    I must admit when I saw the title I thought you'll be talking about Segger's J-link.
    Nice video nevertheless.

  • @waynekeenansvideos
    @waynekeenansvideos 2 роки тому +1

    Does VSCode do: 1. Python 2. Python Debugging & 3. Remote Python Debuggin on a Pi??

    • @evancourtney7746
      @evancourtney7746 2 роки тому +1

      Yes to 1 & 2, don’t know on 3, but I’ve been putting it off all week, I’ll let you know.