Error building pi4 system image with ubuntu-image

I’m trying to build an ubuntu core system image for pi4 arm64, using the ubuntu-image tool.
I already have this working for pi3 arm32.

However, when trying to build the pi4 image, I get this error:

$ ./
Fetching snapd
Fetching pi-kernel
Fetching core20
Fetching pi
Fetching core18
Fetching capturegrid4
panic: runtime error: slice bounds out of range [recovered]
        panic: runtime error: slice bounds out of range

goroutine 1 [running]:
        /build/snapd/parts/snapd-deb/build/_build/src/ +0x84
panic(0xaaaad27c9280, 0xaaaad2b934b0)
        /usr/lib/go-1.10/src/runtime/panic.go:502 +0x1e8, 0x32, 0x1, 0x0, 0x0, 0x0)
        /build/snapd/parts/snapd-deb/build/_build/src/ +0x3b4*uboot).SetBootVars(0x4420496020, 0x442034a1b0, 0x44200384b0, 0x49)
        /build/snapd/parts/snapd-deb/build/_build/src/ +0x3c, 0x4420149440, 0x1d, 0x44206318c8, 0x0, 0x44200dc0f0)
        /build/snapd/parts/snapd-deb/build/_build/src/ +0x538, 0x4420149440, 0x1d, 0x44206318c8, 0x0, 0x0)
        /build/snapd/parts/snapd-deb/build/_build/src/ +0xf8, 0x44202de700, 0x442035bc70, 0x1, 0x44201d1968)
        /build/snapd/parts/snapd-deb/build/_build/src/ +0x1334, 0xaaaad2bf6888, 0x0)
        /build/snapd/parts/snapd-deb/build/_build/src/ +0x2e8
main.(*cmdPrepareImage).Execute(0x442031ae00, 0x4420360a50, 0x0, 0x3, 0x442031ae00, 0x1)
        /build/snapd/parts/snapd-deb/build/_build/src/ +0x408*Parser).ParseArgs(0x44202fd180, 0x44200c0050, 0x3, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0)
        /build/snapd/parts/snapd-deb/build/_build/src/ +0x678*Parser).Parse(0x44202fd180, 0x44202fd180, 0xaaaad2bd99a0, 0xffff9dcf66c8, 0x0, 0x442010f8f8)
        /build/snapd/parts/snapd-deb/build/_build/src/ +0x70, 0xaaaad28972c0)
        /build/snapd/parts/snapd-deb/build/_build/src/ +0x3c
        /build/snapd/parts/snapd-deb/build/_build/src/ +0x2a0
COMMAND FAILED: snap prepare-image /home/francis/code/repo/smartshooter4/smartshooter/installer/snap/image/capturegrid4-pi4-arm64.model /tmp/tmpv5yai8et/unpack

Here is the model I’m using for the image:

    "type": "model",
    "authority-id": "...",
    "brand-id": "...",
    "series": "16",
    "model": "capturegrid4-pi4-arm64",
    "architecture": "arm64",
    "base": "core20",
    "gadget": "pi=20",
    "kernel": "pi-kernel=20",
    "timestamp": "2020-05-05T10:20:00+00:00",
    "required-snaps": ["core18", "capturegrid4"]

I’m not really sure where to begin trying to fix this.
Can anyone give me some guidance?

core20 was completely re-designed and might work completely different to all former UC versions, the new build process for local builds does not seem to be documented yet …

also UC20 is still in early beta stage, i’d stick to base: core18 for now …

The reason I’ve been trying core20 instead of core18 is for pi4 64bit support.
As far as I know core18 does not support that (yet?).


(though unless you have an 8GB Pi4 using 64bit is rather just a waste of ram (binaries allocate about twice the ram at runtime in 64bit mode (even 32bit ones which is the majority)) for no actual benefit …

That code needs better error handling but the underlying issue is that the pi gadget for core 20 is very different, and the snapd used is too old to deal with it. Even in that case the syntax for the model assertion to have a working UC20 system has changed.

There will be more information about this with snapd 2.45. should turn that panic into an error