In this assignment, you will create two versions of sdkconfig
(production and debug).
The only difference between the two is the logging: Debug will display all logs, while production has all the logs suppressed.
Assignment Detail#
You project must have the following configuration files:
sdkconfig.defaults
: containing theesp32-c3
targetsdkconfig.prod
: containing the logging suppression configuration (both app log and bootloader log)sdkconfig.debug
: containing the logging enable configurationprofile
files to simplify the build command
The final project folder tree is
.
|-- main
| |-- CMakeLists.txt
| |-- app_main.c
| `-- idf_component.yml
|-- profiles
| |-- debug
| `-- prod
|-- sdkconfig
|-- sdkconfig.debug
|-- sdkconfig.defaults
|-- sdkconfig.old
`-- sdkconfig.prod
Assignment steps#
We will:
- Create the production sdkconfig version (guided)
- Create a profile file (guided)
- Create the debug sdkconfig version
Create production version (guided)#
To create the debug configuration, we first need to find the log configuration.
Changing the configuration in menuconfig#
ESP-IDF: SDK Configuration Editor (menuconfig)
- Search for
log
- Uncheck the fields
- Bootloader Config → Bootloader log verbosity
- Log → Log Lever → Default log verbosity
- Search for
Create sdkconfig.prod
file#
The easiest way to find the configuration names that we changed is to run the save-defconfig
tool, which will generate a sdkconfig.defaults
file with only the changed parameters.
ESP-IDF: Save Default Config File (save-defconfig)
Looking at the new sdkconfig.defaults
, we can see two new configurations:
CONFIG_LOG_DEFAULT_LEVEL_NONE=y
CONFIG_BOOTLOADER_LOG_LEVEL_NONE=y
- Cut these configs and paste them into a
sdkconfig.prod
file
Build and flash#
To build the project use
idf.py -B build-production -DSDKCONFIG=build-production/sdkconfig -DSDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.prod" build
It will create a build-production
folder for this version.
To flash the project, you just need to specify the build folder, which already contains all the required information
idf.py -B build-debug -p <YOUR_PORT> flash monitor
Create Profile files#
To simplify the process we will create a profile file.
- Create a
profile
folder - Create a
prod
file inside the folder - Add the CLI parameters
-B build-production -DSDKCONFIG=build-production/sdkconfig -DSDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.prod"
We can now build the production version using
idf.py @profiles/prod build
Debug version#
Now you can do the same for the debugging setup. For this assignment step, you need to create and fill:
sdkconfig.debug
profile/debug
Assignment solution code#
Show solution code
skdconfig.defaults
# This file was generated using idf.py save-defconfig. It can be edited manually.
# Espressif IoT Development Framework (ESP-IDF) 5.4.2 Project Minimal Configuration
#
CONFIG_IDF_TARGET="esp32c3"
skdconfig.prod
CONFIG_LOG_DEFAULT_LEVEL_NONE=y
CONFIG_BOOTLOADER_LOG_LEVEL_NONE=y
skdconfig.prod
CONFIG_LOG_DEFAULT_LEVEL_INFO=y
You can find the whole solution project in the assignment_1_3 folder in the GitHub repo.
Next step: Lecture 2