How to setup serial-port slot on ubuntu not core

I know serial-port slot defined in gadget snap, so other snap can use serial-port interface to access it. But I found there is no gadget snap in ubuntu (not ubuntu core). I want the same snap can both work in ubuntu and ubuntu core. So do I need to create a gadget snap for ubuntu?

Thank you.

see

you’d do:

sudo snap set system experimental.hotplug=true

then plug in your serial device

snap interface serial-port

should then return you a serial slot you can use for your application…

in case of an actual (non USB) serial port, you would have to use a model assertion along with a gadget as you described to pre-build a classic ubuntu image. “just installing” gadgets is not possible (gadgets are designed for dedicated images on productized devices and always have to go along with signatures, IDs and certificates from the model assertion) …

2 Likes

Thanks for your reply @ogra . I have already integrated gadget snap for my ubuntu core. But classic ubuntu does not use gadget snap to boot. So I need to pre-build the gadget snap just like what I do on ubuntu core, and then? How to run gadget snap on classic ubuntu? Or I can not install the gadget snap remotely, but I can install it locally?

Thank you.

if you really want to go that route (note that every user would have to have the same hardware and they would have to install your OS image to the system before being able to use your snap)

you’d need to create a classic gadget (i.e. witout bootloader bits and only with interface definitions), create a signed model assertion and use ubuntu-image classic ... just like you do with core …

Thank you. I will give a try.

Hi @ogra, I have another question.
Without gadget snap, there will be no snap can provide hardware slot such serial-port, GPIO, can-bus etc. And other snaps can not use these hardware interfaces only if the snap was installed on classic mode. Is it right?

Thank you.

correct …

well, the snap needs to be built as classic snap from the ground up, there is no “installing in classic mode” it needs to be designed as a classic snap to be able to be installed with --classic …