TinyFPGA BX Libusb issue


#1

I am trying to use the APIO plugin in Atom - when I use the upload option, I see the following error:

tinyprog --libusb --program hardware.bin

Traceback (most recent call last):

File “/usr/local/bin/tinyprog”, line 11, in <module>

sys.exit(main())

File “/usr/local/lib/python2.7/site-packages/tinyprog/main.py”, line 326, in main

fpga = TinyProg(active_port, progress)

File “/usr/local/lib/python2.7/site-packages/tinyprog/init.py”, line 215, in init

self.wake()

File “/usr/local/lib/python2.7/site-packages/tinyprog/init.py”, line 256, in wake

self.cmd(0xab)

File “/usr/local/lib/python2.7/site-packages/tinyprog/init.py”, line 248, in cmd

self.ser.write(bytearray(cmd_write_string))

File “/usr/local/lib/python2.7/site-packages/tinyprog/init.py”, line 98, in write

self.OUT.write(data)

File “/usr/local/lib/python2.7/site-packages/usb/core.py”, line 387, in write

return self.device.write(self, data, timeout)

File “/usr/local/lib/python2.7/site-packages/usb/core.py”, line 940, in write

intf, ep = self._ctx.setup_request(self, endpoint)

File “/usr/local/lib/python2.7/site-packages/usb/core.py”, line 102, in wrapper

return f(self, *args, **kwargs)

File “/usr/local/lib/python2.7/site-packages/usb/core.py”, line 216, in setup_request

self.managed_claim_interface(device, intf)

File “/usr/local/lib/python2.7/site-packages/usb/core.py”, line 102, in wrapper

TinyProg CLI


Using device id 1d50:6130

Only one board with active bootloader, using it.

return f(self, *args, **kwargs)

File “/usr/local/lib/python2.7/site-packages/usb/core.py”, line 167, in managed_claim_interface

self.backend.claim_interface(self.handle, i)
File “/usr/local/lib/python2.7/site-packages/usb/backend/libusb1.py”, line 811, in claim_interface

_check(self.lib.libusb_claim_interface(dev_handle.handle, intf))

File “/usr/local/lib/python2.7/site-packages/usb/backend/libusb1.py”, line 595, in _check

raise USBError(_strerror(ret), ret, _libusb_errno[ret])

usb.core.USBError: [Errno 13] Access denied (insufficient permissions)

scons: *** [upload] Error 1

========================= [ ERROR ] Took 1.70 seconds =========================


#2

It looks like you have a permissions problem on /dev/ttyACM0. Have you tried executing

sudo tinyprog --libusb --program hardware.bin

to see if that works?

To run the command in user mode adding your user to the tty and dialout groups is all that is usually necessary. What OS are you running on?


#3

Thanks Lawrie. I am using Os X 10.9.4. I will try this out. How do you add user to tty and dialout in Mac?


#4

Sorry, I thought you were running on Linux from the messages. I don’t know what the solution to the permissions problem is on MAC OSX. Perhaps a MAC user can help.


#5

Thanks Lawrie for the response.


#6

Which version of libusb are you using? how did you get it?

I’m using 1.0.22, downloaded from Sourceforge, on Mojave, 10.14.1. I don’t know for sure whether I used FSF GCC to build it or clang, looks like clang.


#7

pyusb==1.0.2 on Python 2.7


#8

pyusb==1.0.2 on python 2.7


#9

I actually meant the version of libusb … I have the same pyusb.
Anyway,

  1. did @lawrie.griffiths’s suggestion to use sudo make any difference?
  2. try LIBUSB_DEBUG=4 tinyprog -p hardware.bin, should result in reams of output (including the actual version of libusb!), which might be a bit more revealing.

What does id say? mine gives

simon$ id
uid=505(simon) gid=20(staff) groups=20(staff),103(access_bpf),
  12(everyone),61(localaccounts),79(_appserverusr),80(admin),
  81(_appserveradm),98(_lpadmin),33(_appstore),100(_lpoperator),
  204(_developer),250(_analyticsusers),395(com.apple.access_ftp),
  398(com.apple.access_screensharing),399(com.apple.access_ssh)

