Espressif IDF – Menuconfig

Last Updated on 8 January 2021 by Suffocation

Eine der schönen Erungenschaften der IDF ist die Menü gesteuerte Konfiguration. Noch schöner finde ich, dass eigenen Konfiguratiospunkte erstellt werden können. Diese werden dann automatisch in das Haupt Menü eingehängt. Vorab:

  • Die Biliothek „esp_system.h“ wird im Quellcode benötigt sonst klappts nicht
  • Nach Änderungen am Menü ein idf.py clean durchführen

To create such a configuration point, I'll use the program from the example Console output und ersetze den Text durch einen Konfigruationspunkt. Benannt werden diese grundsätzlich mit CONFIG_ , gefolgt von einen sprechenden Namen.

‚); document.write(‚

‚); document.write(‚

‚);

Damit diese Konfiguration im Menuconfig angezeigt wird, muss noch eine Datei „Kconfig.projbuild“ erstellt werden. Diese enthält zusätzliche Informationen zum Konfigurationspunkt:

Now, start Menuconfig (>idf.py menuconfig):

Still building and seeing what it looks like (idf.py build flash -p COM7 monitor)

Output with configured text.

Es gibt nicht nur die Möglichkeit Text zu formatieren, Zahlen und Auswahlisten sind ebenfalls möglich. Hier ein paar Beipiele

menu "Example Configuration"
config MOSI_GPIO
       int "MOSI GPIO number"
       range 0 46
       default 23 if IDF_TARGET_ESP32
       default 35 if IDF_TARGET_ESP32S2
       help
           GPIO number (IOxx) to SPI MOSI. ...

config INVERSION
       bool "Enable Display Inversion"
       default false
       help
           Enable Display Inversion.

choice
      bool "Mesh AP Authentication Mode"
      default WIFI_AUTH_WPA2_PSK
      help
          Authentication mode.

      config WIFI_AUTH_OPEN
          bool "WIFI_AUTH_OPEN"
      config WIFI_AUTH_WPA_PSK
          bool "WIFI_AUTH_WPA_PSK"
      config WIFI_AUTH_WPA2_PSK
          bool "WIFI_AUTH_WPA2_PSK"
      config WIFI_AUTH_WPA_WPA2_PSK
          bool "WIFI_AUTH_WPA_WPA2_PSK"
endchoice

config MESH_GLOBAL_DNS_IP
       hex "Global DNS"
       depends on MESH_USE_GLOBAL_DNS_IP
       default 0x08080808
       help
           The IP address of global DNS server that is used
           for internal IP subnet formed by the mesh network
           if MESH_USE_GLOBAL_DNS_IP is enabled.
           Note: The IP address is in platform (not network)
           format.
...

endmenu

Es sind auch Abhängigkeiten zwischen Kondifgurations Punkten möglich. Diese werden mit dem Schlüsselwörtern "depends on" gefolgt von einem oder mehreren Konfigurationsname mit logischen verknüpfungen. Logische Verknüpfungen sind || (oder) oder && (und).

.config SW1_PIN
		int "SW1 pin"
		range 0 39
        default 36
		depends on SW1_ENABLE
		help
			Switch 1 Gpio pin
config SW2_ENABLE
		bool "SW2 Enable"
        default false
		help
			Enable Switch 2
config SW2_PIN
		int "SW2 pin"
		range 0 39
        default 35
		depends on SW2_ENABLE
		help
			SW2 Gpio pin
config LONG_PRESS_ENABLED
		bool "Long press enabled"
        default false
		depends on (SW1_ENABLE || SW2_ENABLE)
		help
		   If this is enabled the system
		   distinguishes between long pressed buttons
                   and short pressed buttons
	config LONG_PRESS_TIME_MS
		int "Long press time ms"
		range 1000 8000
        default 2000
		depends on LONG_PRESS_ENABLED
		help
		  How long should a button be pressed to be
                  marked as a long press; if it is not long pressed
                  it is a short press
...

Conclusion

Die Idee Konfigurationen auszulagern ist nicht neu. Sie aber mit eine Menü zu versehen finde ich sehr charmant gelöst.

Verwandte Beiträge

Main contribution

Sources

IDF - Configuration

KConfig Guide

KConfig Extensions

DateChangeAuthor
08.01.2021Post createdSuffocation

2 thoughts on “Espressif IDF – Menuconfig

  1. Hello Jürgen,

    As stated in the imprint, I do not create guides for beginners but merely document what I develop myself. I don't think professionals need this guide. However, I am happy to make adjustments/additions if you write to me exactly where the problem lies.

    To illustrate the project structure, an example project is linked on GitHub, where all necessary files are in the correct positions. Is that not enough? What can I do better here?

    Your comment is about a report on using Menuconfig via the console; where does VSCode fit into that? Yes, operation is also possible with VSCode, but here it's based on a menu controlled by the mouse. However, it's also the case for me that VSCode works one day and then doesn't with the next version. Therefore, I would first try to get the IDF running on the console (CMD).

    NCurses menus were/are often used under Linux (or similar in the Windows console), which is why I haven't gone into more detail here. Basically, you only need Enter to get into a submenu or edit a menu item, and Esc to get back out. The arrow keys help with navigation, possibly plus Tab to jump or S to save.

    The IDF is definitely not particularly suitable for beginners, unfortunately there's no way around it for new ESPs, as the implementation for the Arduino GUI always lags a bit behind. Otherwise, as a beginner, I would recommend using the Arduino GUI.

    Hello
    Stefan

  2. Hello,

    I can't share your enthusiasm for menuconfig.

    Yes, it can be called from VS Code/PlatformIO. The madness starts with some keyboard shortcuts at the bottom, but the most important ones (j and k) are missing.

    And it's not as simple as just creating a „kconfig.projbuild“ and starting menuconfig. Where does it need to be so that it's recognised?

    There is an „o“ key for loading, but 'j' and 'k' don't even work in the window that appears. So how do I navigate to the path where kconfig.projbuild is located?

    Your blog seems geared more towards professionals who already know everything. As a beginner, you just spend hours wading through the internet, and Espressif's documentation is also of little help.

    Greetings

Leave a Reply

Your email address will not be published. Required fields are marked *