Platform IDE for VSCode on Mac ARM/M1?

If it can’t find that library you might need to install a OpenSSL development package that has this header file… Maybe checkout 'openssl/opensslv.h' file not found and Mac install fails with fatal error: 'openssl/opensslv.h' file not found (tried previous instructions) · Issue #3489 · pyca/cryptography · GitHub.

But I agree this is very fiddily and complicated. Right now it’s not installing because the PyPi registry does not have a precompiled version for cryptography for the Darwin ARM architecture.

Even if that hurdle is removed, PlatformIO still lacks the platform-native compiler toolchains and upload tools (like, toolchain-atmelavr with AVR-GCC, avrdude uploader etc, depending on target embedded board). So it will be much more work after that, compiling those yourself. That is just something the maintainers of PlatformIO (@ivankravets) will surely do in the future to support the darwin_arm64 platform with the Apple M1 silicon, but right now it’ll be hard with these problems in even standard Python libraries.

1 Like

Thanks again Maximilian,

sounds like a bit too high level for my development skills.
Must switch to my 10 years old outdated Mac mini with Intel CPU for this kind of task then…

kr
j

2 Likes

Probably your best option for now. Given that the M1 has basically only just been released, and is completely different architecture, there will be a lot of things that won’t just work (yet!) despite what Apple might like to claim. It won’t take long to change that if the demand is there. :wink:

1 Like

You can install https://brew.sh/ and then

brew install openssl
1 Like

hi Ivan,

yepp as the 1st Homebrew release with M1 support was announced some days ago I installed it and used the openssl install you sent over. The error that C/C++ Extension does not support Arm Architecture is still there when I open up VSC but:

Platform IDE comes up like usual! I even imported Tasmota as a Project (=Arduino stuff for home automation). But when I try to compile Tasmota I get the following error:

Executing task: pio run <

Processing tasmota-DE (platform: espressif8266 @ 2.6.2; framework: arduino; board: esp01_1m)

Tool Manager: Installing platformio/toolchain-xtensa @ 2.40802.200502
Error: Could not find the package with ‘platformio/toolchain-xtensa @ 2.40802.200502’ requirements for your system ‘darwin_arm64’
Der Terminalprozess “pio ‘run’” wurde mit folgendem Exitcode beendet: 1.

Is this toolchain-xtensa something fixable too?

kr
Chako

Let’s test it. Please download and unpack this toolchain Service End for Bintray, JCenter, GoCenter, and ChartCenter | JFrog

Try to run from CLI some binary from bin folder. For example gcc-xxxx --version. Does it work?

1 Like

Hi Ivan,

Not 100% sure what I must do within PlatformIDE, but what I did

a) Downloaded your archive and extracted it into a temp Directory.
b) Disabled Mac security as I was not allowed to execute cmdlline gcc due to „not verified Developer“.

Then I used the GCC Compiler command you mentioned:
chako@MacMini bin % xtensa-lx106-elf-gcc --version

xtensa-lx106-elf-gcc (GCC) 10.2.0

Copyright (C) 2020 Free Software Foundation, Inc.

This is free software; see the source for copying conditions. There is NO

warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Looks to me as if gcc ran ok. To answer your question: Yes it worked.

Will check later on today if I find this path in PlatfromIDE setup to understand where I must extract it to exchange your “extensa” with the installed version ….

Great! Apple uses Rosetta emulator. It means, we just need to repack our existing packages for x86 and add Arm to manifest.

I’ll need the last confirmation. please do the next steps:

  1. Download ***-contrib-pysite-darwin_x86_64-2.39-*** from Service End for Bintray, JCenter, GoCenter, and ChartCenter | JFrog . It looks you have Python 3.9 in the system
  2. Unpack it
  3. Replace ALL files in ~/.platformio/packages/contrib-pysite by files from archive. But!!! KEEP OLD package.json and .pm.
  4. Open PlatformIO CLI in IDE and type pio home.

So, does it works WITHOUT recompiling which you reported above in the initial comment?

hmm … there is no .pm file in this directory only the package.json is there.

ok, I did:

  • renamed old contrib-pysite and even moved it to another location.
  • Downloaded the file you mentioned and extracted it.
  • created a new contrib-pysite directory and copied all files from extracted archive over.
  • Superseeded package.json with the version from original contrib-pysite directory.

and started VSC.

Results:

  • PlatfromIO IDE did not start automatically. But when I clicked the open button it started up.
  • Compile Error stayed the same.
  • I used even the package.json from the downloaded tar file. Then it started up automatically but compile error stayed the same again.
  • result from pio home is the same as well, see picture further down.

If you like we can do a team viewer session then you can verify or even suggest additional steps.
Simply let me know if you would like to do that and when.

merry Christmas to everybody who reads this … :wink:

kr
j

Contacted in PM. I would be thankful for the remote session to test all binaries.

hi Ivan,

the changes took place this morning on my side. All fine now!

Fyi:

  • When I 1st tried to compile I got the following Linker Error:
