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

Get Started for Mac M2 #44

Closed
ramkumarkoppu opened this issue Jun 13, 2023 · 11 comments
Closed

Get Started for Mac M2 #44

ramkumarkoppu opened this issue Jun 13, 2023 · 11 comments
Assignees
Labels
Hardware:Dev Board Coral Dev Board issues subtype:macOS type:build/Install Build and install issues

Comments

@ramkumarkoppu
Copy link

ramkumarkoppu commented Jun 13, 2023

Description

By following instruction in https://coral.ai/docs/dev-board-micro/get-started/#5-try-the-face-detection-example on Apple Silicon Mac, I get following error:
bash-3.2$ lsusb
Bus 000 Device 002: ID 18d1:9308 Google Inc. Coral Dev Board Micro Serial: 1b31080e829089dd
Bus 000 Device 000: ID 18d1:9308 Google Inc. USB 3.1 Bus
bash-3.2$ lsusb
Bus 000 Device 002: ID 18d1:9308 Google Inc. Coral Dev Board Micro Serial: 1b31080e829089dd
Bus 000 Device 000: ID 18d1:9308 Google Inc. USB 3.1 Bus
bash-3.2$ python3 scripts/flashtool.py -e detect_faces
Finding all necessary files
Creating Filesystem
Section: 0x0
iMX bootable image generated successfully
Boot Section 0x00000000:
FILL | adr=0x00010000 | len=0x00000004 | ptn=0xc2000105
FILL | adr=0x00010004 | len=0x00000004 | ptn=0x00010020
FILL | adr=0x00010008 | len=0x00000004 | ptn=0x00040004
FILL | adr=0x0001000c | len=0x00000004 | ptn=0x00080004
FILL | adr=0x00010020 | len=0x00000004 | ptn=0xc0010021
ENA | adr=0x00010000 | cnt=0x00000004 | flg=0x0110
ERAS | adr=0x00000004 | cnt=0x00000004 | flg=0x0110
ERAS | adr=0x00000008 | cnt=0x00000004 | flg=0x0110
ERAS | adr=0x0000000c | cnt=0x00000040 | flg=0x0110
LOAD | adr=0x00000004 | len=0x0001780c | crc=0x852c658e | flg=0x0110
LOAD | adr=0x00000008 | len=0x0001780c | crc=0xcbf635c8 | flg=0x0110
STATE_CHECK_FOR_ANY
STATE_CHECK_FOR_CORAL_MICRO
STATE_RESET_TO_SDP
STATE_CHECK_FOR_SDP
Python interpreter cannot find libusb, please install it.

Click to expand!

Issue Type

Build/Install

Operating System

Mac OS

Coral Device

Dev Board Micro

Other Devices

No response

Programming Language

Python 3.9

Relevant Log Output

bash-3.2$ lsusb
Bus 000 Device 002: ID 18d1:9308 Google Inc. Coral Dev Board Micro Serial: 1b31080e829089dd
Bus 000 Device 000: ID 18d1:9308 Google Inc. USB 3.1 Bus
bash-3.2$ lsusb
Bus 000 Device 002: ID 18d1:9308 Google Inc. Coral Dev Board Micro Serial: 1b31080e829089dd
Bus 000 Device 000: ID 18d1:9308 Google Inc. USB 3.1 Bus
bash-3.2$ python3 scripts/flashtool.py -e detect_faces
Finding all necessary files
Creating Filesystem
Section: 0x0
iMX bootable image generated successfully
Boot Section 0x00000000:
FILL | adr=0x00010000 | len=0x00000004 | ptn=0xc2000105
FILL | adr=0x00010004 | len=0x00000004 | ptn=0x00010020
FILL | adr=0x00010008 | len=0x00000004 | ptn=0x00040004
FILL | adr=0x0001000c | len=0x00000004 | ptn=0x00080004
FILL | adr=0x00010020 | len=0x00000004 | ptn=0xc0010021
ENA | adr=0x00010000 | cnt=0x00000004 | flg=0x0110
ERAS | adr=0x00000004 | cnt=0x00000004 | flg=0x0110
ERAS | adr=0x00000008 | cnt=0x00000004 | flg=0x0110
ERAS | adr=0x0000000c | cnt=0x00000040 | flg=0x0110
LOAD | adr=0x00000004 | len=0x0001780c | crc=0x852c658e | flg=0x0110
LOAD | adr=0x00000008 | len=0x0001780c | crc=0xcbf635c8 | flg=0x0110
STATE_CHECK_FOR_ANY
STATE_CHECK_FOR_CORAL_MICRO
STATE_RESET_TO_SDP
STATE_CHECK_FOR_SDP
Python interpreter cannot find libusb, please install it.
@google-coral-bot google-coral-bot bot added Hardware:Dev Board Coral Dev Board issues subtype:macOS type:build/Install Build and install issues labels Jun 13, 2023
@hjonnala
Copy link

hjonnala commented Jun 13, 2023

please try the steps mentioned here to install libusb. Thanks!!

@ramkumarkoppu
Copy link
Author

