diff --git a/components/esp_common/src/esp_err_to_name.c b/components/esp_common/src/esp_err_to_name.c index 2f33b3ab96..d0b17543ce 100644 --- a/components/esp_common/src/esp_err_to_name.c +++ b/components/esp_common/src/esp_err_to_name.c @@ -1,6 +1,7 @@ //Do not edit this file because it is autogenerated by gen_esp_err_to_name.py #include +#include "esp_err.h" #if __has_include("soc/soc.h") #include "soc/soc.h" #endif @@ -10,9 +11,6 @@ #if __has_include("esp_efuse.h") #include "esp_efuse.h" #endif -#if __has_include("esp_err.h") -#include "esp_err.h" -#endif #if __has_include("esp_http_client.h") #include "esp_http_client.h" #endif @@ -59,7 +57,7 @@ typedef struct { } esp_err_msg_t; static const esp_err_msg_t esp_err_msg_table[] = { - // components/esp32/include/esp_err.h + // components/esp_common/include/esp_err.h # ifdef ESP_FAIL ERR_TBL_IT(ESP_FAIL), /* -1 Generic esp_err_t code indicating failure */ # endif @@ -271,11 +269,11 @@ static const esp_err_msg_t esp_err_msg_table[] = { # ifdef ESP_ERR_IMAGE_INVALID ERR_TBL_IT(ESP_ERR_IMAGE_INVALID), /* 8194 0x2002 */ # endif - // components/esp32/include/esp_err.h + // components/esp_common/include/esp_err.h # ifdef ESP_ERR_WIFI_BASE ERR_TBL_IT(ESP_ERR_WIFI_BASE), /* 12288 0x3000 Starting number of WiFi error codes */ # endif - // components/esp32/include/esp_wifi.h + // components/esp_wifi/include/esp_wifi.h # ifdef ESP_ERR_WIFI_NOT_INIT ERR_TBL_IT(ESP_ERR_WIFI_NOT_INIT), /* 12289 0x3001 WiFi driver was not installed by esp_wifi_init */ # endif @@ -322,7 +320,7 @@ static const esp_err_msg_t esp_err_msg_table[] = { # ifdef ESP_ERR_WIFI_NOT_CONNECT ERR_TBL_IT(ESP_ERR_WIFI_NOT_CONNECT), /* 12303 0x300f Station still in disconnect status */ # endif - // components/esp32/include/esp_wps.h + // components/esp_wifi/include/esp_wps.h # ifdef ESP_ERR_WIFI_REGISTRAR ERR_TBL_IT(ESP_ERR_WIFI_REGISTRAR), /* 12339 0x3033 WPS registrar is not supported */ # endif @@ -332,7 +330,7 @@ static const esp_err_msg_t esp_err_msg_table[] = { # ifdef ESP_ERR_WIFI_WPS_SM ERR_TBL_IT(ESP_ERR_WIFI_WPS_SM), /* 12341 0x3035 WPS state machine is not initialized */ # endif - // components/esp32/include/esp_now.h + // components/esp_wifi/include/esp_now.h # ifdef ESP_ERR_ESPNOW_BASE ERR_TBL_IT(ESP_ERR_ESPNOW_BASE), /* 12388 0x3064 ESPNOW error number base. */ # endif @@ -360,11 +358,11 @@ static const esp_err_msg_t esp_err_msg_table[] = { # ifdef ESP_ERR_ESPNOW_IF ERR_TBL_IT(ESP_ERR_ESPNOW_IF), /* 12396 0x306c Interface error */ # endif - // components/esp32/include/esp_err.h + // components/esp_common/include/esp_err.h # ifdef ESP_ERR_MESH_BASE ERR_TBL_IT(ESP_ERR_MESH_BASE), /* 16384 0x4000 Starting number of MESH error codes */ # endif - // components/esp32/include/esp_mesh.h + // components/esp_wifi/include/esp_mesh.h # ifdef ESP_ERR_MESH_WIFI_NOT_START ERR_TBL_IT(ESP_ERR_MESH_WIFI_NOT_START), /* 16385 0x4001 */ # endif diff --git a/components/esp_common/src/esp_err_to_name.c.in b/components/esp_common/src/esp_err_to_name.c.in index 5f623c62dc..b9db3a05e6 100644 --- a/components/esp_common/src/esp_err_to_name.c.in +++ b/components/esp_common/src/esp_err_to_name.c.in @@ -1,6 +1,7 @@ @COMMENT@ #include +#include "esp_err.h" #if __has_include("soc/soc.h") #include "soc/soc.h" #endif diff --git a/tools/gen_esp_err_to_name.py b/tools/gen_esp_err_to_name.py index 8db6290657..68a7d21125 100755 --- a/tools/gen_esp_err_to_name.py +++ b/tools/gen_esp_err_to_name.py @@ -46,7 +46,11 @@ ignore_files = ['components/mdns/test_afl_fuzz_host/esp32_compat.h'] ignore_dirs = ('examples') # macros from here have higher priorities in case of collisions -priority_headers = ['components/esp32/include/esp_err.h'] +priority_headers = ['components/esp_common/include/esp_err.h'] + +# The following headers won't be included. This is useful if they are permanently included from esp_err_to_name.c.in. +dont_include = ['soc/soc.h', + 'esp_err.h'] err_dict = collections.defaultdict(list) # identified errors are stored here; mapped by the error code rev_err_dict = dict() # map of error string to error code @@ -265,7 +269,8 @@ def generate_c_output(fin, fout): elif re.match(r'@HEADERS@', line): for i in include_list: - fout.write("#if __has_include(\"" + i + "\")\n#include \"" + i + "\"\n#endif\n") + if i not in dont_include: + fout.write("#if __has_include(\"" + i + "\")\n#include \"" + i + "\"\n#endif\n") elif re.match(r'@ERROR_ITEMS@', line): last_file = "" for k in sorted(err_dict.keys()): @@ -321,7 +326,7 @@ def main(): parser = argparse.ArgumentParser(description='ESP32 esp_err_to_name lookup generator for esp_err_t') parser.add_argument('--c_input', help='Path to the esp_err_to_name.c.in template input.', default=idf_path + '/components/esp_common/src/esp_err_to_name.c.in') - parser.add_argument('--c_output', help='Path to the esp_err_to_name.c output.', default=idf_path + '/components/esp32/esp_err_to_name.c') + parser.add_argument('--c_output', help='Path to the esp_err_to_name.c output.', default=idf_path + '/components/esp_common/src/esp_err_to_name.c') parser.add_argument('--rst_output', help='Generate .rst output and save it into this file') args = parser.parse_args()