Skip to content

Commit

Permalink
Arduino 2.0.2 / IDF 4.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason2866 authored Dec 28, 2021
1 parent 495c689 commit 654a9d5
Show file tree
Hide file tree
Showing 16 changed files with 263 additions and 257 deletions.
15 changes: 3 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Espressif 32: development platform for [PlatformIO](http://platformio.org)
# Tasmota Espressif 32: development platform for [PlatformIO](http://platformio.org)

[![Build Status](https://github.com/platformio/platform-espressif32/workflows/Examples/badge.svg)](https://github.com/platformio/platform-espressif32/actions)
[![Examples](https://github.com/Jason2866/platform-espressif32/actions/workflows/examples.yml/badge.svg?branch=idf_v4.4%2Farduino_v2.0.2)](https://github.com/Jason2866/platform-espressif32/actions/workflows/examples.yml)

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.

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

```ini
[env:stable]
platform = espressif32
board = ...
...
```

## Development version

```ini
[env:development]
platform = https://github.com/platformio/platform-espressif32.git
platform = todo
board = ...
...
```
Expand Down
1 change: 1 addition & 0 deletions boards/esp32-c3-devkitm-1.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"openocd_target": "esp32c3.cfg"
},
"frameworks": [
"arduino",
"espidf"
],
"name": "Espressif ESP32-C3-DevKitM-1",
Expand Down
1 change: 1 addition & 0 deletions boards/esp32-s2-kaluga-1.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"openocd_target": "esp32s2.cfg"
},
"frameworks": [
"arduino",
"espidf"
],
"name": "Espressif ESP32-S2-Kaluga-1 Kit",
Expand Down
1 change: 1 addition & 0 deletions boards/esp32-s2-saola-1.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"openocd_target": "esp32s2.cfg"
},
"frameworks": [
"arduino",
"espidf"
],
"name": "Espressif ESP32-S2-Saola-1",
Expand Down
116 changes: 93 additions & 23 deletions builder/frameworks/espidf.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,9 @@
)
)

# Legacy toolchains for mixed IDF/Arduino projects
if "arduino" in env.subst("$PIOFRAMEWORK"):
TOOLCHAIN_DIR = platform.get_package_dir("toolchain-xtensa32")

assert os.path.isdir(FRAMEWORK_DIR)
assert os.path.isdir(TOOLCHAIN_DIR)

# Arduino framework as a component is not compatible with ESP-IDF >=4.1
if "arduino" in env.subst("$PIOFRAMEWORK"):
ARDUINO_FRAMEWORK_DIR = platform.get_package_dir("framework-arduinoespressif32")
# Possible package names in 'package@version' format is not compatible with CMake
Expand Down Expand Up @@ -341,7 +336,7 @@ def _add_archive(archive_path, link_args):
if fragment.startswith("-l"):
link_args["LIBS"].extend(args)
elif fragment.startswith("-L"):
lib_path = fragment.replace("-L", "").strip()
lib_path = fragment.replace("-L", "").strip().strip('"')
_add_to_libpath(lib_path, link_args)
elif fragment.startswith("-") and not fragment.startswith("-l"):
# CMake mistakenly marks LINKFLAGS as libraries
Expand Down Expand Up @@ -455,17 +450,23 @@ def find_framework_service_files(search_path, sdk_config):
os.path.join(
FRAMEWORK_DIR,
"components",
idf_variant,
"ld",
"%s_fragments.lf" % idf_variant,
),
"esp_common",
"common.lf"),

os.path.join(
FRAMEWORK_DIR,
"components",
idf_variant,
"linker.lf",
),
"esp_common",
"soc.lf"),

os.path.join(
FRAMEWORK_DIR,
"components",
"esp_system",
"app.lf"),

os.path.join(FRAMEWORK_DIR, "components", "newlib", "newlib.lf"),
os.path.join(FRAMEWORK_DIR, "components", "newlib", "system_libs.lf"),
]
)

Expand Down Expand Up @@ -515,14 +516,63 @@ def generate_project_ld_script(sdk_config, ignore_targets=None):
libraries_list = create_custom_libraries_list(
os.path.join(BUILD_DIR, "ldgen_libraries"), ignore_targets
)
# Rework the memory template linker script, following components/esp_system/ld.cmake
args = {
"preprocess" : os.path.join(
TOOLCHAIN_DIR,
"bin",
env.subst("$CC")),
"ld_output": os.path.join("$BUILD_DIR", "memory.ld"),
"ld_dir": os.path.join(FRAMEWORK_DIR,
"components",
"esp_system",
"ld"),
"ld_input": os.path.join(
FRAMEWORK_DIR,
"components",
"esp_system",
"ld",
idf_variant,
"memory.ld.in",
),
"project_output": os.path.join("$BUILD_DIR", "%s.project.ld" % idf_variant),
"config": os.path.join("$BUILD_DIR", "config"),
"flags" : '-C -P -x c -E -o '
}

