-
Notifications
You must be signed in to change notification settings - Fork 134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unify sdkconfig configuration options #38
Conversation
I don't like it either, but I also do not understand: how come the |
That's right, values from sdkconfig.defaults will be used if sdkconfig file doesn't exist yet, or if some value is not yet found in sdkconfig (docs). sdkconfig file will be updated by the build process:
There are two ways to treat sdkconfig file:
Depending on their preference, we see customers using either of these options. |
Normally the `cmake` crate sets this variable depending on the current cargo profile, but we don't want this as it interferes with esp-idf's own configuration. The esp-idf is configured with kconfig and in that system there already exist options for configuring optimization settings (using sdkconfig). Additionally, while compiling the esp-idf, the bootloader is compiled too and setting `CMAKE_BUILD_PROFILE` would also interfere with bootloader optimization options which are seperate from the application's.
Native build now more closely mirrors the pio build. The sdkconfig can now be specific per build profile (debug/release) by adding the suffix `.<profile>`. Additionally, one can also now specify the chip or both the chip and profile. Selecting the sdkconfig has the following precendence: 1. `<path>.<profile>.<chip>` 2. `<path>.<chip>` 3. `<path>.<profile>` 4. `<path>`
Generates a sdkconfig.defaults file that contains the rust optimization level approximately translated to the kconfig options.
This implementation has the same capabilities as the native now.
As far as I've seen it, the sdkconfig will always be updated if not all options are specified in it. So for example, if you comment an option out, the file will be updated with the option set based on the defaults. But this makes forwarding the compiler optimization options redundant after the first build, because then the sdkconfig is already fully specified and for example I see three options on how to proceed here:
Option 1 matches the pio build, option 2 matches the behavior of an We could sidestep the I think option 1 makes the most sense for us. |
You are right, I didn't consider the "sdkconfig was edited manually" situation. This will also cause sdkconfig to be updated. Am I right that if we eliminate the issue of setting compiler optimization via sdkconfig (and replace it, for instance, with standard CMake -DCMAKE_BUILD_TYPE=Release type of setting) then we no longer need to handle sdkconfig in esp-idf-sys in any special way? Is there anything other than the build optimization level that we need to control sdkconfig for? |
Yes. Maybe in the future there are other configuration options that we want to set the cargo way instead of sdkconfig, but I don't see any others now. But we still have to choose either the way it is for the pio build or the native esp-idf way. |
Prevents the sdkconfig from being updated by the build, which maches the pio build behavior.
Okay, I've implemented option 1 and with this, the This PR should be ready for merge. Please tell me if you have any comments or suggestions. |
Go ahead, merge and publish! :) |
Mention that `ESP_IDF_SDKCONFIG_DEFAULTS` and `ESP_IDF_SDKCONFIG` is also supported by the pio build.
This mostly implements the plan outlined here.
Native and pio build now match with the sdkconfig configuration. Though I've implemented in addition to specifying the profile in the file name (like pio required before), that one can now also specify only the mcu or both. Also, the
.<profile>
requirement for pio has been lifted.Selecting the sdkconfig now has the following precendence:
<path>.<profile>.<chip>
<path>.<chip>
<path>.<profile>
<path>
For the native build, the optimization configurations now don't conflict anymore. They are set using a generated
sdkconfig.defaults
file from the cargoopt-level
anddebug
settings.One quirk remains for the native build though:
When the path to the
sdkconfig
is specified, it is always updated to the configurations used in the latest build. So, if you leave some things unspecified in thesdkconfig
it will be set after the build, which makessdkconfig.defaults
redundant after the first build. Because we copy the files in the pio build this does not happen there (i.e. the sdkconfig used for the build and generated after the build are separate).This seems to be intended behavior for normal esp-idf C projects, but doesn't make sense for me. Please tell me what you think about this.