I packaged the kernel for Gentoo

I have written an ebuild (the equivalent to a package on Gentoo) that builds and installs a kernel for the MNT Reform 2.

You can find documentation on how to install the kernel on the MNT Reform page in the Gentoo wiki.

On the same page you can also find instructions on how to configure dracut to generate an accompanying Initrd.

The ebuild uses the patches provided by MNT, but unlike the kernel included in the official Debian image, it is not actually based on the Debian kernel sources and configuration. Instead it is based on the Gentoo-patched kernel sources and the Gentoo kernel configuration (which in turn is based on the Fedora kernel configuration).

If you’re interested in how it’s done, you can find the ebuild in my repository here: sys-kernel/mnt-reform2-kernel · master · Niklaus Hofer / mnt-reform2-overlay · GitLab

12 Likes

I bumped the version of the package to 6.1.12. I also tested it with USE=“hardened” and it works just fine :slight_smile:

Nice work! I like the detailed documentation.

bdw… the link to the generic bootscr.uboot doesn’t work (not existing in the linked path)

1 Like

I bumped the version to 6.1.20. Plus I tested the out-of-tree LPC module from the reform-tools repository and it works fine. Currently looking into how to best package that for Gentoo.

2 Likes

I bumped the version to 6.4.7.

Since the last post, I’ve also had a chance to test HDMI, which was a success :slight_smile:

1 Like

Bumped to 6.6.8!

Note that I only test the kernel on the stock (i.MX8MQ) SOM.

4 Likes

Thank you for this. I have my Pocket on order, I was planning on running Funtoo and this is very helpful.

1 Like

Thanks so much!

I’m planning to go the full manual kernel config route, but your ebuild (together with the build script in the official repo) is an excellent starting point.

1 Like

By the way, I’ve hacked together a seemingly working ebuild for the lpc-driver:

EAPI=8

DESCRIPTION="MNT Reform 2 LPC driver"
HOMEPAGE="https://mnt.re"

LICENSE="GPL-3"
SLOT="0"
KEYWORDS="~arm64"

DEPEND=""
RDEPEND="${DEPEND}"
BDEPEND=""

EGIT_REPO_URI="https://source.mnt.re/reform/reform-tools.git"
inherit git-r3
inherit linux-mod-r1

S="${WORKDIR}/${P}/lpc"

CONFIG_CHECK="OF POWER_SUPPLY SPI"

src_compile() {
        local modlist=(
                reform2_lpc=misc
        )
        linux-mod-r1_src_compile
}

@vimja, do you think it’s worth adding this ebuild to your overlay?

Oh wow, this is so cool! With your permission, I would love to add this to the overlay, yes.

Any ideas for what category it should go in and what it’s name should be?

Good question…

On my machine I put it under sys-power and named it reform2-lpc-module, but that was just because I couldn’t come up with a better name.

@soulsource I’ve added the ebuild to the overlay.

Haven’t had a chance to test it myself as of yet though. Still struggling to get my customer kernel up and running on the LS1028A :sweat_smile:

I bumped the kernel ebuild to 6.6.16. This one is supposed to work on both the i.MX8MQ and the LS1028A. Note however, that I have only tested on LS1028A.

@soulsource I’ve also tested the ebuild now. It works well, module compiled and can be loaded.

For some reason though, /sys/class/power_supply/ remains empty after loading the module, but that might be an ls1028a thing?

Hmm, I have the /sys/class/power_supply/8xlifepo4 folder on my machine, which is using a custom kernel on the Banana Pi CM4 SoM.

The CONFIG_CHECK line in the ebuild was guesswork, based on the headers that the module includes. I might have missed some runtime dependency (if such things exist in the Linux kernel).

I could also imagine that there is still some hardware waiting for prerequisite modules to get loaded - /sys/kernel/debug/devices_deferred - but that’s guesswork too.

EDIT: I just saw that you got an answer in LPC kernel module on ls1028a - #2 by josch - so it is a device tree issue.

Ah hes, it was.

Luckily I managed to grab a friend who is well versed with such things and he helped me to patch the device tree. By now MNT have merged the change and I have updated my ebuild.

I have moved my overlay over into the MNT GitLab: Niklaus Hofer / Mnt Reform Gentoo Overlay · GitLab

Plus, it has been merged into the list of overlays known by eselect repository. So you can now run the following on stock Gentoo to add it to your system:

eselect repository enable mnt-reform
1 Like

The latest ebuild, 6.8.12-r1, now has support for all the same SOMs as the reference kernel.

Had to update anyway to add support for the i.mx8mplus on mnt reform2. I figured whilst I’m at it, I might as well include all the patches.

This means the kernel should now also work on the pocket reform.

Obviously I don’t have access to all SOMs. So I can’t say for sure what works and what doesn’t. I’ve tested on ls1028a and i.mx8mplus.

Booting on i.mx8mplus works mostly, but the keyboard ends up inoperable. Probably an issue with my initrd, but I’ll have to do some more testing some other time.

1 Like

I got an rk3588. The latest ebuild, 6.11.6, is booting successfully on my reform 2.

For whatever reason, dracut is terrible at guessing which kernel modules need to be included in the initrd. So I have manually configured the list. It’s a bit of a mess since it’s a mostly unfiltered list of everything that gets loaded during typical use, but it works, so :man_shrugging:

force_drivers+=" xfs libcrc32c authenc crypto_null dm_integrity async_xor async_tx dm_bufio xor xor_neon dm_crypt dm_mod micrel dwmac_rk binfmt_misc ath9k ath9k_common ath9k_hw ath libarc4 rfkill hantro_vpu rockchip_vdec2 rockchip_saradc optee industrialio_triggered_buffer panthor evdev kfifo_buf industrialio tee rk805_pwrkey rockchip_thermal drm_gpuvm dw_wdt rockchip_dfi drm_exec nvme_fabrics efi_pstore configfs nfnetlink autofs4 ext4 crc16 mbcache jbd2 crc32c_generic hid_generic mali_dp panfrost drm_shmem_helper gpu_sched ao_cec_g12a meson_vdec videobuf2_dma_contig videobuf2_memops videodev videobuf2_common nvme mc rk808_regulator nvme_core dw_hdmi_i2s_audio meson_drm meson_canvas meson_dw_mipi_dsi meson_dw_hdmi usbhid hid mxsfb mux_mmio panel_edp imx_dcss ti_sn65dsi86 drm_dp_aux_bus nwl_dsi mux_core pwm_imx27 xhci_plat_hcd xhci_hcd rtc_pcf8523 stmmac_platform fan53555 stmmac sdhci_of_dwcmshc pcs_xpcs sdhci_pltfm cqhci phylink sdhci gpio_rockchip mdio_devres pwm_rockchip phy_rockchip_usbdp of_mdio fixed_phy fwnode_mdio libphy typec crct10dif_ce fixed dw_mmc_rockchip dw_mmc_pltfm dw_mmc phy_rockchip_naneng_combphy phy_rockchip_snps_pcie3 phy_rockchip_samsung_hdptx pl330 i2c_rk3x dwc3 ohci_platform ohci_hcd udc_core ehci_platform ehci_hcd phy_rockchip_inno_usb2 rockchipdrm usbcore dw_hdmi_qp dw_mipi_dsi analogix_dp cpufreq_dt ulpi usb_common aes_neon_bs aes_neon_blk usb_storage mmc_block "

Absolutely loving the performance, btw!

I have the same issue on void. If I’m running dracut to make my initrootfs from chroot, I have to run it manually, but if I’m generating from within my booted system, IIRC it works