cancel
Showing results for 
Search instead for 
Did you mean: 
SOLVED

libusb on ctrlX CORE

libusb on ctrlX CORE

DiluMarku
Established Member

Hi,

is it somehow possible to install the libusb library on the ctrlX CORE? (Or any other library)

Since apt is not available on the core and it is not enough to stage this library within a snap (as far as I know), I tried to manually copy the files to '/lib' and '/usr/lib' through ssh with a root user. But that doesn't work either (cp: cannot create regular file '/lib/aarch64-linux-gnu/libusb-1.0.so.0': Read-only file system).

Any other workarounds?

Thanks for your help!

9 REPLIES 9

CodeShepherd
Community Moderator
Community Moderator

In general there are some snaps available on GitHub that uses this lib.

You need the library as stage package and use the plug [raw-usb]. It should be auto connected but as you have root access you could also do it by hand.

I tried exactly that but it is not working. I made the same snap for an Ubuntu-VM (amd64) and the ctrlX CORE (arm64), it works fine on the Ubuntu-VM but not on the CORE. The only difference between the two systems is, that the libusb library is already installed on the Ubuntu-VM.

Annotation 2022-02-21 091633.jpg

Annotation 2022-02-21 091706.jpg

Annotation 2022-02-21 091608.jpg

Annotation 2022-02-21 091839.jpg

Could you please try to set "LD_LIBRARY_PATH=$SNAP/lib...." so the path to the library is known in the snap.

Further it would be good to have some debug information. Please, do a 'set PYUSB_DEBUG=debug' on the command line to define the PYUSB_DEBUG environment variable and post the output. (See snapcraft bug)

Annotation 2022-02-21 105653.jpg

Still not working. I also tried to set the environment variable directly on the command line (export LD_LIBRARY_PATH=/snap/mouse-example/current/lib/aarch64-linux-gnu/) but without any success.

Also, 'set PYUSB_DEBUG=debug' doesn't change the output.

Annotation 2022-02-21 110531.jpg

I have already tried the suggestions from github and https://forum.snapcraft.io but none of them worked. That's why I thought, this could be an issue specific to the ctrlX CORE (or Ubuntu Core). Both of them don't have the libusb library directly on the system.

I really appreciate your help, do you have any other suggestions?

Something I noticed during the build process of the snap:

Annotation 2022-02-21 121636.jpg

- "Unable to determine library dependencies for ...", this is something I have seen in other cross-builds as well, but the snaps worked fine.

- "not a dynamic executable", this could be an issue, since I have never seen this in other builds.

jochen-scheib
Established Member

I had a quick look into the topic. It seems like pyusb is "hardcoding" where to find the libusb, but you can provide it by code:

backend = usb.backend.libusb1.get_backend(find_library=lambda x: "/snap/my-snap-name/current/lib/x86_64-linux-gnu/libusb-1.0.so.0")

 Does this work for you?

Actually, I have tried this solution (https://github.com/pyusb/pyusb/pull/29) before and it didn't work. But for some odd reason, it works now. 

Annotation 2022-02-21 143632.jpg

Nevertheless, thank you for your help!

If you don't mind, there is an other issue where I need help.

Even though the specified usb-mouse with the correct vendor- and product-id is connected to the ctrlX CORE, somehow it is not recognized within the snap.

Annotation 2022-02-21 143558.jpg

(Again, this problem doesn't occur with the mouse connected to the Ubuntu-VM.)

Can you provide the output of dmesg? Is there any hint with regard to "denied"?

Thanks.

DiluMarku_0-1645453292667.png

You were right, there are logs with 'DENIED'. 

Do you know how to solve this?

Thanks.

DiluMarku
Established Member

I was able to solve the problem with an additional plug in snapcraft.yaml

Annotation 2022-02-21 155715.jpg

But I don't know why the 'hardware-observe'-plug is only necessary on the ctrlX CORE and not on the Ubuntu-VM.

Thanks everybody!

Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist