Gadget slots for devices that don't exist


I was talking with @ogra and @pedronis about this, and I was wondering what the behavior should be when we have a single gadget snap for multiple hardware configurations and some of those hardware configurations don’t have all of the devices the gadget declares.

AFAICT this is the case for the Raspberry Pi 2 UC18 and Raspberry Pi 3 UC18 gadget snaps which are provided by the same pi gadget here. The gadget for the pi3 in UC16 (the pi3 gadget here) declares a bt-serial serial-port interface slot, but now with UC18 since the gadgets have been unified and it seems that bt-serial interface was dropped from the gadget. I want to add it back so that we can use bluez on the Raspberry Pi 3 B+ eventually with this interface, but it seems that since the gadgets were unified if I were to add the following slot to the pi gadget:

    interface: serial-port
    path: /dev/ttyAMA0

this will be fine for the Raspberry Pi 3B+ where the /dev/AMA0 device actually exists, but for the Raspberry Pi 2, this device path doesn’t exist.

What should the behavior of snapd be when a gadget snap declares a slot for a device path that doesn’t exist on that system? Is this a bug with the gadget or a bug with snapd? Maybe snapd should auto-hide that interface?

my expectation as a developer (until we discussed it yesterday), would have been that interfaces that have a defined path actually check this path before snapd exposes them …

Note that snapd allowing the slot to exist, but not have an actual device node would probably run into some variant of if a snap with gpio plug was installed and someone tried to connect that. Unclear if that’s okay or not though