I’m trying to use the flutter quick-usb package in core. Does anyone know what I need to do to make the usb bus visible/usable?
I’ve tried adding the raw-usb plug into my snap but no luck.
I’m new to snaps/snapcraft and my knowledge is limited so any help would be much appreciated
Generally speaking, USB Printers can be reached from /dev/usb/lpx. Is that also the case for you? If so, this is already exposed as part of the raw-usb plug.
What I could suggest is that, please run your snap at Ubuntu Desktop first. Probably, you would need to add some additional plugs to your snap. To understand what would be the problem, please run tail -f /var/log/syslog | grep audit in another terminal screen while running your snap to see if there is any permission issue due to missing plugs.
In the meantime, you could try running cups to check if it is possible to print by using your printer.
Thank for your response @bugraaydogar. I have the snap working in desktop mode. This is the output from syslog. This looks like my app discovering the usb hub then searching through for the device:
hmmm. There is no permission issue within this snap. Just to verify, what is your confinement in the snapcraft.yaml while running on desktop? Is it classic, devmode or strict? I assume it is strict.
I also realize that your printer is using /dev/bus/usb/… instead of /dev/usb/lpx. But, that’s not a problem since /dev/bus/usb is also exposed by usb-raw.
Is there any logs from the application that could be compared with Desktop and Core?
Did you have time to check if you could print anything by using CUPS on Core? And finally, when you install your snap in devmode by using snap install yoursnap --devmode, can you print?
Hello @bugraaydogar I should have made clear in my original post that I’m running core on a NUC device.
I’m running both snaps (desktop and core) in devmode. So just to confirm, the desktop snap works, the snap on core (which is running on a NUC device) does not.
The application doesn’t really give me anything useful other than it seems it is unable to instantiate the ‘_libusb’ variable it needs to perform any usb device discovery
Thanks @ogra. I’ve now got the snap running on the desktop in strict mode and I’m now able to replicate the issue that I’m having on the NUC but now I have some new logs:
It looks like there is some sort of permissions error but why is the snap referencing the build source? How do I package the built flutter artifact into the snap so it can find it?
We are making good progress here. Probably you need a home plug and one additional plug.
I’m assuming you cannot share the source, what you could do is using snappy-debug to give you some hint about missing plug configurations.
In Desktop, please install, snap install snappy-debug
Before running your application run the following command in a terminal; sudo journalctl --output=short --follow --all | sudo snappy-debug
Run your application, you can see what would be missing plug in the terminal of the above command.
daemon:
daemon: simple
restart-condition: always
command-chain:
- bin/run-daemon
- bin/wayland-launch
command: bin/test_print_app
extensions: [flutter-master] # Where “master” defines which Flutter channel to use for the build
plugs: [raw-usb, network-control, home]
@laughing-gravy thanks for sharing these.
It seems like /sys/vm/max_map_count is not exposed by any interface that is available. There is no plug available for that purpose. I also assume that, you have no idea why quick_usb or your application would like to reach that.
hmm, i wonder if moving these to the assets part instead would help to not have the app look for them in a weird path …
the manually started app seems to be missing all plugs … it should have the same set of plugs listed as the daemon to give it the same set of permissions …
@laughing-gravy: Did you hard-coded the path of libusb-1.0.23.so in your flutter application?
I believe you don’t have a path like /home/developer/flutter-workspace/test_print_app/build/linux/debug/bundle/lib/libusb-1.0.23.so in your UC.
Would it be possible to use the library from /usr/lib/x86_64-linux-gnu?
@bugraaydogar It isn’t hard coded, it is put there by the flutter build.
I alluded to this earlier. I suspect the problem here is that this path doesn’t exist in the snap. Perhaps in devmode it can access that folder? However, I don’t know why it is included when the flutter plugin builds the app. I would have thought that the flutter app (which is from the bundle directory down) would be included somewhere in the snap rather than there being a reference to my source directory on my build machine. Do you know anything about the flutter plugin and how to achieve this?