DEV Community

Tomáš Pilný
Tomáš Pilný

Posted on

How to compile Arduino-ESP32 core with ESP_LOGx

Why?
In Arduino IDE you can set the core debug level, however, this only sets debug level for files in Arduino-esp32 but the core which is distributed as a precompiled library in .sdk files, located in your Arduinio installation folder, is unaffected - the debug level remains the default “error”.

What?
If you want to change the core code or debug level, you need to clone the repo: https://github.com/espressif/esp32-arduino-lib-builder, make the modifications there, compile and apply the changes (automatically by the build script).

How?
There are 2 basic approaches. Both of them involve editing file esp32-arduino-lib-builder/configs/defconfig.common.

The first option is to edit the file directly and then build.
Later you can git restore configs/defconfig.common to go back.

The second option is to copy the file cp configs/defconfig.common configs/defconfig.debug, edit the debug version and then compile.

Open the defconfig file
vim configs/defconfig.common or vim configs/defconfig.debug

Edit line 45 containing by default CONFIG_LOG_DEFAULT_LEVEL_ERROR=y to one of the following lines depending on your desired log level:

CONFIG_LOG_DEFAULT_LEVEL_NONE=y # No output
CONFIG_LOG_DEFAULT_LEVEL_ERROR=y # Errors - default
CONFIG_LOG_DEFAULT_LEVEL_WARN=y # Warnings
CONFIG_LOG_DEFAULT_LEVEL_INFO=y # Info
CONFIG_LOG_DEFAULT_LEVEL_DEBUG=y # Debug
CONFIG_LOG_DEFAULT_LEVEL_VERBOSE=y # Verbose - All of the above
Enter fullscreen mode Exit fullscreen mode

Then simply build the libs for all SoCs or one specific SoC. Note that building for all SoCs takes a lot of time, so if you work only with one specific SoC, build only for that one.
If you have copied the defconfig file and the debug settings are in file configs/defconfig.debug add flag debug
example : ./build.sh debug
Build all SoCs: ./build.sh
Build only selected SoC: ./build.sh -t <soc>
The exact text to choose the SoC:

  • esp32
  • esp32s2
  • esp32c3
  • esp32s3 Example: ./build.sh -t esp32 A wrong format or non-existing SoC will result in the error sed: can't read sdkconfig: No such file or directory

Top comments (0)