Thanks tried it, I get,

bash-3.2$ brew install libusb
==> Downloading https://formulae.brew.sh/api/formula.jws.json

==> Downloading https://formulae.brew.sh/api/cask.jws.json

Warning: libusb 1.0.26 is already installed and up-to-date.
To reinstall 1.0.26, run:
brew reinstall libusb
bash-3.2$ sudo ln -s $(brew --prefix)/lib/libusb-1.0.0.dylib /usr/local/lib/libusb.dylib
ln: /usr/local/lib/libusb.dylib: No such file or directory
bash-3.2$

@hjonnala
Copy link

Please share the output of below command:

brew info libusb

@ramkumarkoppu
Copy link
Author

(tensorflow-macos) bash-3.2$ brew info libusb
==> libusb: stable 1.0.26 (bottled), HEAD
Library for USB device access
https://libusb.info/
/opt/homebrew/Cellar/libusb/1.0.26 (22 files, 595.0KB) *
Poured from bottle using the formulae.brew.sh API on 2023-06-13 at 21:10:42
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/libusb.rb
License: LGPL-2.1-or-later
==> Options
--HEAD
Install HEAD version
==> Analytics
install: 31,865 (30 days), 6,365 (90 days), 838,148 (365 days)
install-on-request: 6,083 (30 days), 1,620 (90 days), 84,598 (365 days)
build-error: 0 (30 days)
(tensorflow-macos) bash-3.2$

@hjonnala
Copy link

Looks like the system python interpreter cannot find the libusb installed by brew. Can you try to install python via brew.

@ramkumarkoppu
Copy link
Author

Hi Hemanth (@hjonnala) you are a star contributor for this community. Thank you for your help.
As per your recommendation, I followed below steps and did work on my MacBookPro M2 Max:

bash-3.2$ brew install python
==> Fetching [email protected]
Python has been installed as
/opt/homebrew/bin/python3

bash-3.2$ which python3
/opt/homebrew/bin/python3

bash-3.2$ python3 --version
Python 3.11.4

bash-3.2$ brew uninstall libusb
Uninstalling /opt/homebrew/Cellar/libusb/1.0.26... (22 files, 595.0KB)

bash-3.2$ brew install libusb
bash-3.2$ brew info libusb
==> libusb: stable 1.0.26 (bottled), HEAD
Library for USB device access
https://libusb.info/
/opt/homebrew/Cellar/libusb/1.0.26 (22 files, 595.0KB) *
Poured from bottle using the formulae.brew.sh API on 2023-06-14 at 21:11:33
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/libusb.rb
License: LGPL-2.1-or-later
==> Options
--HEAD
Install HEAD version
==> Analytics
install: 30,951 (30 days), 6,321 (90 days), 833,064 (365 days)
install-on-request: 6,083 (30 days), 1,614 (90 days), 84,159 (365 days)
build-error: 0 (30 days)

bash-3.2$ lsusb
Bus 000 Device 002: ID 18d1:9308 Google Inc. Coral Dev Board Micro Serial: 1b31080e829089dd
Bus 000 Device 000: ID 18d1:9308 Google Inc. USB 3.1 Bus

bash-3.2$ bash setup.sh

bash-3.2$ bash build.sh

bash-3.2$ python3 scripts/flashtool.py -e detect_faces

Hopefully this will help someone like me who using Apple Silicon Mac. Cheers!

@google-coral-bot
Copy link

Are you satisfied with the resolution of your issue?
Yes
No

@cyborgdennett
Copy link

cyborgdennett commented Sep 14, 2023

Hi, I have the same issue on Windows (WSL) ubuntu22

coralmicro$ lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 011: ID 18d1:9308 Google Inc. Coral Dev Board Micro
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

coralmicro$ python3 scripts/flashtool.py -e detect_faces
Finding all necessary files
Creating Filesystem
        Section: 0x0
iMX bootable image generated successfully
Boot Section 0x00000000:
  FILL | adr=0x00010000 | len=0x00000004 | ptn=0xc2000105
  FILL | adr=0x00010004 | len=0x00000004 | ptn=0x00010020
  FILL | adr=0x00010008 | len=0x00000004 | ptn=0x00040004
  FILL | adr=0x0001000c | len=0x00000004 | ptn=0x00080004
  FILL | adr=0x00010020 | len=0x00000004 | ptn=0xc0010021
  ENA  | adr=0x00010000 | cnt=0x00000004 | flg=0x0110
  ERAS | adr=0x00000004 | cnt=0x00000004 | flg=0x0110
  ERAS | adr=0x00000008 | cnt=0x00000004 | flg=0x0110
  ERAS | adr=0x0000000c | cnt=0x00000040 | flg=0x0110
  LOAD | adr=0x00000004 | len=0x00017854 | crc=0xdd594538 | flg=0x0110
  LOAD | adr=0x00000008 | len=0x00017854 | crc=0x9b88b39a | flg=0x0110
STATE_CHECK_FOR_ANY
STATE_CHECK_FOR_CORAL_MICRO
STATE_RESET_TO_SDP
STATE_CHECK_FOR_SDP
Encountered an error during flashing: Unable to find device in SDP mode.