Linking .pio/build/tasmota-DE/firmware.elf
/Users/chako/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld: .pio/build/tasmota-DE/libFrameworkArduino.a(core_esp8266_main.cpp.o):(.text._ZL12loop_wrapperv+0x4): undefined reference to `setup'
/Users/chako/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld: .pio/build/tasmota-DE/libFrameworkArduino.a(core_esp8266_main.cpp.o):(.text._ZL12loop_wrapperv+0x8): undefined reference to `loop'
/Users/chako/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld: .pio/build/tasmota-DE/libFrameworkArduino.a(core_esp8266_main.cpp.o): in function `loop_wrapper()':
core_esp8266_main.cpp:(.text._ZL12loop_wrapperv+0x21): undefined reference to `setup'
/Users/chako/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld: core_esp8266_main.cpp:(.text._ZL12loop_wrapperv+0x2d): undefined reference to `loop'
collect2: error: ld returned 1 exit status
*** [.pio/build/tasmota-DE/firmware.elf] Error 1

but when I restarted compilation (without any change) everything went through fine and successfully.
To verify I flashed two Shellys successfully and tested them “in the wild” … :wink:

Great job, thanks!

kr
j

1 Like

Yes, we repacked all macOS packages and added support for ARM64 architecture.

Thank you so much for the provided remote session to investigate this issue.

Happy Holidays and Happy New Year! :christmas_tree: :gift:

1 Like

you are welcome, anytime! … :grinning: :metal:

1 Like

Does this means that PlatformIO is supposed to work under the ARM version of VSCode? Because I’m not being able to compile my project.

What’s the exact platformio.ini, code and the output of pio system info (in a CLI)? You have an Apple M1 based computer, yeah?

Yes I have an M1 based computer.

pio system info output:

> pio system info
--------------------------  ------------------------------------------------------
PlatformIO Core             5.1.0
Python                      3.8.4-final.0
System Type                 darwin_x86_64
Platform                    macOS-10.16
File System Encoding        utf-8
Locale Encoding             UTF-8
PlatformIO Core Directory   ~/.platformio
PlatformIO Core Executable  ~/.platformio/penv/bin/platformio
Python Executable           ~/.platformio/penv/bin/python
Global Libraries            0
Development Platforms       2
Tools & Toolchains          11
--------------------------  ------------------------------------------------------

PlatformIO.ini:

; PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[env:teensy31]
platform = teensy
board = teensy31
framework = arduino

lib_deps = adafruit/Adafruit MQTT Library @ ^2.1.0,

Output when compiling:

Executing task in folder ESP32_TEST: pio run <

Processing teensy31 (platform: teensy; board: teensy31; framework: arduino)
------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/teensy/teensy31.html
PLATFORM: Teensy (4.12.0) > Teensy 3.1 / 3.2
HARDWARE: MK20DX256 72MHz, 64KB RAM, 256KB Flash
DEBUG: Current (jlink) External (jlink)
PACKAGES: 
 - framework-arduinoteensy 1.153.0 (1.53) 
 - toolchain-gccarmnoneeabi 1.50401.190816 (5.4.1)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
ValueError: Invalid simple block '':
  File "~/.platformio/penv/lib/python3.8/site-packages/platformio/builder/main.py", line 177:
    env.SConscript("$BUILD_SCRIPT")
  File "~/.platformio/packages/tool-scons/scons-local-4.1.0/SCons/Script/SConscript.py", line 591:
    return _SConscript(self.fs, *files, **subst_kw)
  File "~/.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 "~/.platformio/platforms/teensy/builder/main.py", line 144:
    target_elf = env.BuildProgram()
  File "~/.platformio/packages/tool-scons/scons-local-4.1.0/SCons/Util.py", line 658:
    return self.method(*nargs, **kwargs)
  File "~/.platformio/penv/lib/python3.8/site-packages/platformio/builder/tools/platformio.py", line 62:
    env.ProcessProjectDeps()
  File "~/.platformio/packages/tool-scons/scons-local-4.1.0/SCons/Util.py", line 658:
    return self.method(*nargs, **kwargs)
  File "~/.platformio/penv/lib/python3.8/site-packages/platformio/builder/tools/platformio.py", line 140:
    project_lib_builder = env.ConfigureProjectLibBuilder()
  File "~/.platformio/packages/tool-scons/scons-local-4.1.0/SCons/Util.py", line 658:
    return self.method(*nargs, **kwargs)
  File "~/.platformio/penv/lib/python3.8/site-packages/platformio/builder/tools/piolib.py", line 1062:
    project.install_dependencies()
  File "~/.platformio/penv/lib/python3.8/site-packages/platformio/builder/tools/piolib.py", line 886:
    if lm.get_package(spec):
  File "~/.platformio/penv/lib/python3.8/site-packages/platformio/package/manager/base.py", line 234:
    spec = self.ensure_spec(spec)
  File "~/.platformio/penv/lib/python3.8/site-packages/platformio/package/manager/base.py", line 102:
    return spec if isinstance(spec, PackageSpec) else PackageSpec(spec)
  File "~/.platformio/penv/lib/python3.8/site-packages/platformio/package/meta.py", line 124:
    self._parse(self.raw)
  File "~/.platformio/penv/lib/python3.8/site-packages/platformio/package/meta.py", line 227:
    raw = parser(raw)
  File "~/.platformio/penv/lib/python3.8/site-packages/platformio/package/meta.py", line 250:
    self.requirements = tokens[1].strip()
  File "~/.platformio/penv/lib/python3.8/site-packages/platformio/package/meta.py", line 167:
    else semantic_version.SimpleSpec(str(value))
  File "~/.platformio/penv/lib/python3.8/site-packages/semantic_version/base.py", line 618:
    self.clause = self._parse_to_clause(expression)
  File "~/.platformio/penv/lib/python3.8/site-packages/semantic_version/base.py", line 1014:
    return cls.Parser.parse(expression)
  File "~/.platformio/penv/lib/python3.8/site-packages/semantic_version/base.py", line 1034:
    raise ValueError("Invalid simple block %r" % block)

Remove the comma at the end of the line.

My bad… I should have tried another project. It’s working now. Is it running natively or under Rosseta 2?

Assuming that PlatformIO thinks you’re on darwin x84_x64 anyways…

and

I would assume it’s using emulation. Ivan can correct me if I’m wrong.

1 Like

Yes, macOS does this job automatically on-the-fly. All our packages are compatible with M1.