Modifying Arduino ESP32 setup with menuconfig

Hi pio guys, I am getting confused about how to change configurations with ESP’s menuconfig.

First, here is my environment from platformio.ini:

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino

and I am running VS Code using Ubuntu 20.04

I am having memory problems using secure TLS messages. I need to limit the max size of TCP messages. Apparently there is a parameter “TLS max message content length” available in menuconfig.

But I am having a lot of problems understanding how to use menuconfig in pio. First, I have seen the claim that it is accessible using the PIO CLI using “pio run -t menuconfig.” However, this just returns “Do not know how to make File target ‘menuconfig’” like it’s trying to compile. So maybe this isn’t available under the Arduino environment.

Some people also claim you can just edit sdkconfig.h, but I cannot find this file. Probably not available in the Arduino environment either.

I can probably run menuconfig in ESP-IDF but it is not clear to me how this links with the Arduino environment.

Can someone help with the best strategy?

Thanks, Kevin

1 Like

Exactly. When using framework = arduino, you are using a precompiled version of ESP-IDF that you cannot change. menuconfig works only for ESP-IDF projects.

Not available since not a ESP-IDF project.

Arduino-ESP32 is an extension on top of ESP-IDF (technical details: Using esp-idf library within the Arduino Framework (ESP32)) – you can actually start with an ESP-IDF project, activate the Arduino component and then write normal Arduino code while still having a fully configurable ESP-IDF base. The arduino-espidf-blink example shows just that. You should first try and clone this project to see if you can build it normally, then you can start making modifications to it as per docs.

1 Like

Hi Max
Thanks for your detailed explanations. I was able to get the arduino, espidf framework working, but it was hard. Here were some of the difficulties which you might find interesting:

  1. It took some iterations, but I got Arduino-espidf-blink to compile correctly. Then, I just inserted my own program into the project and when I compiled I saw more red than a slasher film.
  2. Most of the errors came from undefined compiler variables. I used build flags to solve this:
    build_flags =
    -D ESP32=1
    -D ARDUINO=10805
    -D ARDUINO_ARCH_ESP32=1
    ESP32 and ARDUINO are used in several parts of the Arduino libraries, and if not defined they create errors. Something in the Arduino framework defines these and is missing in the Arduino, espidf framework. Since I do not know where this is, I am worried there are other things I need to define. The odd value of ARDUINO I just copied from what if is in the Arduino framework.

The ARDUINO_ARCH_ESP32 flag is interesting because without it the Bluetooth module immediately crashes the system upon initialization.

  1. Speaking of Bluetooth, it was turned off by default in sdkconfig.h. The settings in this file are not the same as in the pre-compiled Arduino framework.
  2. I was also confused about sdkconfig options vs platformio.ini options. For example
    board_build.partitions = min_spiffs.csv
    seems to have no effect in platformio.ini but is instead set in sdkconfig. (I used menuconfig.)
  3. In general, it would have helped if I could have started with the same environment as in the Arduino framework.

It is also interesting that now my program takes about 8% less space. This is a good thing, but reminds me of this Far side drawing:

image

Thanks again, Kevin

1 Like

@anthro314 your record here was really helpful. To pay it forward for anyone coming along after me:

  • You don’t need to set those build flags any more, they’re done automatically (somehow). It isn’t done early enough for the library dependency finder to process conditional includes based on one of those when set to chain+ though - see this github issue
  • But you do need to set some items in sdkconfig.defaults (located alongside the platformio.ini file), including:
    • Cut & paste the items from the blink example sdkconfig.defaults
    • Disable the Idle watchdog timer on core 1. Under arduino, the loop() function runs continuously on that core so it’s never idle and the watchdog keeps tripping if you’re working the processor hard. It’s set to off in the esp32-arduino pre-compiled version. CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU1=n