Browse Source

PIO: patch lwip1 MTU bug in travis (#1723)

rules-rpn
Max Prokhorov 5 years ago
committed by GitHub
parent
commit
c7d467144a
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 48 additions and 0 deletions
  1. +1
    -0
      .travis.yml
  2. +34
    -0
      code/extra_scripts.py
  3. +13
    -0
      dist/patches/lwip_mtu_issue_1610.patch

+ 1
- 0
.travis.yml View File

@ -15,6 +15,7 @@ install:
env: env:
global: global:
- BUILDER_TOTAL_THREADS=4 - BUILDER_TOTAL_THREADS=4
- ESPURNA_PIO_PATCH_ISSUE_1610=y
script: script:
- cd code && ./build.sh -p && cd .. - cd code && ./build.sh -p && cd ..
stages: stages:


+ 34
- 0
code/extra_scripts.py View File

@ -92,6 +92,36 @@ def dummy_ets_printf(target, source, env):
env.Execute(env.VerboseAction(" ".join(cmd), "Removing ets_printf / ets_printf_P")) 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") env.Depends(postmortem_obj_file,"$BUILD_DIR/src/dummy_ets_printf.c.o")
def patch_lwip():
# ignore when building with lwip2
if "lwip_gcc" not in env["LIBS"]:
return
framework_dir = env["FRAMEWORK_ARDUINOESP8266_DIR"]
platform = env.PioPlatform()
toolchain_prefix = os.path.join(platform.get_package_dir("toolchain-xtensa"), "bin", "xtensa-lx106-elf-")
patch_action = env.VerboseAction(" ".join([
"-patch", "-u", "-N", "-d",
os.path.join(framework_dir, "tools", "sdk", "lwip"),
os.path.join("src", "core", "tcp_out.c"),
env.subst(os.path.join("$PROJECT_DIR", "..", "dist", "patches", "lwip_mtu_issue_1610.patch"))
]), "Patching lwip source")
build_action = env.VerboseAction(" ".join([
"make", "-C", os.path.join(framework_dir, "tools", "sdk", "lwip", "src"),
"install",
"TOOLS_PATH={}".format(toolchain_prefix),
"LWIP_LIB=liblwip_gcc.a"
]), "Rebuilding lwip")
patcher = env.Alias("patch-lwip", None, patch_action)
builder = env.Alias("build-lwip", patcher, build_action)
if os.environ.get("ESPURNA_PIO_PATCH_ISSUE_1610"):
env.Depends("$BUILD_DIR/${PROGNAME}.elf", builder)
env.AlwaysBuild(patcher)
env.AlwaysBuild(builder)
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Hooks # Hooks
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@ -109,3 +139,7 @@ env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", check_size)
if "DISABLE_POSTMORTEM_STACKDUMP" in 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.c.o", dummy_ets_printf)
env.AddPostAction("$BUILD_DIR/FrameworkArduino/core_esp8266_postmortem.cpp.o", dummy_ets_printf) env.AddPostAction("$BUILD_DIR/FrameworkArduino/core_esp8266_postmortem.cpp.o", dummy_ets_printf)
# patch lwip1 sources conditionally:
# https://github.com/xoseperez/espurna/issues/1610
patch_lwip()

+ 13
- 0
dist/patches/lwip_mtu_issue_1610.patch View File

@ -0,0 +1,13 @@
diff --git a/src/core/tcp_out.c b/src/core/tcp_out.c
index fa8d77f..a7b0595 100644
--- a/src/core/tcp_out.c
+++ b/src/core/tcp_out.c
@@ -469,7 +469,7 @@ tcp_write(struct tcp_pcb *pcb, const void *arg, u16_t len, u8_t apiflags)
if (oversize > 0) {
LWIP_ASSERT("inconsistent oversize vs. space", oversize_used <= space);
seg = last_unsent;
- oversize_used = oversize < len ? oversize : len;
+ oversize_used = LWIP_MIN(space, LWIP_MIN(oversize, len));
pos += oversize_used;
oversize -= oversize_used;
space -= oversize_used;

Loading…
Cancel
Save