This Is 100% How You Should Be Debugging | How to Use OpenOCD to Debug Embedded Software with GDB

  Рет қаралды 61,885

Low Level Learning

Low Level Learning

2 жыл бұрын

Finding bugs in your embedded code is hard. Without print statements and minimal LED's to show signs of life, finding out why your embedded code is crashing is never easy. In this video, we use OpenOCD to debug our embedded code and watch the system as it runs. OpenOCD provides a seamless interface via Telnet and GDB to allow an embedded developer to watch their system as it runs.
Low Level Merch!: www.linktr.ee/lowlevellearning
Code from the Video: www.github.com/lowlevellearni...
🏫 COURSES 🏫
Learn to code in C at lowlevel.academy
Follow me on Twitter: / lowlevellearni1
Follow me on Twitch: / lowlevellearning
Join me on Discord!: / discord

Пікірлер: 101
@edgeeffect
@edgeeffect 2 жыл бұрын
When you talk about debuggers please don't forget The Black Magic probe.... so cheap, so easy, so cheap! I debug my Blue Pill with... well.... another Blue Pill!!!
@Otakutaru
@Otakutaru 2 жыл бұрын
Would someone do a Black Magic Probe for dummies?
@syousufimam
@syousufimam 2 жыл бұрын
Yes, that's already there in my to-do list. Black Magic 101 ( From making your own BMP using blue pill to debugging STM 32 with BMP) It's like a Swiss knife for embedded enthusiast.
@andybrown-maw1593
@andybrown-maw1593 2 жыл бұрын
Thanks so much, you would not believe how few, straight forward explanations of how to do this there are out there.
@Kid420
@Kid420 2 жыл бұрын
This is great, I’ve always wanted to get into embedded systems programming and it seems as your channel is where I’ll start 😁🙏🏽
@gideonz74b
@gideonz74b 2 жыл бұрын
I think I learned more in the last 7 and a half minute than I had expected. Wow! Well done!
@eyalgerber
@eyalgerber 2 жыл бұрын
Really informative video. Thanks a lot. For me personally you hit the nail on the head with this video. It was exactly what I was looking for.
@chrisidema
@chrisidema Жыл бұрын
Thank you so much! It's really hard to find working up-to-date examples like this. So many old examples don't work anymore. I was able to get SWO working. And I also got debugging of the nRF using the st-link working.
@LowLevelLearning
@LowLevelLearning Жыл бұрын
Glad it helped!
@paulvohs9889
@paulvohs9889 2 жыл бұрын
I wasn't aware you could toggle the display format while inside gdb... I normally just run with --tui when I start. Will have to give that a go next time!
@jorgelinares1944
@jorgelinares1944 2 жыл бұрын
Thank you so much, it is really hard to find simple, relevant information regarding debugging on embedded
@magnoelmagnifico957
@magnoelmagnifico957 2 жыл бұрын
Wow, this is really cool! I didn't know gdb could do that
@LowLevelLearning
@LowLevelLearning 2 жыл бұрын
Thanks for watching!
@benarcher372
@benarcher372 3 ай бұрын
Perfect! I've done something similar with two rpi picos. Now I know also what openOCD actually does! Thanks.
@diegopinilla3431
@diegopinilla3431 2 жыл бұрын
great video! never debugged a microcontroller, but it doesn't seems too difficult.
@burningglory2373
@burningglory2373 Жыл бұрын
Almost every embedded system I have worked with, one of the engineers has dedicated a UART for a serial debugging console.
@hacksontable5850
@hacksontable5850 8 ай бұрын
Great tutorial, thank you.
@jbvalle
@jbvalle Жыл бұрын
Thank you sooo much for this tutorial!
@minirop
@minirop 2 жыл бұрын
that's why I love my little Arduino Zero, since it has an EDBG included. (I also have a jlink for my other boards)
@AlessioSangalli
@AlessioSangalli 2 жыл бұрын
Another fantastic video, thanks.
@LowLevelLearning
@LowLevelLearning 2 жыл бұрын
Glad you enjoyed it!
@felixbaum2180
@felixbaum2180 Жыл бұрын
awesome tutorial, thanks!
@OthnielCundangan
@OthnielCundangan 2 жыл бұрын
My only experience with embedded is from messing around with Arduino using PlatformIO in vscode. Is this better than PIO? Or maybe they can compliment each other?
@herbertpocket8855
@herbertpocket8855 Жыл бұрын
Hold up could I use one of these little chips instead of a PLC for some basic robotics? Like I would have to use different relays but that may be worth the sacrifice if I don’t have to use ladder programming
@thoyibbasarah3302
@thoyibbasarah3302 Жыл бұрын
I have 250pcs STM32 bluepill witch is same variant with this video (black jumper and wrong device ID). and having issue USB not recognized. Need help....
@jorgeguerrerorocha8140
@jorgeguerrerorocha8140 Жыл бұрын
Do you have any course/video playlist/certificate where i can learn to program stm32 based systems using this method?
@krishnakhandelwal9466
@krishnakhandelwal9466 Жыл бұрын
Thank you. Atleast I could see the ST-link V2 leds blink after so long. After target extended-remote localhost:3333 command, OpenOCD gives an error: "undefined debug reason 7 - target needs reset" and GDB gives: "0x00000000 in ?? ()" What does these two error mean and how to resolve it ?
@BinGanzLieb
@BinGanzLieb Жыл бұрын
whats the different to hit debug in eclipse ide with openocd or stlink, jlink Interface?
@MrKristian252
@MrKristian252 2 жыл бұрын
What's the difference between PyOCD and OpenOCD? I haven't used them directly, but I have used software that relies on PyOCD
@jakehallam2113
@jakehallam2113 11 ай бұрын
Jesus Christ, I've wasted a week being stuck with debugging because I forgot to add the "target extended-remote" step to my damn notes! Thanks for the video though, the instructions hold up for other boards too.
@SomeTechGuy666
@SomeTechGuy666 Жыл бұрын
FYI, in Fedora, the st-link package is stlink, not st-link. Also, there is no gdb-multiarch on Fedora. Use regular gdb but set arch once you start it. Great video.
@bennguyen1313
@bennguyen1313 2 жыл бұрын
Is there a command-line-parameter to scan the JTAG chain for devices? Any thoughts on using a GUI for debugging.. VSCode , Eclipse, or VisualGDB? For example VisualGDB supports OpenOCD, yet it doesn't support popular debuggers that use OpenOCD, like the Black Magic Pro. (Perhaps the BMP debugger is a little different as it doesn't seem to require any server software running on your computer (OpenOCD /STLink/urjtag/etc).. Instead, I think the Black Pill just appears as a remote (serial) GDB debugger.. with all the JTAG/SWD-TRACESWO support handled on the BMP itself?) Speaking of debuggers, I'm a little confused as to the difference between JTAG and SWO/SWD, and "ETM Traces". Segger has tons of different J-Link/J-Trace models.. and there's also plenty of cheap clones (EDU Mini, RealView U-Link2, etc). I have an AT ATMEL-ICE debugger, which supports CMSIS-DAP/SW/JTAG but no SWO. Perhaps this explains why ITM_SendChar doesn't work when I tried it with Keil (limited version 32KB). Does OpenOCD support the advanced streaming/tracing capability?
@arnabbiswasalsodeep
@arnabbiswasalsodeep 2 жыл бұрын
Jtag & swd are the same thing, except Jtag is more versatile & designed for multichip while swd removes the extra wires needed & their signalling requirements. Kind of think of spi, with more devices u need multiple chip enable lines. But if its just single device, then you can remove the chip enable signal & use few wires. Thus swd is Jtag compatible (since u can just not connect the wires from Jtag) but not vice versa (since swd doesn't generate & use the signals needed for daisy chaining Jtag)
@conorstewart2214
@conorstewart2214 2 жыл бұрын
Not to be that guy but is there a GUI for it? I’ve used the STM32CubeIDE and it has a debug mode that has all the functionality of this and probably more, like having a live view of global variables as the program runs and being able to see the disassembly, and it seems it would be easier just to scroll through your code whilst it running and just click to create a breakpoint wherever you want it, the interface in the IDE seems a lot easier to use with more functionality than this, so is there a non STM GUI version of this for other chips?
@brandonallen7748
@brandonallen7748 2 жыл бұрын
The IDEs are using these exact tools, the user just interacts with it through a GUI.
@conorstewart2214
@conorstewart2214 2 жыл бұрын
@@brandonallen7748 I know that, I was asking is there a non vendor specific version of the GUI.
@CandyHam
@CandyHam 5 ай бұрын
I had the same question. This seems like an overly obtuse command-ljne way to accomplish the same thing that's provided in cube IDE's GUI
@youtubeviewer7077
@youtubeviewer7077 3 ай бұрын
Almost every editor/IDE can talk to GDB, so it should be usable with any of them, it's a matter of correctly configuring them. There are videos on youtube on how to setup with VSCode and Eclipse (IIRC).
@TheStuartstardust
@TheStuartstardust 2 жыл бұрын
I think it might be easier to just code correct the first time 😁🤓😂 ..just kidding, really nice, did not know this could be done command line like this! Good content! 💪👌👍🤓
@LowLevelLearning
@LowLevelLearning 2 жыл бұрын
😁
@bob-ny6kn
@bob-ny6kn 2 жыл бұрын
Do you realize that you are completely correct? Debug allows you to learn to achieve that level. Back when I taught myself to code, I typed-in code from a paper form (hand written or printed), watched it fail, learned to recognize my failures, and poof - eventually coded for top airlines... where bugs do not fly well... So, I live by, you are alive by, and want to emphasize your post: "Code right or die."
@hackvlix
@hackvlix 2 жыл бұрын
@@bob-ny6kn Maybe one of the top airline's engineers should have done some debugging on their 737 MAX.
@bob-ny6kn
@bob-ny6kn 2 жыл бұрын
@@hackvlix eeek. That was a managerial failure. Reliving the space shuttle.
@hackvlix
@hackvlix 2 жыл бұрын
@@bob-ny6kn Fair enough. Debugging the management is probably harder.
@germanvelardez7947
@germanvelardez7947 Жыл бұрын
You are great man. That's all.
@s_i_m_o_n_e_n_g_e_l
@s_i_m_o_n_e_n_g_e_l Жыл бұрын
I could only find the jlink for like 500 Euros. Are they really that expensive?
@mustafaenany9388
@mustafaenany9388 Жыл бұрын
where do I get the configuration file for my controller : stm32f401ccu6
@Ma_X64
@Ma_X64 Жыл бұрын
Oscilloscope helps with debugging very much. Sometimes I can make all the job using only one or two pins to out either logical states through them or use them as a clock/data pair to see bytes on the oscilloscope directly.
@BinGanzLieb
@BinGanzLieb Жыл бұрын
thats bad
@Ma_X64
@Ma_X64 Жыл бұрын
@@BinGanzLieb that's fast)
@user-jr8kv2fh4e
@user-jr8kv2fh4e Жыл бұрын
@@Ma_X64 For sure, but how many of us have an oscilloscope?)
@user-io4sr7vg1v
@user-io4sr7vg1v 8 ай бұрын
​@@user-jr8kv2fh4ewe all should
@DeLaCruzer11
@DeLaCruzer11 4 ай бұрын
Are you sure you're not just trying to brag?
@adammontgomery7980
@adammontgomery7980 Жыл бұрын
Just spent 2 days banging my head against the desk trying to get I2C working on the blue-pill using the libopencm3 library. By the way, you have to gpio_set(I2CPORT, SDA|SCL) to get it to work (at least in master-mode). Question: I found some 'optimized out' variables while debugging INSIDE libopencm3 code. I don't know if the debugger symbols were optimized out or if the variables were, any thoughts? I changed the -O level in the library's makefile, and re-compiled. Thanks so much for these videos, man. I tried cubeIDE and hated it; register level programming is fun and all, but I want to actually get stuff done. You introduced me to this library that fits my style.
@coolink243
@coolink243 3 ай бұрын
Hey man, I am also trying to setup i2c using libopencm3 with no luck. Seems you have it set up. Could you help me out?
@adammontgomery7980
@adammontgomery7980 3 ай бұрын
@@coolink243 I'd like to. Have you got the libopencm3-template repo cloned?
@coolink243
@coolink243 3 ай бұрын
@@adammontgomery7980 hey man thanks for reaching out. Yes I have cloned the repo
@ikefir
@ikefir 2 жыл бұрын
Hello, LLL, may i humbly request a dive into GD32VF103 MCU. It's a 32-bit RISC-V chip. It is rather basic at the moment, but something tells me that as time goes on this architecture will become more and more mainstream. And a lot of folks would like to watch series on RISC-V assembly as well as corresponding GCC stack. Cheers.
@meanxmeanx1763
@meanxmeanx1763 2 жыл бұрын
Gigadevice does not seem interested in selling it. it's becoming harder & more expensive to find them on ali express. Too bad, it's a good enough chip.
@cebubikebootcamp
@cebubikebootcamp 2 жыл бұрын
I can't seem to run OpenOCD, why is it so hard to use this?
@MarkusBurrer
@MarkusBurrer 2 ай бұрын
The package st-link doesn't seem to exist on Ubuntu 24.04. Any suggestions?
@MarkusBurrer
@MarkusBurrer 2 ай бұрын
Package name is now stlink-tools
@user-sg2kr1wg8u
@user-sg2kr1wg8u Жыл бұрын
You are love my dear. I want to give you a hug!!
@hwhat
@hwhat 2 жыл бұрын
Hello,just found ur channel,i want to ask if arduino is a good entry to low level programming
@LowLevelLearning
@LowLevelLearning 2 жыл бұрын
Arduino is a great place to start!
@hwhat
@hwhat 2 жыл бұрын
@@LowLevelLearning thanks for the reply! I just saw ur video about arduino too,cant wait to get started
@edgeeffect
@edgeeffect 2 жыл бұрын
I "restarted" low level on Arduino. Then moved onto "AVR style" C. And then got back into assembly. But I wouldn't have done any of it without Arduino to get me started... it's a great introduction.
@Dygear
@Dygear 2 жыл бұрын
I take it it's possible to do this with rust code as well?
@LowLevelLearning
@LowLevelLearning 2 жыл бұрын
Teehee maybe
@shahinhaque95
@shahinhaque95 Жыл бұрын
Do you have an stm32 openocd tutorial on the raspberry pi? f4 preferably
@CandyHam
@CandyHam 5 ай бұрын
STM32F4 or Raspberry Pi? Which one?
@shahinhaque95
@shahinhaque95 5 ай бұрын
@@CandyHam not too sure, this was a year ago. I now use gdb for debugging
@CandyHam
@CandyHam 5 ай бұрын
Why would I do this instead of just using SWD's SWO pin via STM32Cube IDE?
@ninjoetsu
@ninjoetsu 4 күн бұрын
imo the power of openocd is that it can be used with many types of chip, and can use something more generic as your programmer such as a raspberry pi, which lets you program loads of kinds of chips without specialised hardware or software. Do whatever works for you really, i mainly use it so i don't have to buy an st link and so i can program and debug from the terminal
@kayakMike1000
@kayakMike1000 2 жыл бұрын
I brought this in for show and tell at work... They adopted it for a piece of legacy firmware.
@pingburner
@pingburner Жыл бұрын
ty
@Ruhgtfo
@Ruhgtfo 10 ай бұрын
First time heard thoughts it was about someone is keep washing his hand
@timsmith2525
@timsmith2525 10 ай бұрын
Maybe you could make a video on why unix/linux developers give their products just goofy names.
@emblink27
@emblink27 Жыл бұрын
This is a good demonstration for a basic understanding of the embedded system debug process. BUT IMHO it's a fucking nightmare to debug an actual project like that. Any ide GUI is much more convinient. And for the remote target, it's easier to log in to the PC with a debugger by RDP and use GUI.
@bob-ny6kn
@bob-ny6kn 2 жыл бұрын
When you say "bare metal" is that AtmelStudio or are you digging into the .h files to use lowest command possible. I just saw AtmelStudio is 1 GB in size (ugh) and Arduino is in Linux's Synaptic Package Manager and only 20 MB (yeay). Thank you.
@LowLevelLearning
@LowLevelLearning 2 жыл бұрын
Baremetal to me just means I'm using as little abstraction's as possible. Here we use libopencm3, which technically is an HAL but it doesn't add a ton of bloat middleware like Arduino or Atmel libraries.
@bob-ny6kn
@bob-ny6kn 2 жыл бұрын
@@LowLevelLearning thank you
@AlessioSangalli
@AlessioSangalli 2 жыл бұрын
@@LowLevelLearning or Rust 😂 ahah 😂😂
@LowLevelLearning
@LowLevelLearning 2 жыл бұрын
@@AlessioSangalli RUST IS THE FUTURE I WILL NOT BE CONVINCED OTHERWISE🤣
@brianwest7344
@brianwest7344 2 жыл бұрын
C++ is the future and I will be laughing at all the Rust programmers sleeping in shop doorways.
@m1geo
@m1geo 11 ай бұрын
Really, really good video! Thanks!
@BogdanSerban
@BogdanSerban 2 жыл бұрын
Nah just print everything to serial console and hope for the best. Why is all this stuff so damn complicated? I couldn't even understand what all of these do before watching this.
@AttilaAsztalos
@AttilaAsztalos Жыл бұрын
Sure, just as long as you're aware that depending on where in the code is the print used, how often it is triggered, how much data formatting it needs to do and how long the message is it can easily cause absolutely unacceptable delays, on an MCU that is more often than not expected to perform hard real-time duties.
@imlassuom
@imlassuom 2 жыл бұрын
First!!
@LowLevelLearning
@LowLevelLearning 2 жыл бұрын
:D
everything is open source if you can reverse engineer (try it RIGHT NOW!)
13:56
Low Level Learning
Рет қаралды 1,3 МЛН
EEVblog #499 - What is JTAG and Boundary Scan?
28:59
EEVblog
Рет қаралды 464 М.
🤔Какой Орган самый длинный ? #shorts
00:42
마시멜로우로 체감되는 요즘 물가
00:20
진영민yeongmin
Рет қаралды 30 МЛН
How to Debug HardFaults on ARM Cortex-M MCUs
57:58
Memfault
Рет қаралды 11 М.
GDB is REALLY easy! Find Bugs in Your Code with Only A Few Commands
7:29
Low Level Learning
Рет қаралды 200 М.
zig will change programming forever
9:34
Low Level Learning
Рет қаралды 251 М.
Remote Debugging ARM Chip with SWD/JTAG - Hardware Wallet Research #3
12:20
one of the craziest exploits i've ever seen
8:40
Low Level Learning
Рет қаралды 371 М.
Debugging Embedded Systems With GDB?
13:51
Jacob Sorber
Рет қаралды 44 М.
This is the BEST Board to Learn RISC-V Assembly.
17:52
Low Level Learning
Рет қаралды 83 М.
A Competition for Unreadable Code?
12:33
LaurieWired
Рет қаралды 157 М.
PART 52 || DIY Wireless Switch forElectronic Lights - Easy Guide!
1:01
HUBAB__OFFICIAL
Рет қаралды 66 МЛН
Это - iPhone 16 и вот что надо знать...
17:20
Overtake lab
Рет қаралды 88 М.
Отдых для геймера? 😮‍💨 Hiper Engine B50
1:00
Вэйми
Рет қаралды 1,2 МЛН
Как распознать поддельный iPhone
0:44
PEREKUPILO
Рет қаралды 2 МЛН
Это Xiaomi Su7 Max 🤯 #xiaomi #su7max
1:01
Tynalieff Shorts
Рет қаралды 906 М.