cmd = (
'"{preprocess}" {flags} "{ld_output}" -I "{config}" -I "{ld_dir}" "{ld_input}"'
).format(**args)

env.Command(
os.path.join("$BUILD_DIR", "memory.ld"),
os.path.join(
FRAMEWORK_DIR,
"components",
"esp_system",
"ld",
idf_variant,
"memory.ld.in",
),
env.VerboseAction(cmd, "Generating memory linker script $TARGET"),
)

args = {
"script": os.path.join(FRAMEWORK_DIR, "tools", "ldgen", "ldgen.py"),
"config": SDKCONFIG_PATH,
"fragments": " ".join(['"%s"' % f for f in project_files.get("lf_files")]),
"fragments": " ".join(['"%s"' % f for f in project_files.get("lf_files")]),
# "fragments": "".join(['%s;' % f for f in project_files.get("lf_files")]).strip(';'),
"kconfig": os.path.join(FRAMEWORK_DIR, "Kconfig"),
"env_file": os.path.join("$BUILD_DIR", "config.env"),
"libraries_list": libraries_list,
"section_input": os.path.join(
FRAMEWORK_DIR,
"components",
"esp_system",
"ld",
idf_variant,
"sections.ld.in",
),
"objdump": os.path.join(
TOOLCHAIN_DIR,
"bin",
Expand All @@ -539,13 +589,14 @@ def generate_project_ld_script(sdk_config, ignore_targets=None):
).format(**args)

return env.Command(
os.path.join("$BUILD_DIR", "%s.project.ld" % idf_variant),
os.path.join("$BUILD_DIR", "sections.ld"),
os.path.join(
FRAMEWORK_DIR,
"components",
idf_variant,
"esp_system",
"ld",
"%s.project.ld.in" % idf_variant,
idf_variant,
"sections.ld.in",
),
env.VerboseAction(cmd, "Generating project linker script $TARGET"),
)
Expand Down Expand Up @@ -703,6 +754,20 @@ def find_lib_deps(components_map, elf_config, link_args, ignore_components=None)

return result

def fix_ld_paths(extra_flags):
peripheral_framework_path = os.path.join(FRAMEWORK_DIR, "components", "soc", idf_variant, "ld")
rom_framework_path = os.path.join(FRAMEWORK_DIR, "components", "esp_rom", idf_variant, "ld")
bl_framework_path = os.path.join(FRAMEWORK_DIR, "components", "bootloader", "subproject", "main", "ld", idf_variant)

# ESP linker scripts changed path in ESP-IDF 4.4+, so add missing paths to linker's search path
try:
ld_index = extra_flags.index("%s.peripherals.ld" % idf_variant)
extra_flags[ld_index-1:ld_index-1] = [ "-L", peripheral_framework_path, "-L", rom_framework_path, "-L", bl_framework_path]
except:
print("Error while parsing the flags")

return extra_flags


def build_bootloader():
bootloader_src_dir = os.path.join(
Expand Down Expand Up @@ -747,6 +812,7 @@ def build_bootloader():
build_components(bootloader_env, components_map, bootloader_src_dir, "bootloader")
link_args = extract_link_args(elf_config)
extra_flags = filter_args(link_args["LINKFLAGS"], ["-T", "-u"])
extra_flags = fix_ld_paths(extra_flags)
link_args["LINKFLAGS"] = sorted(
list(set(link_args["LINKFLAGS"]) - set(extra_flags))
)
Expand Down Expand Up @@ -1061,21 +1127,23 @@ def _get_installed_pip_packages():

if not board.get("build.ldscript", ""):
linker_script = env.Command(
os.path.join("$BUILD_DIR", "%s_out.ld" % idf_variant),
os.path.join("$BUILD_DIR", "memory.ld"),
board.get(
"build.esp-idf.ldscript",
os.path.join(
FRAMEWORK_DIR, "components", idf_variant, "ld", "%s.ld" % idf_variant
FRAMEWORK_DIR, "components", "esp_system", "ld", idf_variant, "memory.ld.in"
),
),
env.VerboseAction(
'$CC -I"$BUILD_DIR/config" -C -P -x c -E $SOURCE -o $TARGET',
'$CC -I"$BUILD_DIR/config" -I"' +
os.path.join(FRAMEWORK_DIR, "components", "esp_system", "ld") +
'" -C -P -x c -E $SOURCE -o $TARGET',
"Generating LD script $TARGET",
),
)

env.Depends("$BUILD_DIR/$PROGNAME$PROGSUFFIX", linker_script)
env.Replace(LDSCRIPT_PATH="%s_out.ld" % idf_variant)
env.Replace(LDSCRIPT_PATH="memory.ld")

#
# Generate partition table
Expand Down Expand Up @@ -1257,13 +1325,15 @@ def _get_installed_pip_packages():
# Extra flags which need to be explicitly specified in LINKFLAGS section because SCons
# cannot merge them correctly
extra_flags = filter_args(link_args["LINKFLAGS"], ["-T", "-u"])
extra_flags = fix_ld_paths(extra_flags)
link_args["LINKFLAGS"] = sorted(list(set(link_args["LINKFLAGS"]) - set(extra_flags)))

# remove the main linker script flags '-T esp32_out.ld'
# remove the main linker script flags '-T memory.ld' since it already appears later on
try:
ld_index = extra_flags.index("%s_out.ld" % idf_variant)
ld_index = extra_flags.index("memory.ld")
extra_flags.pop(ld_index)
extra_flags.pop(ld_index - 1)
pass
except:
print("Warning! Couldn't find the main linker script in the CMake code model.")

Expand Down
3 changes: 0 additions & 3 deletions examples/espidf-arduino-blink/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ framework = arduino, espidf
build_flags =
-D CONFIG_BLINK_GPIO=2
monitor_speed = 115200
platform_packages =
; use a special branch
framework-arduinoespressif32 @ https://github.com/marcovannoord/arduino-esp32.git#idf-release/v4.0

[env:esp32dev]
board = esp32dev
Expand Down
3 changes: 1 addition & 2 deletions examples/espidf-arduino-blink/sdkconfig.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ CONFIG_ARDUINO_EVENT_RUN_CORE1=y
CONFIG_ARDUINO_EVENT_RUNNING_CORE=1
CONFIG_ARDUINO_UDP_RUN_CORE1=y
CONFIG_ARDUINO_UDP_RUNNING_CORE=1
CONFIG_DISABLE_HAL_LOCKS=y
CONFIG_ARDUHAL_LOG_DEFAULT_LEVEL_ERROR=y
CONFIG_ARDUHAL_LOG_DEFAULT_LEVEL=1
CONFIG_ARDUHAL_PARTITION_SCHEME_DEFAULT=y
CONFIG_ARDUHAL_PARTITION_SCHEME="default"
CONFIG_AUTOCONNECT_WIFI=y
CONFIG_ARDUINO_SELECTIVE_WiFi=y
CONFIG_MBEDTLS_PSK_MODES=y
CONFIG_MBEDTLS_KEY_EXCHANGE_PSK=y
CONFIG_MBEDTLS_KEY_EXCHANGE_PSK=y
3 changes: 0 additions & 3 deletions examples/espidf-arduino-wifiscan/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
platform = espressif32
framework = arduino, espidf
monitor_speed = 115200
platform_packages =
; use a special branch
framework-arduinoespressif32 @ https://github.com/marcovannoord/arduino-esp32.git#idf-release/v4.0

[env:esp32dev]
board = esp32dev
Expand Down
1 change: 0 additions & 1 deletion examples/espidf-arduino-wifiscan/sdkconfig.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ CONFIG_ARDUINO_EVENT_RUN_CORE1=y
CONFIG_ARDUINO_EVENT_RUNNING_CORE=1
CONFIG_ARDUINO_UDP_RUN_CORE1=y
CONFIG_ARDUINO_UDP_RUNNING_CORE=1
CONFIG_DISABLE_HAL_LOCKS=y
CONFIG_ARDUHAL_LOG_DEFAULT_LEVEL_ERROR=y
CONFIG_ARDUHAL_LOG_DEFAULT_LEVEL=1
CONFIG_ARDUHAL_PARTITION_SCHEME_DEFAULT=y
Expand Down
46 changes: 25 additions & 21 deletions examples/espidf-coap-server/src/certs/coap_ca.pem
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
-----BEGIN CERTIFICATE-----
MIID3DCCA0WgAwIBAgIJAMnlgL1czsmjMA0GCSqGSIb3DQEBCwUAMIGTMQswCQYD
VQQGEwJGUjEPMA0GA1UECAwGUmFkaXVzMRIwEAYDVQQHDAlTb21ld2hlcmUxFTAT
BgNVBAoMDEV4YW1wbGUgSW5jLjEgMB4GCSqGSIb3DQEJARYRYWRtaW5AZXhhbXBs
ZS5jb20xJjAkBgNVBAMMHUV4YW1wbGUgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MB4X
DTE3MDYwNzA4MDY0OVoXDTI3MDYwNTA4MDY0OVowgZMxCzAJBgNVB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1UEBhMCQ0EwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAATZ1BRM
T1//Fzh9sneRZNwS4kgCxN1PvgwT271qCpYqyxnjLEa38AP1IAanhpiD/OkVc0Zd
7NgDPCw7n94EULMyoy8wLTAdBgNVHQ4EFgQUCyLcptURGIonMUJ8L8ZWtiSwbMQw
DAYDVR0TBAUwAwEB/zAMBggqhkjOPQQDAgUAA0cAMEQCIAdLEgcUWdpAl9jwdJiz
/cHW7/CBIWEvqiQfzE+XLyLOAiAvuxSdOtSDjh2aC5qEjUCH8CSKCxWB74j23tmp
aqPH4A==
-----END CERTIFICATE-----
Loading

0 comments on commit 654a9d5

Please sign in to comment.