Make snap with bluetooth for Ubuntu Core 20.04 on Raspberry Pi 4

Hi, i’m trying to do a snap for Ubuntu Core 20.04.3 that must run on a Raspberry Pi 4 Model B. This snap is based on a python script that use the python library ‘bleak’. When i run the snap on Ubuntu desktop there isn’t problem. The problem is when i try to run the snap on Ubuntu Core 20.04 because there is the following error:

OSError: [Errno 8] Exec format error: 'bluetoothctl'.

I understood that to use the bluetooth on Ubuntu Core with the Raspberry Pi i must use the pi-bluetooth snap, but i don’t know how to use this with my snap. More precisely, I don’t know how to make my snap in such a way as to be able to use bluetooth on the Raspberry Pi.

This is my current snapcraft file to realize the snap:

name: iot-band
base: core20 
version: '1.0' 
summary: Iot band app
description: |
  Iot band app

grade: devel 
confinement: devmode 

  - build-on: amd64
    run-on: arm64

      PYTHONPATH: $SNAP/lib/python3.8/site-packages/iot-band
    command: bin/
      - bluez
    # See 'snapcraft plugins'
    source: .
    plugin: python
      - .
    plugin: nil
    stage-snaps: [bluez]

How can i realize correctly the snap (using the “snap pi-bluetooth”) to resolve this problem with the bluetooth?

well, this will download the amd64 bluez snap and stage its binaries inside your arm64 build … surely not what you want … better build your snap on the pi4 … here is a blog post i wrote about how to create snaps natively on a running Ubuntu Core system:

thank you so much for the solution it works

1 Like