From fe280fe6aa88ee2571beacbd5f78b75328838838 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Thu, 20 Jun 2024 16:22:49 +0200 Subject: [PATCH] remove compile flag for risc-v MCUs which is only valid for xtensa MCUs (#21665) --- pio-tools/add_c_flags.py | 9 +++++++++ pio-tools/strip-floats.py | 19 ++++++++++--------- platformio_tasmota_cenv_sample.ini | 6 ------ platformio_tasmota_env32.ini | 16 ---------------- 4 files changed, 19 insertions(+), 31 deletions(-) diff --git a/pio-tools/add_c_flags.py b/pio-tools/add_c_flags.py index 1ce5d5936..7e51a4fe1 100644 --- a/pio-tools/add_c_flags.py +++ b/pio-tools/add_c_flags.py @@ -5,3 +5,12 @@ env.Append(CXXFLAGS=["-Wno-volatile"]) # General options that are passed to the C compiler (C only; not C++). env.Append(CFLAGS=["-Wno-discarded-qualifiers", "-Wno-implicit-function-declaration", "-Wno-incompatible-pointer-types"]) + + +# Remove build flags which are not valid for risc-v +build_flags = env['BUILD_FLAGS'] +chip = env.get("BOARD_MCU").lower() + +if "c" in chip: + build_flags.pop(build_flags.index("-mno-target-align")) + build_flags.pop(build_flags.index("-mtarget-align")) diff --git a/pio-tools/strip-floats.py b/pio-tools/strip-floats.py index dfb8916dc..4b49321fb 100644 --- a/pio-tools/strip-floats.py +++ b/pio-tools/strip-floats.py @@ -1,21 +1,22 @@ Import('env') -build_flags = " ".join(env.GetProjectOption("build_flags")) +link_flags = " ".join(env['LINKFLAGS']) +build_flags = " ".join(env['BUILD_FLAGS']) # # Dump build environment (for debug) -#print env.Dump() +#print(env.Dump()) # -flags = " ".join(env['LINKFLAGS']) -flags = flags.replace("-u _printf_float", "") -flags = flags.replace("-u _scanf_float", "") +link_flags = link_flags.replace("-u _printf_float", "") +link_flags = link_flags.replace("-u _scanf_float", "") if "FIRMWARE_SAFEBOOT" in build_flags: # Crash Recorder is not included in safeboot firmware -> remove Linker wrap - flags = flags.replace("-Wl,--wrap=panicHandler", "") - flags = flags.replace("-Wl,--wrap=xt_unhandled_exception", "") -newflags = flags.split() + link_flags = link_flags.replace("-Wl,--wrap=panicHandler", "") + link_flags = link_flags.replace("-Wl,--wrap=xt_unhandled_exception", "") + +new_link_flags = link_flags.split() env.Replace( - LINKFLAGS=newflags + LINKFLAGS=new_link_flags ) \ No newline at end of file diff --git a/platformio_tasmota_cenv_sample.ini b/platformio_tasmota_cenv_sample.ini index 1fd7c5e17..3643e3d7c 100644 --- a/platformio_tasmota_cenv_sample.ini +++ b/platformio_tasmota_cenv_sample.ini @@ -81,8 +81,6 @@ build_flags = ${env:tasmota32_base.build_flags} [env:tasmota32c3-bluetooth] extends = env:tasmota32_base board = esp32c3 -build_unflags = ${env:tasmota32_base.build_unflags} - -mtarget-align build_flags = ${env:tasmota32_base.build_flags} -DFIRMWARE_BLUETOOTH ; -DUSE_EQ3_ESP32 @@ -111,8 +109,6 @@ lib_ignore = Micro-RTSP [env:tasmota32c3-mi32] extends = env:tasmota32_base board = esp32c3 -build_unflags = ${env:tasmota32_base.build_unflags} - -mtarget-align build_flags = ${env:tasmota32_base.build_flags} -DFIRMWARE_BLUETOOTH -DUSE_MI_EXT_GUI @@ -133,8 +129,6 @@ lib_ignore = Micro-RTSP [env:tasmota32c6-mi32] extends = env:tasmota32_base board = esp32c6 -build_unflags = ${env:tasmota32_base.build_unflags} - -mtarget-align build_flags = ${env:tasmota32_base.build_flags} -DFIRMWARE_BLUETOOTH -DUSE_MI_EXT_GUI diff --git a/platformio_tasmota_env32.ini b/platformio_tasmota_env32.ini index ce888463c..ef8d46a58 100644 --- a/platformio_tasmota_env32.ini +++ b/platformio_tasmota_env32.ini @@ -71,8 +71,6 @@ lib_ignore = ${safeboot_flags.lib_ignore} extends = env:tasmota32_base board = esp32c2 board_build.app_partition_name = safeboot -build_unflags = ${env:tasmota32_base.build_unflags} - -mno-target-align build_flags = ${env:tasmota32_base.build_flags} -DFIRMWARE_SAFEBOOT -DOTA_URL='"http://ota.tasmota.com/tasmota32/release/tasmota32c2-safeboot.bin"' @@ -83,8 +81,6 @@ lib_ignore = ${safeboot_flags.lib_ignore} extends = env:tasmota32_base board = esp32c3 board_build.app_partition_name = safeboot -build_unflags = ${env:tasmota32_base.build_unflags} - -mno-target-align build_flags = ${env:tasmota32_base.build_flags} -DFIRMWARE_SAFEBOOT -DOTA_URL='"http://ota.tasmota.com/tasmota32/release/tasmota32c3-safeboot.bin"' @@ -95,8 +91,6 @@ lib_ignore = ${safeboot_flags.lib_ignore} extends = env:tasmota32_base board = esp32c3ser board_build.app_partition_name = safeboot -build_unflags = ${env:tasmota32_base.build_unflags} - -mno-target-align build_flags = ${env:tasmota32_base.build_flags} -DFIRMWARE_SAFEBOOT -DOTA_URL='"http://ota.tasmota.com/tasmota32/release/tasmota32c3ser-safeboot.bin"' @@ -117,8 +111,6 @@ lib_ignore = ${safeboot_flags.lib_ignore} extends = env:tasmota32_base board = esp32c6 board_build.app_partition_name = safeboot -build_unflags = ${env:tasmota32_base.build_unflags} - -mno-target-align build_flags = ${env:tasmota32_base.build_flags} -DFIRMWARE_SAFEBOOT -DOTA_URL='"http://ota.tasmota.com/tasmota32/release/tasmota32c6-safeboot.bin"' @@ -129,8 +121,6 @@ lib_ignore = ${safeboot_flags.lib_ignore} extends = env:tasmota32_base board = esp32c6ser board_build.app_partition_name = safeboot -build_unflags = ${env:tasmota32_base.build_unflags} - -mno-target-align build_flags = ${env:tasmota32_base.build_flags} -DFIRMWARE_SAFEBOOT -DOTA_URL='"http://ota.tasmota.com/tasmota32/release/tasmota32c6ser-safeboot.bin"' @@ -187,8 +177,6 @@ lib_ignore = ${env:tasmota32_base.lib_ignore} [env:tasmota32c2] extends = env:tasmota32_base board = esp32c2 -build_unflags = ${env:tasmota32_base.build_unflags} - -mno-target-align build_flags = ${env:tasmota32_base.build_flags} -DFIRMWARE_TASMOTA32 -DOTA_URL='"http://ota.tasmota.com/tasmota32/release/tasmota32c2.bin"' @@ -198,8 +186,6 @@ lib_ignore = ${env:tasmota32_base.lib_ignore} [env:tasmota32c3] extends = env:tasmota32_base board = esp32c3 -build_unflags = ${env:tasmota32_base.build_unflags} - -mno-target-align build_flags = ${env:tasmota32_base.build_flags} -DFIRMWARE_TASMOTA32 -DOTA_URL='"http://ota.tasmota.com/tasmota32/release/tasmota32c3.bin"' @@ -209,8 +195,6 @@ lib_ignore = ${env:tasmota32_base.lib_ignore} [env:tasmota32c6] extends = env:tasmota32_base board = esp32c6 -build_unflags = ${env:tasmota32_base.build_unflags} - -mno-target-align build_flags = ${env:tasmota32_base.build_flags} -DFIRMWARE_TASMOTA32 -DOTA_URL='"http://ota.tasmota.com/tasmota32/release/tasmota32c6.bin"'