Jump to content

Porting to a new device/Kernel package/Kernel configuration

From postmarketOS Wiki
Note If pmbootstrap throws an error here, you need to remove the example patch!

The magic command, which lets you change the kernel configuration is pmbootstrap kconfig edit. Don't try to manually change the defconfig file, because only by running menuconfig, the dependencies will get resolved properly. menuconfig always runs on the kernel with all patches applied, so we'll run it once to see if we need to remove patch files first.

Remove failed patches

You will find some example patches already in the generated kernel package. When a patch does not apply correctly, you will get something like the following in the log window (scroll up, the error is above the ^^^ line).

$ pmbootstrap kconfig edit linux-wiki-example
>>> linux-wiki-example: Unpacking /var/cache/distfiles/linux-wiki-example-ffff.tar.gz...
>>> linux-wiki-example: 01_msm-fix-perf_trace_counters.patch
patching file arch/arm/mach-msm/perf_trace_counters.h
Hunk #1 succeeded at 158 (offset 37 lines).
>>> linux-wiki-example: 02_this_patch_fails.patch
patching file arch/arm/mach-msm/perf_trace_counters.h
Hunk #1 FAILED at 121.
1 out of 1 hunk FAILED -- saving rejects to file arch/arm/mach-msm/perf_trace_counters.h.rej
>>> ERROR: linux-wiki-example: all failed

When this happens, remove the failing patch from the source= variable in the APKBUILD, and delete the patch file from the same folder. Finally, correct the checksums and try kconfig edit again.

$ nano pmaports/device/testing/linux-wiki-example/APKBUILD # remove from source
$ rm pmaports/device/testing/linux-wiki-example/02_this_patch_fails.patch
$ pmbootstrap checksum linux-wiki-example
$ pmbootstrap kconfig edit

Make kconfig check happy

Run pmbootstrap kconfig check before compiling kernel to know what changes to kernel config are recommended.

$ pmbootstrap kconfig check linux-wiki-example

If there are recommended changes, run

$ pmbootstrap kconfig edit linux-wiki-example

to change values of the options. Press / to use search and number next to search entry to go to the option.

Note GUI is available for kconfig edit, check kconfig edit -h for more info

Troubleshooting kconfig edit

If kconfig edit failed to launch with Install ncurses (ncurses-devel) and try again. message, create symlink to device/.shared-patches/linux/fix-check-lxdialog.patch file in linux-wiki-example folder and add the filename in source= in the APKBUILD

If you get an error anyway, add device/.shared-patches/linux/fix-check-lxdialog-makefile.patch to the package as described above.