this is my first post here because usually everything work
I have a mac M1 (M1 Pro, darwin_arm64), I just install Platformio (I tried VSCode plugin and Platformio CLI), everything looks good then it’s time to build a basic project for my arduino (arduino nano), then it failled.
Platformio automatically download the required packages, but I think the package toolchain-atmelavr downloaded isn’t correct because it said
Bad CPU type in executable for the binary inside
~/.platformio/packages/toolchain-atmelavr/bin/* (probably for darwin_x86_64). But it’s compatible for darwin_arm64 for this package : PlatformIO Registry
I know if I install Rosetta 2 everything will be ok, but I would like to use the M1 natively because everything looks compatible.
Do you know how I can force the download of the darwin_arm64 version ?
Platformio know i’m on a darwin_arm64 cpu
➜ ~ pio system info
PlatformIO Core 5.2.5
System Type darwin_arm64
File System Encoding utf-8
Locale Encoding UTF-8
Correct, PlatformIO requires ARM Mac users to have Rosetta installed so that x64 binaries can be executed. No native ARM binaries are provided.
But why in the registry the darwin_arm64 is checked ?
It’s because of Rosetta 2 ? If it’s the case it’s wrong to say compatible with darwin_64, because it’s the work of Rosetta 2 to emulate darwin_x86_64 and it’s not toolchain-atmelavr working on darwin_arm64
I didn’t test it on linux_aarch64/ linux_armvXl but it say compatible too, so binary for ARM should exist because there is no x86 “emulator” natively on linux
I tried it on my raspberry-pi 2 and works perfectly, so binary for linux_armv7l exist and are correctly downloaded, so for darwin_arm64 they should exist too according to the registry ?
Because every ARM Mac with Rosetta (2) installed should be capable of executing executing x64 binaries. The workings of this were confirmed 2 years ago in Platform IDE for VSCode on Mac ARM/M1? - #17 by ivankravets.
CC @ivankravets or @manuelbl can you check a simple Arduino Uno project on an ARM Mac?
As I understand they just tag the darwin_x86_64 package with darwin_arm64. So the package is not really compatible with darwin_arm64 until you use Rosetta 2 ?
And if I’m correct, why not rebuild the binary to be natively compatible with darwin_arm64 ?
And otherwise how can I build it myself ?
It should have better performance and do not rely on Rosetta 2.
I think Ivan’s thoughts behind that is that hundreds of packages that are already known-working do not have to be rebuilt that, especially when tool vendors don’t supply precompiled Mac ARM64 binaries for their stuff. Where can you get the Atmel AVR GCC
5.1.0 7.3.0 for Darwin ARM64?
Hum ok, my case is for atmel avr but there is more package obviously and it’s easier to do it like this, I understand.
It’s personal reason I don’t want Rosetta 2 on my machine, for efficiency and if it’s installed they will be more software using it than just Plaformio.
I would like to re-build it my self, maybe there is a source code and documentation ? But I can’t find it on the registry detail.
Focus on compiling the needed compiler version first (“~7.3.0,” per platform.json, meaning exactly 7.3.0 here), once you have that, it’s just about adding the
package.json from the previous toolchain-atmelavr version and removing the darwin_x86_64 entry from the compatibility array. (See
~/.platformio/packages/toolchain-atmelavr/package.json). You can also grab all available versions and their download links from the API: https://api.registry.platformio.org/v3/packages/platformio/tool/toolchain-atmelavr
Regarding GCC, there are build scripts in GitHub - ZakKemble/avr-gcc-build for Windows + Linux, maybe also adaptable for Mac. The sources are at GCC 7 Release Series - GNU Project, but the linked build scripts makes them configurable.
Thanks for the help I will try that today.
Maybe it will be more correct to write (Rosetta 2) after darwin_arm64 on the registry compatibility table
Thanks, @maxgerhardt for your comments, they are correct. I’ll not try to repeat the same.
Short answer. we manually added compatibility for
darwin_arm64 to each
darwin_x86_64 package. If you provide us with native ARM packages, we can upload them to the registry. There is no problem with this.
As @maxgerhardt noted, dozens of packages are compiled by their owners/maintainers. We even don’t have sources. It means that we will need some time when package maintainers provide native packages for the
A temporary solution is to install Rosetta. We don’t have other solutions. Sorry