Skip to content

Commit 5e57f28

Browse files
committed
mnt/reform: init
1 parent 170ff93 commit 5e57f28

File tree

12 files changed

+1346
-0
lines changed

12 files changed

+1346
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,7 @@ See code for all available configurations.
375375
| [Microsoft Surface Pro 9](microsoft/surface-pro/9) | `<nixos-hardware/microsoft/surface-pro/9>` | `microsoft-surface-pro-9` |
376376
| [Morefine M600](morefine/m600) | `<nixos-hardware/morefine/m600>` | `morefine-m600` |
377377
| [Minisforum V3](minisforum/v3) | `<nixos-hardware/minisforum/v3>` | `minisforum-v3` |
378+
| [MNT Reform with RK3588 module](mnt/reform/rk3588) | `<nixos-hardware/mnt/reform/rk3588` | `mnt-reform-rk3588` |
378379
| [MECHREVO Yilong15Pro](mechrevo/GM5HG0A) | `<nixos-hardware/mechrevo/GM5HG0A>` | `mechrevo-gm5hg0a` |
379380
| [NXP iMX8 MPlus Evaluation Kit](nxp/imx8mp-evk) | `<nixos-hardware/nxp/imx8mp-evk>` | `nxp-imx8mp-evk` |
380381
| [NXP iMX8 MQuad Evaluation Kit](nxp/imx8mq-evk) | `<nixos-hardware/nxp/imx8mq-evk>` | `nxp-imx8mq-evk` |

flake.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@
312312
microsoft-surface-pro-9 = import ./microsoft/surface-pro/9;
313313
milkv-pioneer = import ./milkv/pioneer;
314314
minisforum-v3 = import ./minisforum/v3;
315+
mnt-reform-rk3588 = import ./mnt/reform/rk3588;
315316
morefine-m600 = import ./morefine/m600;
316317
msi-b350-tomahawk = import ./msi/b350-tomahawk;
317318
msi-b550-a-pro = import ./msi/b550-a-pro;

mnt/reform/default.nix

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
config,
3+
lib,
4+
pkgs,
5+
...
6+
}:
7+
{
8+
boot.kernelPackages = pkgs.callPackage ./kernel.nix { };
9+
boot.extraModulePackages = [ (config.boot.kernelPackages.callPackage ./lpc.nix { }) ];
10+
}

