Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mbed framework is incompatible with pyelftools-0.30 which is installed by pio #4834

Closed
rishyak opened this issue Jan 15, 2024 · 4 comments
Closed
Milestone

Comments

@rishyak
Copy link

rishyak commented Jan 15, 2024

Configuration

Operating system: Arch Linux

PlatformIO Version: 6.1.13

Description of problem

PIO fails to initialise with certain boards because of a pyelftools dependency.

Steps to Reproduce

  1. Create a new mbed project with any mbed-supported board
  2. It will fail

Actual Results

Failure

CONFIGURATION: https://docs.platformio.org/page/boards/nordicnrf52/nrf52840_dk.html
PLATFORM: Nordic nRF52 (10.1.0) > Nordic nRF52840-DK
HARDWARE: NRF52840 64MHz, 256KB RAM, 1MB Flash
DEBUG: Current (jlink) On-board (cmsis-dap, jlink) External (blackmagic, stlink)
PACKAGES: 
 - framework-mbed @ 6.61700.230818 (6.17.0) 
 - tool-sreccat @ 1.164.0 (1.64) 
 - toolchain-gccarmnoneeabi @ 1.90201.191206 (9.2.1)
ModuleNotFoundError: No module named 'elftools.common.py3compat':
  File "/home/rishyak/.platformio/penv/lib/python3.11/site-packages/platformio/builder/main.py", line 173:
    env.SConscript("$BUILD_SCRIPT")
  File "/home/rishyak/.platformio/packages/tool-scons/scons-local-4.6.0/SCons/Script/SConscript.py", line 609:
    return _SConscript(self.fs, *files, **subst_kw)
  File "/home/rishyak/.platformio/packages/tool-scons/scons-local-4.6.0/SCons/Script/SConscript.py", line 279:
    exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
  File "/home/rishyak/.platformio/platforms/nordicnrf52/builder/main.py", line 195:
    target_elf = env.BuildProgram()
  File "/home/rishyak/.platformio/packages/tool-scons/scons-local-4.6.0/SCons/Util/envs.py", line 251:
    return self.method(*nargs, **kwargs)
  File "/home/rishyak/.platformio/penv/lib/python3.11/site-packages/platformio/builder/tools/piobuild.py", line 61:
    env.ProcessProgramDeps()
  File "/home/rishyak/.platformio/packages/tool-scons/scons-local-4.6.0/SCons/Util/envs.py", line 251:
    return self.method(*nargs, **kwargs)
  File "/home/rishyak/.platformio/penv/lib/python3.11/site-packages/platformio/builder/tools/piobuild.py", line 121:
    env.BuildFrameworks(env.get("PIOFRAMEWORK"))
  File "/home/rishyak/.platformio/packages/tool-scons/scons-local-4.6.0/SCons/Util/envs.py", line 251:
    return self.method(*nargs, **kwargs)
  File "/home/rishyak/.platformio/penv/lib/python3.11/site-packages/platformio/builder/tools/piobuild.py", line 347:
    SConscript(env.GetFrameworkScript(name), exports="env")
  File "/home/rishyak/.platformio/packages/tool-scons/scons-local-4.6.0/SCons/Script/SConscript.py", line 673:
    return method(*args, **kw)
  File "/home/rishyak/.platformio/packages/tool-scons/scons-local-4.6.0/SCons/Script/SConscript.py", line 609:
    return _SConscript(self.fs, *files, **subst_kw)
  File "/home/rishyak/.platformio/packages/tool-scons/scons-local-4.6.0/SCons/Script/SConscript.py", line 279:
    exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
  File "/home/rishyak/.platformio/platforms/nordicnrf52/builder/frameworks/mbed.py", line 35:
    SConscript(
  File "/home/rishyak/.platformio/packages/tool-scons/scons-local-4.6.0/SCons/Script/SConscript.py", line 673:
    return method(*args, **kw)
  File "/home/rishyak/.platformio/packages/tool-scons/scons-local-4.6.0/SCons/Script/SConscript.py", line 609:
    return _SConscript(self.fs, *files, **subst_kw)
  File "/home/rishyak/.platformio/packages/tool-scons/scons-local-4.6.0/SCons/Script/SConscript.py", line 279:
    exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
  File "/home/rishyak/.platformio/packages/framework-mbed/platformio/platformio-build.py", line 61:
    from pio_mbed_adapter import PlatformioMbedAdapter
  File "/home/rishyak/.platformio/packages/framework-mbed/platformio/pio_mbed_adapter.py", line 23:
    from tools.build_api import prepare_toolchain, UPDATE_WHITELIST
  File "/home/rishyak/.platformio/packages/framework-mbed/tools/build_api.py", line 36:
    from .arm_pack_manager import Cache
  File "/home/rishyak/.platformio/packages/framework-mbed/tools/arm_pack_manager/__init__.py", line 29:
    from tools.flash_algo import PackFlashAlgo
  File "/home/rishyak/.platformio/packages/framework-mbed/tools/flash_algo/__init__.py", line 33:
    from elftools.common.py3compat import bytes2str
========================== [FAILED] Took 0.15 seconds ==========================

Expected Results

It doesn't fail.

Additional info

Downgrading pyelftools to 0.29 fixes the issue. Seems like you're suffering from the same issue pwntools did in September 2023.

Seems like PIO installs a version 0.30 which moves bytes2str to elftools.common.utils. Frameworks use the same virtual environment and causes failure in the case of mbed.

Began tracking this issue when I got this.

@rishyak rishyak changed the title PlatformIO is incompatible with pyelftools-0.30 mbed framework is incompatible with pyelftools-0.30 Jan 15, 2024
@rishyak rishyak changed the title mbed framework is incompatible with pyelftools-0.30 mbed framework is incompatible with pyelftools-0.30 which is installed by pio Jan 15, 2024
@ivankravets ivankravets added this to the 6.1.14 milestone Jan 17, 2024
@ivankravets
Copy link
Member

Thanks for the report. Please re-test with pio upgrade --dev.

@lakshanwijerathne
Copy link

this issue was regenerated for pyelftools 0.31. should check this also.

@ivankravets
Copy link
Member

Open PlatformIO Core CLI and type pip install pyelftools==0.29

@lakshanwijerathne
Copy link

lakshanwijerathne commented Mar 26, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants