From 9fbdc8cbdb766247254914478d4789ec19bf72dd Mon Sep 17 00:00:00 2001 From: Jakob Leifhelm Date: Sat, 8 Nov 2025 10:51:57 +0100 Subject: [PATCH 1/5] mnt-reform: Update kernel to 6.17.2 --- mnt/reform/kernel.nix | 47 +++++++---------- mnt/reform/kernelPatches.nix | 85 ++++++++++++++++++++++++++++++ mnt/reform/lpc.nix | 6 ++- mnt/reform/sources.json | 10 ++++ mnt/reform/updateKernelPatches.nix | 10 ++++ mnt/reform/updateKernelPatches.sh | 4 ++ 6 files changed, 131 insertions(+), 31 deletions(-) create mode 100644 mnt/reform/kernelPatches.nix create mode 100644 mnt/reform/sources.json create mode 100644 mnt/reform/updateKernelPatches.nix create mode 100755 mnt/reform/updateKernelPatches.sh diff --git a/mnt/reform/kernel.nix b/mnt/reform/kernel.nix index b67dad7a..10c90929 100644 --- a/mnt/reform/kernel.nix +++ b/mnt/reform/kernel.nix @@ -7,14 +7,9 @@ ... }: let - modDirVersion = "6.16.5"; - reformDebianPackages = fetchFromGitLab { - domain = "source.mnt.re"; - owner = "reform"; - repo = "reform-debian-packages"; - rev = "830c94db42beef876dc58ea56711659ae7bd415d"; - hash = "sha256-mdORgTOM7RJnEjY5G/iWMHf69wQkql11yRpQ/DrQKb4="; - }; + sources = lib.importJSON ./sources.json; + modDirVersion = sources.modDirVersion; + reformDebianPackages = fetchFromGitLab sources.reformDebianPackages; linuxPkg = { lib, @@ -31,26 +26,20 @@ let src = fetchzip { url = "mirror://kernel/linux/kernel/v${lib.versions.major modDirVersion}.x/linux-${modDirVersion}.tar.xz"; - hash = "sha256-XiTuH40b3VJqzwygZzU0FcvMDj41Rq6IsMbm+3+QxDY="; + hash = "sha256-sE+AfJwaQueiL1caWWfGQ1nf0qsDvEJOe3ZaVHTwelA="; }; - # Use postPatch to apply patches from a directory without IFD - postPatch = '' - for patch in ${reformDebianPackages}/linux/patches${lib.versions.majorMinor modDirVersion}/*/*.patch; do - echo "Applying patch: $patch" - patch -p1 < "$patch" - done - ''; - - kernelPatches = [ - { - name = "reform-dts"; - patch = callPackage ./dtsPatch.nix { - inherit reformDebianPackages; - kernelSource = src; - }; - } - ]; + kernelPatches = + (map (patch: { patch = "${reformDebianPackages}/${patch}"; }) (import ./kernelPatches.nix)) + ++ [ + { + name = "reform-dts"; + patch = callPackage ./dtsPatch.nix { + inherit reformDebianPackages; + kernelSource = src; + }; + } + ]; structuredExtraConfig = with lib.kernel; { # configuration options from https://source.mnt.re/reform/reform-debian-packages/-/blob/7f31ba3a6742d60d8d502c1d86e63ef5df3916bf/linux/config @@ -82,7 +71,7 @@ let JOYSTICK_XPAD_LEDS = yes; INTERCONNECT_IMX8MP = yes; - SND_SOC_FSL_ASRC = yes; + SND_SOC_FSL_ASRC = module; # From the documentation: This option is only useful for out-of-tree drivers since in-tree drivers select it automatically. DRM_IMX_LCDIF = yes; DRM_IMX8MP_DW_HDMI_BRIDGE = yes; DRM_IMX8MP_HDMI_PVI = yes; @@ -135,7 +124,7 @@ let SPI_ROCKCHIP = yes; SPI_ROCKCHIP_SFC = module; ARM_SCMI_CPUFREQ = module; - VIDEO_ROCKCHIP_VDEC2 = module; + # VIDEO_ROCKCHIP_VDEC2 = module; # no rkvdec2 patch included any more ROCKCHIP_DW_HDMI_QP = yes; ROCKCHIP_DW_MIPI_DSI2 = yes; PHY_ROCKCHIP_SAMSUNG_DCPHY = yes; @@ -143,7 +132,7 @@ let GPIO_ROCKCHIP = yes; PL330_DMA = yes; - DRM_MEGACHIPS_STDPXXXX_GE_B850V3_FW = no; # patches for 6.16 break this driver + DRM_ZYNQMP_DPSUB = no; # patches for 6.17 break this driver }; } // (args.argsOverride or { }) diff --git a/mnt/reform/kernelPatches.nix b/mnt/reform/kernelPatches.nix new file mode 100644 index 00000000..704b4aad --- /dev/null +++ b/mnt/reform/kernelPatches.nix @@ -0,0 +1,85 @@ +[ + "linux/patches6.17/imx8mp-mnt-pocket-reform/2ghz/0001-imx8mp-2ghz-clk.patch" + "linux/patches6.17/imx8mp-mnt-pocket-reform/2ghz/0002-imx8mp-2ghz-opp.patch" + "linux/patches6.17/imx8mp-mnt-pocket-reform/audio/0000-revert-crashy-audiomix-pm-support.patch" + "linux/patches6.17/imx8mp-mnt-pocket-reform/mmc-sdio/0001-sdhci-add-no-sd-uhs-sdr104-devicetree-property.patch" + "linux/patches6.17/imx8mp-mnt-pocket-reform/mmc-sdio/0002-During-the-card-init-the-host-side-sometimes-may-nee.patch" + "linux/patches6.17/imx8mp-mnt-pocket-reform/mmc-sdio/0003-USDHC-IP-has-one-limitation-the-tuning-circuit-can-t.patch" + "linux/patches6.17/imx8mp-mnt-pocket-reform/pocket-panel/0001-v5-add-multi-display-panel-driver.patch" + "linux/patches6.17/imx8mp-mnt-pocket-reform/pocket-panel/0002-pocket-panel-fix-sleep-add-orientation.patch" + "linux/patches6.17/imx8mp-mnt-reform2/0001-sn65dsi86-use-hs-clock-of-samsung-dsim-host-directly.patch" + "linux/patches6.17/imx8mp-mnt-reform2/0002-lcdif-dont-exceed-desired-pixel-clock.patch" + "linux/patches6.17/imx8mq-mnt-reform2/0001-drm-etnaviv-Fix-flush-sequence-logic.patch" + "linux/patches6.17/imx8mq-mnt-reform2/0001-imx8mq-mnt-reform2.dts-multiple-fixes-for-display-wi.patch" + "linux/patches6.17/imx8mq-mnt-reform2/0001-nwl-dsi-fixup-mode-only-for-LCDIF-input-not-DCSS.patch" + "linux/patches6.17/imx8mq-mnt-reform2/0002-Revert-drm-bridge-nwl-dsi-Use-vsync-hsync-polarity-f.patch" + "linux/patches6.17/imx8mq-mnt-reform2/0003-lcdif-fix-pcie-interference.patch" + "linux/patches6.17/imx8mq-mnt-reform2/0004-mnt4002-imx-gpcv2-wake-smccc.patch.patch" + "linux/patches6.17/imx8mq-mnt-reform2/0005-pci-imx6-add-support-for-internal-refclk-imx8mq.patch" + "linux/patches6.17/imx8mq-mnt-reform2/0006-imx8mq-import-HDMI-driver-and-make-DCSS-compatible-w.patch" + "linux/patches6.17/ls1028a-mnt-reform2/0000-dtsi-add-hdptx.patch" + "linux/patches6.17/meson-g12b-bananapi-cm4-mnt-pocket-reform/0001-a311d-viu-fifo-lines-config.patch" + "linux/patches6.17/meson-g12b-bananapi-cm4-mnt-pocket-reform/0002-a311d-viu-fifo-lines-config-header.patch" + "linux/patches6.17/meson-g12b-bananapi-cm4-mnt-pocket-reform/0003-tlv320aic31xx-add-1228800hz-support.patch" + "linux/patches6.17/meson-g12b-bananapi-cm4-mnt-reform2/0001-Revert-drm-bridge-synopsys-dw-mipi-dsi-enable-EoTp-b.patch" + "linux/patches6.17/meson-g12b-bananapi-cm4-mnt-reform2/0001-meson-g12b-bananapi-cm4-mnt-reform2.dts-fix-audio-an.patch" + "linux/patches6.17/meson-g12b-bananapi-cm4-mnt-reform2/0011-dw-mipi-dsi-phy-stop-wait-time.patch" + "linux/patches6.17/meson-g12b-bananapi-cm4-mnt-reform2/0012-innolux-n125hce-gn1-timing-tweaks.patch" + "linux/patches6.17/meson-g12b-bananapi-cm4-mnt-reform2/0013-meson-viu-hold-fifo-lines.patch" + "linux/patches6.17/meson-g12b-bananapi-cm4-mnt-reform2/0014-meson-venc-sync.patch.patch" + "linux/patches6.17/meson-g12b-bananapi-cm4-mnt-reform2/0015-meson-dw-mipi-dsi-sync-invert.patch" + "linux/patches6.17/meson-g12b-bananapi-cm4-mnt-reform2/0016-sn65dsi86-burst-mode-support.patch" + "linux/patches6.17/meson-g12b-bananapi-cm4-mnt-reform2/0018-sn65dsi86-never-turn-off.patch" + "linux/patches6.17/meson-g12b-bananapi-cm4-mnt-reform2/0020-LOCAL-ALSA-Assign-internal-PCM-chmap-ELD-IEC958-kctl.patch" + "linux/patches6.17/meson-g12b-bananapi-cm4-mnt-reform2/0021-HACK-of-partial-revert-of-fdt.c-changes.patch" + "linux/patches6.17/meson-g12b-bananapi-cm4-mnt-reform2/0022-add-bt-and-eth-resets.patch" + "linux/patches6.17/meson-g12b-bananapi-cm4-mnt-reform2/0023-sdio-pullups.patch" + "linux/patches6.17/meson-g12b-bananapi-cm4-mnt-reform2/0024-sdio-improve-wifi-speed.patch" + "linux/patches6.17/meson-g12b-bananapi-cm4-mnt-reform2/0030-WORKAROUND-meson-plane-disable-afbc-32x8.patch" + "linux/patches6.17/rk3588-mnt-reform2/0001-MERGED-drm-bridge-Pass-down-connector-to-drm-bridge-.patch" + "linux/patches6.17/rk3588-mnt-reform2/0010-MERGED-arm64-dts-rockchip-add-pd_npu-label-for-RK358.patch" + "linux/patches6.17/rk3588-mnt-reform2/0011-MERGED-arm64-dts-rockchip-Add-nodes-for-NPU-and-its-.patch" + "linux/patches6.17/rk3588-mnt-reform2/0024-math.h-add-DIV_ROUND_UP_NO_OVERFLOW.patch" + "linux/patches6.17/rk3588-mnt-reform2/0025-clk-divider-Fix-divisor-masking-on-64-bit-platforms.patch" + "linux/patches6.17/rk3588-mnt-reform2/0026-clk-composite-replace-open-coded-abs_diff.patch" + "linux/patches6.17/rk3588-mnt-reform2/0030-mfd-rk8xx-Fix-shutdown-handler.patch" + "linux/patches6.17/rk3588-mnt-reform2/0033-arm64-dts-rockchip-Add-VOP-clock-resets-for-rk3588s.patch" + "linux/patches6.17/rk3588-mnt-reform2/0035-drm-rockchip-vop2-Add-core-reset-support.patch" + "linux/patches6.17/rk3588-mnt-reform2/0037-drm-bridge-synopsys-Add-DW-DPTX-Controller-support-l.patch" + "linux/patches6.17/rk3588-mnt-reform2/0038-drm-rockchip-Add-RK3588-DPTX-output-support.patch" + "linux/patches6.17/rk3588-mnt-reform2/0041-drm-birdge-simple-bridge-Add-support-for-radxa-ra620.patch" + "linux/patches6.17/rk3588-mnt-reform2/0042-arm64-dts-rockchip-Add-DP0-for-rk3588.patch" + "linux/patches6.17/rk3588-mnt-reform2/0043-arm64-dts-rockchip-Add-DP1-for-rk3588.patch" + "linux/patches6.17/rk3588-mnt-reform2/0046-arm64-defconfig-Enable-Rockchip-RK3588-DisplayPort-C.patch" + "linux/patches6.17/rk3588-mnt-reform2/0048-arm64-dts-rockchip-Fix-USB-C-description-for-RK3588-.patch" + "linux/patches6.17/rk3588-mnt-reform2/0068-drm-bridge-dw-hdmi-qp-Add-CEC-support.patch" + "linux/patches6.17/rk3588-mnt-reform2/0069-drm-bridge-dw-hdmi-qp-Fixup-timer-base-setup.patch" + "linux/patches6.17/rk3588-mnt-reform2/0070-drm-rockchip-dw_hdmi_qp-Improve-error-handling-with-.patch" + "linux/patches6.17/rk3588-mnt-reform2/0071-drm-rockchip-dw_hdmi_qp-Provide-CEC-IRQ-in-dw_hdmi_q.patch" + "linux/patches6.17/rk3588-mnt-reform2/0072-drm-rockchip-dw_hdmi_qp-Provide-ref-clock-rate-in-dw.patch" + "linux/patches6.17/rk3588-mnt-reform2/0075-phy-hdmi-Add-HDMI-2.1-FRL-configuration-options.patch" + "linux/patches6.17/rk3588-mnt-reform2/0076-phy-rockchip-samsung-hdptx-Fix-reported-clock-rate-i.patch" + "linux/patches6.17/rk3588-mnt-reform2/0077-phy-rockchip-samsung-hdptx-Reduce-ROPLL-loop-bandwid.patch" + "linux/patches6.17/rk3588-mnt-reform2/0078-phy-rockchip-samsung-hdptx-Prevent-Inter-Pair-Skew-f.patch" + "linux/patches6.17/rk3588-mnt-reform2/0079-phy-rockchip-samsung-hdptx-Use-usleep_range-instead-.patch" + "linux/patches6.17/rk3588-mnt-reform2/0080-phy-rockchip-samsung-hdptx-Fix-coding-style-alignmen.patch" + "linux/patches6.17/rk3588-mnt-reform2/0081-phy-rockchip-samsung-hdptx-Consistently-use-rk_-hdpt.patch" + "linux/patches6.17/rk3588-mnt-reform2/0082-phy-rockchip-samsung-hdptx-Enable-lane-output-in-com.patch" + "linux/patches6.17/rk3588-mnt-reform2/0083-phy-rockchip-samsung-hdptx-Cleanup-_cmn_init_seq-lis.patch" + "linux/patches6.17/rk3588-mnt-reform2/0084-phy-rockchip-samsung-hdptx-Compute-clk-rate-from-PLL.patch" + "linux/patches6.17/rk3588-mnt-reform2/0085-phy-rockchip-samsung-hdptx-Drop-hw_rate-driver-data.patch" + "linux/patches6.17/rk3588-mnt-reform2/0086-phy-rockchip-samsung-hdptx-Switch-to-driver-specific.patch" + "linux/patches6.17/rk3588-mnt-reform2/0087-phy-rockchip-samsung-hdptx-Extend-rk_hdptx_phy_verif.patch" + "linux/patches6.17/rk3588-mnt-reform2/0088-phy-rockchip-samsung-hdptx-Add-HDMI-2.1-FRL-support.patch" + "linux/patches6.17/rk3588-mnt-reform2/0089-drm-rockchip-vop2-Check-bpc-before-switching-DCLK-so.patch" + "linux/patches6.17/rk3588-mnt-reform2/0091-drm-rockchip-dw_hdmi_qp-Switch-to-phy_configure.patch" + "linux/patches6.17/rk3588-mnt-reform2/0114-media-dt-bindings-video-interfaces-add-defines-for-s.patch" + "linux/patches6.17/rk3588-mnt-reform2/0123-phy-rockchip-phy-rockchip-inno-csidphy-allow-writes-.patch" + "linux/patches6.17/rk3588-mnt-reform2/0126-arm64-defconfig-enable-rockchip-camera-interface-and.patch" + "linux/patches6.17/rk3588-mnt-reform2/0127-arm64-dts-rockchip-add-the-vip-node-to-px30.patch" + "linux/patches6.17/rk3588-mnt-reform2/0131-arm64-dts-rockchip-add-mipi-csi-2-dphy-nodes-to-rk35.patch" + "linux/patches6.17/rk3588-mnt-reform2/0142-drm-bridge-dw-hdmi-qp-Fix-spurious-IRQ-on-resume.patch" + "linux/patches6.17/rk3588-mnt-reform2/2001-drm-bridge-dw-hdmi-qp-Return-0-in-audio-prepare-when.patch" + "linux/patches6.17/rk3588-mnt-reform2/2003-drm-bridge-synopsys-Do-not-warn-about-audio-params-c.patch" + "linux/patches6.17/rk3588-mnt-reform2/5200-drm-rockchip-Set-dma-mask-to-64-bit.patch" +] diff --git a/mnt/reform/lpc.nix b/mnt/reform/lpc.nix index ad1ef3d8..12c4cc7c 100644 --- a/mnt/reform/lpc.nix +++ b/mnt/reform/lpc.nix @@ -14,8 +14,8 @@ stdenv.mkDerivation rec { domain = "source.mnt.re"; owner = "reform"; repo = "reform-tools"; - rev = "45f930403492aa2156522bfe30edb02e33494b69"; - hash = "sha256-no33CsV69nu1TR0cqxQDd1bFXqhjqOW9IUDxds0fyxE="; + rev = "95fff02ea84386e4e9815ee650032b1a5bd6107c"; + hash = "sha256-bFiVvpLTboxhA5SmMcf60iazEsgFehabsdqZMZ3APuI="; }; sourceRoot = "source/lpc"; @@ -26,7 +26,9 @@ stdenv.mkDerivation rec { nativeBuildInputs = kernel.moduleBuildDependencies; installPhase = '' + runHook preInstall make -C "${kernel.dev}/lib/modules/${kernel.modDirVersion}/build" M="$(pwd)" INSTALL_MOD_PATH=$out modules_install $makeFlags + runHook postInstall ''; makeFlags = kernelModuleMakeFlags ++ [ diff --git a/mnt/reform/sources.json b/mnt/reform/sources.json new file mode 100644 index 00000000..eef9357b --- /dev/null +++ b/mnt/reform/sources.json @@ -0,0 +1,10 @@ +{ + "modDirVersion": "6.17.2", + "reformDebianPackages": { + "domain": "source.mnt.re", + "owner": "reform", + "repo": "reform-debian-packages", + "rev": "5716c458627142bcce54caf39e4018e58b16e3ac", + "hash": "sha256-aZMzlt8DwlFLMnG0PvF80nlb8eCvgbVy9CHkPA1gU7c=" + } +} diff --git a/mnt/reform/updateKernelPatches.nix b/mnt/reform/updateKernelPatches.nix new file mode 100644 index 00000000..59d3e4ca --- /dev/null +++ b/mnt/reform/updateKernelPatches.nix @@ -0,0 +1,10 @@ +let + nixpkgs = import { }; + pkgs = nixpkgs.pkgs; + lib = nixpkgs.lib; + sources = lib.importJSON ./sources.json; + reformDebianPackages = pkgs.fetchFromGitLab sources.reformDebianPackages; +in +map (lib.removePrefix "${reformDebianPackages}/") ( + lib.filesystem.listFilesRecursive "${reformDebianPackages}/linux/patches${lib.versions.majorMinor sources.modDirVersion}" +) diff --git a/mnt/reform/updateKernelPatches.sh b/mnt/reform/updateKernelPatches.sh new file mode 100755 index 00000000..032fc3af --- /dev/null +++ b/mnt/reform/updateKernelPatches.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env sh + +nix eval --file updateKernelPatches.nix > kernelPatches.nix +nix fmt kernelPatches.nix From 20baaa0d682e592c4525d1050d12a4543d3305a2 Mon Sep 17 00:00:00 2001 From: Jakob Leifhelm Date: Sat, 8 Nov 2025 10:53:01 +0100 Subject: [PATCH 2/5] mnt-reform: uboot remove x86 dependency --- mnt/reform/rk3588/firmware.nix | 20 +++----------------- mnt/reform/rk3588/installer.nix | 2 +- mnt/reform/rk3588/uboot.nix | 11 ++++++----- 3 files changed, 10 insertions(+), 23 deletions(-) diff --git a/mnt/reform/rk3588/firmware.nix b/mnt/reform/rk3588/firmware.nix index 6d97991f..37784721 100644 --- a/mnt/reform/rk3588/firmware.nix +++ b/mnt/reform/rk3588/firmware.nix @@ -3,23 +3,9 @@ uboot, fetchFromGitHub, }: -# script from https://source.mnt.re/reform/reform-rk3588-uboot/-/blob/b530d65f4a878c0329a594fa248ba8da59d2e05f/build.sh +# script from https://source.mnt.re/reform/reform-rk3588-uboot/-/blob/28289e36cd1cb90b302780e83b014250c880c4ec/build.sh runCommand "mnt-reform-firmware-rk3855${uboot.variant}" { } '' mkdir $out - cp -r ${uboot} u-boot - cp -r ${uboot.rkbin} rkbin - chmod -R +rw u-boot - chmod -R +rw rkbin - cd u-boot - mkdir spl - mv u-boot-spl.bin spl - ../rkbin/tools/boot_merger rock5b-rk3588.ini - cd .. - # rkbin stuff - cd rkbin - ./tools/boot_merger RKBOOT/RK3588MINIALL.ini - # concatenate - cd .. - cp u-boot/idbloader.img $out/mnt-reform2-rk3588${uboot.variant}-flash.bin - dd if=u-boot/u-boot.itb of=$out/mnt-reform2-rk3588${uboot.variant}-flash.bin seek=16320 + cp ${uboot}/idbloader.img $out/rk3588-mnt-reform2${uboot.variant}-flash.bin + dd if=${uboot}/u-boot.itb of=$out/rk3588-mnt-reform${uboot.variant}-flash.bin seek=16320 '' diff --git a/mnt/reform/rk3588/installer.nix b/mnt/reform/rk3588/installer.nix index 4e0c12c0..dca4e3ec 100644 --- a/mnt/reform/rk3588/installer.nix +++ b/mnt/reform/rk3588/installer.nix @@ -215,7 +215,7 @@ eval $(partx $img -o START,SECTORS --nr 1 --pairs) dd conv=notrunc if=${content} of=$img seek=$START count=$SECTORS - dd conv=notrunc if=${firmware}/mnt-reform2-rk3588-dsi-flash.bin of=$img seek=64 + dd conv=notrunc if=${firmware}/rk3588-mnt-reform2-dsi-flash.bin of=$img seek=64 if test -n "$compressImage"; then zstd -T$NIX_BUILD_CORES --rm $img diff --git a/mnt/reform/rk3588/uboot.nix b/mnt/reform/rk3588/uboot.nix index da073d1c..f89579a1 100644 --- a/mnt/reform/rk3588/uboot.nix +++ b/mnt/reform/rk3588/uboot.nix @@ -10,14 +10,14 @@ let domain = "source.mnt.re"; owner = "reform"; repo = "reform-rk3588-uboot"; - rev = "55bca0174e7bb449e96028d64ad8348f5af35977"; - hash = "sha256-A3u1afGK65cGOwENQtu8Hh+fLsSDNxc3rEebkd3QOic="; + rev = "28289e36cd1cb90b302780e83b014250c880c4ec"; + hash = "sha256-fWGyC+rlfL0NYYRFLvdF7EiO3s9GfFkfhAbTEM5ECAM="; }; rkbin = fetchFromGitHub { owner = "rockchip-linux"; repo = "rkbin"; - rev = "f43a462e7a1429a9d407ae52b4745033034a6cf9"; - hash = "sha256-geESfZP8ynpUz/i/thpaimYo3kzqkBX95gQhMBzNbmk="; + rev = "272136301989d493000425935bd4ead0ef04d06b"; + hash = "sha256-qXnuZyFNc6gYTkAtPg1t9WHwj8OiTxOLvsHUuvolK/w="; }; in buildUBoot rec { @@ -32,6 +32,7 @@ buildUBoot rec { patches = [ "${mntPatches}/0001-ini-ddrbin-bump.patch" "${mntPatches}/0002-add-target-init-mnt-reform-series.patch" + "${mntPatches}/0003-scripts-dtc-pylibfdt-libfdt-i_shipped-Use-SWIG_AppendOutp.patch" ]; prePatch = '' cp ${mntPatches}/*.dts arch/arm/dts/ @@ -45,7 +46,7 @@ buildUBoot rec { "spl/u-boot-spl.bin" ]; variant = "-dsi"; - defconfig = "mnt-reform2-rk3588${variant}_defconfig"; + defconfig = "rk3588-mnt-reform2${variant}_defconfig"; extraMakeFlags = [ "BL31=${armTrustedFirmwareRK3588}/bl31.elf" "ROCKCHIP_TPL=${rkbin}/bin/rk35/rk3588_ddr_lp4_2112MHz_lp5_2400MHz_v1.18.bin" From a31d53a0b2baf3a27eb7bab618df4c5cdc7150cc Mon Sep 17 00:00:00 2001 From: Jakob Leifhelm Date: Sun, 9 Nov 2025 11:11:36 +0100 Subject: [PATCH 3/5] mnt-reform: Add uboot flash script --- mnt/reform/pkgs/default.nix | 23 ++++++++++ mnt/reform/pkgs/reform-flash-uboot.nix | 44 +++++++++++++++++++ mnt/reform/rk3588/installer.nix | 6 +-- .../rk3588/{firmware.nix => uboot-image.nix} | 2 +- 4 files changed, 71 insertions(+), 4 deletions(-) create mode 100644 mnt/reform/pkgs/default.nix create mode 100644 mnt/reform/pkgs/reform-flash-uboot.nix rename mnt/reform/rk3588/{firmware.nix => uboot-image.nix} (84%) diff --git a/mnt/reform/pkgs/default.nix b/mnt/reform/pkgs/default.nix new file mode 100644 index 00000000..0c1a7b4e --- /dev/null +++ b/mnt/reform/pkgs/default.nix @@ -0,0 +1,23 @@ +{ + lib, + callPackage, +}: +rec { + reform-flash-uboot = + lib.mapAttrs (name: config: callPackage ./reform-flash-uboot.nix { inherit config; }) + { + reform2-rk3588-dsi = { + warn = true; + mmc = "mmcblk0"; + mmcBoot0 = false; + ubootOffset = 32768; + flashbinOffset = 0; + image = "${ubootImage.reform2-rk3588-dsi}/rk3588-mnt-reform2-dsi-flash.bin"; + }; + }; + + uboot.reform2-rk3588-dsi = callPackage ../rk3588/uboot.nix { }; + ubootImage.reform2-rk3588-dsi = callPackage ../rk3588/uboot-image.nix { + uboot = uboot.reform2-rk3588-dsi; + }; +} diff --git a/mnt/reform/pkgs/reform-flash-uboot.nix b/mnt/reform/pkgs/reform-flash-uboot.nix new file mode 100644 index 00000000..0320d091 --- /dev/null +++ b/mnt/reform/pkgs/reform-flash-uboot.nix @@ -0,0 +1,44 @@ +{ + lib, + writeShellApplication, + config, +}: +let + dev = "/dev/" + config.mmc + lib.optionalString config.mmcBoot0 "boot0"; +in +writeShellApplication { + name = "reform-flash-uboot"; + text = '' + if [ "$(id -u)" -ne 0 ]; then + echo "reform-flash-uboot has to be run as root / using sudo." + exit 1 + fi + '' + + lib.optionalString config.warn '' + echo "W: Flashing u-boot to eMMC on $(cat /proc/device-tree/model) is not without risk." >&2 + echo "W: If you flash the wrong u-boot or if the flashing process goes wrong, it is" >&2 + echo "W: possible to soft-brick your board. Restoring it might need some extra hardware." >&2 + echo "W: Please only proceed if you are sure that the benefits outweigh the risks for you." >&2 + printf "Are you sure you want to proceed? [y/N] " + read -r response + + if [ "$response" != "y" ]; then + echo "Exiting." + exit + fi + '' + + '' + echo "Writing ${config.image} to ${dev}" >&2 + '' + + lib.optionalString config.mmcBoot0 '' + echo 0 >"/sys/class/block/${config.mmc}boot0/force_ro" + '' + + '' + dd if='${config.image}' of='${dev}' bs=512 seek='${ + builtins.toString (config.ubootOffset / 512) + }' skip='${builtins.toString (config.flashbinOffset / 512)}' + '' + + lib.optionalString config.mmcBoot0 '' + echo 1 >"/sys/class/block/${config.mmc}boot0/force_ro" + ''; +} diff --git a/mnt/reform/rk3588/installer.nix b/mnt/reform/rk3588/installer.nix index dca4e3ec..73a3647c 100644 --- a/mnt/reform/rk3588/installer.nix +++ b/mnt/reform/rk3588/installer.nix @@ -44,8 +44,8 @@ storeContents = config.installerImage.storeContents; comp = config.installerImage.squashfsCompression; }; - uboot = pkgs.callPackage ./uboot.nix { }; - firmware = pkgs.callPackage ./firmware.nix { inherit uboot; }; + packages = pkgs.callPackage ../pkgs { }; + ubootImage = packages.ubootImage.reform2-rk3588-dsi; content = pkgs.callPackage ( { stdenv, @@ -215,7 +215,7 @@ eval $(partx $img -o START,SECTORS --nr 1 --pairs) dd conv=notrunc if=${content} of=$img seek=$START count=$SECTORS - dd conv=notrunc if=${firmware}/rk3588-mnt-reform2-dsi-flash.bin of=$img seek=64 + dd conv=notrunc if=${ubootImage}/rk3588-mnt-reform2-dsi-flash.bin of=$img seek=64 if test -n "$compressImage"; then zstd -T$NIX_BUILD_CORES --rm $img diff --git a/mnt/reform/rk3588/firmware.nix b/mnt/reform/rk3588/uboot-image.nix similarity index 84% rename from mnt/reform/rk3588/firmware.nix rename to mnt/reform/rk3588/uboot-image.nix index 37784721..c6003ea5 100644 --- a/mnt/reform/rk3588/firmware.nix +++ b/mnt/reform/rk3588/uboot-image.nix @@ -4,7 +4,7 @@ fetchFromGitHub, }: # script from https://source.mnt.re/reform/reform-rk3588-uboot/-/blob/28289e36cd1cb90b302780e83b014250c880c4ec/build.sh -runCommand "mnt-reform-firmware-rk3855${uboot.variant}" { } '' +runCommand "mnt-reform-uboot-image-rk3855${uboot.variant}" { } '' mkdir $out cp ${uboot}/idbloader.img $out/rk3588-mnt-reform2${uboot.variant}-flash.bin dd if=${uboot}/u-boot.itb of=$out/rk3588-mnt-reform${uboot.variant}-flash.bin seek=16320 From 6ae02e4ebd00aed45fa67a355cb0c643d856e03b Mon Sep 17 00:00:00 2001 From: Jakob Leifhelm Date: Sun, 9 Nov 2025 11:24:47 +0100 Subject: [PATCH 4/5] mnt-reform: Add name parameter to kernel patches --- mnt/reform/kernel.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mnt/reform/kernel.nix b/mnt/reform/kernel.nix index 10c90929..1125f960 100644 --- a/mnt/reform/kernel.nix +++ b/mnt/reform/kernel.nix @@ -30,7 +30,10 @@ let }; kernelPatches = - (map (patch: { patch = "${reformDebianPackages}/${patch}"; }) (import ./kernelPatches.nix)) + (map (patch: { + name = patch; + patch = "${reformDebianPackages}/${patch}"; + }) (import ./kernelPatches.nix)) ++ [ { name = "reform-dts"; From 238316ce4406e0d94f845cde25dea0ccbc6af499 Mon Sep 17 00:00:00 2001 From: Jakob Leifhelm Date: Sun, 9 Nov 2025 11:31:44 +0100 Subject: [PATCH 5/5] mnt-reform: Format --- mnt/reform/pkgs/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mnt/reform/pkgs/default.nix b/mnt/reform/pkgs/default.nix index 0c1a7b4e..de8a2f6d 100644 --- a/mnt/reform/pkgs/default.nix +++ b/mnt/reform/pkgs/default.nix @@ -4,7 +4,7 @@ }: rec { reform-flash-uboot = - lib.mapAttrs (name: config: callPackage ./reform-flash-uboot.nix { inherit config; }) + lib.mapAttrs (_name: config: callPackage ./reform-flash-uboot.nix { inherit config; }) { reform2-rk3588-dsi = { warn = true;