Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ See code for all available configurations.
| [Microsoft Surface Pro 9](microsoft/surface-pro/9) | `<nixos-hardware/microsoft/surface-pro/9>` | `microsoft-surface-pro-9` |
| [Morefine M600](morefine/m600) | `<nixos-hardware/morefine/m600>` | `morefine-m600` |
| [Minisforum V3](minisforum/v3) | `<nixos-hardware/minisforum/v3>` | `minisforum-v3` |
| [MNT Reform with RK3588 module](mnt/reform/rk3588) | `<nixos-hardware/mnt/reform/rk3588` | `mnt-reform-rk3588` |
| [MECHREVO Yilong15Pro](mechrevo/GM5HG0A) | `<nixos-hardware/mechrevo/GM5HG0A>` | `mechrevo-gm5hg0a` |
| [NXP iMX8 MPlus Evaluation Kit](nxp/imx8mp-evk) | `<nixos-hardware/nxp/imx8mp-evk>` | `nxp-imx8mp-evk` |
| [NXP iMX8 MQuad Evaluation Kit](nxp/imx8mq-evk) | `<nixos-hardware/nxp/imx8mq-evk>` | `nxp-imx8mq-evk` |
Expand Down
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@
microsoft-surface-pro-9 = import ./microsoft/surface-pro/9;
milkv-pioneer = import ./milkv/pioneer;
minisforum-v3 = import ./minisforum/v3;
mnt-reform-rk3588 = import ./mnt/reform/rk3588;
morefine-m600 = import ./morefine/m600;
msi-b350-tomahawk = import ./msi/b350-tomahawk;
msi-b550-a-pro = import ./msi/b550-a-pro;
Expand Down
10 changes: 10 additions & 0 deletions mnt/reform/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
config,
lib,
pkgs,
...
}:
{
boot.kernelPackages = pkgs.callPackage ./kernel.nix { };
boot.extraModulePackages = [ (config.boot.kernelPackages.callPackage ./lpc.nix { }) ];
}
48 changes: 48 additions & 0 deletions mnt/reform/dtsPatch.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
stdenv,
reformDebianPackages,
kernelSource,
quilt,
}:
stdenv.mkDerivation {
name = "mnt-dts-patch";
nativeBuildInputs = [ quilt ];
buildCommand = ''
cp -r --reflink=auto ${reformDebianPackages}/linux/* .
mkdir -p linux/debian/patches/reform
cp -r --reflink=auto ${kernelSource}/* linux
chmod +w -R .
env --chdir=linux QUILT_PATCHES=debian/patches quilt new reform/dts.patch
env --chdir=linux QUILT_PATCHES=debian/patches quilt add arch/arm64/boot/dts/freescale/fsl-ls1028a-mnt-reform2.dts
cp fsl-ls1028a-mnt-reform2.dts linux/arch/arm64/boot/dts/freescale/fsl-ls1028a-mnt-reform2.dts
env --chdir=linux QUILT_PATCHES=debian/patches quilt add arch/arm64/boot/dts/freescale/imx8mq-mnt-reform2-hdmi.dts
cp imx8mq-mnt-reform2-hdmi.dts linux/arch/arm64/boot/dts/freescale/imx8mq-mnt-reform2-hdmi.dts
env --chdir=linux QUILT_PATCHES=debian/patches quilt add arch/arm64/boot/dts/freescale/Makefile
sed -i '/fsl-ls1028a-rdb.dtb/a dtb-$(CONFIG_ARCH_LAYERSCAPE) += fsl-ls1028a-mnt-reform2.dtb' linux/arch/arm64/boot/dts/freescale/Makefile
sed -i '/imx8mq-mnt-reform2.dtb/a dtb-$(CONFIG_ARCH_MXC) += imx8mq-mnt-reform2-hdmi.dtb' linux/arch/arm64/boot/dts/freescale/Makefile
env --chdir=linux QUILT_PATCHES=debian/patches quilt add arch/arm64/boot/dts/freescale/imx8mp-mnt-pocket-reform.dts
cp imx8mp-mnt-pocket-reform.dts linux/arch/arm64/boot/dts/freescale/imx8mp-mnt-pocket-reform.dts
env --chdir=linux QUILT_PATCHES=debian/patches quilt add arch/arm64/boot/dts/freescale/imx8mp-mnt-reform2.dts
cp imx8mp-mnt-reform2.dts linux/arch/arm64/boot/dts/freescale/imx8mp-mnt-reform2.dts
sed -i '/imx8mq-mnt-reform2.dtb/a dtb-$(CONFIG_ARCH_MXC) += imx8mp-mnt-pocket-reform.dtb' linux/arch/arm64/boot/dts/freescale/Makefile
sed -i '/imx8mq-mnt-reform2.dtb/a dtb-$(CONFIG_ARCH_MXC) += imx8mp-mnt-reform2.dtb' linux/arch/arm64/boot/dts/freescale/Makefile
env --chdir=linux QUILT_PATCHES=debian/patches quilt add arch/arm64/boot/dts/amlogic/meson-g12b-bananapi-cm4-mnt-pocket-reform.dts
cp meson-g12b-bananapi-cm4-mnt-pocket-reform.dts linux/arch/arm64/boot/dts/amlogic/meson-g12b-bananapi-cm4-mnt-pocket-reform.dts
env --chdir=linux QUILT_PATCHES=debian/patches quilt add arch/arm64/boot/dts/amlogic/Makefile
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
env --chdir=linux QUILT_PATCHES=debian/patches quilt add arch/arm64/boot/dts/rockchip/rk3588-mnt-reform2.dts
cp rk3588-mnt-reform2.dts linux/arch/arm64/boot/dts/rockchip/rk3588-mnt-reform2.dts
env --chdir=linux QUILT_PATCHES=debian/patches quilt add arch/arm64/boot/dts/rockchip/rk3588-mnt-reform2-dsi.dts
cp rk3588-mnt-reform2-dsi.dts linux/arch/arm64/boot/dts/rockchip/rk3588-mnt-reform2-dsi.dts
env --chdir=linux QUILT_PATCHES=debian/patches quilt add arch/arm64/boot/dts/rockchip/rk3588-mnt-pocket-reform.dts
cp rk3588-mnt-pocket-reform.dts linux/arch/arm64/boot/dts/rockchip/rk3588-mnt-pocket-reform.dts
env --chdir=linux QUILT_PATCHES=debian/patches quilt add arch/arm64/boot/dts/rockchip/rk3588-mnt-reform-next.dts
cp rk3588-mnt-reform-next.dts linux/arch/arm64/boot/dts/rockchip/rk3588-mnt-reform-next.dts
env --chdir=linux QUILT_PATCHES=debian/patches quilt add arch/arm64/boot/dts/rockchip/Makefile
sed -i '/rk3588-mnt-reform2.dtb/a dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3588-mnt-reform2-dsi.dtb' linux/arch/arm64/boot/dts/rockchip/Makefile
sed -i '/rk3588-mnt-reform2-dsi.dtb/a dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3588-mnt-reform-next.dtb' linux/arch/arm64/boot/dts/rockchip/Makefile
sed -i '/rk3588-mnt-reform-next.dtb/a dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3588-mnt-pocket-reform.dtb' linux/arch/arm64/boot/dts/rockchip/Makefile
env --chdir=linux QUILT_PATCHES=debian/patches quilt refresh
cp linux/debian/patches/reform/dts.patch $out
'';
}
148 changes: 148 additions & 0 deletions mnt/reform/kernel.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
{
lib,
callPackage,
linuxPackagesFor,
kernelPatches,
fetchFromGitLab,
...
}:
let
modDirVersion = "6.16.5";
reformDebianPackages = fetchFromGitLab {
domain = "source.mnt.re";
owner = "reform";
repo = "reform-debian-packages";
rev = "830c94db42beef876dc58ea56711659ae7bd415d";
hash = "sha256-mdORgTOM7RJnEjY5G/iWMHf69wQkql11yRpQ/DrQKb4=";
};
linuxPkg =
{
lib,
fetchzip,
buildLinux,
callPackage,
...
}@args:
buildLinux (
args
// rec {
version = "${modDirVersion}-mnt-reform";
inherit modDirVersion;

src = fetchzip {
url = "mirror://kernel/linux/kernel/v${lib.versions.major modDirVersion}.x/linux-${modDirVersion}.tar.xz";
hash = "sha256-XiTuH40b3VJqzwygZzU0FcvMDj41Rq6IsMbm+3+QxDY=";
};

kernelPatches =
(map (patch: { inherit patch; }) (
lib.filesystem.listFilesRecursive "${reformDebianPackages}/linux/patches${lib.versions.majorMinor modDirVersion}"
))
++ [
{
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
DRM_LVDS_CODEC = module;
DRM_CDNS_MHDP8546 = module;
DRM_CDNS_HDMI_CEC = module;
DRM_IMX_CDNS_MHDP = module;
DRM_IMX_DCSS = module;
# PHY_FSL_IMX8MQ_HDPTX = module; # configuration option does not exist
DRM_PANEL_LVDS = module;
I2C_IMX_LPI2C = module;
I2C_MUX_REG = module;
INTERCONNECT_IMX = yes;
INTERCONNECT_IMX8MQ = yes;
MFD_WM8994 = module;
MUX_GPIO = module;
MUX_MMIO = module;
RTC_DRV_PCF8523 = module;
USB_EHCI_FSL = module;
# NO_HZ_IDLE = yes; # conflicts with NO_HZ_FULL
SND_SOC_FSL_MICFIL = module;
SND_IMX_SOC = module;
SND_SOC_FSL_ASOC_CARD = module;
SND_SOC_IMX_AUDMIX = module;
SND_SOC_IMX_HDMI = module;
INPUT_JOYSTICK = yes;
JOYSTICK_XPAD = module;
JOYSTICK_XPAD_FF = yes;
JOYSTICK_XPAD_LEDS = yes;

INTERCONNECT_IMX8MP = yes;
SND_SOC_FSL_ASRC = yes;
DRM_IMX_LCDIF = yes;
DRM_IMX8MP_DW_HDMI_BRIDGE = yes;
DRM_IMX8MP_HDMI_PVI = yes;
IMX8MM_THERMAL = yes;
IMX2_WDT = yes;
DRM_SAMSUNG_DSIM = yes;
PHY_FSL_SAMSUNG_HDMI_PHY = yes;
DRM = yes;
DRM_PANEL_MNT_POCKET_REFORM = module;
IMX8M_BLK_CTRL = yes;
IMX_GPCV2_PM_DOMAINS = yes;
DRM_DISPLAY_CONNECTOR = yes;
DRM_FSL_LDB = yes;
BACKLIGHT_CLASS_DEVICE = yes;
BACKLIGHT_PWM = yes;
BACKLIGHT_GPIO = yes;
BACKLIGHT_LED = yes;
CPU_FREQ_GOV_PERFORMANCE = yes;
CPU_FREQ_GOV_POWERSAVE = yes;
CPU_FREQ_GOV_USERSPACE = yes;
CPU_FREQ_GOV_ONDEMAND = yes;
CPU_FREQ_GOV_CONSERVATIVE = yes;
CPU_FREQ_GOV_SCHEDUTIL = yes;
ARM_IMX_CPUFREQ_DT = yes;
ARM_IMX_BUS_DEVFREQ = yes;
IMX_IRQSTEER = yes;

PCI_MESON = yes;
DWMAC_MESON = module;
MDIO_BUS_MUX_MESON_G12A = yes;
I2C_MESON = yes;
PWM_MESON = yes;
USB_DWC3_MESON_G12A = yes;
MMC_MESON_GX = yes;
MMC_MESON_MX_SDIO = yes;
MESON_DDR_PMU = yes;
RTW88_8822CS = module;

PWM_FSL_FTM = yes;
FSL_RCPM = yes;

ARCH_ROCKCHIP = yes;
# ARM_ROCKCHIP_CPUFREQ = module; # configuration option does not exist
DRM_PANTHOR = module;
NVMEM_ROCKCHIP_OTP = yes;
PHY_ROCKCHIP_SAMSUNG_HDPTX = module;
PHY_ROCKCHIP_USBDP = module;
REGULATOR = yes;
# ROCKCHIP_REGULATOR_COUPLER = yes; # configuration option does not exist
SPI_ROCKCHIP = yes;
SPI_ROCKCHIP_SFC = module;
ARM_SCMI_CPUFREQ = module;
VIDEO_ROCKCHIP_VDEC2 = module;
ROCKCHIP_DW_HDMI_QP = yes;
ROCKCHIP_DW_MIPI_DSI2 = yes;
PHY_ROCKCHIP_SAMSUNG_DCPHY = yes;
REGULATOR_FIXED_VOLTAGE = yes;
GPIO_ROCKCHIP = yes;
PL330_DMA = yes;

DRM_MEGACHIPS_STDPXXXX_GE_B850V3_FW = no; # patches for 6.16 break this driver
};
}
// (args.argsOverride or { })
);

in
lib.recurseIntoAttrs (linuxPackagesFor (callPackage linuxPkg { }))
36 changes: 36 additions & 0 deletions mnt/reform/lpc.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
stdenv,
lib,
fetchFromGitLab,
kernel,
kernelModuleMakeFlags,
kmod,
}:

stdenv.mkDerivation rec {
name = "lpc";

src = fetchFromGitLab {
domain = "source.mnt.re";
owner = "reform";
repo = "reform-tools";
rev = "45f930403492aa2156522bfe30edb02e33494b69";
hash = "sha256-no33CsV69nu1TR0cqxQDd1bFXqhjqOW9IUDxds0fyxE=";
};

sourceRoot = "source/lpc";
hardeningDisable = [
"pic"
"format"
];
nativeBuildInputs = kernel.moduleBuildDependencies;

installPhase = ''
make -C "${kernel.dev}/lib/modules/${kernel.modDirVersion}/build" M="$(pwd)" INSTALL_MOD_PATH=$out modules_install $makeFlags
'';

makeFlags = kernelModuleMakeFlags ++ [
"KERNEL_DIR=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"
"INSTALL_MOD_PATH=${placeholder "out"}"
];
}
48 changes: 48 additions & 0 deletions mnt/reform/rk3588/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# MNT Reform Laptop with RK3588 CPU module

## Creating an installer SD-Image

Create and configure the `flake.nix` file:
``` nix
{
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
inputs.nixos-hardware.url = "github:nixos/nixos-hardware";
inputs.flake-utils.url = "github:numtide/flake-utils";

outputs = { self, nixpkgs, nixos-hardware, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
rec {
packages.default = packages.installer;
packages.installer = (import "${nixpkgs}/nixos" {
configuration =
{ config, ... }: {
imports = [
"${nixos-hardware}/mnt/reform/rk3588/installer.nix"
];

# If you want to use ssh set a password
# users.users.nixos.password = "super secure password";
# OR add your public ssh key
# users.users.nixos.openssh.authorizedKeys.keys = [ "ssh-rsa ..." ];

# Additional configuration goes here

# Only used when cross compiling
nixpkgs.crossSystem = {
config = "aarch64-unknown-linux-gnu";
system = "aarch64-linux";
};

system.stateVersion = "23.05";
};
inherit system;
}).config.system.build.image;;
});
}
```

Build the installer image.

``` sh
nix build .#
```
35 changes: 35 additions & 0 deletions mnt/reform/rk3588/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
config,
lib,
pkgs,
...
}:
{
imports = [ ../. ];
boot = {
# kernelParams = [ "console=ttyS2,1500000n8" ];
kernelParams = [
"no_console_suspend"
"console=tty1"
];
# kernel modules needed for the virtual console
initrd.availableKernelModules = [
"panel-edp"
"phy-rockchip-samsung-hdptx"
"rockchipdrm"
"ti-sn65dsi86"
];

};
boot.loader = {
grub.enable = false;
generic-extlinux-compatible.enable = true;
};
hardware.alsa.enablePersistence = true;
system.activationScripts.asound = ''
if [ ! -e "/var/lib/alsa/asound.state" ]; then
mkdir -p /var/lib/alsa
cp ${./initial-asound.state} /var/lib/alsa/asound.state
fi
'';
}
25 changes: 25 additions & 0 deletions mnt/reform/rk3588/firmware.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
runCommand,
uboot,
fetchFromGitHub,
}:
# script from https://source.mnt.re/reform/reform-rk3588-uboot/-/blob/b530d65f4a878c0329a594fa248ba8da59d2e05f/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
''
Loading