I’ve also posted this as a bug on the cm3-gadget
page, but I wanted to ask here too because it seems like something else might be happening that isn’t necessarily related to the cm3-gadget Snap.
I’m trying to make a custom gadget Snap for a Compute Module 3, so that I can change the default device tree.
As an example, I’ve created a model assertion, which contains this:
type: model
authority-id: JUVaYs8gDh212C6nrFVN4CYsuPo6kixd
series: 16
brand-id: JUVaYs8gDh212C6nrFVN4CYsuPo6kixd
model: cm3-stock
architecture: armhf
gadget: cm3
kernel: pi2-kernel
timestamp: 2018-05-07T01:24:38+00:00
sign-key-sha3-384: u1OFY0uzgzlU7xZ1P3Sr4UavaF3I6Wjq3cNxA1OaUQ4pt8e213tH-uuwQUW2jD6Y
AcLBXAQAAQoABgUCWvJqwAAKCRC5TOT5ixabevKvD/46GvlxM6/v1eqLyycXXxmoD5ljv9dusTDB
E/kFM7wlp912qvizbH9grxS0IXImlRqIl7ty5mcAob3wzV0ZrgLhWmbYtO26lDYN/gv93Y5UR2zN
O5bq3Fq9b74lzKxRDNVo6DKz+yOqXvl7sqBBh2jmpilsk6WWAkXNU2vT0V0fJ1IuVJef+xfK/xAx
lcrLeJZMolYWC3QilSTeFbjNwLpyD4pihtVg0wmCq8F6PAy4sFST+FCb1cCx+DVSdzDCubE1siX7
z0hIC2ATWFPK4/88Vbq/OHriQ7/UhnRle4/bXMCvZralmJA0JfJvbR+BXXN0OanVTSiLDXZmuVDY
6cq2Ca5KH3ocLcuuzbIqjllv5HmcKmcj57DPkUquUiw83UZ7xiMiqlwlwgDXGHmjKL6KPZ9+F9KL
HSNX0UCwjBrRcqFplcj3w+O/Bkm3iWqcrMeEN8kzCGRnRvoMV3tkt8VdjEUU97pSlOXegt8Oy5xm
icdnVlCzdMebJHVgUhXuNNeRkjkhk/pNm4+T+GCObmmgTIphbPHmZKtkAb4sEl3h3t5PAPk6IDiC
bu/30+5Wi193TCTtjlhe8VCv5lzVf0e9p59bbpFfTjc8RrESbYQKTSTQAlrN/YpBCOXCj4fxNv37
V+yWttReQjZlj9jKNMZgNBDCFwHhA3ZJJB3c2dkrMg==
If I create an Ubuntu Core image using this model assertion with the kernel and gadget Snaps from the global store, it works fine. This is the command to make the image:
$ sudo ubuntu-image snap -c stable cm3-stock.model
I can copy this to the Compute Module, and it works fine.
However, if I clone the cm3-gadget
repo and build it with Snapcraft, like this:
$ git clone https://github.com/snapcore/cm3-gadget.git
...
$ cd cm3-gadget
$ snapcraft
...
I get a (seemingly) correctly built Snap package, cm3_16.04-0.5_amd64.snap
(I realise it says amd64
but I presume this is because that is my host system architecture). I then build a new image with:
$ sudo ubuntu-image snap -c stable --extra-snaps cm3_16.04-0.5_amd64.snap cm3-stock.model
I can copy this to the Compute Module, and it works and correctly boots - the first time. But as soon as I reboot, regardless of if done with sudo reboot
or by a power cycle, the subsequent boots never work. U-boot gives output like this:
U-Boot 2017.05-dirty (May 09 2018 - 14:35:32 +1000)
DRAM: 944 MiB
RPI Compute Module 3 (0xa020a0)
MMC: bcm2835_sdhci: 0
reading uboot.env
In: serial
Out: lcd
Err: lcd
Net: Net Initialization Skipped
No ethernet found.
Hit any key to stop autoboot: 0
switch to partitions #0, OK
mmc0(part 0) is current device
LOADBOOTENV
reading uEnv.txt
** Unable to read file uEnv.txt **
Running uenvcmd ...
ENVCMD
reading pi2-kernel_52.snap/kernel.img
** Unable to read file pi2-kernel_52.snap/kernel.img **
reading pi2-kernel_52.snap/initrd.img
** Unable to read file pi2-kernel_52.snap/initrd.img **
Bad Linux ARM zImage magic!
Scanning mmc 0:1...
Scanning mmc 0:2...
starting USB...
USB0: Core Release: 2.80a
scanning bus 0 for devices... 3 USB Device(s) found
scanning usb for storage devices... 0 Storage Device(s) found
scanning usb for ethernet devices... 0 Ethernet Device(s) found
USB device 0: unknown device
No ethernet found.
It somehow is unable to read the kernel image. If I mount the CM3 storage, it looks like the kernel Snap folder has been completely removed!
This is the initial, working, system-boot
folder:
$ ls -lh system-boot
total 13M
-rw-r--r-- 1 sean sean 15K May 10 2018 bcm2709-rpi-2-b.dtb
-rw-r--r-- 1 sean sean 16K May 10 2018 bcm2710-rpi-3-b.dtb
-rw-r--r-- 1 sean sean 15K May 10 2018 bcm2710-rpi-cm3.dtb
-rw-r--r-- 1 sean sean 50K May 10 2018 bootcode.bin
-rw-r--r-- 1 sean sean 104 May 10 2018 cmdline.txt
-rw-r--r-- 1 sean sean 1.6K May 10 2018 config.txt
-rw-r--r-- 1 sean sean 19K May 10 2018 COPYING.linux
-rw-r--r-- 1 sean sean 2.6K May 10 2018 fixup_cd.dat
-rw-r--r-- 1 sean sean 6.6K May 10 2018 fixup.dat
-rw-r--r-- 1 sean sean 9.6K May 10 2018 fixup_db.dat
-rw-r--r-- 1 sean sean 9.6K May 10 2018 fixup_x.dat
-rw-r--r-- 1 sean sean 1.5K May 10 2018 LICENCE.broadcom
drwxr-xr-x 2 sean sean 10K May 10 2018 overlays
drwxr-xr-x 3 sean sean 512 May 10 2018 pi2-kernel_52.snap
-rw-r--r-- 1 sean sean 643K May 10 2018 start_cd.elf
-rw-r--r-- 1 sean sean 4.8M May 10 2018 start_db.elf
-rw-r--r-- 1 sean sean 2.8M May 10 2018 start.elf
-rw-r--r-- 1 sean sean 3.8M May 10 2018 start_x.elf
-rw-r--r-- 1 sean sean 352K May 10 2018 uboot.bin
-rw-r--r-- 1 sean sean 128K May 10 2018 uboot.env
And this is after the first boot and reboot:
$ ls -lh system-boot
total 13M
-rw-r--r-- 1 sean sean 15K May 10 2018 bcm2709-rpi-2-b.dtb
-rw-r--r-- 1 sean sean 16K May 10 2018 bcm2710-rpi-3-b.dtb
-rw-r--r-- 1 sean sean 15K May 10 2018 bcm2710-rpi-cm3.dtb
-rw-r--r-- 1 sean sean 50K May 10 2018 bootcode.bin
-rw-r--r-- 1 sean sean 104 May 10 2018 cmdline.txt
-rw-r--r-- 1 sean sean 1.6K May 10 2018 config.txt
-rw-r--r-- 1 sean sean 19K May 10 2018 COPYING.linux
-rw-r--r-- 1 sean sean 2.6K May 10 2018 fixup_cd.dat
-rw-r--r-- 1 sean sean 6.6K May 10 2018 fixup.dat
-rw-r--r-- 1 sean sean 9.6K May 10 2018 fixup_db.dat
-rw-r--r-- 1 sean sean 9.6K May 10 2018 fixup_x.dat
-rw-r--r-- 1 sean sean 1.5K May 10 2018 LICENCE.broadcom
drwxr-xr-x 2 sean sean 10K May 10 2018 overlays
-rw-r--r-- 1 sean sean 643K May 10 2018 start_cd.elf
-rw-r--r-- 1 sean sean 4.8M May 10 2018 start_db.elf
-rw-r--r-- 1 sean sean 2.8M May 10 2018 start.elf
-rw-r--r-- 1 sean sean 3.8M May 10 2018 start_x.elf
-rw-r--r-- 1 sean sean 352K May 10 2018 uboot.bin
-rw-r--r-- 1 sean sean 128K May 10 2018 uboot.env
The pi2-kernel_52.snap
folder is entirely gone! Why would this be? This doesn’t happen with the cm3
gadget Snap from the global store, only when I use my self-built Snap - and everything else is the same.