Espressif32 (ESP-IDF) - how to enable debug mode via `platformio.ini`?

Hello everyone,
EDIT 23.07.2017:
I think the issue I described below regarding error related to upload_flags is because --debug option applies to OTA uploader, not the standard USB one.

Then the question is how should I define the log level via config file?
I see for instance CONFIG_LOG_DEFAULT_LEVEL in sdkconfig.h. But this file is generated and in its header it is said Automatically generated file; DO NOT EDIT.

How about the correct approach then?
Is there a way to enable debug (modify the log level) via platformio.ini file without defining custom constants to be handled programmatically later?


Previously defined question below. I modified my question as above.

I use ESP32 in ESP-IDF framework variant.
Unfortunately I’ve faced an issue and reported it here: Upload fails when upload_flags debug is set · Issue #30 · platformio/platform-espressif32 · GitHub .
Please find more detailed description under the link above. I will shortly describe the problem here again.

The problem is I’m not able to upload compiled firmware with debug option enabled as described in specification.

I’ve tried to set upload_flags in platformio.ini as following:

[env:esp32dev]
platform = espressif32
framework = espidf
board = esp32dev
upload_flags = --debug

The device is connect via USB.
When I try to upload the compiled firmware with command:

platformio run --target upload

It fails as following:

Auto-detected: /dev/ttyUSB0
Uploading .pioenvs/esp32dev/firmware.bin
usage: esptool write_flash [-h] [--flash_freq {40m,26m,20m,80m}]
[--flash_mode {qio,qout,dio,dout}]
[--flash_size FLASH_SIZE] [--ucIsHspi]
[--ucIsLegacy] [--no-progress] [--verify]
[--compress | --no-compress]
<address> <filename> [<address> <filename> ...]
esptool write_flash: error: argument <address> <filename>: Must be pairs of an address and the binary filename to write there
*** [upload] Error 2

When I remove upload_flags from the platformio.ini everything is ok and it ends with something like [SUCCESS] Took 44.22 seconds.

I’ve tried to study the specification and the Authentication and upload options section. I followed the instructions, unfortunately I couldn’t get it working.

Could you please tell me how to enable debug from plaftormio.ini?

Ok, problem solved :slight_smile:
I tired to use OTA related flags for USB upload, thus something could fail and those errors appeared.
I should have been using build_flags instead of upload_flags.
Then it’s simple. ESP-IDF doc says that “log library has two ways of managing log verbosity: compile time, set via menuconfig; and runtime, using esp_log_set_level function”.

It works very well!
To mute all debug messages I set it properly by providing LOG_LOCAL_LEVEL flag.
Please see an example platformio.ini content below:

[env:esp32dev]
platform = espressif32
framework = espidf
board = esp32dev
build_flags = -DLOG_LOCAL_LEVEL=ESP_LOG_NONE

To enable logging again I change the flag as below and set DEBUG or whatever according to spec:

-DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG

That’s all. Problem solved! :slight_smile:

Thanks for the info. Does -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG overrides the compile time setting that was done in menuconfig? (I presume that its’ a compile time setting, not a runtime setting).