Is it possible to program menuConfig settings in code?

KeithInAsia
Posts: 29
Joined: Thu Sep 26, 2019 5:44 am

Is it possible to program menuConfig settings in code?

Postby KeithInAsia » Mon May 29, 2023 7:40 pm

Other than doing text comparison and replacement in the sdkconfig file -- is there any slick way to control the menuConfig selections programmatically?

Can anyone point me in a direction?

captain_morgan
Posts: 42
Joined: Wed Dec 09, 2015 6:39 pm

Re: Is it possible to program menuConfig settings in code?

Postby captain_morgan » Tue May 30, 2023 4:30 pm

is there any slick way to control the menuConfig selections programmatically?
Probably not in the way you are thinking. The contents of the sdkconfig file are macro definitions, anywhere they appear in the code, they are replaced with that value that macro represents. What this means is once the code is running, those macro definitions don't even exist anymore, just their values.

example

Code: Select all

#include "freertos/FreeRTOS.h"
#define TAG "main"
....
ESP_LOGI(TAG, "app_main running");
After the preprocessing step runs, the code that is actually compiled looks like

Code: Select all

#include "freertos/FreeRTOS.h"
....
ESP_LOGI("main" "app_main running");
There is one way to change the values, but as it can only happen once, before the code starts running, it's not super useful, unless you're making the changes based on other sdkconfig values.

Code: Select all

#ifdef TAG
#undef TAG
#define TAG "main2"
#endif

MicroController
Posts: 1729
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: Is it possible to program menuConfig settings in code?

Postby MicroController » Tue May 30, 2023 7:39 pm

captain_morgan wrote:
Tue May 30, 2023 4:30 pm
There is one way to change the values,...
... which actually won't work either: None of the (IDF) components you use, and which #include "sdkconfig.h" for their configuration, will "see" the new definition from your code.

As I understand it, the OP doesn't want to reconfigure the SDK from inside the ESP application (code) but wants to set/override certain values e.g. from the command line w/o having to interactively navigate through the menuconfig TUI. - But I can't seem to find a solution for that either.
It would be kind-of doable if the sdkconfig.h were generated as a set of

Code: Select all

#ifndef X
#define X ...
#endif
so that one could override values via -D compiler arguments.

Or, more simple, if sdkconfig.h would contain a line like #include "custom_sdkconfig.h" at the end, with a custom_sdkconfig.h which would be created empty by default but would not be re-generated by the build system. (Or even using __has_include("custom_sdkconfig.h") to also work in the absence of the file.)

MicroController
Posts: 1729
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: Is it possible to program menuConfig settings in code?

Postby MicroController » Tue May 30, 2023 8:20 pm

Just found idf.py confserver which could help get the trick done.

KeithInAsia
Posts: 29
Joined: Thu Sep 26, 2019 5:44 am

Re: Is it possible to program menuConfig settings in code?

Postby KeithInAsia » Wed May 31, 2023 11:41 am

I have read your posts... very helpful information.

I'm trying to automate the application of security features and I'm not seeing a way forward without controlling items in menuConfig...

I have been setting eFuses -- but the application won't respond as expected. Then when I go back and set the menuConfig appropriately, then everything works.

I was just trying to get past the manual portion of this.

K.

Who is online

Users browsing this forum: Google [Bot] and 143 guests