From 8f74271d5d5d4257a07cfce7db6fa713483a6f7d Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Thu, 8 Aug 2019 15:27:22 +1000 Subject: [PATCH] esp_rom: Fail immediately if the wrong SoC's header file is included --- components/bootloader_support/src/bootloader_clock.c | 11 +++++++++-- components/esp_rom/include/esp32/rom/ets_sys.h | 4 ++++ components/esp_rom/include/esp32s2beta/rom/ets_sys.h | 6 ++++++ components/spi_flash/spi_flash_os_func_app.c | 1 - components/spi_flash/spi_flash_os_func_noos.c | 11 ++++++++--- components/wpa_supplicant/src/rsn_supp/wpa.h | 6 ++++++ components/xtensa/debug_helpers.c | 8 +++++++- 7 files changed, 40 insertions(+), 7 deletions(-) diff --git a/components/bootloader_support/src/bootloader_clock.c b/components/bootloader_support/src/bootloader_clock.c index c851295af..d61f7a943 100644 --- a/components/bootloader_support/src/bootloader_clock.c +++ b/components/bootloader_support/src/bootloader_clock.c @@ -11,13 +11,20 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -#include "esp32/rom/uart.h" -#include "esp32/rom/rtc.h" +#include "sdkconfig.h" #include "soc/soc.h" #include "soc/rtc.h" #include "soc/dport_reg.h" #include "soc/efuse_periph.h" +#ifdef CONFIG_IDF_TARGET_ESP32 +#include "esp32/rom/uart.h" +#include "esp32/rom/rtc.h" +#else +#include "esp32s2beta/rom/uart.h" +#include "esp32s2beta/rom/rtc.h" +#endif + void bootloader_clock_configure(void) { // ROM bootloader may have put a lot of text into UART0 FIFO. diff --git a/components/esp_rom/include/esp32/rom/ets_sys.h b/components/esp_rom/include/esp32/rom/ets_sys.h index fe1dacbf2..3485f0d40 100644 --- a/components/esp_rom/include/esp32/rom/ets_sys.h +++ b/components/esp_rom/include/esp32/rom/ets_sys.h @@ -25,6 +25,10 @@ #include "soc/soc.h" #endif +#ifndef CONFIG_IDF_TARGET_ESP32 +#error "This header should only be included when building for ESP32" +#endif + #ifdef __cplusplus extern "C" { #endif diff --git a/components/esp_rom/include/esp32s2beta/rom/ets_sys.h b/components/esp_rom/include/esp32s2beta/rom/ets_sys.h index 653ca2826..f52994ad8 100644 --- a/components/esp_rom/include/esp32s2beta/rom/ets_sys.h +++ b/components/esp_rom/include/esp32s2beta/rom/ets_sys.h @@ -19,6 +19,12 @@ #include "soc/soc.h" +#include "sdkconfig.h" + +#ifndef CONFIG_IDF_TARGET_ESP32S2BETA +#error "This header should only be included when building for esp32s2beta" +#endif + #ifdef __cplusplus extern "C" { #endif diff --git a/components/spi_flash/spi_flash_os_func_app.c b/components/spi_flash/spi_flash_os_func_app.c index df4f131ab..7328250eb 100644 --- a/components/spi_flash/spi_flash_os_func_app.c +++ b/components/spi_flash/spi_flash_os_func_app.c @@ -13,7 +13,6 @@ // limitations under the License. #include -#include "esp32/rom/ets_sys.h" #include "esp_attr.h" #include "esp_spi_flash.h" //for ``g_flash_guard_default_ops`` #include "esp_flash.h" diff --git a/components/spi_flash/spi_flash_os_func_noos.c b/components/spi_flash/spi_flash_os_func_noos.c index 4b494279b..0e4cc34a8 100644 --- a/components/spi_flash/spi_flash_os_func_noos.c +++ b/components/spi_flash/spi_flash_os_func_noos.c @@ -13,12 +13,17 @@ // limitations under the License. #include +#include "sdkconfig.h" #include "esp_flash.h" - -#include "esp32/rom/ets_sys.h" -#include "esp32/rom/cache.h" #include "esp_attr.h" +#ifdef CONFIG_IDF_TARGET_ESP32 +#include "esp32/rom/ets_sys.h" +#include "esp32/rom/cache.h" +#else +#include "esp32s2beta/rom/ets_sys.h" +#include "esp32s2beta/rom/cache.h" +#endif static esp_err_t start(void *arg) { diff --git a/components/wpa_supplicant/src/rsn_supp/wpa.h b/components/wpa_supplicant/src/rsn_supp/wpa.h index c3475eafe..b7c9a3588 100644 --- a/components/wpa_supplicant/src/rsn_supp/wpa.h +++ b/components/wpa_supplicant/src/rsn_supp/wpa.h @@ -15,7 +15,13 @@ #ifndef WPA_H #define WPA_H +#include "sdkconfig.h" + +#ifdef CONFIG_IDF_TARGET_ESP32 #include "esp32/rom/ets_sys.h" +#else +#include "esp32s2beta/rom/ets_sys.h" +#endif #include "utils/common.h" #include "common/defs.h" #include "common/wpa_common.h" diff --git a/components/xtensa/debug_helpers.c b/components/xtensa/debug_helpers.c index 564e6eb15..74f66a6cc 100644 --- a/components/xtensa/debug_helpers.c +++ b/components/xtensa/debug_helpers.c @@ -12,14 +12,20 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "sdkconfig.h" #include "esp_types.h" #include "esp_attr.h" #include "esp_err.h" #include "esp_debug_helpers.h" -#include "esp32/rom/ets_sys.h" #include "soc/soc_memory_layout.h" #include "soc/cpu.h" +#ifdef CONFIG_IDF_TARGET_ESP32 +#include "esp32/rom/ets_sys.h" +#else +#include "esp32s2beta/rom/ets_sys.h" +#endif + bool IRAM_ATTR esp_backtrace_get_next_frame(esp_backtrace_frame_t *frame) { //Use frame(i-1)'s BS area located below frame(i)'s sp to get frame(i-1)'s sp and frame(i-2)'s pc