mnt/reform/dtsPatch.nix

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
stdenv,
3+
reformDebianPackages,
4+
kernelSource,
5+
quilt,
6+
}:
7+
stdenv.mkDerivation {
8+
name = "mnt-dts-patch";
9+
nativeBuildInputs = [ quilt ];
10+
buildCommand = ''
11+
cp -r --reflink=auto ${reformDebianPackages}/linux/* .
12+
mkdir -p linux/debian/patches/reform
13+
cp -r --reflink=auto ${kernelSource}/* linux
14+
chmod +w -R .
15+
env --chdir=linux QUILT_PATCHES=debian/patches quilt new reform/dts.patch
16+
env --chdir=linux QUILT_PATCHES=debian/patches quilt add arch/arm64/boot/dts/freescale/fsl-ls1028a-mnt-reform2.dts
17+
cp fsl-ls1028a-mnt-reform2.dts linux/arch/arm64/boot/dts/freescale/fsl-ls1028a-mnt-reform2.dts
18+
env --chdir=linux QUILT_PATCHES=debian/patches quilt add arch/arm64/boot/dts/freescale/imx8mq-mnt-reform2-hdmi.dts
19+
cp imx8mq-mnt-reform2-hdmi.dts linux/arch/arm64/boot/dts/freescale/imx8mq-mnt-reform2-hdmi.dts
20+
env --chdir=linux QUILT_PATCHES=debian/patches quilt add arch/arm64/boot/dts/freescale/Makefile
21+
sed -i '/fsl-ls1028a-rdb.dtb/a dtb-$(CONFIG_ARCH_LAYERSCAPE) += fsl-ls1028a-mnt-reform2.dtb' linux/arch/arm64/boot/dts/freescale/Makefile
22+
sed -i '/imx8mq-mnt-reform2.dtb/a dtb-$(CONFIG_ARCH_MXC) += imx8mq-mnt-reform2-hdmi.dtb' linux/arch/arm64/boot/dts/freescale/Makefile
23+
env --chdir=linux QUILT_PATCHES=debian/patches quilt add arch/arm64/boot/dts/freescale/imx8mp-mnt-pocket-reform.dts
24+
cp imx8mp-mnt-pocket-reform.dts linux/arch/arm64/boot/dts/freescale/imx8mp-mnt-pocket-reform.dts
25+
env --chdir=linux QUILT_PATCHES=debian/patches quilt add arch/arm64/boot/dts/freescale/imx8mp-mnt-reform2.dts
26+
cp imx8mp-mnt-reform2.dts linux/arch/arm64/boot/dts/freescale/imx8mp-mnt-reform2.dts
27+
sed -i '/imx8mq-mnt-reform2.dtb/a dtb-$(CONFIG_ARCH_MXC) += imx8mp-mnt-pocket-reform.dtb' linux/arch/arm64/boot/dts/freescale/Makefile
28+
sed -i '/imx8mq-mnt-reform2.dtb/a dtb-$(CONFIG_ARCH_MXC) += imx8mp-mnt-reform2.dtb' linux/arch/arm64/boot/dts/freescale/Makefile
29+
env --chdir=linux QUILT_PATCHES=debian/patches quilt add arch/arm64/boot/dts/amlogic/meson-g12b-bananapi-cm4-mnt-pocket-reform.dts
30+
cp meson-g12b-bananapi-cm4-mnt-pocket-reform.dts linux/arch/arm64/boot/dts/amlogic/meson-g12b-bananapi-cm4-mnt-pocket-reform.dts
31+
env --chdir=linux QUILT_PATCHES=debian/patches quilt add arch/arm64/boot/dts/amlogic/Makefile
32+
sed -i '/meson-g12b-bananapi-cm4-mnt-reform2.dtb/a dtb-$(CONFIG_ARCH_MESON) += meson-g12b-bananapi-cm4-mnt-pocket-reform.dtb' linux/arch/arm64/boot/dts/amlogic/Makefile
33+
env --chdir=linux QUILT_PATCHES=debian/patches quilt add arch/arm64/boot/dts/rockchip/rk3588-mnt-reform2.dts
34+
cp rk3588-mnt-reform2.dts linux/arch/arm64/boot/dts/rockchip/rk3588-mnt-reform2.dts
35+
env --chdir=linux QUILT_PATCHES=debian/patches quilt add arch/arm64/boot/dts/rockchip/rk3588-mnt-reform2-dsi.dts
36+
cp rk3588-mnt-reform2-dsi.dts linux/arch/arm64/boot/dts/rockchip/rk3588-mnt-reform2-dsi.dts
37+
env --chdir=linux QUILT_PATCHES=debian/patches quilt add arch/arm64/boot/dts/rockchip/rk3588-mnt-pocket-reform.dts
38+
cp rk3588-mnt-pocket-reform.dts linux/arch/arm64/boot/dts/rockchip/rk3588-mnt-pocket-reform.dts
39+
env --chdir=linux QUILT_PATCHES=debian/patches quilt add arch/arm64/boot/dts/rockchip/rk3588-mnt-reform-next.dts
40+
cp rk3588-mnt-reform-next.dts linux/arch/arm64/boot/dts/rockchip/rk3588-mnt-reform-next.dts
41+
env --chdir=linux QUILT_PATCHES=debian/patches quilt add arch/arm64/boot/dts/rockchip/Makefile
42+
sed -i '/rk3588-mnt-reform2.dtb/a dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3588-mnt-reform2-dsi.dtb' linux/arch/arm64/boot/dts/rockchip/Makefile
43+
sed -i '/rk3588-mnt-reform2-dsi.dtb/a dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3588-mnt-reform-next.dtb' linux/arch/arm64/boot/dts/rockchip/Makefile
44+
sed -i '/rk3588-mnt-reform-next.dtb/a dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3588-mnt-pocket-reform.dtb' linux/arch/arm64/boot/dts/rockchip/Makefile
45+
env --chdir=linux QUILT_PATCHES=debian/patches quilt refresh
46+
cp linux/debian/patches/reform/dts.patch $out
47+
'';
48+
}

mnt/reform/kernel.nix

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
{
2+
lib,
3+
callPackage,
4+
linuxPackagesFor,
5+
kernelPatches,
6+
fetchFromGitLab,
7+
...
8+
}:
9+
let
10+
modDirVersion = "6.16.5";
11+
reformDebianPackages = fetchFromGitLab {
12+
domain = "source.mnt.re";
13+
owner = "reform";
14+
repo = "reform-debian-packages";
15+
rev = "830c94db42beef876dc58ea56711659ae7bd415d";
16+
hash = "sha256-mdORgTOM7RJnEjY5G/iWMHf69wQkql11yRpQ/DrQKb4=";
17+
};
18+
linuxPkg =
19+
{
20+
lib,
21+
fetchzip,
22+
buildLinux,
23+
callPackage,
24+
...
25+
}@args:
26+
buildLinux (
27+
args
28+
// rec {
29+
version = "${modDirVersion}-mnt-reform";
30+
inherit modDirVersion;
31+
32+
src = fetchzip {
33+
url = "mirror://kernel/linux/kernel/v${lib.versions.major modDirVersion}.x/linux-${modDirVersion}.tar.xz";
34+
hash = "sha256-XiTuH40b3VJqzwygZzU0FcvMDj41Rq6IsMbm+3+QxDY=";
35+
};
36+
37+
kernelPatches =
38+
(map (patch: { inherit patch; }) (
39+
lib.filesystem.listFilesRecursive "${reformDebianPackages}/linux/patches${lib.versions.majorMinor modDirVersion}"
40+
))
41+
++ [
42+
{
43+
patch = callPackage ./dtsPatch.nix {
44+
inherit reformDebianPackages;
45+
kernelSource = src;
46+
};
47+
}
48+
];
49+
50+
structuredExtraConfig = with lib.kernel; {
51+
# configuration options from https://source.mnt.re/reform/reform-debian-packages/-/blob/7f31ba3a6742d60d8d502c1d86e63ef5df3916bf/linux/config
52+
DRM_LVDS_CODEC = module;
53+
DRM_CDNS_MHDP8546 = module;
54+
DRM_CDNS_HDMI_CEC = module;
55+
DRM_IMX_CDNS_MHDP = module;
56+
DRM_IMX_DCSS = module;
57+
# PHY_FSL_IMX8MQ_HDPTX = module; # configuration option does not exist
58+
DRM_PANEL_LVDS = module;
59+
I2C_IMX_LPI2C = module;
60+
I2C_MUX_REG = module;
61+
INTERCONNECT_IMX = yes;
62+
INTERCONNECT_IMX8MQ = yes;
63+
MFD_WM8994 = module;
64+
MUX_GPIO = module;
65+
MUX_MMIO = module;
66+
RTC_DRV_PCF8523 = module;
67+
USB_EHCI_FSL = module;
68+
# NO_HZ_IDLE = yes; # conflicts with NO_HZ_FULL
69+
SND_SOC_FSL_MICFIL = module;
70+
SND_IMX_SOC = module;
71+
SND_SOC_FSL_ASOC_CARD = module;
72+
SND_SOC_IMX_AUDMIX = module;
73+
SND_SOC_IMX_HDMI = module;
74+
INPUT_JOYSTICK = yes;
75+
JOYSTICK_XPAD = module;
76+
JOYSTICK_XPAD_FF = yes;
77+
JOYSTICK_XPAD_LEDS = yes;
78+
79+
INTERCONNECT_IMX8MP = yes;
80+
SND_SOC_FSL_ASRC = yes;
81+
DRM_IMX_LCDIF = yes;
82+
DRM_IMX8MP_DW_HDMI_BRIDGE = yes;
83+
DRM_IMX8MP_HDMI_PVI = yes;
84+
IMX8MM_THERMAL = yes;
85+
IMX2_WDT = yes;
86+
DRM_SAMSUNG_DSIM = yes;
87+
PHY_FSL_SAMSUNG_HDMI_PHY = yes;
88+
DRM = yes;
89+
DRM_PANEL_MNT_POCKET_REFORM = module;
90+
IMX8M_BLK_CTRL = yes;
91+
IMX_GPCV2_PM_DOMAINS = yes;
92+
DRM_DISPLAY_CONNECTOR = yes;
93+
DRM_FSL_LDB = yes;
94+
BACKLIGHT_CLASS_DEVICE = yes;
95+
BACKLIGHT_PWM = yes;
96+
BACKLIGHT_GPIO = yes;
97+
BACKLIGHT_LED = yes;
98+
CPU_FREQ_GOV_PERFORMANCE = yes;
99+
CPU_FREQ_GOV_POWERSAVE = yes;
100+
CPU_FREQ_GOV_USERSPACE = yes;
101+
CPU_FREQ_GOV_ONDEMAND = yes;
102+
CPU_FREQ_GOV_CONSERVATIVE = yes;
103+
CPU_FREQ_GOV_SCHEDUTIL = yes;
104+
ARM_IMX_CPUFREQ_DT = yes;
105+
ARM_IMX_BUS_DEVFREQ = yes;
106+
IMX_IRQSTEER = yes;
107+
108+
PCI_MESON = yes;
109+
DWMAC_MESON = module;
110+
MDIO_BUS_MUX_MESON_G12A = yes;
111+
I2C_MESON = yes;
112+
PWM_MESON = yes;
113+
USB_DWC3_MESON_G12A = yes;
114+
MMC_MESON_GX = yes;
115+
MMC_MESON_MX_SDIO = yes;
116+
MESON_DDR_PMU = yes;
117+
RTW88_8822CS = module;
118+
119+
PWM_FSL_FTM = yes;
120+
FSL_RCPM = yes;
121+
122+
ARCH_ROCKCHIP = yes;
123+
# ARM_ROCKCHIP_CPUFREQ = module; # configuration option does not exist
124+
DRM_PANTHOR = module;
125+
NVMEM_ROCKCHIP_OTP = yes;
126+
PHY_ROCKCHIP_SAMSUNG_HDPTX = module;
127+
PHY_ROCKCHIP_USBDP = module;
128+
REGULATOR = yes;
129+
# ROCKCHIP_REGULATOR_COUPLER = yes; # configuration option does not exist
130+
SPI_ROCKCHIP = yes;
131+
SPI_ROCKCHIP_SFC = module;
132+
ARM_SCMI_CPUFREQ = module;
133+
VIDEO_ROCKCHIP_VDEC2 = module;
134+
ROCKCHIP_DW_HDMI_QP = yes;
135+
ROCKCHIP_DW_MIPI_DSI2 = yes;
136+
PHY_ROCKCHIP_SAMSUNG_DCPHY = yes;
137+
REGULATOR_FIXED_VOLTAGE = yes;
138+
GPIO_ROCKCHIP = yes;
139+
PL330_DMA = yes;
140+
141+
DRM_MEGACHIPS_STDPXXXX_GE_B850V3_FW = no; # patches for 6.16 break this driver
142+
};
143+
}
144+
// (args.argsOverride or { })
145+
);
146+
147+
in
148+
lib.recurseIntoAttrs (linuxPackagesFor (callPackage linuxPkg { }))

mnt/reform/lpc.nix

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
stdenv,
3+
lib,
4+
fetchFromGitLab,
5+
kernel,
6+
kernelModuleMakeFlags,
7+
kmod,
8+
}:
9+
10+
stdenv.mkDerivation rec {
11+
name = "lpc";
12+
13+
src = fetchFromGitLab {
14+
domain = "source.mnt.re";
15+
owner = "reform";
16+
repo = "reform-tools";
17+
rev = "45f930403492aa2156522bfe30edb02e33494b69";
18+
hash = "sha256-no33CsV69nu1TR0cqxQDd1bFXqhjqOW9IUDxds0fyxE=";
19+
};
20+
21+
sourceRoot = "source/lpc";
22+
hardeningDisable = [
23+
"pic"
24+
"format"
25+
];
26+
nativeBuildInputs = kernel.moduleBuildDependencies;
27+
28+
installPhase = ''
29+
make -C "${kernel.dev}/lib/modules/${kernel.modDirVersion}/build" M="$(pwd)" INSTALL_MOD_PATH=$out modules_install $makeFlags
30+
'';
31+
32+
makeFlags = kernelModuleMakeFlags ++ [
33+
"KERNEL_DIR=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"
34+
"INSTALL_MOD_PATH=${placeholder "out"}"
35+
];
36+
}

mnt/reform/rk3588/README.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# MNT Reform Laptop with RK3588 CPU module
2+
3+
## Creating an installer SD-Image
4+
5+
Create and configure the `flake.nix` file:
6+
``` nix
7+
{
8+
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
9+
inputs.nixos-hardware.url = "github:nixos/nixos-hardware";
10+
inputs.flake-utils.url = "github:numtide/flake-utils";
11+
12+
outputs = { self, nixpkgs, nixos-hardware, flake-utils, ... }:
13+
flake-utils.lib.eachDefaultSystem (system:
14+
rec {
15+
packages.default = packages.installer;
16+
packages.installer = (import "${nixpkgs}/nixos" {
17+
configuration =
18+
{ config, ... }: {
19+
imports = [
20+
"${nixos-hardware}/mnt/reform/rk3588/installer.nix"
21+
];
22+
23+
# If you want to use ssh set a password
24+
# users.users.nixos.password = "super secure password";
25+
# OR add your public ssh key
26+
# users.users.nixos.openssh.authorizedKeys.keys = [ "ssh-rsa ..." ];
27+
28+
# Additional configuration goes here
29+
30+
# Only used when cross compiling
31+
nixpkgs.crossSystem = {
32+
config = "aarch64-unknown-linux-gnu";
33+
system = "aarch64-linux";
34+
};
35+
36+
system.stateVersion = "23.05";
37+
};
38+
inherit system;
39+
}).config.system.build.image;;
40+
});
41+
}
42+
```
43+
44+
Build the installer image.
45+
46+
``` sh
47+
nix build .#
48+
```

mnt/reform/rk3588/default.nix

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
config,
3+
lib,
4+
pkgs,
5+
...
6+
}:
7+
{
8+
imports = [ ../. ];
9+
boot = {
10+
# kernelParams = [ "console=ttyS2,1500000n8" ];
11+
kernelParams = [
12+
"no_console_suspend"
13+
"console=tty1"
14+
];
15+
# kernel modules needed for the virtual console
16+
initrd.availableKernelModules = [
17+
"panel-edp"
18+
"phy-rockchip-samsung-hdptx"
19+
"rockchipdrm"
20+
"ti-sn65dsi86"
21+
];
22+
23+
};
24+
boot.loader = {
25+
grub.enable = false;
26+
generic-extlinux-compatible.enable = true;
27+
};
28+
hardware.alsa.enablePersistence = true;
29+
system.activationScripts.asound = ''
30+
if [ ! -e "/var/lib/alsa/asound.state" ]; then
31+
mkdir -p /var/lib/alsa
32+
cp ${./initial-asound.state} /var/lib/alsa/asound.state
33+
fi
34+
'';
35+
}

mnt/reform/rk3588/firmware.nix

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
runCommand,
3+
uboot,
4+
fetchFromGitHub,
5+
}:
6+
# script from https://source.mnt.re/reform/reform-rk3588-uboot/-/blob/b530d65f4a878c0329a594fa248ba8da59d2e05f/build.sh
7+
runCommand "mnt-reform-firmware-rk3855${uboot.variant}" { } ''
8+
mkdir $out
9+
cp -r ${uboot} u-boot
10+
cp -r ${uboot.rkbin} rkbin
11+
chmod -R +rw u-boot
12+
chmod -R +rw rkbin
13+
cd u-boot
14+
mkdir spl
15+
mv u-boot-spl.bin spl
16+
../rkbin/tools/boot_merger rock5b-rk3588.ini
17+
cd ..
18+
# rkbin stuff
19+
cd rkbin
20+
./tools/boot_merger RKBOOT/RK3588MINIALL.ini
21+
# concatenate
22+
cd ..
23+
cp u-boot/idbloader.img $out/mnt-reform2-rk3588${uboot.variant}-flash.bin
24+
dd if=u-boot/u-boot.itb of=$out/mnt-reform2-rk3588${uboot.variant}-flash.bin seek=16320
25+
''

0 commit comments

Comments
 (0)