Skip to content

Commit 30f2d55

Browse files
committed
Merge branch 'release/v1.11.1'
2 parents 1c9d00d + afa7d2f commit 30f2d55

File tree

8 files changed

+133
-108
lines changed

8 files changed

+133
-108
lines changed

boards/m5stick-c.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"maximum_ram_size": 327680,
2626
"maximum_size": 4194304,
2727
"require_upload_port": true,
28-
"speed": 460800
28+
"speed": 1500000
2929
},
3030
"url": "http://www.m5stack.com",
3131
"vendor": "M5Stack"

builder/frameworks/_embed_files.py

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# Copyright 2014-present PlatformIO <[email protected]>
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import shutil
16+
from os import SEEK_CUR, SEEK_END
17+
from os.path import basename, isfile, join
18+
19+
from SCons.Script import Builder
20+
21+
from platformio.util import cd
22+
23+
Import("env")
24+
25+
board = env.BoardConfig()
26+
27+
#
28+
# Embedded files helpers
29+
#
30+
31+
def extract_files(cppdefines, files_type):
32+
files = []
33+
if "build." + files_type in board:
34+
files.extend(
35+
[join("$PROJECT_DIR", f) for f in board.get(
36+
"build." + files_type, "").split() if f])
37+
else:
38+
files_define = "COMPONENT_" + files_type.upper()
39+
for define in cppdefines:
40+
if files_define not in define:
41+
continue
42+
43+
value = define[1]
44+
if not isinstance(define, tuple):
45+
print("Warning! %s macro cannot be empty!" % files_define)
46+
return []
47+
48+
if not isinstance(value, str):
49+
print("Warning! %s macro must contain "
50+
"a list of files separated by ':'" % files_define)
51+
return []
52+
53+
for f in value.split(':'):
54+
if not f:
55+
continue
56+
files.append(join("$PROJECT_DIR", f))
57+
58+
for f in files:
59+
if not isfile(env.subst(f)):
60+
print("Warning! Could not find file \"%s\"" % basename(f))
61+
62+
return files
63+
64+
65+
def remove_config_define(cppdefines, files_type):
66+
for define in cppdefines:
67+
if files_type in define:
68+
env.ProcessUnFlags("-D%s" % "=".join(str(d) for d in define))
69+
return
70+
71+
72+
def prepare_file(source, target, env):
73+
filepath = source[0].get_abspath()
74+
shutil.copy(filepath, filepath + ".piobkp")
75+
76+
with open(filepath, "rb+") as fp:
77+
fp.seek(-1, SEEK_END)
78+
if fp.read(1) != '\0':
79+
fp.seek(0, SEEK_CUR)
80+
fp.write(b'\0')
81+
82+
83+
def revert_original_file(source, target, env):
84+
filepath = source[0].get_abspath()
85+
if isfile(filepath + ".piobkp"):
86+
shutil.move(filepath + ".piobkp", filepath)
87+
88+
89+
def embed_files(files, files_type):
90+
for f in files:
91+
filename = basename(f) + ".txt.o"
92+
file_target = env.TxtToBin(join("$BUILD_DIR", filename), f)
93+
env.Depends("$PIOMAINPROG", file_target)
94+
if files_type == "embed_txtfiles":
95+
env.AddPreAction(file_target, prepare_file)
96+
env.AddPostAction(file_target, revert_original_file)
97+
env.Append(PIOBUILDFILES=[env.File(join("$BUILD_DIR", filename))])
98+
99+
100+
env.Append(
101+
BUILDERS=dict(
102+
TxtToBin=Builder(
103+
action=env.VerboseAction(" ".join([
104+
"xtensa-esp32-elf-objcopy",
105+
"--input-target", "binary",
106+
"--output-target", "elf32-xtensa-le",
107+
"--binary-architecture", "xtensa",
108+
"--rename-section", ".data=.rodata.embedded",
109+
"$SOURCE", "$TARGET"
110+
]), "Converting $TARGET"),
111+
suffix=".txt.o"))
112+
)
113+
114+
flags = env.get("CPPDEFINES")
115+
for files_type in ("embed_txtfiles", "embed_files"):
116+
if "COMPONENT_" + files_type.upper() not in env.Flatten(
117+
flags) and "build." + files_type not in board:
118+
continue
119+
120+
files = extract_files(flags, files_type)
121+
embed_files(files, files_type)
122+
remove_config_define(flags, files_type)

builder/frameworks/_embedtxt_files.py

Lines changed: 0 additions & 102 deletions
This file was deleted.

builder/frameworks/arduino.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
env = DefaultEnvironment()
3030

31-
SConscript("_embedtxt_files.py", exports="env")
31+
SConscript("_embed_files.py", exports="env")
3232

3333
if "espidf" not in env.subst("$PIOFRAMEWORK"):
3434
SConscript(

builder/frameworks/espidf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
platform = env.PioPlatform()
3434

3535
env.SConscript("_bare.py", exports="env")
36-
env.SConscript("_embedtxt_files.py", exports="env")
36+
env.SConscript("_embed_files.py", exports="env")
3737

3838
ulp_lib = None
3939
ulp_dir = join(env.subst("$PROJECT_DIR"), "ulp")

builder/main.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@ def __fetch_spiffs_size(target, source, env):
158158
],
159159
ERASECMD='"$PYTHONEXE" "$OBJCOPY" $ERASEFLAGS erase_flash',
160160

161-
MKSPIFFSTOOL="mkspiffs_${PIOPLATFORM}_${PIOFRAMEWORK}",
161+
MKSPIFFSTOOL="mkspiffs_${PIOPLATFORM}_" + ("espidf" if "espidf" in env.subst(
162+
"$PIOFRAMEWORK") else "${PIOFRAMEWORK}"),
162163
PROGSUFFIX=".elf"
163164
)
164165

examples/espidf-aws-iot/platformio.ini

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ framework = espidf
1313
board = esp32dev
1414
monitor_speed = 115200
1515
build_flags =
16-
-DCOMPONENT_EMBED_TXTFILES=src/private.pem.key:src/certificate.pem.crt:src/aws-root-ca.pem
1716
-DCONFIG_WIFI_SSID=\"ESP_AP\"
1817
-DCONFIG_WIFI_PASSWORD=\"MYPASS\"
18+
19+
board_build.embed_txtfiles =
20+
src/private.pem.key
21+
src/certificate.pem.crt
22+
src/aws-root-ca.pem

platform.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"type": "git",
1313
"url": "https://github.com/platformio/platform-espressif32.git"
1414
},
15-
"version": "1.11.0",
15+
"version": "1.11.1",
1616
"packageRepositories": [
1717
"https://dl.bintray.com/platformio/dl-packages/manifest.json",
1818
"http://dl.platformio.org/packages/manifest.json",

0 commit comments

Comments
 (0)