From 06dc15a39315b7c9f1af676df8809dd4733b0c50 Mon Sep 17 00:00:00 2001 From: zwx Date: Wed, 12 Nov 2025 15:24:13 +0800 Subject: [PATCH] feat(script): refactor the script for fixing the printf symbol --- fix_printf.sh | 59 +++++++++++++++++---------------------------------- 1 file changed, 19 insertions(+), 40 deletions(-) diff --git a/fix_printf.sh b/fix_printf.sh index a3e1c53..b119024 100755 --- a/fix_printf.sh +++ b/fix_printf.sh @@ -12,50 +12,29 @@ for dir in "${chip_list[@]}"; do TOOLCHAIN="riscv32-esp-elf" fi if [ -d "$dir" ]; then - cd $dir + cd "$dir" || continue - if [ $dir = esp32 ]; then - git status librtc.a | grep "modified\|new file" >/dev/null 2>&1 - if [ $? -eq 0 ]; then - echo $dir/librtc.a fixed - $TOOLCHAIN-objcopy --redefine-sym ets_printf=rtc_printf librtc.a - fi - elif [ $dir != esp32s2 ]; then - git status libbtbb.a | grep "modified\|new file" >/dev/null 2>&1 - if [ $? -eq 0 ]; then - echo $dir/libbtbb.a fixed - $TOOLCHAIN-objcopy --redefine-sym ets_printf=phy_printf libbtbb.a - fi - fi - git status libphy.a | grep "modified\|new file" >/dev/null 2>&1 - if [ $? -eq 0 ]; then - echo $dir/libphy.a fixed - $TOOLCHAIN-objcopy --redefine-sym ets_printf=phy_printf libphy.a - fi - case "$dir" in - esp32c3|esp32s3|esp32c2|esp32c6|esp32c5|esp32c61|esp32s2|esp32h2|esp32h4|esp32) - if [ $dir != esp32s2 ]; then - git status libbttestmode.a | grep "modified\|new file" >/dev/null 2>&1 - if [ $? -eq 0 ]; then - echo $dir/libbttestmode.a fixed - $TOOLCHAIN-objcopy --redefine-sym ets_printf=phy_printf libbttestmode.a - fi - fi - if [ $dir != esp32 ]; then - git status librfate.a | grep "modified\|new file" >/dev/null 2>&1 - if [ $? -eq 0 ]; then - echo $dir/librfate.a fixed - $TOOLCHAIN-objcopy --redefine-sym ets_printf=phy_printf librfate.a - fi - fi - git status librftest.a | grep "modified\|new file" >/dev/null 2>&1 + for lib in *.a; do + echo $dir/$lib + if [ "$lib" = "librtc.a" ]; then + git status "$lib" | grep -E "modified|new file" >/dev/null 2>&1 if [ $? -eq 0 ]; then - echo $dir/librftest.a fixed - $TOOLCHAIN-objcopy --redefine-sym ets_printf=phy_printf librftest.a + echo "$dir/$lib fixed" + $TOOLCHAIN-objcopy --redefine-sym ets_printf=rtc_printf "$lib" fi - esac + continue + fi + + git status "$lib" | grep -E "modified|new file" >/dev/null 2>&1 + if [ $? -eq 0 ]; then + echo "$dir/$lib fixed" + $TOOLCHAIN-objcopy --redefine-sym ets_printf=phy_printf "$lib" + fi + done cd .. else echo "$dir does not exist" fi -done; +done + +