question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't use custom framework-espidf since v3.3.0

See original GitHub issue

Trying to specify a custom framework-espidf is broken since v3.3.0 with this error:

TypeError: write() argument must be str, not None:
  File "/usr/local/Cellar/platformio/5.1.1/libexec/lib/python3.9/site-packages/platformio/builder/main.py", line 177:
    env.SConscript("$BUILD_SCRIPT")
  File "/Users/rohan/.platformio/packages/tool-scons/scons-local-4.1.0/SCons/Script/SConscript.py", line 591:
    return _SConscript(self.fs, *files, **subst_kw)
  File "/Users/rohan/.platformio/packages/tool-scons/scons-local-4.1.0/SCons/Script/SConscript.py", line 280:
    exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
  File "/Users/rohan/.platformio/platforms/espressif32/builder/main.py", line 218:
    target_elf = env.BuildProgram()
  File "/Users/rohan/.platformio/packages/tool-scons/scons-local-4.1.0/SCons/Util.py", line 658:
    return self.method(*nargs, **kwargs)
  File "/usr/local/Cellar/platformio/5.1.1/libexec/lib/python3.9/site-packages/platformio/builder/tools/platformio.py", line 61:
    env.ProcessProgramDeps()
  File "/Users/rohan/.platformio/packages/tool-scons/scons-local-4.1.0/SCons/Util.py", line 658:
    return self.method(*nargs, **kwargs)
  File "/usr/local/Cellar/platformio/5.1.1/libexec/lib/python3.9/site-packages/platformio/builder/tools/platformio.py", line 127:
    env.BuildFrameworks(env.get("PIOFRAMEWORK"))
  File "/Users/rohan/.platformio/packages/tool-scons/scons-local-4.1.0/SCons/Util.py", line 658:
    return self.method(*nargs, **kwargs)
  File "/usr/local/Cellar/platformio/5.1.1/libexec/lib/python3.9/site-packages/platformio/builder/tools/platformio.py", line 342:
    SConscript(env.GetFrameworkScript(f), exports="env")
  File "/Users/rohan/.platformio/packages/tool-scons/scons-local-4.1.0/SCons/Script/SConscript.py", line 654:
    return method(*args, **kw)
  File "/Users/rohan/.platformio/packages/tool-scons/scons-local-4.1.0/SCons/Script/SConscript.py", line 591:
    return _SConscript(self.fs, *files, **subst_kw)
  File "/Users/rohan/.platformio/packages/tool-scons/scons-local-4.1.0/SCons/Script/SConscript.py", line 280:
    exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
  File "/Users/rohan/.platformio/platforms/espressif32/builder/frameworks/espidf.py", line 1052:
    create_version_file()
  File "/Users/rohan/.platformio/platforms/espressif32/builder/frameworks/espidf.py", line 841:
    fp.write(

I believe this is a regression caused by 4cb06337d678312dbcb293f508d7de7d7124ee68 (/cc @valeros), which was meant to resolve #558. Here is the code in question:

def create_version_file():
    version_file = os.path.join(FRAMEWORK_DIR, "version.txt")
    if not os.path.isfile(version_file):
        with open(version_file, "w") as fp:
            fp.write(platform.get_package_version("framework-espidf"))
            fp.write(
                get_original_version(platform.get_package_version("framework-espidf"))
            )

For example, let’s say I want to explicitly specify ESP-IDF v4.3 from the Espressif origin:

platform_packages =
  framework-espidf @ https://github.com/espressif/esp-idf#v4.3

In this case, platform.get_package_version("framework-espidf") will return '1.1.0+sha.c9646ff'. In that string, c9646ff is the Git commit hash for v4.3.

However, this causes get_original_version to return None:

def get_original_version(version):
    if version.count(".") != 2:
        return None
    _, raw = version.split(".")[:2]
    if int(raw) <= 99:
        return None
    if int(raw) <= 9999:
        return "%s.%s" % (raw[:-2], int(raw[-2:]))
    return "%s.%s.%s" % (raw[:-4], int(raw[-4:-2]), int(raw[-2:]))

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
rohansinghcommented, Oct 24, 2021

@klvnptr That’s a separate issue, wherein you can’t actually use an ESP-IDF branch directly. Instead you have to make a fork that contains a package.json.

That’s always been the case, though it’s not really documented anywhere.

0reactions
mvdbergecommented, Nov 24, 2021

@klvnptr That’s a separate issue, wherein you can’t actually use an ESP-IDF branch directly. Instead you have to make a fork that contains a package.json.

That’s always been the case, though it’s not really documented anywhere.

Do you have a working example somewhere which could be used for reference? I’m new to platform.io and this would help a lot. Thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Get Started - - — ESP-IDF Programming Guide release-v3. ...
The software development framework by Espressif is intended for rapidly ... of using a prebuilt toolchain, you may want to customize your environment....
Read more >
Problems building with ESP-IDF latest version (4.3.0)
Hello, I'm trying to build a project that uses esp-idf in Platformio and I could still not compile it. There seems to be...
Read more >
Unable to buid VS Code - ESP32 Forum
VSCode Version: [e.g. 1.35.1] - ESP-IDF Version: [e.g. v3.2.2] - Python Version: [e.g. 2.7.10] You can use the "ESP-IDF: Doctor command" to ...
Read more >
Get Started (CMake) — ESP-IDF Programming Guide ...
Through a simple example we would like to illustrate how to use ESP-IDF (Espressif IoT Development Framework), including the menu based configuration, ...
Read more >
The Internet of Things with ESP32
Generated from the docs directory in the ESP-IDF repository. ... Use an ESP32/Arduino to connect Bluetooth devices to the Watson IoT Platform.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found