DistroKit - A Playground BSP for PTXdist

At Pengutronix we are using PTXdist to automatically integrate many industrial embedded Linux projects. Some time ago I started DistroKit: This example BSP shall be able to demonstrate PTXdist features.

For DistroKit, I had these design criteria in mind:

  • Small BSP, but not optimized for minimum size: Modern Embedded Linux systems have enough resources for a certain set of comfort features; however, DistroKit leaves out anything that does not qualify as base features.
  • Modern Linux Userspace: DistroKit makes use of glib, D-Bus, systemd and NetworkManager.
  • Multi Platform Support: We support several target devices, such as Raspberry Pi 1+2, BeagleBone white and black, the RIoT Board, Udoo Neo and a QEmu supported Versatile Express platform.

During this tutorial I'd like to show you, how to set up DistroKit.

Setting Up a Development Environment

If you like to start playing with DistroKit, the Versatile Express supported in QEmu is probably a good target device, as you don't need any hardware. To build the BSP, a cross compiler toolchain is needed; although you can build it yourself from the sources, we also provide OSELAS.Toolchain as debian packages, which can easily be installed with:

rsc@leda:~$ sudo echo 'deb http://debian.pengutronix.de/debian/ sid main contrib non-free' > /etc/apt/sources.list.d/pengutronix.sid.list
rsc@leda:~$ sudo apt install oselas.toolchain-2016.06.1-arm-v7a-linux-gnueabihf-gcc-5.4.0-glibc-2.23-binutils-2.26-kernel-4.6-sanitized

Now checkout DistroKit from our git server:

rsc@leda:~$ cd git
rsc@leda:~/git$ git clone https://git.pengutronix.de/git/DistroKit
rsc@leda:~/git$ cd DistroKit
rsc@leda:~/git/DistroKit$

To build DistroKit, you need the PTXdist version specified in the ptxconfig file:

rsc@leda:~/git/DistroKit$ grep PTXCONF_CONFIGFILE_VERSION configs/ptxconfig
PTXCONF_CONFIGFILE_VERSION="2017.07.0"

Ok, in this example, we need ptxdist-2017.07.0, which can be downloaded from the PTXdist archive server. Installing PTXdist is a separate step, which can be done with the usual configure/make/make install. Make sure that you have the ptxdist command in your path.

Now everything is prepared to build DistroKit from sources.

Building DistroKit

To build DistroKit with ptxdist, you need to select a "platform" first. In ptxdist terminology, a platform is something you need a dedicated compiler for: in our case, we can start with the ARM v7a platform:

rsc@leda:~/git/DistroKit$ ptxdist platform configs/platform-v7a/platformconfig
info: selected platformconfig:
      'configs/platform-v7a/platformconfig'

found and using toolchain:
'/opt/OSELAS.Toolchain-2016.06.1/arm-v7a-linux-gnueabihf/gcc-5.4.0-glibc-2.23-binutils-2.26-kernel-4.6-sanitized/bin'

rsc@leda:~/git/DistroKit$

Building a BSP from sources needs some time and CPU resources, therefore ptxdist tries do do as many things as possible in parallel if you run it like this:

rsc@leda:~/git/DistroKit$ ptxdist -j --quiet images
started : host-dummy-install-info.get
started : base.get
started : host-system-perl.get
started : cross-dummy-strip.get
finished: host-dummy-install-info.get
finished: base.get
finished: host-system-perl.get
finished: cross-dummy-strip.get
started : usr-rootfs.get
started : cross-pkg-config-wrapper.get
started : blspec-boneblack.get
finished: usr-rootfs.get
finished: cross-pkg-config-wrapper.get
started : gcclibs.get

The "ptxdist images" command instructs ptxdist to build the firmware images for the selected v7a platform. In order to do so, ptxdist executes many rules that specify how to fetch, configure and build the involved source packages and does all necessary steps to build a firmware image.

Once the image has been built, you can start it in QEmu:

rsc@leda:~/git/DistroKit$ configs/platform-v7a/run barebox


barebox 2017.07.0-20170703-1 #1 Fri Aug 18 13:00:12 CEST 2017


Board: ARM Vexpress
smc911x 4e000000.ethernet: LAN911x identified, idrev: 0x01180001, generation: 1
mdio_bus: miibus0: probed
eth0: got preset MAC address: 52:54:00:12:34:56
cfi_flash 40000000.flash: found cfi flash at 0x40000000, size 64 MiB
cfi_flash 40000000.flash: found cfi flash at 0x44000000, size 64 MiB
Concatenating MTD devices:
(0): "40000000.flash"
(1): "40000000.flash"
into device "nor"
state: New state registered 'state'
netconsole: registered as netconsole-1
mmci-pl18x mmci-pl18x: registered as mmci-pl18x
mci0: detected SD card version 1.0
mci0: registered disk0
malloc space: 0x7bfd7580 -> 0x7ffd757f (size 64 MiB)
found force-builtin environment, using defaultenv
running /env/bin/init...

Hit any key to stop autoboot:    1

And, after Linux has created the SSH keys for the simulated devices:

ext4 ext40: EXT2 rev 1, inode_size 128, descriptor size 32
blspec: ignoring entry with incompatible devicetree "ti,am335x-bone"
blspec: ignoring entry with incompatible devicetree "raspberrypi,2-model-b"
blspec: ignoring entry with incompatible devicetree "riot,imx6s-riotboard"
blspec: ignoring entry with incompatible devicetree "fsl,imx6q-sabrelite"
blspec: ignoring entry with incompatible devicetree "ti,am335x-bone-black"
blspec: ignoring entry with incompatible devicetree "udoo,neofull"
booting 'PTXdist - Pengutronix-DistroKit'
blspec: booting PTXdist - Pengutronix-DistroKit from mci0
Adding "root=PARTUUID=74823abf-01" to Kernel commandline

Loading ARM Linux zImage '/mnt/disk0.0//boot/zImage'
Loading devicetree from '/mnt/disk0.0//boot/vexpress-v2p-ca9.dtb'
commandline:  root=PARTUUID=74823abf-01 loglevel=5 systemd.log_level=warning systemd.show_status=auto rootwait rootfstype=ext4 console=ttyAMA0,115200
[    0.000000] GIC CPU mask not found - kernel will fail to boot.
[    0.000000] GIC CPU mask not found - kernel will fail to boot.
[    0.000000] L2C: platform modifies aux control register: 0x02020000 -> 0x02420000
[    0.000000] L2C: DT/platform modifies aux control register: 0x02020000 -> 0x02420000
[    0.000000] smp_twd: clock not found -2
[    0.004158] Failed to initialize '/smb@4000000/motherboard/iofpga@7,00000000/timer@12000': -22
[    0.479904] OF: amba_device_add() failed (-19) for /memory-controller@100e0000
[    0.481207] OF: amba_device_add() failed (-19) for /memory-controller@100e1000
[    0.481664] OF: amba_device_add() failed (-19) for /watchdog@100e5000
[    0.506035] OF: amba_device_add() failed (-19) for /smb@4000000/motherboard/iofpga@7,00000000/wdt@f000
[    0.511195] irq: type mismatch, failed to map hwirq-75 for /interrupt-controller@1e001000!
[    0.940917] of-flash 48000000.psram: do_map_probe() failed for type map_ram
[    0.941772] of-flash 48000000.psram: do_map_probe() failed
[   17.466631] systemd-rc-once[138]: remounting root rw...done
[   17.577853] systemd-rc-once[138]: running rc.once.d services...
[   18.917195] systemd-rc-once[138]: Creating dynamic linker cache...
[   25.394839] systemd-rc-once[138]: Creating ED25519 key; this may take some time ...
[   26.306195] systemd-rc-once[138]: Creating ED25519 key; done.
[   26.388585] systemd-rc-once[138]: Creating RSA key; this may take some time ...
[  107.122933] systemd-rc-once[138]: Creating RSA key; done.
[  110.396604] systemd-rc-once[138]: remounting root ro...done

 ____                        _                   _
|  _ ` ___ _ __   __ _ _   _| |_ _ __ ___  _ __ (_)_  __
| |_) / _ ` '_ ` / _` | | | | __| '__/ _ `| '_ `| ` `/ /
|  __/  __/ | | | (_| | |_| | |_| | | (_) | | | | |>  <
|_|   `___|_| |_|`__, |`__,_|`__|_|  `___/|_| |_|_/_/`_`
                 |___/

 ____  _     _             _  ___ _
|  _ `(_)___| |_ _ __ ___ | |/ (_) |_
| | | | / __| __| '__/ _ `| ' /| | __|
| |_| | `__ ` |_| | | (_) | . `| | |_
|____/|_|___/`__|_|  `___/|_|`_`_|`__|


OSELAS(R)-DistroKit-0000.00.0-00260-g838ea9d300c8 / v7a-0000.00.0-00260-g838ea9d300c8
ptxdist-2017.07.0/2017-08-18T13:09:40+0200

DistroKit login:

Weiterführende Links

Lizenzmanagement mittels ptxdist make license-report

PTXdist kommt standardmäßig mit einem Werkzeug, welches das Lizenzmanagement erleichtert: ptxdist make license-report. Hiermit lässt sich ein Lizenzreport als PDF erstellen, welcher aus dem verwendeten BSP alle auffindbaren Lizenzen herausfiltert. Die Generierung und Befolgung des Lizenzreports sollte als Mindestanforderung mit viel Raum für weitergehende Lizenzpflege verstanden werden.


Statische Dateisysteme

Wann immer es erforderlich ist, ein embedded Gerät einfach so ohne Vorbereitung ausschalten zu können, kommt das Thema Dateisystem-Konsistenz auf. Werden Daten geschrieben und haben vor dem Ausschalten ihren Weg auf das Speichermedium noch nicht vollständig gefunden, droht deren Verlust.


Jump Start your BSP using DistroKit and PTXdist Layers

A BSP (Board Support Package) in Embedded Software is the layer of software that lets you run your application on a specific hardware. For Pengutronix a BSP usually contains a bootloader, Linux Kernel and a userspace. DistroKit is our Demo-BSP that supports a variety of common evaluation boards. DistroKit gives you a head start if you want to develop an application on top of such an evaluation board with most of the hard problems already solved.