Tool-dfuutil for macOS M1 / ARM_64

When I run pio build with a target that has upload_command = dfu-util ... on a Mac system with an M1 / ARM64 architecture, the x86_64 version of dfu-prefix, dfu-suffix, and dfu-util are installed, so the final step of the build fails…

Tool Manager: Installing platformio/tool-dfuutil @ ~1.9.190708
. . .
> file ~/.platformio/packages/tool-dfuutil/bin/dfu-util
.../bin/dfu-util: Mach-O 64-bit executable x86_64

Is there some hint I can give to the Tool Manager to make it download the ARM64 version of these tools?

PlatformIO relies on the Rosetta x86/64 translation layer to execute these binaries. There are no native-compiled binaries for Mac in the PlatformIO registry, just x86 ones retagged as ARM.

The time is nigh to start including a Universal binary with correct linkage to libusb-1.0.0.dylib because the x86_64 build of dfu-suffix will not load that arm64 library – which in any case is not even included with macOS by default. You must install it from something like Homebrew or MacPorts. But, the default for M1 is the arm64-only build of the library.

For the build of our project, we can’t ask users to install a package manager and then use it to install the non-default version of libusb-1.0.0.dylib. Nor can we really ask the user to authorize us to install it. So it would just be best and proper to have a universal build of dfu-suffix (and the others) that can run without any other system additions.

CC @ivankravets – maybe this was already solved with the new package versions introduced in Updated used dfu-util to latest version available (#630) · platformio/platform-ststm32@9ce784b · GitHub?

1 Like

See my comment on the relevant GitHub issue. It’s the right version, just not a universal binary. I built the dfu utilities as arm64 with ./configure && make and they work great, with no complaints about being unable to find libusb. But the versions being distributed with PlatformIO are still just x86_64 builds that cannot link to dynamic libusb on the M1 / M2 architecture. I can build x86_64 versions as well, join them all together into universal binaries, and submit them to the PIO project, if needed.

Could you share somewhere tar.gzipped packages? We will re-publish them in the registry. Thanks!

Has this been resolved? I seem to be running into the same issue (Mac M1, macOS 15.0.1):

$ file ~/.platformio/packages/tool-dfuutil/bin/dfu-util
/Users/jcw/.platformio/packages/tool-dfuutil/bin/dfu-util: Mach-O 64-bit executable x86_64
$ pio --version
PlatformIO Core, version 6.1.16

With homebrew, I get a native build:

$ file `which dfu-util`
/opt/homebrew/bin/dfu-util: Mach-O 64-bit executable arm64

I can create a tarfile of this area, if that’s of any use:

$ tree -d /opt/homebrew/Cellar/dfu-util/
/opt/homebrew/Cellar/dfu-util/
├── 0.11
│   ├── bin
│   └── share
│       └── man
│           └── man1
└── HEAD-be49612
    ├── bin
    └── share
        └── man
            └── man1

The HEAD area is the latest brew reinstall dfu-util.

Update - relinking the binaries in tool-dfuutil/bin/ to homebrew’s versions fixes the problem for now:

lrwxr-xr-x  1 jcw  staff  28 10 Oct 15:57 dfu-prefix -> /opt/homebrew/bin/dfu-prefix
lrwxr-xr-x  1 jcw  staff  28 10 Oct 15:56 dfu-suffix -> /opt/homebrew/bin/dfu-suffix
lrwxr-xr-x  1 jcw  staff  26 10 Oct 15:56 dfu-util -> /opt/homebrew/bin/dfu-util

But the lib/ directory next to it also contains x86_64 files, so this may need a little more work to get PIO’s own version working properly on Apple Silicon.

With the October 29, 2024 version we should finally have a linked and complete dfu-util. Use the following in your environments to get the latest patched 1.11.

platform_packages = platformio/tool-dfuutil@~1.11.0

If there are any issues, add to the discussion at Dfuutil missing for arm64 · Issue #436 · platformio/platform-ststm32 · GitHub