summaryrefslogtreecommitdiff
path: root/hardware/cmsb-001
diff options
context:
space:
mode:
authorAndrew Opalach <andrew@akon.city> 2024-11-20 09:57:49 -0500
committerAndrew Opalach <andrew@akon.city> 2024-11-20 09:57:49 -0500
commitb41b7acf80ad6d49cfde49ae562aaf85ba4f8768 (patch)
treebcf45cf830dda75a026b64b4f447c042f7570a3e /hardware/cmsb-001
parent588b6d8bfa1b2efdebf8c424c86f6069cceafa41 (diff)
downloadcamu-b41b7acf80ad6d49cfde49ae562aaf85ba4f8768.tar.gz
camu-b41b7acf80ad6d49cfde49ae562aaf85ba4f8768.tar.bz2
camu-b41b7acf80ad6d49cfde49ae562aaf85ba4f8768.zip
Initial hardware config, refactor flake
doc -> docs Signed-off-by: Andrew Opalach <andrew@akon.city>
Diffstat (limited to 'hardware/cmsb-001')
-rw-r--r--hardware/cmsb-001/cma-overlay.dts36
-rw-r--r--hardware/cmsb-001/configuration.nix168
-rw-r--r--hardware/cmsb-001/disable-bt-overlay.dts59
-rw-r--r--hardware/cmsb-001/justboom-digi-overlay.dts41
-rw-r--r--hardware/cmsb-001/vc4-fkms-v3d-overlay.dts44
5 files changed, 348 insertions, 0 deletions
diff --git a/hardware/cmsb-001/cma-overlay.dts b/hardware/cmsb-001/cma-overlay.dts
new file mode 100644
index 0000000..b473793
--- /dev/null
+++ b/hardware/cmsb-001/cma-overlay.dts
@@ -0,0 +1,36 @@
+/*
+ * cma.dts
+ */
+
+/dts-v1/;
+/plugin/;
+
+/ {
+ compatible = "brcm,bcm2837";
+
+ fragment@0 {
+ target = <&cma>;
+ frag0: __overlay__ {
+ /*
+ * The default size when using this overlay is 256 MB
+ * and should be kept as is for backwards
+ * compatibility.
+ */
+ size = <0x10000000>;
+ };
+ };
+
+ __overrides__ {
+ cma-512 = <&frag0>,"size:0=",<0x20000000>;
+ cma-448 = <&frag0>,"size:0=",<0x1c000000>;
+ cma-384 = <&frag0>,"size:0=",<0x18000000>;
+ cma-320 = <&frag0>,"size:0=",<0x14000000>;
+ cma-256 = <&frag0>,"size:0=",<0x10000000>;
+ cma-192 = <&frag0>,"size:0=",<0xC000000>;
+ cma-128 = <&frag0>,"size:0=",<0x8000000>;
+ cma-96 = <&frag0>,"size:0=",<0x6000000>;
+ cma-64 = <&frag0>,"size:0=",<0x4000000>;
+ cma-size = <&frag0>,"size:0"; /* in bytes, 4MB aligned */
+ cma-default = <0>,"-0";
+ };
+};
diff --git a/hardware/cmsb-001/configuration.nix b/hardware/cmsb-001/configuration.nix
new file mode 100644
index 0000000..d3525f7
--- /dev/null
+++ b/hardware/cmsb-001/configuration.nix
@@ -0,0 +1,168 @@
+# https://citizen428.net/blog/installing-nixos-raspberry-pi-3/
+{ config, lib, pkgs, modulesPath, ... }: {
+ imports = [
+ #"${modulesPath}/installer/sd-card/sd-image.nix"
+ ];
+
+ users.users.akiyo = {
+ isNormalUser = true;
+ uid = 1000;
+ extraGroups = [ "wheel" "input" "audio" "video" "render" "disk" "cdrom" ];
+ };
+
+ security.sudo.extraRules = [
+ { users = [ "akiyo" ]; commands = [ { command = "ALL"; options = [ "NOPASSWD" ]; } ]; }
+ ];
+
+ nix = {
+ settings = {
+ experimental-features = [ "nix-command" "flakes" ];
+ system-features = [ "big-parallel" ];
+ auto-optimise-store = true;
+ download-buffer-size = 134217728;
+ trusted-users = [ "akiyo" ];
+ };
+ gc.automatic = false;
+ optimise.automatic = true;
+ };
+
+ fileSystems."/" =
+ { device = "/dev/disk/by-label/NIXOS_SD";
+ fsType = "ext4";
+ options = [ "noatime" ];
+ };
+
+ # https://forums.gentoo.org/viewtopic-t-1101170-start-0.html
+ nixpkgs.hostPlatform = lib.mkDefault "aarch64-linux";
+ boot.initrd.availableKernelModules = [
+ "usbhid"
+ "usb_storage"
+ "vc4"
+ "reset-raspberrypi"
+ "bcm2835_dma"
+ "i2c_bcm2835"
+ ];
+ boot.kernelModules = [ ];
+ boot.kernelParams = [ "mitigations=off" "file_caps=1" ];
+ boot.supportedFilesystems = [ ];
+ boot.extraModulePackages = [ ];
+ boot.initrd.kernelModules = [ ];
+
+ hardware.enableRedistributableFirmware = true;
+ hardware.graphics.enable = true;
+
+ console = {
+ font = "Lat2-Terminus16";
+ keyMap = "us";
+ useXkbConfig = false;
+ };
+
+ time.timeZone = "America/New_York";
+ i18n.defaultLocale = "en_US.UTF-8";
+ i18n.supportedLocales = [
+ "C.UTF-8/UTF-8"
+ "${config.i18n.defaultLocale}/UTF-8"
+ ];
+ i18n.glibcLocales = pkgs.glibcLocales.override {
+ allLocales = false;
+ locales = [
+ "C.UTF-8/UTF-8"
+ "${config.i18n.defaultLocale}/UTF-8"
+ ];
+ };
+
+ networking = {
+ hostName = "cmsb-001";
+ wireless = {
+ enable = true;
+ fallbackToWPA2 = false;
+ networks."Verizon_TMKS9N" = {
+ pskRaw = "794b2c76b39a7f83d08e028e20fb980cef890424ae0b69acdf2e37c590a9fb6a";
+ authProtocols = [ "WPA-PSK" "WPA-EAP" "FT-PSK" "FT-EAP" ];
+ };
+ userControlled.enable = true;
+ };
+ firewall = {
+ enable = true;
+ allowedTCPPorts = [];
+ };
+ };
+
+ services.openssh.enable = true;
+
+ programs.zsh.enable = true;
+ environment.shells = [ pkgs.zsh ];
+ environment.pathsToLink = [ "/share/zsh" ];
+ users.defaultUserShell = pkgs.zsh;
+
+ environment.systemPackages = with pkgs; [
+ libraspberrypi
+ dtc
+ alsa-utils
+ kitty.terminfo
+ htop
+ # https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/editors/vim/full.nix#L12
+ ((vim-full.override {
+ features = "small";
+ guiSupport = "off";
+ luaSupport = false;
+ pythonSupport = false;
+ rubySupport = false;
+ cscopeSupport = false;
+ netbeansSupport = false;
+ ximSupport = false;
+ ftNixSupport = false;
+ sodiumSupport = false;
+ }).customize {
+ name = "vi";
+ vimrcConfig = { customRC = ""; };
+ })
+ mesa-demos
+ vulkan-tools
+ mpv
+ ];
+
+ # https://pablo.tools/blog/computers/nixos-generate-raspberry-images/
+ #sdImage = {
+ # populateFirmwareCommands = let
+ # configTxt = pkgs.writeText "config.txt" ''
+ # '';
+ # in ''
+ # (cd ${pkgs.raspberrypifw}/share/raspberrypi/boot && cp bootcode.bin fixup*.dat start*.elf $NIX_BUILD_TOP/firmware/)
+ # cp ${configTxt} firmware/config.txt
+ # cp ${pkgs.ubootRaspberryPi3_64bit}/u-boot.bin firmware/u-boot-rpi3.bin
+ # '';
+ # populateRootCommands = ''
+ # mkdir -p ./files/boot
+ # ${config.boot.loader.generic-extlinux-compatible.populateCmd} -c ${config.system.build.toplevel} -d ./files/boot
+ # '';
+ #};
+
+ # https://github.com/NixOS/nixos-hardware/issues/631
+ hardware.deviceTree = {
+ enable = true;
+ filter = "bcm2837-rpi-3-b*.dtb";
+ overlays = [
+ # brcm,bcm2835 -> brcm,bcm2837
+ { # https://raw.githubusercontent.com/raspberrypi/linux/refs/heads/rpi-6.6.y/arch/arm/boot/dts/overlays/justboom-digi-overlay.dts
+ name = "justboom-digi";
+ dtsFile = ./justboom-digi-overlay.dts;
+ }
+ { # https://raw.githubusercontent.com/raspberrypi/linux/refs/heads/rpi-6.6.y/arch/arm/boot/dts/overlays/cma-overlay.dts
+ name = "cma-overlay";
+ dtsFile = ./cma-overlay.dts;
+ }
+ { # https://raw.githubusercontent.com/raspberrypi/linux/refs/heads/rpi-6.6.y/arch/arm/boot/dts/overlays/vc4-fkms-v3d-overlay.dts
+ name = "vc4-fkms-v3d";
+ # remove '#include "cma-overlay.dts"'
+ dtsFile = ./vc4-fkms-v3d-overlay.dts;
+ }
+ { # https://raw.githubusercontent.com/raspberrypi/linux/refs/heads/rpi-6.6.y/arch/arm/boot/dts/overlays/disable-bt-overlay.dts
+ name = "disable-bt";
+ dtsFile = ./disable-bt-overlay.dts;
+ }
+ ];
+ };
+
+ system.stateVersion = "25.05";
+}
diff --git a/hardware/cmsb-001/disable-bt-overlay.dts b/hardware/cmsb-001/disable-bt-overlay.dts
new file mode 100644
index 0000000..48e06a6
--- /dev/null
+++ b/hardware/cmsb-001/disable-bt-overlay.dts
@@ -0,0 +1,59 @@
+/dts-v1/;
+/plugin/;
+
+/* Disable Bluetooth and restore UART0/ttyAMA0 over GPIOs 14 & 15. */
+
+#include <dt-bindings/gpio/gpio.h>
+
+/{
+ compatible = "brcm,bcm2837";
+
+ fragment@0 {
+ target = <&uart1>;
+ __overlay__ {
+ status = "disabled";
+ };
+ };
+
+ fragment@1 {
+ target = <&uart0>;
+ __overlay__ {
+ pinctrl-names = "default";
+ pinctrl-0 = <&uart0_pins>;
+ status = "okay";
+ };
+ };
+
+ fragment@2 {
+ target = <&bt>;
+ __overlay__ {
+ status = "disabled";
+ };
+ };
+
+ fragment@3 {
+ target = <&uart0_pins>;
+ __overlay__ {
+ brcm,pins;
+ brcm,function;
+ brcm,pull;
+ };
+ };
+
+ fragment@4 {
+ target = <&bt_pins>;
+ __overlay__ {
+ brcm,pins;
+ brcm,function;
+ brcm,pull;
+ };
+ };
+
+ fragment@5 {
+ target-path = "/aliases";
+ __overlay__ {
+ serial0 = "/soc/serial@7e201000";
+ serial1 = "/soc/serial@7e215040";
+ };
+ };
+};
diff --git a/hardware/cmsb-001/justboom-digi-overlay.dts b/hardware/cmsb-001/justboom-digi-overlay.dts
new file mode 100644
index 0000000..7fa757f
--- /dev/null
+++ b/hardware/cmsb-001/justboom-digi-overlay.dts
@@ -0,0 +1,41 @@
+// Definitions for JustBoom Digi
+/dts-v1/;
+/plugin/;
+
+/ {
+ compatible = "brcm,bcm2837";
+
+ fragment@0 {
+ target = <&i2s_clk_consumer>;
+ __overlay__ {
+ status = "okay";
+ };
+ };
+
+ fragment@1 {
+ target = <&i2c1>;
+ __overlay__ {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ status = "okay";
+
+ wm8804@3b {
+ #sound-dai-cells = <0>;
+ compatible = "wlf,wm8804";
+ reg = <0x3b>;
+ PVDD-supply = <&vdd_3v3_reg>;
+ DVDD-supply = <&vdd_3v3_reg>;
+ status = "okay";
+ };
+ };
+ };
+
+ fragment@2 {
+ target = <&sound>;
+ __overlay__ {
+ compatible = "justboom,justboom-digi";
+ i2s-controller = <&i2s_clk_consumer>;
+ status = "okay";
+ };
+ };
+};
diff --git a/hardware/cmsb-001/vc4-fkms-v3d-overlay.dts b/hardware/cmsb-001/vc4-fkms-v3d-overlay.dts
new file mode 100644
index 0000000..4c836fb
--- /dev/null
+++ b/hardware/cmsb-001/vc4-fkms-v3d-overlay.dts
@@ -0,0 +1,44 @@
+/*
+ * vc4-fkms-v3d-overlay.dts
+ */
+
+/dts-v1/;
+/plugin/;
+
+/ {
+ compatible = "brcm,bcm2837";
+
+ fragment@1 {
+ target = <&fb>;
+ __overlay__ {
+ status = "disabled";
+ };
+ };
+
+ fragment@2 {
+ target = <&firmwarekms>;
+ __overlay__ {
+ status = "okay";
+ };
+ };
+
+ fragment@3 {
+ target = <&v3d>;
+ __overlay__ {
+ status = "okay";
+ };
+ };
+
+ fragment@4 {
+ target = <&vc4>;
+ __overlay__ {
+ status = "okay";
+ };
+ };
+ fragment@5 {
+ target-path = "/chosen";
+ __overlay__ {
+ bootargs = "clk_ignore_unused";
+ };
+ };
+};