Jump to content

Porting to a new device/Device specific package

From postmarketOS Wiki
Note If your device has a boot partition smaller than ~16MB, or if flashing the kernel fails with an "image too large" error, you might need to switch to the minimal initramfs.

To do so, open the deviceinfo file in an editor (replace wiki-example).

$ nano pmaports/device/testing/device-wiki-example/deviceinfo

Add the following line:

deviceinfo_create_initfs_extra="true"

Flash Offsets

TODO TODO: add instructions on where to put the values after you get them
TODO TODO: Add how to check header version

If you skipped analyzing boot.img during the initialization step, follow the appropriate steps below to determine the correct deviceinfo_flash_offset_ values.

Header Version < 3

pmbootstrap bootimg_analyze path/to/boot.img

Header Version ≥ 3

unpack_bootimg vendor_boot.img

Manual entry

TODO TODO: Add instructions for the manual method.
Note Manual entry is discouraged due to the high risk of errors. Use the provided tools whenever possible.

UFS

If your device uses UFS storage, you may need to configure the rootfs image sector size. It defaults to 512b, but some devices use 4096b. In a root shell, check your sector size with:

# blockdev --getss /dev/block/sda

If the sector size is 4096 bytes, add the following line to the deviceinfo file:

deviceinfo_rootfs_image_sector_size="4096"

You can read more about sector sizes on this pull request thread.

deviceinfo_dtb

If deviceinfo_header_version is 2 or higher, fill in deviceinfo_dtb with your device's dtb. This can be found in your kernel source under /arch/{your device's arch}/boot/dts/{your device's SOC brand}/. It may take some trial and error to figure out which .dts file is used. If in doubt, choose the one with the name of your SOC or the name of your device.

Thus, in deviceinfo_dtb, put {your device's SOC brand}/{the name of your device's .dts file, not including the file extension}. See Device Tree (dtb) for more information.

Deviceinfo documentation

See deviceinfo reference for a listing of all available variables and their meanings. The device specific package article explains advanced customization of the APKBUILD.

Building device-specific package

Create checksums and build the device package once to make sure it doesn't contain errors at this point (we didn't do that earlier, because pmbootstrap would have complained about the invalid pkgver of the kernel package):

$ pmbootstrap checksum device-wiki-example
$ pmbootstrap build device-wiki-example

Packaging tips

Notice If your device requires executing udev rules early in boot (initramfs), they must be added to the initramfs configuration

This can be done in the device package by creating a file that lists the rules:

# 10-device-initramfs-extra.files
/usr/lib/udev/rules.d/device-specific.rules

And installing this file in the device package APKBUILD:

install() {
...

	install -Dm644 "$srcdir"/10-device-initramfs-extra.files \
		-t "$pkgdir"/usr/share/mkinitfs/files-extra/

...
}