From a14fb9ab2827e666ca9a9544e325a65434c74c8b Mon Sep 17 00:00:00 2001 From: Thomas Watson Date: Sat, 7 Dec 2024 20:36:32 -0600 Subject: [PATCH] AP_HAL_ESP32: regenerate sdkconfig after sdkconfig.defaults change 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. --- Tools/ardupilotwaf/esp32.py | 31 +++++++++++++++++++++++++++++++ libraries/AP_HAL_ESP32/README.md | 6 +++--- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/Tools/ardupilotwaf/esp32.py b/Tools/ardupilotwaf/esp32.py index 5e30e39ce3a8e..11df54d6ceae9 100644 --- a/Tools/ardupilotwaf/esp32.py +++ b/Tools/ardupilotwaf/esp32.py @@ -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""" @@ -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""" diff --git a/libraries/AP_HAL_ESP32/README.md b/libraries/AP_HAL_ESP32/README.md index eda355171e504..9874574a57a20 100644 --- a/libraries/AP_HAL_ESP32/README.md +++ b/libraries/AP_HAL_ESP32/README.md @@ -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: ```