feat(uConsole): add disko, backlight fix, GPIO 23, mt7921u
- Add disko flake input + partition config (/boot/firmware, /, /home) - Add cm5-backlight-fix service as display fallback - Add enable-gpio23-usb-hub service for internal USB hub - Add mt7921u kernel module for MediaTek AC1200 WiFi - Add gpiod package for GPIO userspace control
This commit is contained in:
@@ -8,6 +8,10 @@
|
||||
inputs.darwin.follows = "";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
disko = {
|
||||
url = "github:nix-community/disko";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
lix = {
|
||||
url = "git+https://git.lix.systems/lix-project/lix?ref=main";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
@@ -23,7 +27,7 @@
|
||||
self.submodules = true;
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, agenix, lix, nixos-uconsole, nixos-raspberrypi, ... }@inputs:
|
||||
outputs = { self, nixpkgs, agenix, disko, lix, nixos-uconsole, nixos-raspberrypi, ... }@inputs:
|
||||
let
|
||||
system = "x86_64-linux";
|
||||
keys = import ./lib/keys.nix;
|
||||
@@ -100,8 +104,10 @@
|
||||
}
|
||||
nixos-raspberrypi.nixosModules.raspberry-pi-5.base
|
||||
nixos-uconsole.nixosModules.uconsole-cm5
|
||||
disko.nixosModules.disko
|
||||
./hosts/uConsole/configuration.nix
|
||||
./hosts/uConsole/hardware-configuration.nix
|
||||
./hosts/uConsole/disko-config.nix
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,5 +1,19 @@
|
||||
{ config, lib, pkgs, paths, self, keys, ... }:
|
||||
|
||||
let
|
||||
# Backlight fallback for CM5 display quirk
|
||||
# The kernel driver usually handles this, but some boots need a kick
|
||||
backlightFixScript = pkgs.writeShellScript "backlight-fix" ''
|
||||
# Try sysfs backlight control
|
||||
for bl in /sys/class/backlight/*/brightness; do
|
||||
if [ -f "$bl" ]; then
|
||||
max=$(cat "$(dirname "$bl")/max_brightness" 2>/dev/null || echo 100)
|
||||
echo "$max" > "$bl" 2>/dev/null || true
|
||||
fi
|
||||
done
|
||||
'';
|
||||
in
|
||||
|
||||
{
|
||||
# Basic Host Info
|
||||
networking.hostName = "uConsole";
|
||||
@@ -56,6 +70,7 @@
|
||||
htop
|
||||
tmux
|
||||
neovim
|
||||
gpiod # GPIO control (for internal USB hub, AIO modules)
|
||||
|
||||
# ===== HAM Radio =====
|
||||
js8call
|
||||
@@ -139,9 +154,10 @@
|
||||
};
|
||||
|
||||
# ============================================================
|
||||
# Kernel modules for SDR and radio
|
||||
# Kernel modules for SDR, radio, and WiFi
|
||||
# ============================================================
|
||||
boot.kernelModules = [
|
||||
"mt7921u" # MediaTek MT7921 USB WiFi (uConsole AC1200)
|
||||
"88x2bu" # Realtek 8812/8821BU USB WiFi (common adapter)
|
||||
"rtl8xxxu" # RTL8188/8192/8723 USB WiFi
|
||||
"rtl2832_sdr" # RTL-SDR kernel module
|
||||
@@ -168,4 +184,37 @@
|
||||
# Reticulum uses its own encryption and doesn't need open ports
|
||||
# for basic mesh operations (peer-to-peer discovery).
|
||||
# For TCP interfaces, open additional ports as needed.
|
||||
|
||||
# ============================================================
|
||||
# CM5 Display Backlight Fix
|
||||
# The kernel driver initializes backlight, but some boots fail.
|
||||
# This service kicks it after boot as a reliable fallback.
|
||||
# ============================================================
|
||||
systemd.services.cm5-backlight-fix = {
|
||||
description = "CM5 Display Backlight Fix";
|
||||
after = [ "multi-user.target" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
ExecStart = "${backlightFixScript}";
|
||||
};
|
||||
};
|
||||
|
||||
# ============================================================
|
||||
# Internal USB Hub Enable (GPIO 23)
|
||||
# The Hacker Gadgets AIO V2 board has an internal USB hub for
|
||||
# the AC1200 WiFi, SDR, and other peripherals. GPIO 23 must be
|
||||
# HIGH to power the hub. CM5 defaults GPIO 23 to LOW.
|
||||
# ============================================================
|
||||
systemd.services.enable-gpio23-usb-hub = {
|
||||
description = "Enable Internal USB Hub (GPIO 23)";
|
||||
before = [ "network.target" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
RemainAfterExit = true;
|
||||
ExecStart = "${pkgs.gpiod}/bin/gpioset 0 23=1";
|
||||
ExecStop = "${pkgs.gpiod}/bin/gpioset 0 23=0";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
48
hosts/uConsole/disko-config.nix
Normal file
48
hosts/uConsole/disko-config.nix
Normal file
@@ -0,0 +1,48 @@
|
||||
{ lib, ... }:
|
||||
{
|
||||
disk = {
|
||||
main = {
|
||||
type = "disk";
|
||||
device = "/dev/disk/by-path/platform-fe340000.mmc";
|
||||
content = {
|
||||
type = "gpt";
|
||||
partitions = {
|
||||
boot = {
|
||||
name = "FIRMWARE";
|
||||
size = "1G";
|
||||
type = "EF00";
|
||||
content = {
|
||||
type = "filesystem";
|
||||
format = "vfat";
|
||||
mountpoint = "/boot/firmware";
|
||||
mountOptions = [
|
||||
"fmask=0022"
|
||||
"dmask=0022"
|
||||
];
|
||||
};
|
||||
};
|
||||
root = {
|
||||
name = "NIXOS_UCM5";
|
||||
size = "30G";
|
||||
content = {
|
||||
type = "filesystem";
|
||||
format = "ext4";
|
||||
mountpoint = "/";
|
||||
mountOptions = [ "noatime" ];
|
||||
};
|
||||
};
|
||||
home = {
|
||||
name = "NIXOS_HOME";
|
||||
size = "100%";
|
||||
content = {
|
||||
type = "filesystem";
|
||||
format = "ext4";
|
||||
mountpoint = "/home";
|
||||
mountOptions = [ "noatime" ];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -9,15 +9,26 @@
|
||||
boot.initrd.kernelModules = [ ];
|
||||
boot.extraModulePackages = [ ];
|
||||
|
||||
# uConsole CM5 uses NVMe or eMMC for boot storage
|
||||
# The uconsole-cm5 module sets up /boot/firmware and default /
|
||||
# Override device label here if using different storage
|
||||
fileSystems."/" = lib.mkDefault {
|
||||
# uConsole CM5 eMMC partitions managed by disko
|
||||
# Labels defined in disko-config.nix
|
||||
fileSystems."/" = {
|
||||
device = "/dev/disk/by-label/NIXOS_UCM5";
|
||||
fsType = "ext4";
|
||||
options = [ "noatime" ];
|
||||
};
|
||||
|
||||
fileSystems."/boot/firmware" = {
|
||||
device = "/dev/disk/by-label/FIRMWARE";
|
||||
fsType = "vfat";
|
||||
options = lib.mkForce [ "fmask=0022" "dmask=0022" ];
|
||||
};
|
||||
|
||||
fileSystems."/home" = {
|
||||
device = "/dev/disk/by-label/NIXOS_HOME";
|
||||
fsType = "ext4";
|
||||
options = [ "noatime" ];
|
||||
};
|
||||
|
||||
swapDevices = [ ];
|
||||
|
||||
nixpkgs.hostPlatform = lib.mkDefault "aarch64-linux";
|
||||
|
||||
Reference in New Issue
Block a user