From 051b5c45c5284b891d0d7256da7ba0b46163d222 Mon Sep 17 00:00:00 2001 From: Hagen Fritsch Date: Sat, 4 May 2019 15:16:15 +0200 Subject: [PATCH 1/3] Fix includes in esp_err_to_name.c.in. esp_err_t provided by esp_err.h and thus is required and not optional. While the python script adds the header, it wraps it with an __has_include directive that is not supported on all compilers (notably GCC 4.8). Closes https://github.com/espressif/esp-idf/pull/3424 --- components/esp_common/src/esp_err_to_name.c | 1 + components/esp_common/src/esp_err_to_name.c.in | 1 + 2 files changed, 2 insertions(+) diff --git a/components/esp_common/src/esp_err_to_name.c b/components/esp_common/src/esp_err_to_name.c index 2f33b3ab96..1440eabb73 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 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 From 20bd142077cea61eff1ed3f49a4444f0418b6a98 Mon Sep 17 00:00:00 2001 From: Roland Dobai Date: Mon, 6 May 2019 14:57:52 +0200 Subject: [PATCH 2/3] Fix paths to the new esp_common in the ESP error code generator --- components/esp_common/src/esp_err_to_name.c | 14 +++++++------- tools/gen_esp_err_to_name.py | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/components/esp_common/src/esp_err_to_name.c b/components/esp_common/src/esp_err_to_name.c index 1440eabb73..5c36985765 100644 --- a/components/esp_common/src/esp_err_to_name.c +++ b/components/esp_common/src/esp_err_to_name.c @@ -60,7 +60,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 @@ -272,11 +272,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 @@ -323,7 +323,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 @@ -333,7 +333,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 @@ -361,11 +361,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/tools/gen_esp_err_to_name.py b/tools/gen_esp_err_to_name.py index 8db6290657..bd9d4b045b 100755 --- a/tools/gen_esp_err_to_name.py +++ b/tools/gen_esp_err_to_name.py @@ -46,7 +46,7 @@ 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'] 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 @@ -321,7 +321,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() From bfe5b139052bc7d6a9dda520b39e3caef53687f5 Mon Sep 17 00:00:00 2001 From: Roland Dobai Date: Mon, 6 May 2019 15:06:19 +0200 Subject: [PATCH 3/3] tools/gen_esp_err_to_name.py: Don't include already included headers --- components/esp_common/src/esp_err_to_name.c | 3 --- tools/gen_esp_err_to_name.py | 7 ++++++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/components/esp_common/src/esp_err_to_name.c b/components/esp_common/src/esp_err_to_name.c index 5c36985765..d0b17543ce 100644 --- a/components/esp_common/src/esp_err_to_name.c +++ b/components/esp_common/src/esp_err_to_name.c @@ -11,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 diff --git a/tools/gen_esp_err_to_name.py b/tools/gen_esp_err_to_name.py index bd9d4b045b..68a7d21125 100755 --- a/tools/gen_esp_err_to_name.py +++ b/tools/gen_esp_err_to_name.py @@ -48,6 +48,10 @@ ignore_dirs = ('examples') # macros from here have higher priorities in case of collisions 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 unproc_list = list() # errors with unknown codes which depend on other errors @@ -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()):