Skip to content

Commit f5423c4

Browse files
authored
@platformio: VTables, custom lwIP, sync libs and flags // Resolve esp8266#4618
1 parent 68f04bc commit f5423c4

File tree

1 file changed

+73
-10
lines changed

1 file changed

+73
-10
lines changed

tools/platformio-build.py

+73-10
Original file line numberDiff line numberDiff line change
@@ -50,41 +50,104 @@ def scons_patched_match_splitext(path, suffixes=None):
5050
assert isdir(FRAMEWORK_DIR)
5151

5252

53-
env.Prepend(
53+
env.Append(
54+
CCFLAGS=[
55+
"-Wall"
56+
],
57+
5458
CPPDEFINES=[
5559
("ARDUINO", 10805),
60+
("ARDUINO_BOARD", '\\"PLATFORMIO_%s\\"'
61+
% env.BoardConfig().id.upper()),
5662
"LWIP_OPEN_SRC"
5763
],
64+
5865
CPPPATH=[
5966
join(FRAMEWORK_DIR, "tools", "sdk", "include"),
60-
join(FRAMEWORK_DIR, "tools", "sdk", "lwip", "include"),
6167
join(FRAMEWORK_DIR, "tools", "sdk", "libc",
6268
"xtensa-lx106-elf", "include"),
6369
join(FRAMEWORK_DIR, "cores", env.BoardConfig().get("build.core"))
6470
],
71+
6572
LIBPATH=[
73+
join("$BUILD_DIR", "ld"), # eagle.app.v6.common.ld
6674
join(FRAMEWORK_DIR, "tools", "sdk", "lib"),
6775
join(FRAMEWORK_DIR, "tools", "sdk", "ld"),
6876
join(FRAMEWORK_DIR, "tools", "sdk", "libc", "xtensa-lx106-elf", "lib")
6977
],
78+
7079
LIBS=[
71-
"wpa2", "smartconfig", "espnow", "pp", "main", "wpa", "lwip_gcc",
72-
"net80211", "wps", "crypto", "phy", "hal", "axtls", "gcc",
73-
"m", "c", "stdc++"
74-
]
75-
)
80+
"hal", "phy", "pp", "net80211", "wpa", "crypto", "main",
81+
"wps", "axtls", "espnow", "smartconfig", "airkiss", "wpa2",
82+
"stdc++", "m", "c", "gcc"
83+
],
7684

77-
env.Append(
7885
LIBSOURCE_DIRS=[
7986
join(FRAMEWORK_DIR, "libraries")
80-
],
87+
]
88+
)
89+
90+
env.Replace(
8191
LINKFLAGS=[
92+
"-Os",
93+
"-nostdlib",
94+
"-Wl,--no-check-sections",
95+
"-Wl,-static",
96+
"-Wl,--gc-sections",
8297
"-Wl,-wrap,system_restart_local",
8398
"-Wl,-wrap,spi_flash_read",
84-
"-u,app_entry"
99+
"-u", "app_entry",
100+
"-u", "_printf_float",
101+
"-u", "_scanf_float"
85102
]
86103
)
87104

105+
flatten_cppdefines = env.Flatten(env['CPPDEFINES'])
106+
107+
#
108+
# lwIP
109+
#
110+
if "PIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY" in flatten_cppdefines:
111+
env.Append(
112+
CPPDEFINES=[("TCP_MSS", 536)],
113+
CPPPATH=[join(FRAMEWORK_DIR, "tools", "sdk", "lwip2", "include")],
114+
LIBS=["lwip2"]
115+
)
116+
elif "PIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH" in flatten_cppdefines:
117+
env.Append(
118+
CPPDEFINES=[("TCP_MSS", 1460)],
119+
CPPPATH=[join(FRAMEWORK_DIR, "tools", "sdk", "lwip2", "include")],
120+
LIBS=["lwip2_1460"]
121+
)
122+
else:
123+
env.Append(
124+
CPPPATH=[join(FRAMEWORK_DIR, "tools", "sdk", "lwip", "include")],
125+
LIBS=["lwip_gcc"]
126+
)
127+
128+
#
129+
# VTables
130+
#
131+
132+
current_vtables = None
133+
for d in flatten_cppdefines:
134+
if str(d).startswith("VTABLES_IN_"):
135+
current_vtables = d
136+
if not current_vtables:
137+
current_vtables = "VTABLES_IN_FLASH"
138+
env.Append(CPPDEFINES=[current_vtables])
139+
assert current_vtables
140+
141+
# Build the eagle.app.v6.common.ld linker file
142+
app_ld = env.Command(
143+
join("$BUILD_DIR", "ld", "eagle.app.v6.common.ld"),
144+
join(FRAMEWORK_DIR, "tools", "sdk", "ld", "eagle.app.v6.common.ld.h"),
145+
env.VerboseAction(
146+
"$CC -CC -E -P -D%s $SOURCE -o $TARGET" % current_vtables,
147+
"Generating LD script $TARGET"))
148+
env.Depends("$BUILD_DIR/$PROGNAME$PROGSUFFIX", app_ld)
149+
150+
88151
#
89152
# Target: Build Core Library
90153
#

0 commit comments

Comments
 (0)