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/... - Наука та технологія
Definitely a vid on remote ESP32 w/ vscode!
Is that even possible?
please! That would be incredible!
+1 @Dave
Definitely interested
Please :)
1:40 I had an excellent sleep last night, thanks!
I thought I might find you in the comments.
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
@@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!
@@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.
@@makkam7575 that sounds great, maybe one you will do a video for us all, thanks
Joke's on you Dave, most bosses haven't coded in decades ;)
Good point! But keep in mind I was a boss too, so there are many kinds 🙂
I once had a boss who enjoyed cracking software.
And we're still cleaning up the mess they made.
@@DavesGarage jokes on you most boss dont code. lol
@@masternobody1896 - I've had several bosses that coded.
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!
You're an excellent teacher. You repeat things that are really important, but you don't repeat them too much.
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 !
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
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!
Wow, a Friendly Giant reference at the end. Someone’s showing their Canuckishness.
PS Hello from Jasper avenue in “Siberia”
Awesome! Stop by that little mall you have in town and treat yourself to something ;-)
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 😁
Thanks so much! I tried to get Wiringpi working last year, but had trouble. Looking forward to getting back into it
Debbuger... what's a debugger?
I just use c out for variables and c in for pauses
🙃
poor man debugger
Wasn't expecting to be transported back to my childhood. Thanks for reminding me of the Friendly Giant.
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.
I would absolutely love a video about debugging an ESP32 in the same way.
I do this kind of debugging daily. I do this on game consoles. Attaching and launching on another pc. It's great!
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.
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
Printf doesn't help a stack out of memory causing a kernel panic reboot.
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.
Thanks for the tutorial, this opens up a new simpler possibility for me
I love the font in your terminal!
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
I recall using pigpio for all my pi gpio access needs. It was a pretty good library
Love Studio's dark background and character-cell font you set up there.
Thank you, Dave. Still working with the LED's, myself. This was a good C++ breakdown for me. Awesome!
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.
I enjoyed that Bill OReilly reference. 🤣
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.
Great video! Yes on a video to debug esp32 on VS Code! Love this channel!
Yes to debugging an ESP32. Man this is going to make my work on a Pi much better.
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.
Great video and reviews
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 :)
You sir. Just changed my life. Wow.
This is a gamechanger for me. Brilliant!
You are a hero and totally my favorite youtuber.
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.
Great video. Yes please on the ESP32 debug like a BOSS.
thanks for this one Dave , very helpful ! =)
I can magically do this over ssh with lldb. :-D I would DEFINITELY like to see this on an ESP32.
Excellent content, thanks for sharing.
Definitely a video on Esp32 debugging via Visual studio. And greetings to Jeff Geerling!
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.
I knew this was possible, but never had the patience to figure out how to configure it
Thanks for still doing videos
More to come!
"Let's try it live ... that's always advisable."
lmao
Very nice. Showing it for a PiCo would also be useful.
Just what I need for my school project
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!
Neat. Visual Studio is almost as featureful as emacs now! :P
Thanks Dave
I knew visual studio was this powerfull, i learned programming with Visual Studio btw
Another great Vid, would also like to see ESP32 version
Hi Dave, yes Please, it would be very nice with a video on setting up and debugging ESP32 on VSC (-:
Wish i knew this before, when i coded a LED spinning globe to display some bitmaps. Would had saved me a lot of time. :)
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.
I used this while working on a Linux target at a past job. Eclipse was horrendous for the big project we were working on.
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?
Hi Dave just been watching this again. Is this possible with VS Code ? Studio code is a bit rich for my budget.
Nice video. Do you have any info on the flame spiral looking thing in the top-right? Looks cool.
Yup, search for tiki lamp on the channel!
love your rolex submariner
Me too with remote ESP32 w/ vscode. Thanks!
Hi Dave. Cool video! Do you know if I can do such a thing with a c# console application and a raspberry pi 4?
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 :)
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?
ESP32 like a boss debugging - YES PLEASE !
Esp32 remote debug video would be handy
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
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)"
Nice!
In-fact, more ESP32 stuff would be epic. I loved this video tho!
Would love the esp32 vid!
ESP32 debugging video would be nice please. Also have you played with the Pi pico yet?
Yes, Please!!! Debugging on the ESP32 using VS-Code. Thanks
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
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.
“Let’s do it live like Bill O’Reilly”. 😂😂😂😂😂 hehe
i would love the vsc one cause i dont have access to visual studio due to linux.
Hey Dave, what processor you flexing there? Also, I'm going for a Timmy run. Want something?
Have you done something similar with VS Code? with python code
Ok, so what if the code was built elsewhere?
Could I still attach Visual Studio to a remote Linux process and debug it?
Yes, Dave! Yes I really would like to debug an ESP32 remotely!
Is it also possible for its little brother, the ESP8266?
Does the visual studio code have a similar extension?
In B4 he automates his truck and makes it self driving and first drives his truck with a laptop in debugger mode.
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.
Thanks!
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).
Friendly Dave
yes please show me how to debug the ESP32 like a BOSS with visual studio. i am very interested
"Let's try it live. That's always advisable."
😂🤣
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?
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?
I know, it *should* cross compile on the fast PC, but I am not sure if that's possible!
This was already streamed?
yes please for the esp32 video
I used to really enjoy debugging through GDB. After debugging daily via visual studio for years now, I think I'd hate using GDB.
Debugging like a boss: "Debug this by tomorrow or you will get fired."
ESP32 debugging for everyone!
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.
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 (
I would like to see an esp-32 debug
Please do a ESP32 setup tutorial, that would be awesome 🙂
I do code for the PI in python
I must admit when I saw the title I thought you'll be talking about Segger's J-link.
Nice video nevertheless.
Does VSCode do: 1. Python 2. Python Debugging & 3. Remote Python Debuggin on a Pi??
Yes to 1 & 2, don’t know on 3, but I’ve been putting it off all week, I’ll let you know.