From 3049ac6dbbc67088789223f4af6895e6e5e0b9ab Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Tue, 4 Jan 2022 00:18:55 +0100 Subject: [PATCH 1/2] ci: improve checks for Wi-Fi/PHYlibraries - add missing Wi-Fi header MD5 checks for esp32c3, esp32s3 - check PHY libraries for references to ets_printf, in addition to checking Wi-Fi libraries. This used to happen until libphy.a was moved into a separate submodule. Reported in https://github.com/espressif/esp-phy-lib/issues/3 --- .gitlab/ci/build.yml | 4 -- .gitlab/ci/pre_check.yml | 9 +++- components/esp_wifi/test_md5/test_md5.sh | 9 +++- tools/ci/check_blobs.sh | 63 ++++++++++++++++++++++++ 4 files changed, 77 insertions(+), 8 deletions(-) create mode 100644 tools/ci/check_blobs.sh diff --git a/.gitlab/ci/build.yml b/.gitlab/ci/build.yml index 4da37d1782..7e28c6212d 100644 --- a/.gitlab/ci/build.yml +++ b/.gitlab/ci/build.yml @@ -84,10 +84,6 @@ build_examples_pytest_esp32c3: - export EXTRA_CXXFLAGS=${PEDANTIC_CXXFLAGS} # Only do the default cmake build for each target, remaining part are done in the build_template_app job - tools/ci/build_template_app.sh ${BUILD_COMMAND_ARGS} - # Check if there are any stray printf/ets_printf references in WiFi libs - - cd components/esp_wifi/lib - - for dir in esp32 esp32s2; do test $(xtensa-esp32-elf-nm $dir/*.a | grep -w printf | wc -l) -eq 0; done; - - for dir in esp32 esp32s2; do test $(xtensa-esp32-elf-nm $dir/*.a | grep -w ets_printf | wc -l) -eq 0; done; # build-related-pre-check-jobs ------------------------------------------------ # Build at least one project for each target at earliest stage to reduce build cost for obvious failing commits diff --git a/.gitlab/ci/pre_check.yml b/.gitlab/ci/pre_check.yml index 77e97933cb..d0121ac7cf 100644 --- a/.gitlab/ci/pre_check.yml +++ b/.gitlab/ci/pre_check.yml @@ -78,15 +78,20 @@ test_check_kconfigs: script: - python ${IDF_PATH}/tools/ci/test_check_kconfigs.py -check_wifi_lib_md5: +check_blobs: extends: .pre_check_base_template tags: - build variables: - SUBMODULES_TO_FETCH: "components/esp_wifi/lib" + SUBMODULES_TO_FETCH: "components/esp_wifi/lib;components/esp_phy/lib" script: + # Check if Wi-Fi library header files match between IDF and the version used when compiling the libraries - IDF_TARGET=esp32 $IDF_PATH/components/esp_wifi/test_md5/test_md5.sh - IDF_TARGET=esp32s2 $IDF_PATH/components/esp_wifi/test_md5/test_md5.sh + - IDF_TARGET=esp32s3 $IDF_PATH/components/esp_wifi/test_md5/test_md5.sh + - IDF_TARGET=esp32c3 $IDF_PATH/components/esp_wifi/test_md5/test_md5.sh + # Check if Wi-Fi, PHY, BT blobs contain references to specific symbols + - bash $IDF_PATH/tools/ci/check_blobs.sh check_fuzzer_compilation: extends: .pre_check_base_template diff --git a/components/esp_wifi/test_md5/test_md5.sh b/components/esp_wifi/test_md5/test_md5.sh index 635e5338c9..2c7321718b 100755 --- a/components/esp_wifi/test_md5/test_md5.sh +++ b/components/esp_wifi/test_md5/test_md5.sh @@ -15,17 +15,22 @@ fi case $IDF_TARGET in esp32) PREFIX=xtensa-esp32-elf- - LIB_DIR=esp32 ;; esp32s2) PREFIX=xtensa-esp32s2-elf- - LIB_DIR=esp32s2 + ;; + esp32s3) + PREFIX=xtensa-esp32s3-elf- + ;; + esp32c3) + PREFIX=riscv32-esp-elf- ;; *) echo "Invalid IDF_TARGET value: \"${IDF_TARGET}\"" exit 1 ;; esac +LIB_DIR=${IDF_TARGET} ELF_FILE=test.elf diff --git a/tools/ci/check_blobs.sh b/tools/ci/check_blobs.sh new file mode 100644 index 0000000000..f84cd3b49f --- /dev/null +++ b/tools/ci/check_blobs.sh @@ -0,0 +1,63 @@ +#!/usr/bin/env bash +set -euo pipefail + +if [ -z "${IDF_PATH:-}" ]; then + echo "IDF_PATH must be set before running this script" + exit 1 +fi + +failed="" + +# check_lib_symbols +# +# If the given library contains references to the listed symbols, prints +# a message and adds the library to "failed" list. +function check_lib_symbols { + lib="$1" + symbols="${@:2}" + syms_file="$(mktemp)" + # for symbols="foo bar" create grep search argument "foo\|bar" + symbols_args="${symbols// /\\|}" + errors=0 + nm -A $lib 2>/dev/null | { grep -w "${symbols_args}" > ${syms_file} || true; } + if [ $(wc -l <${syms_file}) != 0 ]; then + echo "${lib}: found illegal symbol references:" + cat ${syms_file} | sed 's/^/\t/' + failed="${failed} ${lib}" + errors=1 + fi + if [ $errors == 0 ]; then + echo "${lib}: OK" + fi + rm -f ${syms_file} +} + +# Check Wi-Fi, PHY libraries for references to "printf"-like functions: +illegal_symbols="printf ets_printf" + +pushd ${IDF_PATH}/components/esp_wifi/lib > /dev/null +wifi_targets=$(find . -type d -name 'esp*' -exec basename {} \; | sort) +for target in ${wifi_targets}; do + for library in ${target}/*.a; do + check_lib_symbols ${library} ${illegal_symbols} + done +done +popd > /dev/null + +pushd ${IDF_PATH}/components/esp_phy/lib > /dev/null +phy_targets=$(find . -type d -name 'esp*' -exec basename {} \; | sort) +for target in ${phy_targets}; do + for library in ${target}/*.a; do + check_lib_symbols ${library} ${illegal_symbols} + done +done +popd > /dev/null + +# Print summary +if [ -n "${failed}" ]; then + echo "Issues found in the following libraries:" + for lib in $failed; do + echo "- $lib" + done + exit 1 +fi From 9802bf41d66a0f60c58ffc6f72de030d6ea9257f Mon Sep 17 00:00:00 2001 From: Jack Date: Tue, 4 Jan 2022 15:35:18 +0800 Subject: [PATCH 2/2] phy: update phy lib to remove ets_printf references --- components/esp_phy/lib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/esp_phy/lib b/components/esp_phy/lib index 2d89c532cc..4779ddaaf2 160000 --- a/components/esp_phy/lib +++ b/components/esp_phy/lib @@ -1 +1 @@ -Subproject commit 2d89c532ccba0bb9988d1d1c6d719bbe1d8b65b8 +Subproject commit 4779ddaaf29e1d6aa2d26980103a1c1bbaa29462