Failed to read /proc/cmdline or /proc/device-tree/serial-number in prepare-device gadget hook

Hello, I’m building a new image for our board. We have /proc/device-tree/serial-number a unique serial that we want to use in prepare-device hook of our gadget snap in this way

snapctl set registration.proposed-serial="'${product_serial}'"

In particular, we tried both

product_serial=$(grep -o "serial=[^ ]*" /proc/cmdline | cut -d= -f2 | xxd -r -p)

and

product_serial=$(xxd -r -p < /proc/device-tree/serial-number)

but we always get permission denied on such commands.

We put in our snapcraft.yaml the string

hooks:
  prepare-device:
    plugs:
      - hardware-observe

and, in gadget.yaml

connections:
  - plug: <gadget_snap_id>:hardware_observe

We have published a first version of the gadget snap in our private brand store, but we are currently building the image using a local built snap.

Do you have any idea how to let it work ? Thanks!

If you side-load your gadget from a local file you will not have a snap ID, this only works for snaps coming from the store, so your connections: entry will be ignored …

If you have a private brand store you should also have an assigned field engineer that should be able to help you with your initial image, you should try to get in contact…