Slots and Plugs do not connect automatically

I would like my application snap to automatically connect to serial-port and joystick interface. The joystick interface is provided by core (through dtb) and serial-port interface is provided by the gadget snap.

I am using Ubuntu core 18, compile my own gadget snap and also have my own brand-store.

The slots and plugs have been defined as shown.

I have added the following in the gadget.yaml of gadget snap

+  - plug: <Snap ID of application snap>:serial-port
+    slot: <Snap ID of gadget snap>:serial-port
+  - plug: <Snap ID of application snap>:joystick
+    slot: system:joystick

and on the application snapcraft.yaml file I have added the following

    daemon: simple
    restart-condition: always
    command: bin/XXXXXXX
        - network-bind
        - system-files
        - avahi-control
        - joystick
        - serial-port

I find that the plugs and slots do not connect automatically. Is my configurations correct? Am I missing anything?

N.B.: Snap ID’s were obtained from the Brand-store. But I am using the snaps locally as I would like to push the snaps after they work correctly

Steps followed for testing

  1. I build the image using the command
    UBUNTU_STORE_ID=xxxxx UBUNTU_STORE_AUTH_DATA_FILENAME=./store.auth ubuntu-image snap -c stable --snap gadget_xxxx.snap -O ./build --cloud-init cloud-init.conf device.model

  2. Installed the image, then scp the applictaion snap and install the application using the command snap install application.snap --dangerous.

Also I find that the snap know serial has a correct entry.

the auto-conections from the gadget snap are processed during first boot of your image so this can not work …

you need to build the application into the image during image build so it is installed during the firstboot process… just use another --snap /path/to/application.snap option for ubuntu-image

if you want auto-connections applied dynamically at snap install time (even after first boot) the “gadget connections way” will not work and you will need a snap declaration set up in the store.

When the application snap is passed as suggested by @ogra the snap installation has errors during first boot. This causes all the snaps to be removed including gadget snap and device just freezes. On a reboot the device is stuck in UBoot.

As tried out above, when the snap is installed manually after the first boot there are no errors. Is there any possibility to see what causes the errors during the first boot.
P.S. There is no serial port available

well, we need more info … the systemd journal and ‘snap changes’ output from before the reboot would be great …

try to flash a fresh copy of the image, mount the second partition and create /writable/system-data/var/log/journal befor doing the very first boot … that should create a persistent journal for inspection after the hang.