raspberrypi / usbboot

Raspberry Pi USB booting code, moved from tools repository
Apache License 2.0
878 stars 221 forks source link

Build usbboot on macOS with apple silicon #176

Closed ApiTracer closed 1 year ago

ApiTracer commented 1 year ago

Describe the bug

On Apple silicon Mac, there is an error on make command : ld: warning: ignoring file /usr/local/Cellar/libusb/1.0.26/lib/libusb-1.0.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64 Undefined symbols for architecture arm64: ....

I applied this workaround : Download the libusb source from github.com: https://github.com/libusb/libusb/releases/tag/v1.0.26

Build it in the standard way: extract libusb-1.0.26.tar.bz2 $ cd libusb-1.0.26 $ ./configure $ make $ make check $ sudo make install

and make again without errors.

Steps to reproduce the behaviour

Try to build on macOS with apple silicon

Device(s)

Other

Compute Module IO board.

No response

RPIBOOT logs

No response

Kernel logs

No response

Device UART logs

No response

timg236 commented 1 year ago

There's no official support for macOS, but happy to leave the bug open in-case anyone has any suggestions.

pelwell commented 1 year ago

Out of interest, does modifying the Makefile to say --libs libusb (instead of --libs libusb-1.0) make any difference?

ApiTracer commented 1 year ago

Out of interest, does modifying the Makefile to say --libs libusb (instead of --libs libusb-1.0) make any difference?

usbboot % make cc -Wall -Wextra -g -o rpiboot main.c pkg-config --cflags --libs libusb -DGIT_VER="\"cdf79ac5\"" -DPKG_VER="\"20221104~153421\"" Package libusb was not found in the pkg-config search path. Perhaps you should add the directory containing `libusb.pc' to the PKG_CONFIG_PATH environment variable No package 'libusb' found main.c:1:10: fatal error: 'libusb.h' file not found

include

It seems to be not found with this notation

timg236 commented 1 year ago

Did you try this workaround from Readme.md

If the build is unable to find the header file libusb.h then most likely the PKG_CONFIG_PATH is not set properly. This should be set via export PKG_CONFIG_PATH="$(brew --prefix libusb)/lib/pkgconfig".

ApiTracer commented 1 year ago

same error after launch the export, with libusb-1.0, the package is found but with the wrong arch

pelwell commented 1 year ago

I think this can become a note in the README.

pelwell commented 1 year ago

See https://github.com/raspberrypi/usbboot/commit/df27ddd93777d31ac4adb6f1b6689db2d4093792.

timg236 commented 1 year ago

Seems to be resolved by commits mentioned above.