Skip to content

Commit

Permalink
AP_HAL_ESP32: regenerate sdkconfig after sdkconfig.defaults change
Browse files Browse the repository at this point in the history
Ensures the sdkconfig does not get out of date as updates are made to
the defaults. The sdkconfig can still be manually changed for testing.
  • Loading branch information
tpwrules authored and tridge committed Dec 9, 2024
1 parent 535f687 commit a14fb9a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
31 changes: 31 additions & 0 deletions Tools/ardupilotwaf/esp32.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,24 @@ def bldpath(path):

#env.append_value('GIT_SUBMODULES', 'esp_idf')

# delete the output sdkconfig file when the input defaults changes. we take the
# stamp as the output so we can compute the path to the sdkconfig, yet it
# doesn't have to exist when we're done.
class clean_sdkconfig(Task.Task):
def keyword(self):
return "delete sdkconfig generated from"

def run(self):
prefix = ".clean-stamp-"
for out in self.outputs:
if not out.name.startswith(prefix):
raise ValueError("not a stamp file: "+out)
dest = out.parent.abspath()+"/"+out.name[len(prefix):]
if os.path.exists(dest):
os.unlink(dest)

# waf needs the output to exist after the task, so touch it
open(out.abspath(), "w").close()

def pre_build(self):
"""Configure esp-idf as lib target"""
Expand All @@ -74,8 +92,21 @@ def pre_build(self):
)

esp_idf_showinc = esp_idf.build('showinc', target='esp-idf_build/includes.list')

# task to delete the sdkconfig (thereby causing it to be regenerated) when
# the .defaults changes. it uses a stamp to find the sdkconfig. changing
# the sdkconfig WILL NOT cause it to be deleted as it's not an input. this
# is by design so the user can tweak it for testing purposes.
clean_sdkconfig_task = esp_idf_showinc.create_task("clean_sdkconfig",
src=self.srcnode.find_or_declare(self.env.AP_HAL_ESP32+"/sdkconfig.defaults"),
tgt=self.bldnode.find_or_declare("esp-idf_build/.clean-stamp-sdkconfig"))

esp_idf_showinc.post()

# ensure the sdkconfig will be deleted before the cmake configure occurs
# that regenerates it
esp_idf_showinc.cmake_config_task.set_run_after(clean_sdkconfig_task)

from waflib import Task
class load_generated_includes(Task.Task):
"""After includes.list generated include it in env"""
Expand Down
6 changes: 3 additions & 3 deletions libraries/AP_HAL_ESP32/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ https://docs.espressif.com/projects/esp-idf/en/latest/get-started/ -
in expansion of macro 'configSUPPORT_STATIC_ALLOCATION'
warning: "CONFIG_SUPPORT_STATIC_ALLOCATION" is not defined

this means your 'sdkconfig' file that the IDF relies on is perhaps a bit out of date or out of sync with your IDF.
this means your 'sdkconfig' file that the IDF relies on is perhaps a bit out of date or out of sync with your IDF. This should not happen, please file a bug if it does!

You can simply remove sdkconfig file and idf build system will recreate it using sdkconfig.defaults, which should fix the problem.
Changing the sdkconfig.defaults file will cause the sdkconfig to be deleted and regenerated. The sdkconfig will also be regenerated if it is manually deleted.

If you need to change sdkconfig, you can edit sdkconfig manually or to use ninja menuconfig:
If you need to change sdkconfig (which will not cause it to be deleted), you can edit sdkconfig manually or to use ninja menuconfig:

So double check you are using the correct IDF version:
```
Expand Down

0 comments on commit a14fb9a

Please sign in to comment.