Chromium can't open serial port on ubuntu 22.04

I’m trying to access serial port of an embedded device using chromium(firefox does not support this feature) but browser can’t recognise any serial ports. It seems like it’s ubuntu specific issue and it’s caused by snap.

Dmesg output: apparmor="DENIED" operation="open" profile="snap.chromium.chromium" name="/run/udev/data/+dmi:id" pid=2613 comm="ThreadPoolForeg" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0

Solutions provided here didn’t help.

There is a serial-port interface, but I don’t think it would be suited for this kind of usage, and it doesn’t allow read access to /run/udev/data/+dmi:id anyway.

If you edit chromium’s generated apparmor profile as suggested in that other bug to allow read access to /run/udev/data/+dmi:id, does it fix the problem?

the serial-port interface should work well (with USB-Serial adapters at least) if you enable hotplug support (which dynamically creates the slot when plugging in the adapter), it probably makes sense to add the plug “just in case” :wink: so people can optionally connect it if needed…


No, it seems like behavior is the same.

What did you add to the profile?

  /run/udev/data/** r,

works for me.

I’m verifying it by opening a the Chromium console (F12) and entering

port = await navigator.serial.requestPort({});

Yes, it works. Thanks a lot. :grinning:

@yeshighway, since modifying the Apparmor profile is more of a temporary workaround, I created a Chromium snap recipe with the serial-port plug.

Could you please enable hot plug support and install that snap:

sudo snap set system experimental.hotplug=true
sudo systemctl restart snapd
sudo snap install --dangerous ./chromium_105.0.5195.19_amd64.snap
snap run chromium

Then try Chromium console (F12) and enter

port = await navigator.serial.requestPort({}); 

and let me know if it works?

1 Like