From f2ad37152be72486a732d1021249dca8428e73d8 Mon Sep 17 00:00:00 2001 From: Max Prokhorov Date: Fri, 29 Mar 2019 11:05:11 +0300 Subject: [PATCH 1/4] special dummy printf to disable Serial using some boards --- code/espurna/config/prototypes.h | 5 +++++ code/extra_scripts.py | 26 ++++++++++++++++++++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/code/espurna/config/prototypes.h b/code/espurna/config/prototypes.h index 684637c4..f6e488da 100644 --- a/code/espurna/config/prototypes.h +++ b/code/espurna/config/prototypes.h @@ -57,6 +57,11 @@ extern "C" { #endif } +// special dummy printf to disable Serial using some boards +int dummy_ets_printf(const char* format, ...) { + return 0; +} + // ----------------------------------------------------------------------------- // Domoticz // ----------------------------------------------------------------------------- diff --git a/code/extra_scripts.py b/code/extra_scripts.py index de37bd31..70bc640d 100644 --- a/code/extra_scripts.py +++ b/code/extra_scripts.py @@ -59,12 +59,12 @@ def remove_float_support(): LINKFLAGS = newflags ) -def cpp_check(source, target, env): +def cpp_check(target, source, env): print("Started cppcheck...\n") call(["cppcheck", os.getcwd()+"/espurna", "--force", "--enable=all"]) print("Finished cppcheck...\n") -def check_size(source, target, env): +def check_size(target, source, env): (binary,) = target path = binary.get_abspath() size = os.stat(path).st_size @@ -78,6 +78,21 @@ def check_size(source, target, env): print_warning("https://github.com/xoseperez/espurna/wiki/TwoStepUpdates", color=Color.LIGHT_CYAN) print_filler("*", color=Color.LIGHT_YELLOW, err=True) +def dummy_ets_printf(target, source, env): + (postmortem_src_file, ) = source + (postmortem_obj_file, ) = target + + cmd = ["xtensa-lx106-elf-objcopy"] + + # recent Core switched to cpp+newlib & ets_printf_P + if postmortem_src_file.get_abspath().endswith(".cpp"): + cmd.extend(["--redefine-sym", "ets_printf_P=dummy_ets_printf"]) + else: + cmd.extend(["--redefine-sym", "ets_printf=dummy_ets_printf"]) + + cmd.append(postmortem_obj_file.get_abspath()) + env.VerboseAction(cmd, "Running $TARGET") + # ------------------------------------------------------------------------------ # Hooks # ------------------------------------------------------------------------------ @@ -85,6 +100,13 @@ def check_size(source, target, env): # Always show warnings for project code projenv.ProcessUnFlags("-w") +# 2.4.0 and up remove_float_support() +# two-step update hint when using 1MB boards env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", check_size) + +# disable postmortem printing to the uart. another one is in eboot, but this is what causes the most harm +if "DISABLE_POSTMORTEM_STACKDUMP" if env["CPPFLAGS"]: + env.AddPostAction("$BUILD_DIR/FrameworkArduino/core_esp8266_postmortem.c.o", dummy_ets_printf) + env.AddPostAction("$BUILD_DIR/FrameworkArduino/core_esp8266_postmortem.cpp.o", dummy_ets_printf) From 76563d4728d832fc5c3b724df43a1ff7cd9f86a4 Mon Sep 17 00:00:00 2001 From: Max Prokhorov Date: Fri, 29 Mar 2019 11:10:34 +0300 Subject: [PATCH 2/4] Add relevant hardware --- code/platformio.ini | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/code/platformio.ini b/code/platformio.ini index 29562679..e6f0711c 100644 --- a/code/platformio.ini +++ b/code/platformio.ini @@ -409,7 +409,7 @@ board = ${common.board_1m} board_build.flash_mode = ${common.flash_mode} lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m0m} -DFOXEL_LIGHTFOX_DUAL +build_flags = ${common.build_flags_1m0m} -DFOXEL_LIGHTFOX_DUAL -DDISABLE_POSTMORTEM_STACKDUMP extra_scripts = ${common.extra_scripts} [env:foxel-lightfox-dual-ota] @@ -419,7 +419,7 @@ board = ${common.board_1m} board_build.flash_mode = ${common.flash_mode} lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m0m} -DFOXEL_LIGHTFOX_DUAL +build_flags = ${common.build_flags_1m0m} -DFOXEL_LIGHTFOX_DUAL -DDISABLE_POSTMORTEM_STACKDUMP upload_speed = ${common.upload_speed} upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} @@ -590,7 +590,7 @@ board = ${common.board_1m} board_build.flash_mode = ${common.flash_mode} lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m0m} -DITEAD_SONOFF_POW_R2 +build_flags = ${common.build_flags_1m0m} -DITEAD_SONOFF_POW_R2 -DDISABLE_POSTMORTEM_STACKDUMP monitor_speed = ${common.monitor_speed} extra_scripts = ${common.extra_scripts} @@ -601,7 +601,7 @@ board = ${common.board_1m} board_build.flash_mode = ${common.flash_mode} lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m0m} -DITEAD_SONOFF_POW_R2 +build_flags = ${common.build_flags_1m0m} -DITEAD_SONOFF_POW_R2 -DDISABLE_POSTMORTEM_STACKDUMP upload_speed = ${common.upload_speed} upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} @@ -615,7 +615,7 @@ board = ${common.board_1m} board_build.flash_mode = ${common.flash_mode} lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m0m} -DITEAD_SONOFF_DUAL +build_flags = ${common.build_flags_1m0m} -DITEAD_SONOFF_DUAL -DDISABLE_POSTMORTEM_STACKDUMP extra_scripts = ${common.extra_scripts} [env:itead-sonoff-dual-ota] @@ -625,7 +625,7 @@ board = ${common.board_1m} board_build.flash_mode = ${common.flash_mode} lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m0m} -DITEAD_SONOFF_DUAL +build_flags = ${common.build_flags_1m0m} -DITEAD_SONOFF_DUAL -DDISABLE_POSTMORTEM_STACKDUMP upload_speed = ${common.upload_speed} upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} @@ -861,7 +861,7 @@ board = ${common.board_1m} board_build.flash_mode = ${common.flash_mode} lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m0m} -DITEAD_SONOFF_RFBRIDGE +build_flags = ${common.build_flags_1m0m} -DITEAD_SONOFF_RFBRIDGE -DDISABLE_POSTMORTEM_STACKDUMP monitor_speed = 19200 extra_scripts = ${common.extra_scripts} @@ -872,7 +872,7 @@ board = ${common.board_1m} board_build.flash_mode = ${common.flash_mode} lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m0m} -DITEAD_SONOFF_RFBRIDGE +build_flags = ${common.build_flags_1m0m} -DITEAD_SONOFF_RFBRIDGE -DDISABLE_POSTMORTEM_STACKDUMP upload_speed = ${common.upload_speed} upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} @@ -1037,7 +1037,7 @@ board = ${common.board_1m} board_build.flash_mode = ${common.flash_mode} lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m0m} -DITEAD_SONOFF_S31 +build_flags = ${common.build_flags_1m0m} -DITEAD_SONOFF_S31 -DDISABLE_POSTMORTEM_STACKDUMP monitor_speed = ${common.monitor_speed} extra_scripts = ${common.extra_scripts} @@ -1048,7 +1048,7 @@ board = ${common.board_1m} board_build.flash_mode = ${common.flash_mode} lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m0m} -DITEAD_SONOFF_S31 +build_flags = ${common.build_flags_1m0m} -DITEAD_SONOFF_S31 -DDISABLE_POSTMORTEM_STACKDUMP upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} monitor_speed = ${common.monitor_speed} @@ -2120,7 +2120,7 @@ board = ${common.board_1m} board_build.flash_mode = ${common.flash_mode} lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m0m} -DSTM_RELAY +build_flags = ${common.build_flags_1m0m} -DSTM_RELAY -DDISABLE_POSTMORTEM_STACKDUMP monitor_speed = ${common.monitor_speed} extra_scripts = ${common.extra_scripts} @@ -2131,7 +2131,7 @@ board = ${common.board_1m} board_build.flash_mode = ${common.flash_mode} lib_deps = ${common.lib_deps} lib_ignore = ${common.lib_ignore} -build_flags = ${common.build_flags_1m0m} -DSTM_RELAY +build_flags = ${common.build_flags_1m0m} -DSTM_RELAY -DDISABLE_POSTMORTEM_STACKDUMP upload_speed = ${common.upload_speed} upload_port = ${common.upload_port} upload_flags = ${common.upload_flags} From fa449082696bb8b5bf50ec580e6d28af528fce4f Mon Sep 17 00:00:00 2001 From: Max Prokhorov Date: Fri, 29 Mar 2019 12:24:51 +0300 Subject: [PATCH 3/4] fix typo and link order --- code/espurna/config/prototypes.h | 5 ----- code/espurna/dummy_ets_printf.c | 4 ++++ code/extra_scripts.py | 5 +++-- 3 files changed, 7 insertions(+), 7 deletions(-) create mode 100644 code/espurna/dummy_ets_printf.c diff --git a/code/espurna/config/prototypes.h b/code/espurna/config/prototypes.h index f6e488da..684637c4 100644 --- a/code/espurna/config/prototypes.h +++ b/code/espurna/config/prototypes.h @@ -57,11 +57,6 @@ extern "C" { #endif } -// special dummy printf to disable Serial using some boards -int dummy_ets_printf(const char* format, ...) { - return 0; -} - // ----------------------------------------------------------------------------- // Domoticz // ----------------------------------------------------------------------------- diff --git a/code/espurna/dummy_ets_printf.c b/code/espurna/dummy_ets_printf.c new file mode 100644 index 00000000..9519c8ba --- /dev/null +++ b/code/espurna/dummy_ets_printf.c @@ -0,0 +1,4 @@ +// special dummy printf to disable Serial using some boards +int dummy_ets_printf(const char* format, ...) { + return 0; +} diff --git a/code/extra_scripts.py b/code/extra_scripts.py index 70bc640d..4709b4ab 100644 --- a/code/extra_scripts.py +++ b/code/extra_scripts.py @@ -91,7 +91,8 @@ def dummy_ets_printf(target, source, env): cmd.extend(["--redefine-sym", "ets_printf=dummy_ets_printf"]) cmd.append(postmortem_obj_file.get_abspath()) - env.VerboseAction(cmd, "Running $TARGET") + env.Execute(env.VerboseAction(" ".join(cmd), "Removing ets_printf / ets_printf_P")) + env.Depends(postmortem_obj_file,"$BUILD_DIR/src/dummy_ets_printf.c.o") # ------------------------------------------------------------------------------ # Hooks @@ -107,6 +108,6 @@ remove_float_support() env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", check_size) # disable postmortem printing to the uart. another one is in eboot, but this is what causes the most harm -if "DISABLE_POSTMORTEM_STACKDUMP" if env["CPPFLAGS"]: +if "DISABLE_POSTMORTEM_STACKDUMP" in env["CPPFLAGS"]: env.AddPostAction("$BUILD_DIR/FrameworkArduino/core_esp8266_postmortem.c.o", dummy_ets_printf) env.AddPostAction("$BUILD_DIR/FrameworkArduino/core_esp8266_postmortem.cpp.o", dummy_ets_printf) From 8cc389fce3afefcf703772b96474f940d9fe6e90 Mon Sep 17 00:00:00 2001 From: Max Prokhorov Date: Fri, 29 Mar 2019 15:19:29 +0300 Subject: [PATCH 4/4] no need to conditionally redefine symbols --- code/extra_scripts.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/code/extra_scripts.py b/code/extra_scripts.py index 4709b4ab..1d8c4f6c 100644 --- a/code/extra_scripts.py +++ b/code/extra_scripts.py @@ -85,10 +85,8 @@ def dummy_ets_printf(target, source, env): cmd = ["xtensa-lx106-elf-objcopy"] # recent Core switched to cpp+newlib & ets_printf_P - if postmortem_src_file.get_abspath().endswith(".cpp"): - cmd.extend(["--redefine-sym", "ets_printf_P=dummy_ets_printf"]) - else: - cmd.extend(["--redefine-sym", "ets_printf=dummy_ets_printf"]) + cmd.extend(["--redefine-sym", "ets_printf=dummy_ets_printf"]) + cmd.extend(["--redefine-sym", "ets_printf_P=dummy_ets_printf"]) cmd.append(postmortem_obj_file.get_abspath()) env.Execute(env.VerboseAction(" ".join(cmd), "Removing ets_printf / ets_printf_P"))