Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PlatformIO: silence postmortem stackdump for boards using serial #1664

Merged
merged 5 commits into from
Mar 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions code/espurna/dummy_ets_printf.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// special dummy printf to disable Serial using some boards
int dummy_ets_printf(const char* format, ...) {
return 0;
}
25 changes: 23 additions & 2 deletions code/extra_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -78,13 +78,34 @@ 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
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"))
env.Depends(postmortem_obj_file,"$BUILD_DIR/src/dummy_ets_printf.c.o")

# ------------------------------------------------------------------------------
# Hooks
# ------------------------------------------------------------------------------

# 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" 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)
24 changes: 12 additions & 12 deletions code/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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}
Expand Down Expand Up @@ -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}

Expand All @@ -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}
Expand All @@ -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]
Expand All @@ -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}
Expand Down Expand Up @@ -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}

Expand All @@ -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}
Expand Down Expand Up @@ -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}

Expand All @@ -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}
Expand Down Expand Up @@ -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}

Expand All @@ -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}
Expand Down