After the error, the Coral Micro is not anylonger found is lsusb, so I think during the flashing the usb connection stops or something

@cyborgdennett
Copy link

So one solution I found is to spam in powershell:

usbipd wsl attach --busid 1-2

Then it will go through this step.

next error is as follow:

coralmicro$ python3 scripts/flashtool.py -e detect_faces
Finding all necessary files
Creating Filesystem
        Section: 0x0
iMX bootable image generated successfully
Boot Section 0x00000000:
  FILL | adr=0x00010000 | len=0x00000004 | ptn=0xc2000105
  FILL | adr=0x00010004 | len=0x00000004 | ptn=0x00010020
  FILL | adr=0x00010008 | len=0x00000004 | ptn=0x00040004
  FILL | adr=0x0001000c | len=0x00000004 | ptn=0x00080004
  FILL | adr=0x00010020 | len=0x00000004 | ptn=0xc0010021
  ENA  | adr=0x00010000 | cnt=0x00000004 | flg=0x0110
  ERAS | adr=0x00000004 | cnt=0x00000004 | flg=0x0110
  ERAS | adr=0x00000008 | cnt=0x00000004 | flg=0x0110
  ERAS | adr=0x0000000c | cnt=0x00000040 | flg=0x0110
  LOAD | adr=0x00000004 | len=0x00017854 | crc=0x93bf7879 | flg=0x0110
  LOAD | adr=0x00000008 | len=0x00017854 | crc=0xf5171da3 | flg=0x0110
STATE_CHECK_FOR_ANY
STATE_CHECK_FOR_CORAL_MICRO
STATE_RESET_TO_SDP
STATE_CHECK_FOR_SDP
STATE_LOAD_FLASHLOADER
Traceback (most recent call last):
  File "/home/casper/ml/coralmicro/scripts/flashtool.py", line 1193, in <module>
    main()
  File "/home/casper/ml/coralmicro/scripts/flashtool.py", line 1182, in main
    RunFlashtool(StateCheckForAny, sbfile_path=sbfile_path,
  File "/home/casper/ml/coralmicro/scripts/flashtool.py", line 821, in RunFlashtool
    (prev_state, state) = (state, state(**state_kwargs))
  File "/home/casper/ml/coralmicro/scripts/flashtool.py", line 543, in StateLoadFlashloader
    subprocess.check_call([blhost_path, '-u', sdp_vidpid(), '--', 'load-image',
  File "/usr/lib/python3.10/subprocess.py", line 369, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/home/casper/ml/coralmicro/third_party/nxp/blhost/bin/linux/amd64/blhost', '-u', '0x1fc9,0x13d', '--', 'load-image', '/tmp/tmpudxc1pku/ivt_flashloader.bin']' returned non-zero exit status 1.

@cyborgdennett
Copy link

cyborgdennett commented Sep 14, 2023

You can use

usbipd wsl attach --busid 1-2 -a

The -a will make the usbipd service to keep looking for the busid even after it is disonnected for a short while.

I changed line 543 of flashtool.py to: subprocess.DEVNELL->sys.stderr

def StateLoadFlashloader(blhost_path, flashloader_path):
  subprocess.check_call([blhost_path, '-u', sdp_vidpid(), '--', 'load-image',
                        flashloader_path], stdout=sys.stderr, stderr=subprocess.DEVNULL)
  return StateCheckForFlashloader

to see output:

Error: UsbHidPeripheral() cannot open USB HID device (vid=0x1fc9, pid=0x013d, sn=).

checking usbipd wsl list in powershell, I get the following two addresses:
18d1:9308 Coral
1fc9:013d USB device(when connecting while holding button)

I guess the problem is that usbipd only can attach a single vidpid.

My version of usbipd is 2.4.1, I see the latest is 3.2.0, let me update and check if that works

Edit:
just updated to 3.2.0 and same issue.
Looking at the output of usbipd I get

PS C:\WINDOWS\system32> usbipd wsl attach --busid 1-2 -a
usbipd: info: Using default WSL distribution 'Ubuntu-22.04'; specify the '--distribution' option to select a different one.
usbipd: warning: USB filter 'USBPcap' is known to be incompatible with this software; 'bind --force' will be required.
usbipd: info: Starting endless attach loop; press Ctrl+C to quit.
Attached
Detached
Attached
Detached
usbip: error: Attach Request for 1-2 failed - Device busy (exported)
Attached

So as you can see, it attaches and detaches, but when the usb gets an new vidpid address, the tool is not made to work with that. I guess what I can do is make a ticket for the usbipd repo

@cyborgdennett
Copy link

cyborgdennett commented Sep 14, 2023

I tried updating the blhost binary, but same error

Error: UsbHidPeripheral() cannot open USB HID device (vid=0x1fc9, pid=0x013d, sn=).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Hardware:Dev Board Coral Dev Board issues subtype:macOS type:build/Install Build and install issues
Projects
None yet
Development

No branches or pull requests

3 participants