#10

Thanks sjw. sudo did not work. Same error

I tired the LIBUSB_DEBUG=4 and the output was

[22840576.000000] [00000d07] libusb: debug [libusb_init] created default context

[22840576.000000] [00000d07] libusb: debug [libusb_init] libusb v1.0.22.11312

[1544757185.688272] [00000d07] libusb: error [darwin_claim_interface] USBInterfaceOpen: another process has device opened for exclusive access
Traceback (most recent call last):
File “/usr/local/bin/tinyprog”, line 11, in
sys.exit(main())
File “/usr/local/lib/python2.7/site-packages/tinyprog/main.py”, line 326, in main
fpga = TinyProg(active_port, progress)
File “/usr/local/lib/python2.7/site-packages/tinyprog/init.py”, line 215, in init
self.wake()
File “/usr/local/lib/python2.7/site-packages/tinyprog/init.py”, line 256, in wake
self.cmd(0xab)
File “/usr/local/lib/python2.7/site-packages/tinyprog/init.py”, line 248, in cmd
self.ser.write(bytearray(cmd_write_string))
File “/usr/local/lib/python2.7/site-packages/tinyprog/init.py”, line 98, in write
self.OUT.write(data)
File “/usr/local/lib/python2.7/site-packages/usb/core.py”, line 387, in write
return self.device.write(self, data, timeout)
File “/usr/local/lib/python2.7/site-packages/usb/core.py”, line 940, in write
intf, ep = self._ctx.setup_request(self, endpoint)
File “/usr/local/lib/python2.7/site-packages/usb/core.py”, line 102, in wrapper
return f(self, *args, **kwargs)
File “/usr/local/lib/python2.7/site-packages/usb/core.py”, line 216, in setup_request
self.managed_claim_interface(device, intf)
File “/usr/local/lib/python2.7/site-packages/usb/core.py”, line 102, in wrapper
return f(self, *args, **kwargs)
File “/usr/local/lib/python2.7/site-packages/usb/core.py”, line 167, in managed_claim_interface
self.backend.claim_interface(self.handle, i)
File “/usr/local/lib/python2.7/site-packages/usb/backend/libusb1.py”, line 811, in claim_interface
_check(self.lib.libusb_claim_interface(dev_handle.handle, intf))
File “/usr/local/lib/python2.7/site-packages/usb/backend/libusb1.py”, line 595, in _check
raise USBError(_strerror(ret), ret, _libusb_errno[ret])
usb.core.USBError: [Errno 13] Access denied (insufficient permissions)

Was there an issue with libsub on Mac Os X 10.9.4 as suggested in

id
uid=501(vijay) gid=20(staff) groups=20(staff),12(everyone),61(localaccounts),79(_appserverusr),80(admin),81(_appserveradm),98(_lpadmin),401(com.apple.sharepoint.group.1),33(_appstore),100(_lpoperator),204(_developer),398(com.apple.access_screensharing),399(com.apple.access_ssh)


#11

Thanks for the trace; it doesn’t seem to reveal anything helpful. Just before what I think is where your trace failed I see

[10.045274] [00000307] libusb: debug [libusb_get_configuration] 
[10.045282] [00000307] libusb: debug [libusb_get_configuration] active config 1
[10.045336] [00000307] libusb: debug [libusb_get_config_descriptor] index 0
...
[10.045955] [00000307] libusb: debug [libusb_claim_interface] interface 1
[10.046496] [00000307] libusb: debug [get_endpoints] building table of endpoints.
[10.046520] [00000307] libusb: debug [get_endpoints] interface: 1 pipe 1: dir: 0 number: 1
[10.046531] [00000307] libusb: debug [get_endpoints] interface: 1 pipe 2: dir: 1 number: 1
[10.046583] [00000307] libusb: debug [darwin_claim_interface] interface opened

Googling for “libusb another process has device opened for exclusive access” shows a lot of people with a similar problem; suggestions include that a macOS built-in has grabbed the device first, which is apparently most likely to happen with certain sorts of device (HID etc).

For what it’s worth, About this Mac/System Report/USB says it’s a Communication Device.