Best practice for porting a board to Ubuntu Core


#1

Hi all,
It would be useful to know the real path that bring a new release of kernel for the canonical supported board.
It is interesting for help the effort for porting other board to the snappy framework.
As we know, there is a tight dependence between kernel snap and core snap:

  1. Seccomp
  2. Apparmor
  3. Cggroup
  4. Namespaces

I understood that the core is build from this snap code Core Snap, but it is not very clear the process that bring a working kernel for the canonical supported board.

Can i suppose the following things?

  1. the supported kernel are the same as supported for the LTS 16.04: 4.4, 4.8, 4.10
  2. the reference repository is git://kernel.ubuntu.com/ubuntu/ubuntu-xenial.git

If these two assumptions are correct, the question is:
any tags on this repo is ready for build a kernel compatible for snap core - it mean to be patched with correct apparmor patch etc etc ?

Cheers,
Nicolino


#2

the core snap is actually the most minimal OS to bring up snapd and boot a basic system, you do not change it when porting to a new board, but use the provided core snap from the store. hardware specific bits have to happen in the kernel and gadget snap packages.

for the kernel we currently default to the 16.04.* source (i.e. 4.4). if you use your own kernel tree (i.e. a BSP one) there are a few places to obtain teh apparmor patches for it.

you might want to watch this webinar for a few more details about Core images and how to assemble them, there are also links to the apparmor trees in the presentation.

there are also docs about image building here.


#3

I can’t get that webinar video to play in either Firefox or Chromium.


#4

Hi @ogra,
thanks for your answer and your webinar about internals of ubuntu core.

About core snap the process is clear: I don’t need to changes it and I think that changing core snap for each board is very useless in any case.

About Apparmor and version of kernel to use it is very clear now.

About kernel configuration the understanding for me need another bit of information:
In your webinar slide your redirect for kernel configuration to a web resource placeholders with “here”:
in this way i can’t know where this information is located because the presentation is not clickable.

The board enablement overview point to a sample kernel for the series 3.10,3.14,3.18 e 4.4.
It is correct to suppose that the information about kernel configuration is placed in kernel/configs/?

Thanks in advance

Cheers,
Nicolino


#5

Yes, any Ubuntu kernel will work fine with Ubuntu core ( LTS 16.04[1]: 4.4, 4.8, 4.10), but we have sample kernels for older releases too[2]: 3.10, 3.14, 3.18 and 4.4.

With regards to the kernel config, if you are using an ubuntu kernel, you can use the config there:

alias fdr='fakeroot debian/rules’
fdr clean
fdr prepare-generic
cp debian/build/build-generic/.config .config

while the sample kernels have the config options to apply on top your defconfig in kernel/configs/snappy[3].

1: https://git.launchpad.net/~ubuntu-kernel/ubuntu/+source/linux/+git/xenial/ - check out the master branch
2: https://github.com/snapcore/sample-kernels
3: e.g. for 3.10 -> https://github.com/snapcore/sample-kernels/tree/stable-3.10.y/kernel/configs/snappy


#6

oh, sorry, when i prepared the webinar i wasnt aware that the presentation wont be provided as a klickable doc alongside the webinar video… the “here” link actually points to https://github.com/snapcore/sample-kernels/blob/master/README.md which includes links to the branches paolo points to.


#7

thanks @ogra @ppisati for the shared informations.
We double check our porting of u-boot with the your porting on raspberry 2/3.

What is the rationale of the following part of the patch?

+#define CONFIG_PREBOOT			"usb start; if test ! \"mmc dev 0\"; then " \
+	"fatload usb 0:1 0x3000000 "FAT_ENV_FILE"; " \
+	"env import -b 0x3000000; " \
+	"fi;"

If the rationale of this patch is permit the board to boot from usb, we found the following facts:

if test ! \"mmc dev 0\"; [1]

return always true.
Furthermore, because it is not checked the existence of FAT_ENV_FILE, the command

 env import -b 0x3000000;

is always execute, so we can load garbage memory in uboot env.
Moreover it is necessary to remove the CRC pad from the file generate from mkenvimage for placing it on USB support.

Is this feature strictly necessary for porting ubuntu core on a new board?

Nicolino & Francesco


#8

this only works if you toggled the ROM of the board to default to USB boot as i understand it (which is a non-reversible setting in the pi ROM) … probably @abeato can expand on that, it is his addition …

indeed, since you boot with an SD card plugged in it will always be true … (see above, teh pi needs to be toggled to USB boot and indeed there needs to be no SD card inserted, then the bootloader will try booting from USB key)


#9

@NCuralli as @ogra says, you need to do a change to a mysterious setting in the board EPROM to be able to boot from a USB drive.

To do this you need to use Raspbian and follow the steps in https://www.raspberrypi.org/documentation/hardware/raspberrypi/bootmodes/msd.md . After that you can boot UC16 images using a USB drive.


#10

Hi, is this still valid after more than a year?

I’m trying to port my board (which uses a 3.10 kernel) to Core. So far, I could merge my kernel with the appropriate sample-kernel, adapt the defconfig and generate a kernel snap. I couldn’t test it yet because I still need to figure out some aspects from the gadget part, but would be good to confirm if this is still up to date before going further.


#11

@mbeneto,

If you’re targeting to UC16, then it should be similar to my works (refer https://github.com/xapp-le/SnappyUbuntuCore).
If you’re looking for UC18 porting, maybe you have to remodel assertion to fit the UC18 spec.


#13

For UC16 the processes are still the same … (and UC18 isnt finally released yet so do not bother yet)