Skip to content

Commit 0fc081d

Browse files
authored
Idf44/esp32 s3
1 parent ef8796c commit 0fc081d

25 files changed

+386
-307
lines changed

Diff for: .github/workflows/examples.yml

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ jobs:
1515
- "examples/arduino-wifiscan"
1616
- "examples/espidf-arduino-blink"
1717
- "examples/espidf-arduino-wifiscan"
18+
- "examples/espidf-blink"
1819
- "examples/espidf-aws-iot"
1920
- "examples/espidf-ble-eddystone"
2021
- "examples/espidf-coap-server"

Diff for: README.md

+3-12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Espressif 32: development platform for [PlatformIO](http://platformio.org)
1+
# Tasmota Espressif 32: development platform for [PlatformIO](http://platformio.org)
22

3-
[![Build Status](https://github.com/platformio/platform-espressif32/workflows/Examples/badge.svg)](https://github.com/platformio/platform-espressif32/actions)
3+
[![Examples](https://github.com/Jason2866/platform-espressif32/actions/workflows/examples.yml/badge.svg)](https://github.com/Jason2866/platform-espressif32/actions/workflows/examples.yml)
44

55
Espressif Systems is a privately held fabless semiconductor company. They provide wireless communications and Wi-Fi chips which are widely used in mobile devices and the Internet of Things applications.
66

@@ -16,16 +16,7 @@ Espressif Systems is a privately held fabless semiconductor company. They provid
1616

1717
```ini
1818
[env:stable]
19-
platform = espressif32
20-
board = ...
21-
...
22-
```
23-
24-
## Development version
25-
26-
```ini
27-
[env:development]
28-
platform = https://github.com/platformio/platform-espressif32.git
19+
platform = replace with url
2920
board = ...
3021
...
3122
```

Diff for: boards/esp32-c3-devkitm-1.json

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"openocd_target": "esp32c3.cfg"
1818
},
1919
"frameworks": [
20+
"arduino",
2021
"espidf"
2122
],
2223
"name": "Espressif ESP32-C3-DevKitM-1",

Diff for: boards/esp32-s2-franzininho.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"variant": "esp32s2"
1212
},
1313
"connectivity": [
14-
"wifi"
14+
"arduino",
15+
"espidf"
1516
],
1617
"debug": {
1718
"openocd_target": "esp32s2.cfg"

Diff for: boards/esp32-s2-kaluga-1.json

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"openocd_target": "esp32s2.cfg"
2222
},
2323
"frameworks": [
24+
"arduino",
2425
"espidf"
2526
],
2627
"name": "Espressif ESP32-S2-Kaluga-1 Kit",

Diff for: boards/esp32-s2-saola-1.json

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"openocd_target": "esp32s2.cfg"
1818
},
1919
"frameworks": [
20+
"arduino",
2021
"espidf"
2122
],
2223
"name": "Espressif ESP32-S2-Saola-1",

Diff for: boards/esp32-s3-devkitc-1.json

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"build": {
3+
"arduino":{
4+
"ldscript": "esp32s3_out.ld"
5+
},
6+
"core": "esp32",
7+
"f_cpu": "240000000L",
8+
"f_flash": "80000000L",
9+
"flash_mode": "dio",
10+
"mcu": "esp32s3",
11+
"variant": "esp32s3"
12+
},
13+
"connectivity": [
14+
"wifi"
15+
],
16+
"debug": {
17+
"openocd_target": "esp32s3.cfg"
18+
},
19+
"frameworks": [
20+
"arduino",
21+
"espidf"
22+
],
23+
"name": "Espressif ESP32-S3-DevKitC-1",
24+
"upload": {
25+
"flash_size": "8MB",
26+
"maximum_ram_size": 524288,
27+
"maximum_size": 8388608,
28+
"require_upload_port": true,
29+
"speed": 460800
30+
},
31+
"url": "https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/hw-reference/esp32s3/user-guide-devkitc-1.html",
32+
"vendor": "Espressif"
33+
}

Diff for: boards/featheresp32-s2.json

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"openocd_target": "esp32s2.cfg"
1818
},
1919
"frameworks": [
20+
"arduino",
2021
"espidf"
2122
],
2223
"name": "Adafruit ESP32-S2 Feather Development Board",

