From 5863b66ba5f509fd2efd81185197faf13604692a Mon Sep 17 00:00:00 2001 From: "harshal.patil" Date: Fri, 17 Jan 2025 14:09:35 +0530 Subject: [PATCH 1/2] fix(soc): Fix incorrect reserved bits calculation in xts_pseudo_round_conf --- components/soc/esp32h2/register/soc/spi_mem_struct.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/components/soc/esp32h2/register/soc/spi_mem_struct.h b/components/soc/esp32h2/register/soc/spi_mem_struct.h index 189a7db5eb..b8af9dcebe 100644 --- a/components/soc/esp32h2/register/soc/spi_mem_struct.h +++ b/components/soc/esp32h2/register/soc/spi_mem_struct.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -1039,7 +1039,7 @@ typedef volatile struct spi_mem_dev_s { uint32_t reg_pseudo_rng_cnt : 3; /*xts aes peseudo function base round that must be performed.*/ uint32_t reg_pseudo_base : 4; /*xts aes peseudo function base round that must be performed.*/ uint32_t reg_pseudo_inc : 2; /*xts aes peseudo function increment round that will be performed randomly between 0 & 2**(inc+1).*/ - uint32_t reserved11 : 27; /*reserved*/ + uint32_t reserved11 : 21; /*reserved*/ }; uint32_t val; } xts_pseudo_round_conf; @@ -1080,6 +1080,11 @@ typedef volatile struct spi_mem_dev_s { } spi_mem_dev_t; extern spi_mem_dev_t SPIMEM0; extern spi_mem_dev_t SPIMEM1; + +#ifndef __cplusplus +_Static_assert(sizeof(spi_mem_dev_t) == 0x400, "Invalid size of spi_mem_dev_t structure"); +#endif + #ifdef __cplusplus } #endif From 0cfa86670a33e49e7b32fa4114386dd3e8959bcb Mon Sep 17 00:00:00 2001 From: laokaiyao Date: Fri, 17 Jan 2025 20:26:23 +0800 Subject: [PATCH 2/2] ci(check): update check_soc_struct_headers script --- .gitlab/ci/pre_check.yml | 2 +- tools/ci/check_soc_struct_headers.py | 19 +++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/.gitlab/ci/pre_check.yml b/.gitlab/ci/pre_check.yml index 5b1adf2429..29e89745e2 100644 --- a/.gitlab/ci/pre_check.yml +++ b/.gitlab/ci/pre_check.yml @@ -72,7 +72,7 @@ check_chip_support_components: expire_in: 1 week script: - python tools/ci/check_soc_headers_leak.py - - find ${IDF_PATH}/components/soc/**/include/soc/ -name "*_struct.h" -print0 | xargs -0 -n1 ./tools/ci/check_soc_struct_headers.py + - find ${IDF_PATH}/components/soc/**/include/soc/ ${IDF_PATH}/components/soc/**/register/soc/ -name "*_struct.h" -print0 | xargs -0 -n1 ./tools/ci/check_soc_struct_headers.py - tools/ci/check_esp_memory_utils_headers.sh check_esp_err_to_name: diff --git a/tools/ci/check_soc_struct_headers.py b/tools/ci/check_soc_struct_headers.py index f121296f50..efdcfe86c2 100755 --- a/tools/ci/check_soc_struct_headers.py +++ b/tools/ci/check_soc_struct_headers.py @@ -1,12 +1,11 @@ #!/usr/bin/env python -# SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD +# SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD # SPDX-License-Identifier: Apache-2.0 - # A check script that just works at the time of writing... # # also builds a structure tree for further reference # -# Input file format must be similiar to those headers generated by regtool, or this script makes no sense at all +# Input file format must be similar to those headers generated by regtool, or this script makes no sense at all # # Known limitation: # 1. won't accept /* ... */ /* ... */': badly behavior with multiline comment @@ -21,18 +20,18 @@ # 5. typedef volatile struct xxx{}: xxx must exists # # Otherwise won't fail but warning - import os import re import sys from typing import Any +from typing import Optional class MemberField: member_type = '' bitfield = None - def __init__(self, m_type: str, m_bits: int=None) -> None: + def __init__(self, m_type: str, m_bits: Optional[int]=None) -> None: self.member_type = m_type self.bitfield = m_bits @@ -74,7 +73,7 @@ class SoCStructureHeaderChecker: # named typedef, or named struct/union. referd but will not delete __temp_ref_types = dict() # type: dict - def __expand_type(self, member_type: str, bitfield: int=None) -> Any: + def __expand_type(self, member_type: str, bitfield: Optional[int]=None) -> Any: if member_type == 'uint32_t': return MemberField(member_type, bitfield) if bitfield is not None: @@ -121,7 +120,7 @@ class SoCStructureHeaderChecker: # skip empty line return self.__getline() if rawline.count(';') > 1: - print('\033[0;34mINFO\033[0m: line: {}: possibily multiple expression within same line'.format(self.__linecount)) + print('\033[0;34mINFO\033[0m: line: {}: possibly multiple expression within same line'.format(self.__linecount)) print(rawline) return rawline @@ -129,7 +128,7 @@ class SoCStructureHeaderChecker: ret_val = 0 # first check for anonymous register structs if is_typedef and is_volatile and name is None: - print('\033[0;31mERROR\033[0m: line {}: annoymous struct'.format(self.__linecount)) + print('\033[0;31mERROR\033[0m: line {}: anonymous struct'.format(self.__linecount)) ret_val = -1 node_tree = dict() bitcount = 0 @@ -252,7 +251,7 @@ class SoCStructureHeaderChecker: ret_val = 0 # first check for anonymous register structs if is_typedef and is_volatile and name is None: - print('\033[0;31mERROR\033[0m: line {}: annoymous union'.format(self.__linecount)) + print('\033[0;31mERROR\033[0m: line {}: anonymous union'.format(self.__linecount)) ret_val = -1 node_tree = dict() # type: Any has_struct_count = 0 @@ -334,7 +333,7 @@ class SoCStructureHeaderChecker: node_tree[match_obj.groups()[1]] = member_node else: if '*' not in match_obj.groups()[0]: - print('\033[0;31mERROR\033[0m: line {}: unknown type {}'.format(self.__linecount, match_obj.groups()[0])) + print('\033[0;31mWARN\033[0m: line {}: unknown type {}'.format(self.__linecount, match_obj.groups()[0])) else: print('\033[0;33mWARN\033[0m: line {}: pointer type {}'.format(self.__linecount, match_obj.groups()[0])) continue