🌈 ESP32-S3 Rainbow: ZX Spectrum Emulator Board! Get it on Crowd Supply →
View All Posts
read
Want to keep up to date with the latest posts and videos? Subscribe to the newsletter
HELP SUPPORT MY WORK: If you're feeling flush then please stop by Patreon Or you can make a one off donation via ko-fi

Time to get with the program and jump to ESP-IDF v6.0.1 in VS Code. I show you how to install the prerequisites (I’m on a Mac with Homebrew), run the ESP-IDF Installation Manager, spin up a Blink example for an ESP32-S3, tweak menuconfig (GPIO21, 500 ms), then build and flash—switching from stubborn USB JTAG to trusty UART when things fail. We check the monitor, bump CPU to 240 MHz, fix flash to 16 MB, peek at PSRAM, and give PCBWay a quick shout-out.

Related Content
Transcript

Okay, so the ESP-IDF6 released back in March. We are slightly behind.
If you actually look at the GitHub repo and the releases tab you can see they were already on
6.0.1 so it’s time to get with the program and get using the ESP-IDF V6.
Now there are a couple of things if you’re new to the ESP-IDF then you need to get some
prerequisites installed. So I’m on a Mac so I need to run this brew install command.
Now if you don’t know what brew is you can go off to this Homebrew link here. It’s on the
ESP-IDF website. I’ll put a link to this in the description. If you’re on Windows or Linux there’s
other instructions but make sure you get the prerequisites set up and installed. Now I’m going
to recommend using Visual Studio Code. There’s a really nice IDE and there’s a nice plugin for
the ESP-IDF. So let’s go over to VS Code and get that set up. So we go over to VS Code. Go here.
Here’s the plugins and extensions. Go here and if you search for ESP you’ll find the ESP-IDF
installation plugin. So let’s install that and then we should have this little icon appearing
here ESP-IDF Explorer. So click here. If you go to Advanced and then you click the open ESP-IDF
installation manager. So it’s going to ask us for where to download the application from. So you see
here EIM executed were not found. Choose a download mirror. Now unless you’re in China just pick GitHub.
If you are in China pick the expressive one. It might be faster. So that’s launched the ESP-IDF
installation manager. So we’re on a fresh install so there’s nothing installed at the moment.
We’ll just click new installation. Now there’s two options you can do. Well there’s four options but
two options that you should probably care about. There’s the easy installation and the offline
installation. Now easy installation should work but if you have problems what you can do is an offline
installation and if you go to this website here then you can download the offline files. Now they
are quite big three to four gigabytes but if you’re on a dodgy internet connection and you can
download these to an SD card or something you might have better luck. But let’s stick with the easy
installation. So we’ll do start easy installation and it can take between 10 to 45 minutes. It really
depends on your internet connection. Now while that’s chugging along let’s do a quick shout out
to PCBWay. So they produce these PCBs and this dev board that I’m using to test this out. They’re
really good. Check out a link to them in the description and get yourself some PCBs made up.
It’s great fun. So what’s happening right now? So at the moment it’s downloading the ESP-IDF.
So it’s cloning that from GitHub. Now this step can take a while so we’ll have to sit here for a bit
and watch the spinning download button. Okay so that’s the first stage done. We’re now pulling
down all the tools. So tool three of 10 and you can see in the log it’s doing a bunch of work.
So it’s got 39 seconds at the moment. This progress bar does tend to be a bit random. So you can see
it’s actually going up even though we’re making progress. So we’ll leave this chugging along.
It should download the tools and it’s normally fairly quick. So five of 10 and again this will
depend on your internet connection. If you have a really fast internet connection this will be
happening very quickly. If you want a slow internet connection make yourself a cup of tea and sit back
and relax. Okay so we’re almost done. It’s done the last of the tools. We’re on to the next stage
setting up Python. Hopefully this will be quite quick. There we go. Onto configuring environment.
12 seconds left. Getting very exciting. I feel like we should have a drum roll.
Although it does seem to be stuck on 12 seconds. Okay we’re done. So if we go to the dashboard
we’ve got installation complete. You can now see we have ESP-IDF-V6.01. Now you can update this and
do all sorts of stuff really handy. But let’s get into VS code and actually create a project.
So we’re back in visual studio code. So what we can do now is we can do new project wizard.
So there’s a little plus thing here. New project wizard. It asks us which ESP-IDF version we want
to use. So we’ve just installed 6.0.1 so I think we should use that. And now we can go to the
example. So let’s have the get started examples and we’ll do the classic blink sketch. So let’s
create a project using the blink template. So I’ll call it blink. Let’s call it blinky1 because I
might have several blinkies. And I’ve got a work folder. I think it’s capital W. Let me just check.
Yes. Capital W. Now I would be very careful on operating systems that don’t take into account
file system case and case sensitivity because the tools do. So if I put a lowercase W I’d end up with
all sorts of problems because it’s actually an uppercase W. Now our IDF target. So I’m using an
ESP32-S3 and I’m going to use the USB JTAG to do the actual programming. And that’s all we need to
do. Now I’ve got the board plugged in right now and it should be this one but we’ll leave it on
detect and see if that works. And that’s all we need. So now we can create the project.
And now let’s open the project. So here’s our blink sketch. Now if you’re using the Arduino
IDE normally you’re probably going to be a bit shocked at all the stuff here but it’s actually
a lot simpler than it may look. So if we look in main you can find our blink example main.c
and if we come into here what you’ll find if we scroll down is there is just this app main. Now
with the ESP-IDF the way you configure things is using the menu config command. So if we go back
to our ESP-IDF plugin and if we look down these things here you can see STK configuration editor
menu config. So let’s click on that. Now here’s all the settings that you don’t normally get to
play with when you’re using the Arduino IDE. But the main thing we want to look at right now is
this example configuration. We can see all these settings. So we’re not using a LED strip. I have
a simple LED on a GPIO pin. So let’s have a look at KiCad. So if we look here GPIO 21 is driving
an LED and now on this board it’s not actually blue I think it’s green because I just put random
LEDs on. So let’s change this to GPIO. Now our GPIO number is 21 and let’s make it flash every
half a second. So 500 milliseconds. So we’ll save that and now we can go back to the ESP-IDF plugin
and we can select build project and then flash device. Now you can also use these icons down
here. So this spanner will build the project. So that’s built and then this lightning symbol will
flash the project. So flash device and we’re going to use JTAG for the flashing because we’re
connected over USB and we failed. Oh dear why did we fail? So let’s use the right port and it didn’t
work. So I’m going to put my thing into programming mode. So I’m going to hold down reset and boot and
let’s try flashing again and we still failed. Well this is very annoying. So what I’m going to do is
I’m going to change the programming thing to use UART. So we do that by selecting flash method.
I’ll change to UART and let’s try flashing again. Okay well that’s working fine. So now
if I hit the reset button we should get our thing blinking and it starts blinking and of course we
can also monitor the device. So if we monitor let’s have a look. So there’s a few interesting
things here. First one is our CPU frequency is 160 megahertz. Now we do know that we can go up to 240
megahertz. The other thing that’s interesting is this thing here. So SPI flash is detected that we
have 16 megs of flash but in our binary header we said we only had two megs. So this can all be
changed in the SDK config. So let’s go in here and if we go into our SDK config editor and if we
search for CPU then we should be able to find the CPU frequency. So let’s stick that on 240 megahertz
and now let’s find the flash size. So if we look for flash then you can see it defaults to two
megabytes we’ve got 16 megabytes. So if we save that and then if we build the project and flash
again so that’s built and then we hit flash and now if we monitor the device when we boot up
we should see that our CPU speed if we scroll down so CPU frequency 240 megahertz and again we
should see that we have 16 megabytes of flash now. So let’s try and find that where do we see that
printed out. We may not see anything because now it actually matches so it doesn’t need to print
out the warning oh there we go SPI flash size 16 megabytes. Now the other thing is my board has PS
RAM so let’s go and find that option and set that up as well. So here we go search for PS RAM so we
have SPI RAM I know it’s octal and that should be all we need we can also bump up the thing to
80 megahertz make it faster so if we save that and then rebuild and we’ll flash the device again
and monitor then now when we boot up if we scroll down we should see it initializing the PS RAM.
So here we go found 8 megabytes PS RAM device set the speed to 80 megahertz the SPI RAM worked okay
test okay so that’s great we have our 8 megabytes of PS RAM as well so brilliant so it is actually
really straightforward to doing this and there’s so many options you can configure so in this menu
config there’s all sorts of things you can do really interesting to play around with and see
what you can do now I want to see if I can get this JTAG thing working as well because you can
do debugging which is really really cool so I can see here we have the open OCD server so let’s try
starting that and here’s the problem so I think it’s already running so what I’m going to do
I’m going to open up a terminal and what I’m going to do is search for OCD
now I think it’s this thing here and I think it’s been running from a previous thing
so what I’m going to do is I’m going to kill that and now if we open the OCD server and we start it
up then I think that’s now working so what I’m going to do is go back here to the ESP IDF thing
I’m going to change the flash method put it back to JTAG
now let’s try hitting flash again and see if that works
so that’s much better flash successfully now what we can do is we can actually debug things
so if I go to the blink example what we can do is set a breakpoint so let’s try putting a breakpoint
here and now let’s try debugging so we’ll go here I have no idea if this will really work
but let’s give it a go so I think we go here somewhere there should be a debug command
here we go launch debug so let’s try that
cool we’ve stopped on a breakpoint it does stop at the start of app main if we just hit continue
then you can see we come here now if we step over this we should get the log messages coming out
now if we go to the seal your monitor I’m hoping they might appear
we do start monitoring let’s see if we step through
do we get the log messages coming out we don’t how annoying oh it’s picked the wrong port hasn’t it
let’s pick the correct port there we go right then now if we step through this
there we go turning the lead off and if we keep stepping through
turn the lead on so pretty powerful and obviously you’ve got all the variables and registers here
pretty interesting stuff so anyway hopefully that gives you an idea of how easy it is to get up and
running with the espidf I mean the code is pretty simple if we look at this blink led thing it’s
very similar to the Arduino code so set the GPIO level use the blink GPIO change it to high or low
so very very simple so let me know what you think in the comments espidf or arduino which do you
prefer


HELP SUPPORT MY WORK: If you're feeling flush then please stop by Patreon Or you can make a one off donation via ko-fi
Want to keep up to date with the latest posts and videos? Subscribe to the newsletter
Blog Logo

Chris Greening

> Image

atomic14

A collection of slightly mad projects, instructive/educational videos, and generally interesting stuff. Building projects around the Arduino and ESP32 platforms - we'll be exploring AI, Computer Vision, Audio, 3D Printing - it may get a bit eclectic...

View All Posts