Diff for: builder/frameworks/_embed_files.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def transform_to_asm(target, source, env):
108108
action=env.VerboseAction(
109109
" ".join(
110110
[
111-
"xtensa-esp32-elf-objcopy",
111+
"xtensa-%s-elf-objcopy" % board.get("build.mcu", "esp32"),
112112
"--input-target",
113113
"binary",
114114
"--output-target",

Diff for: builder/frameworks/espidf.py

+83-31
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,13 @@
5555
% (
5656
"riscv32-esp"
5757
if mcu == "esp32c3"
58-
else ("xtensa-esp32s2" if mcu == "esp32s2" else "xtensa-esp32")
58+
else ("xtensa-%s" % mcu)
5959
)
6060
)
6161

62-
# Legacy toolchains for mixed IDF/Arduino projects
63-
if "arduino" in env.subst("$PIOFRAMEWORK"):
64-
TOOLCHAIN_DIR = platform.get_package_dir("toolchain-xtensa32")
65-
6662
assert os.path.isdir(FRAMEWORK_DIR)
6763
assert os.path.isdir(TOOLCHAIN_DIR)
6864

69-
# Arduino framework as a component is not compatible with ESP-IDF >=4.1
7065
if "arduino" in env.subst("$PIOFRAMEWORK"):
7166
ARDUINO_FRAMEWORK_DIR = platform.get_package_dir("framework-arduinoespressif32")
7267
# Possible package names in 'package@version' format is not compatible with CMake
@@ -233,7 +228,13 @@ def populate_idf_env_vars(idf_env):
233228

234229
if mcu != "esp32c3":
235230
additional_packages.append(
236-
os.path.join(platform.get_package_dir("toolchain-%sulp" % mcu), "bin"),
231+
os.path.join(
232+
platform.get_package_dir(
233+
"toolchain-%sulp"
234+
% ("esp32s2" if (mcu == "esp32s3" or mcu == "esp32s2") else mcu)
235+
),
236+
"bin"
237+
),
237238
)
238239

239240
if "windows" in get_systype():
@@ -341,7 +342,7 @@ def _add_archive(archive_path, link_args):
341342
if fragment.startswith("-l"):
342343
link_args["LIBS"].extend(args)
343344
elif fragment.startswith("-L"):
344-
lib_path = fragment.replace("-L", "").strip()
345+
lib_path = fragment.replace("-L", "").strip().strip('"')
345346
_add_to_libpath(lib_path, link_args)
346347
elif fragment.startswith("-") and not fragment.startswith("-l"):
347348
# CMake mistakenly marks LINKFLAGS as libraries
@@ -452,20 +453,11 @@ def find_framework_service_files(search_path, sdk_config):
452453

453454
result["lf_files"].extend(
454455
[
455-
os.path.join(
456-
FRAMEWORK_DIR,
457-
"components",
458-
idf_variant,
459-
"ld",
460-
"%s_fragments.lf" % idf_variant,
461-
),
462-
os.path.join(
463-
FRAMEWORK_DIR,
464-
"components",
465-
idf_variant,
466-
"linker.lf",
467-
),
456+
os.path.join(FRAMEWORK_DIR, "components", "esp_common", "common.lf"),
457+
os.path.join(FRAMEWORK_DIR, "components", "esp_common", "soc.lf"),
458+
os.path.join(FRAMEWORK_DIR, "components", "esp_system", "app.lf"),
468459
os.path.join(FRAMEWORK_DIR, "components", "newlib", "newlib.lf"),
460+
os.path.join(FRAMEWORK_DIR, "components", "newlib", "system_libs.lf"),
469461
]
470462
)
471463

@@ -515,6 +507,46 @@ def generate_project_ld_script(sdk_config, ignore_targets=None):
515507
libraries_list = create_custom_libraries_list(
516508
os.path.join(BUILD_DIR, "ldgen_libraries"), ignore_targets
517509
)
510+
# Rework the memory template linker script, following components/esp_system/ld.cmake
511+
args = {
512+
"preprocess" : os.path.join(
513+
TOOLCHAIN_DIR,
514+
"bin",
515+
env.subst("$CC")),
516+
"ld_output": os.path.join("$BUILD_DIR", "memory.ld"),
517+
"ld_dir": os.path.join(
518+
FRAMEWORK_DIR,
519+
"components",
520+
"esp_system",
521+
"ld"),
522+
"ld_input": os.path.join(
523+
FRAMEWORK_DIR,
524+
"components",
525+
"esp_system",
526+
"ld",
527+
idf_variant,
528+
"memory.ld.in",
529+
),
530+
"config": os.path.join("$BUILD_DIR", "config"),
531+
"flags" : '-C -P -x c -E -o '
532+
}
533+
534+
cmd = (
535+
'"{preprocess}" {flags} "{ld_output}" -I "{config}" -I "{ld_dir}" "{ld_input}"'
536+
).format(**args)
537+
538+
env.Command(
539+
os.path.join("$BUILD_DIR", "memory.ld"),
540+
os.path.join(
541+
FRAMEWORK_DIR,
542+
"components",
543+
"esp_system",
544+
"ld",
545+
idf_variant,
546+
"memory.ld.in",
547+
),
548+
env.VerboseAction(cmd, "Generating memory linker script $TARGET"),
549+
)
518550

519551
args = {
520552
"script": os.path.join(FRAMEWORK_DIR, "tools", "ldgen", "ldgen.py"),
@@ -539,13 +571,14 @@ def generate_project_ld_script(sdk_config, ignore_targets=None):
539571
).format(**args)
540572

541573
return env.Command(
542-
os.path.join("$BUILD_DIR", "%s.project.ld" % idf_variant),
574+
os.path.join("$BUILD_DIR", "sections.ld"),
543575
os.path.join(
544576
FRAMEWORK_DIR,
545577
"components",
546-
idf_variant,
578+
"esp_system",
547579
"ld",
548-
"%s.project.ld.in" % idf_variant,
580+
idf_variant,
581+
"sections.ld.in",
549582
),
550583
env.VerboseAction(cmd, "Generating project linker script $TARGET"),
551584
)
@@ -703,6 +736,20 @@ def find_lib_deps(components_map, elf_config, link_args, ignore_components=None)
703736

704737
return result
705738

739+
def fix_ld_paths(extra_flags):
740+
peripheral_framework_path = os.path.join(FRAMEWORK_DIR, "components", "soc", idf_variant, "ld")
741+
rom_framework_path = os.path.join(FRAMEWORK_DIR, "components", "esp_rom", idf_variant, "ld")
742+
bl_framework_path = os.path.join(FRAMEWORK_DIR, "components", "bootloader", "subproject", "main", "ld", idf_variant)
743+
744+
# ESP linker scripts changed path in ESP-IDF 4.4+, so add missing paths to linker's search path
745+
try:
746+
ld_index = extra_flags.index("%s.peripherals.ld" % idf_variant)
747+
extra_flags[ld_index-1:ld_index-1] = [ "-L", peripheral_framework_path, "-L", rom_framework_path, "-L", bl_framework_path]
748+
except:
749+
print("Error while parsing the flags")
750+
751+
return extra_flags
752+
706753

707754
def build_bootloader():
708755
bootloader_src_dir = os.path.join(
@@ -747,6 +794,7 @@ def build_bootloader():
747794
build_components(bootloader_env, components_map, bootloader_src_dir, "bootloader")
748795
link_args = extract_link_args(elf_config)
749796
extra_flags = filter_args(link_args["LINKFLAGS"], ["-T", "-u"])
797+
extra_flags = fix_ld_paths(extra_flags)
750798
link_args["LINKFLAGS"] = sorted(
751799
list(set(link_args["LINKFLAGS"]) - set(extra_flags))
752800
)
@@ -1061,21 +1109,23 @@ def _get_installed_pip_packages():
10611109

10621110
if not board.get("build.ldscript", ""):
10631111
linker_script = env.Command(
1064-
os.path.join("$BUILD_DIR", "%s_out.ld" % idf_variant),
1112+
os.path.join("$BUILD_DIR", "memory.ld"),
10651113
board.get(
10661114
"build.esp-idf.ldscript",
10671115
os.path.join(
1068-
FRAMEWORK_DIR, "components", idf_variant, "ld", "%s.ld" % idf_variant
1116+
FRAMEWORK_DIR, "components", "esp_system", "ld", idf_variant, "memory.ld.in"
10691117
),
10701118
),
10711119
env.VerboseAction(
1072-
'$CC -I"$BUILD_DIR/config" -C -P -x c -E $SOURCE -o $TARGET',
1120+
'$CC -I"$BUILD_DIR/config" -I"' +
1121+
os.path.join(FRAMEWORK_DIR, "components", "esp_system", "ld") +
1122+
'" -C -P -x c -E $SOURCE -o $TARGET',
10731123
"Generating LD script $TARGET",
10741124
),
10751125
)
10761126

10771127
env.Depends("$BUILD_DIR/$PROGNAME$PROGSUFFIX", linker_script)
1078-
env.Replace(LDSCRIPT_PATH="%s_out.ld" % idf_variant)
1128+
env.Replace(LDSCRIPT_PATH="memory.ld")
10791129

10801130
#
10811131
# Generate partition table
@@ -1257,13 +1307,15 @@ def _get_installed_pip_packages():
12571307
# Extra flags which need to be explicitly specified in LINKFLAGS section because SCons
12581308
# cannot merge them correctly
12591309
extra_flags = filter_args(link_args["LINKFLAGS"], ["-T", "-u"])
1310+
extra_flags = fix_ld_paths(extra_flags)
12601311
link_args["LINKFLAGS"] = sorted(list(set(link_args["LINKFLAGS"]) - set(extra_flags)))
12611312

1262-
# remove the main linker script flags '-T esp32_out.ld'
1313+
# remove the main linker script flags '-T memory.ld' since it already appears later on
12631314
try:
1264-
ld_index = extra_flags.index("%s_out.ld" % idf_variant)
1315+
ld_index = extra_flags.index("memory.ld")
12651316
extra_flags.pop(ld_index)
12661317
extra_flags.pop(ld_index - 1)
1318+
pass
12671319
except:
12681320
print("Warning! Couldn't find the main linker script in the CMake code model.")
12691321

@@ -1319,7 +1371,7 @@ def _skip_prj_source_files(node):
13191371
FLASH_EXTRA_IMAGES=[
13201372
(
13211373
board.get(
1322-
"upload.bootloader_offset", "0x0" if mcu == "esp32c3" else "0x1000"
1374+
"upload.bootloader_offset", "0x0" if (mcu == "esp32c3" or mcu == "esp32s3") else "0x1000"
13231375
),
13241376
os.path.join("$BUILD_DIR", "bootloader.bin"),
13251377
),

0 commit comments

Comments
 (0)