Step-by-Step: STM32 Development Environment with OpenOCD and Visual Studio Code (Linux)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys welcome back how's it going So today we're gonna try to set up STM to develop an environment on Linux system uh with Visual Studio code cortex debug and open OCD so I already prepare a fresh installation of sodium OS so if you're not familiar with what sorting OS is Sony noise is a Linux distribution based on Ubuntu it uses a genome and xfc test of environment as default just like the many versions of Ubuntu distributions the desktop is heavily customized in order to help users transition from Windows and Mac OS easily software on Windows can be run with wine and play on Linux allowing users to run compatible Windows software like Microsoft Office solid noise creators maintain three free edition of operating system and Provo Edition for purchase so do check out their website at https all right so without further Ado let's get started in sorry no s let's open a terminal and type sudo apt gets update it's always with the every Linux distribution you have to update and upgrade to get the latest fixes box fixes and you know package update from the repo all right next is sudo apt-get upgrade hit yes for that so this is going to take some times to do the upgrade so I'm gonna fast forward the video and I'll be right back all right that's done so we're gonna start installing the tools that we need so type in sudo fdget install git build Essentials and then GCC arm non-ab so this is a compiler that we need for stmg2 and then lib to and then leap USB that's 1.0 USB there's one dot o dash o the staff and then GDP multi-arch hit enter for that provide the password hit the s for that and let's give it some times to collect all of those packages So within uh Ubuntu 2004 or Zodi NOS there is also open OCD package but seems like that open OCD package is too old so we have to build it from source and those some some of those linked to lip tool and lib USB are dependency for that okay so I'm going to reboot the system and I'll be that back all right we're back so open a browser and I'm going to show you where we can download open OCD source code so type in in a browser github.com slash open OCD org slash open OCD hit enter and that's where the source could open OCD on GitHub page GitHub repo now go to the terminal and type in git clone https last github.com slash open ocd-org slash open OCD and this will create a clone of that repository into your local Drive and we're gonna build from there let's give it some time all right that's done let's change into that directory so CD open OCD and type in bootstrap so this command is going to collect all dependency it needs to build um open OCD all right now let's deal with the configuration so slice dot class configure I want to install it under the user local and then I enable stdi enable also that's the link and enable jail link so if you have drilling you can also use with open OCD and the stm32 discovery that I have it has built-in as the link so we're going to use that and if you have a generic ftdi board like ftdi-232 or fpdi-2232 and you can also use opencd so we're going to make some videos on that as well so make sure that you subscribe and like the video if you if you enjoy watching it okay that's done let's type make so this is going to take some time so I'll be right back I'm gonna fast forward the video all right that's done now we can install it so type in sudo make install and provide the password and installation is done now type in openlocity.v to see if it's there yes version 0.12 you want to see the location type which open OCD and yes that's a that was the prefix that we configured slash user slash logo all right so next we're gonna download visual studio code so type in a browser Visual Studio code and hit download so I'm on zorin or Ubuntu base so download the Debian package all right that's done let's take a look inside the folder where it gets downloaded so it's under home downloads so you could actually double click this Debian package it's going to install it for you but I'm gonna show you the way I do it on the terminal why why you ask if you do it on a terminal you you can you know if there is an error message you can capture it in the terminal I changed that directory so you can see it's there so the command is to do the package this eye and the Debian package all right here's a studio installation is done so I'm gonna close this because you're not gonna use the terminal anymore we don't need a browser as well let's open Visual Studio code and that's where's the goodies so what we're gonna do when this is the first time you install a visual studio code you're gonna go to the extension and we're gonna install extension that we need first is C and C plus plus so that is a C and C plus plus extension by Microsoft hit install you might want to install the extension pack as well so hit that install next we're gonna try to find core text debug extension so the first one hit install make sure it's by marriage 25 and then sorry and then make file tools this is also by Microsoft hit install and then git graph so if you work a lot with the Version Control Git Version Control git graph is kind of the graphical user interface of it it's really useful I love that next is serial monitor so if we use a lot of printf or uart messages then this is like a good extension that you might want to have let's clean that and take a look at the progress here so we got everything they're all installing so yeah I'll be right back I'm gonna fast forward this all right so extension installation is done now we're gonna grab the leap open cm3 examples so with the stm32 there is an open source sleep open cm3 instead of using the SDM Hall as alternative and they also provide examples and this is the GitHub repository of the examples so remember that link that's where we can clone their examples so let's open Terminal and type it clone https colon says less github.com slash lip open cm3 slash lip open cm3 dash examples all right cloning is done now let's change into that directory and type in git sub module nipped next command is git sub module update but before I hit enter I'm going to show you why we need to execute GitHub module command so if you look into the folder this is where we clone the lib open cm3 examples and if you go into examples you can see that they're all populated in there but if the if you go to lib opencm3 it's still empty and which is this is actually the library that we need right so they have a separate repo so when you type in git sub module update give someone to you need an update it's going to populate for you as you can see here in this folder this file manager all right it's done now I'm gonna close that we don't need a terminal we don't need a browser so let's focus on visual uh Studio code and open that folder that we just cloned go into lib open cm3 and hit open and I'm gonna put the check mark on this yes I trust the orders and as you can see here this is the exact same folder structure as you can see in the file manager so I have sdm3 to F4 Discovery so I'm gonna go with example St under 2 F4 STM for Discovery and I'm going to choose a simplest one which is mini blink let's open the terminal so there is an integrated terminal within two Visual Studio code which is cool I'm gonna extend this a little bit and now you type make in here and if this is the first time you build uh with lip open cm3 it's gonna build all the libraries for different mcus different architecture for the first time so is it give it some times I'm gonna I'm gonna fast forward this video and be right back right there's an error message there but if you type make again sorry make that's actually going to build the executable for you that's the elf and the map so the error is not actually for uh scm32 F4 it's just for pack qc5xx all right so next we're gonna go to run in debug and create a launch Json file and hit that app configuration cortex debugs open OCD and here you're gonna have to point to where the executable is so that will be examples stm32 F4 stmg2f for discovery mini blink and slash mini bling Dot right there you go in the next go to the config files you're going to add this you're going to point this to the location of interface and also the target so that would be in user local share open OCD slash Scripts slash interface slash St link we got stealing on board on stm4 and the target is USR local share open OCD slash Scripts slash Target it's less stm32f4 x dot CFG and save that and now we're going to create a new files called as settings.json I'm gonna add two configuration here for contact debugs the first one is cortex debug dots GDP paths which is that there you go GDP path and point it to slash USR slash spin slash GDB multi-r or multi-arch the second correlation is cortex debug Dot open OCD path and you need to point that to USR local bin slash open OCD and save that and let's double check what we have written here looks good looks good to me so let's go ahead to debug this that's the debug configuration and let's hit that small triangle button next to it and we should be good to go well not quite so let's see what's the error message is um let's go to terminal and see what that is okay so seems like this is an access permission you know in Linux system you always uh you need to get access permission to access a USB so that's what happened and yeah I'm not sure this is a UDF thing so I'm gonna pause the video I'm gonna try to search for it on Google and be right back all right so I'm back so I what I did was I copied this error and then I open a browser and just search for it it's just a typo fix and I click the second link the sub Link in there and it gives me This Thread so you can go and read the thread but the most important part is that there is a user manual that provides back to you with a step by step on how to do it so we're not gonna do all all the steps here remember what I said that it was permission issue so what we want to do is actually to find the steps so let's search for the access there you go the enable access to USB device so there is a step one blah blah you can read this so if you have a nasty link and jilling you might want to do this uh to set up the UDF rule is Step number two and step number three and well this is actually the step number four that we need so we're gonna need to add our user uh into plug Dev group and that's how to get the permission so I copy and paste that execute here and let's go back to visual studio code hit that triangle button and there you have it now you can uh glass and debug scm32 with the cortex debugs extension on your social Studio code so you can hit play hit run I mean hit run it's faucet step over it step in step out and of course you can also stop it and that's how easy it is so yeah so today we have uh set up htm32 development environment under Linux system uh let me know if you have any comment or questions in the comment section down below and yeah so please subscribe and and like the video if you enjoy watching check also my patreon page and show your support and other than that see you in the next video and happy coding
Info
Channel: Eka Susilo
Views: 4,580
Rating: undefined out of 5
Keywords: STM32, STM32 Debugging, STM32 Programming, OpenOCD, Visual Studio Code, VSCode, Cortex-Debug, libopencm3, Makefile, GNU ARM Toolchain, Free and Open Source, Development Environment, STM32F4, STM32F1, STM32F2, STM32F3, ARM Cortex-M, ARM Cortex-M0, ARM Cortex-M3, ARM Cortex-M4, Beginner STM32, STM32F4-Discovery, STM32 Discovery, ST-Link, Debug, ARM, MCU, C Language, Embedded System, Embedded System Programming, Embedded System Developer, Maker, DIY, Firmware, Hackable, Embeddable, Zorin OS, Ubuntu
Id: FNDp1G0bYoU
Channel Id: undefined
Length: 22min 44sec (1364 seconds)
Published: Thu Sep 29 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.