Jump to content

User:Knuxify/Draft:Porting guide/Device package

From postmarketOS Wiki

The next step is to adjust and build the device-vendor-codename package. A mostly complete device package was generated by pmbootstrap during the initialization step.

Open the ~/.local/var/pmbootstrap/cache_git/pmaports/device/downstream/device-vendor-codename directory (replace vendor-codename with your device's vendor/codename).

deviceinfo adjustments

The deviceinfo file stores information related to the device: its metadata (like name, chassis type or release year), as well as options related to initramfs generation and flashing.

There are some adjustments that you may need to do to the deviceinfo file:

Enabling the minimal initramfs

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.

Add the following line to the deviceinfo file:

deviceinfo_create_initfs_extra="true"

rootfs block size

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"

Flash offsets

If you skipped the boot.img analysis step during pmbootstrap init, you can get the flash offset values by running:

$ pmbootstrap bootimg_analyze path/to/boot.img

Paste the output of the command into the deviceinfo file.

Setting the DTB location

If deviceinfo_header_version is 2 or higher, fill in deviceinfo_dtb with the name of your device's dtb (without the dtb suffix). You should've found the location of the DTB file in the kernel package step.

deviceinfo_dtb="samsung/exynos4412-i9300"

Heimdall: Setting the partition names

For Samsung devices using the Odin protocol/Heimdall flashing method, you may need to set the system/rootfs and boot/kernel partitions manually.

To get a list of valid partitions, boot the device into download mode and run:

# heimdall print-pit

Find the system/rootfs and boot/kernel partitions there, then fill the deviceinfo_flash_heimdall_partition_* options accordingly:

deviceinfo_flash_heimdall_partition_kernel="KERNEL"                     
deviceinfo_flash_heimdall_partition_rootfs="system"

Setting the partition type to MBR

Note This only applies to non-Android devices.

pmbootstrap uses GPT as the default partition table for SD card/disk installs. If your device doesn't support GPT (e.g. if it uses an old U-Boot version), add the following line to use MBR instead:

deviceinfo_partition_type="msdos"

Updating checksums and building the device package

If you modified the deviceinfo file, you need to regenerate the checksums:

$ pmbootstrap checksum device-vendor-codename

Afterwards, you need to build the package:

$ pmbootstrap build device-vendor-codename
TODO TODO: Are there common errors that should be mentioned here?

Continue to First boot.