From 5cb212665ae62ebfd59fdf8d17c60c769657e6ea Mon Sep 17 00:00:00 2001 From: Darian Leung Date: Fri, 28 Jul 2023 11:30:16 +0200 Subject: [PATCH] soc: Move revision MAX/MIN static assert to esp_hw_support Previously, "soc/chip_revision.h" contained a static assert to check that the CONFIG_ESP_REV_MIN_FULL <= CONFIG_ESP_REV_MAX_FULL. There are two issues with this assert: - Contained in a header file, so it is only compiled if the "chip_revision.h" is included somewhere - CONFIG_ESP_REV_MIN_FULL and CONFIG_ESP_REV_MAX_FULL are defined in "esp_hw_support", which is a G0 component. This creates a reverse dependency of G0 on G1. This commit moves the static assert "revision.c" in "esp_hw_support" --- components/esp_hw_support/CMakeLists.txt | 1 + components/esp_hw_support/revision.c | 16 ++++++++++++++++ components/soc/include/soc/chip_revision.h | 4 ---- 3 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 components/esp_hw_support/revision.c diff --git a/components/esp_hw_support/CMakeLists.txt b/components/esp_hw_support/CMakeLists.txt index 6a3f494859..e7dd4aaabc 100644 --- a/components/esp_hw_support/CMakeLists.txt +++ b/components/esp_hw_support/CMakeLists.txt @@ -14,6 +14,7 @@ if(NOT BOOTLOADER_BUILD) "hw_random.c" "intr_alloc.c" "mac_addr.c" + "revision.c" "sleep_modes.c" "sleep_gpio.c" "sleep_mac_bb.c" diff --git a/components/esp_hw_support/revision.c b/components/esp_hw_support/revision.c new file mode 100644 index 0000000000..1ff72f8ce5 --- /dev/null +++ b/components/esp_hw_support/revision.c @@ -0,0 +1,16 @@ +/* + * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "sdkconfig.h" +#include "esp_assert.h" + +/* +Source used to store ESP chip revision and ESP-IDF minimum supported revision in the future. +Currently only used to hold static assert to check that the configured minimum and maximum supported chip revisions of +ESP-IDF are valid. +*/ + +ESP_STATIC_ASSERT(CONFIG_ESP_REV_MIN_FULL <= CONFIG_ESP_REV_MAX_FULL, "Minimum and/or maximum chip revision are invalid"); diff --git a/components/soc/include/soc/chip_revision.h b/components/soc/include/soc/chip_revision.h index 070de4918c..28d3736f30 100644 --- a/components/soc/include/soc/chip_revision.h +++ b/components/soc/include/soc/chip_revision.h @@ -6,8 +6,6 @@ #pragma once -#include "sdkconfig.h" - #ifdef __cplusplus extern "C" { #endif @@ -33,8 +31,6 @@ extern "C" { #define ESP_CHIP_REV_ABOVE(rev, min_rev) ((min_rev) <= (rev)) #define ESP_CHIP_REV_MAJOR_AND_ABOVE(rev, min_rev) (((rev) / 100 == (min_rev) / 100) && ((rev) >= (min_rev))) -_Static_assert(CONFIG_ESP_REV_MIN_FULL <= CONFIG_ESP_REV_MAX_FULL, "Min version must be less than Max version"); - #ifdef __cplusplus } #endif