Oct. 26, 2024, 11:45 p.m.
ESP32 Setup
First thing we need to do is to install all the software that's needed to build ESP32 projects. We do that by cloning the esp-idf repository.
To do that we create a folder withmkdir -p ~/espthe-poption means that no error is thrown if the folder already exists and also creates all parent folders. Then wecdinto the folder just created, and inside we use the commandgit clone --recursive https://github.com/espressif/esp-idf.git.
Now we need to set up the tools we need to compile projects and such things. For this, we go to the folder~/esp/esp-idfand run the command.install.sh esp32,esp32s2,esp32s3to install the packages for these three esp chips.
To add the installed tools to the path so we can use them from the command line, we add an alias to our.bash_aliasesfile. The line we need to add isalias get_idf='. $HOME/esp/esp-idf/export.sh'. So whenever we start to work on esp projects, we can just runget_idfand everything gets set up.
After that, we go back to the~/espfolder. With the commandcp -r $IDF_PATH/examples/get-started/hello_world .we copy an example project into the folder we are currently inside, so~/espin our case. Remember that before that command will work, we will need to runget_idf, the alias we created in the step before.
Now wecdinto the folder that we copied withcd hello_world/.
Inside that folder, we choose what esp chip we want to target, in my case it's an ESP32S3, so we runidf.py set-target esp32s3.
Then we runidf.py menuconfigwhich will open up a CLI menu to make some configurations.
Because I have an ESPS3 with octal ram I enter the serial flasher config and make the changes, I also set the flash size to 32MB because that's what my chip has. Now we can close the menu withESCand save withY.
Now we can build our program withidf.py build. If no errors occur, we can flash it onto the device withidf.py -p PORT flashwherePORTis the port you have to look up on your computer, on Linux likely something like/dev/ttyACM0.
The last step to see if everything is running fine is to monitor the output of our program we just uploaded. We do that withidf.py -p PORT monitor. When everything works, you should see some printout about your esp chip that restarts every ten seconds, you can stop the program withCTRL-].
Congratulations, you just created and uploaded a program on your ESP32. :)