diff options
| -rwxr-xr-x | assets/mhs35b-overlay.dtb | bin | 0 -> 1936 bytes | |||
| -rw-r--r-- | assets/printer/printer.cfg | 2 | ||||
| -rw-r--r-- | machines/fourmi/default.nix | 1 | ||||
| -rw-r--r-- | machines/fourmi/devices.nix | 1 | ||||
| -rw-r--r-- | modules/common.nix | 2 | ||||
| -rw-r--r-- | modules/fbcp.nix | 31 | ||||
| -rw-r--r-- | modules/hardware/ili9486.nix | 91 | ||||
| -rw-r--r-- | pkgs/default.nix | 2 | ||||
| -rw-r--r-- | pkgs/rpi-fbcp.nix | 28 |
9 files changed, 156 insertions, 2 deletions
diff --git a/assets/mhs35b-overlay.dtb b/assets/mhs35b-overlay.dtb new file mode 100755 index 0000000..b687fbc --- /dev/null +++ b/assets/mhs35b-overlay.dtb Binary files differdiff --git a/assets/printer/printer.cfg b/assets/printer/printer.cfg index a98cb2b..b09a875 100644 --- a/assets/printer/printer.cfg +++ b/assets/printer/printer.cfg @@ -52,7 +52,7 @@ enable_pin: !PC14 microsteps: 16 rotation_distance: 8 endstop_pin: PB2 -position_endstop: 0.0 +position_endstop: -1.600 position_max: 260 position_min: -3 homing_speed: 5.0 diff --git a/machines/fourmi/default.nix b/machines/fourmi/default.nix index 879e3fd..e942b3d 100644 --- a/machines/fourmi/default.nix +++ b/machines/fourmi/default.nix @@ -10,6 +10,7 @@ ../../modules/go2rtc.nix ../../modules/klipper.nix ../../modules/klipperscreen.nix + #../../modules/fbcp.nix ]; foundation = { diff --git a/machines/fourmi/devices.nix b/machines/fourmi/devices.nix index 4c0d55e..342e89f 100644 --- a/machines/fourmi/devices.nix +++ b/machines/fourmi/devices.nix @@ -11,6 +11,7 @@ imports = [ nixos-hardware.nixosModules.raspberry-pi-4 ../../modules/hardware/ads7846.nix + #../../modules/hardware/ili9486.nix ]; # boot settings diff --git a/modules/common.nix b/modules/common.nix index ee9d6b2..3fd2ffa 100644 --- a/modules/common.nix +++ b/modules/common.nix @@ -88,7 +88,7 @@ tcpdump ffmpeg_7-headless - ripgrep gnumake gdb gcc clang + ripgrep gnumake gdb gcc clang dtc go gopls delve go-task meson cmake nil direnv nixfmt-rfc-style diff --git a/modules/fbcp.nix b/modules/fbcp.nix new file mode 100644 index 0000000..606dba8 --- /dev/null +++ b/modules/fbcp.nix @@ -0,0 +1,31 @@ +{ auxiliaryPkgs, ... }: + +let + inherit (auxiliaryPkgs) rpi-fbcp; +in +{ + systemd = { + services."fbcp" = { + enable = true; + + before = [ "graphical.target" ]; + after = [ + "systemd-user-sessions.service" + "plymouth-start.service" + "plymouth-quit.service" + "systemd-logind.service" + "getty@tty1.service" + ]; + + unitConfig = { + ConditionPathExists = "/dev/fb0"; + }; + serviceConfig = { + ExecStart = "+${rpi-fbcp}/bin/fbcp"; + DynamicUser = true; + }; + }; + + targets.graphical.wants = [ "fbcp.service" ]; + }; +} diff --git a/modules/hardware/ili9486.nix b/modules/hardware/ili9486.nix new file mode 100644 index 0000000..6bab9ea --- /dev/null +++ b/modules/hardware/ili9486.nix @@ -0,0 +1,91 @@ +{ ... }: + +{ + hardware.deviceTree = + { + overlays = [ + { + name = "ili9486-overlay"; + # decompiled from mhs35 overlay from: + # https://github.com/goodtft/LCD-show/blob/master/usr/mhs35-overlay.dtb + # with adjustments taken from the piscreen overlay: + # https://github.com/raspberrypi/linux/blob/rpi-6.6.y/arch/arm/boot/dts/overlays/piscreen-overlay.dts + dtsText = '' + /dts-v1/; + /plugin/; + + / { + compatible = "brcm,bcm2711"; + + fragment@0 { + target = <&spi0>; + + __overlay__ { + status = "okay"; + + spidev@0 { + status = "disabled"; + }; + + spidev@1 { + status = "disabled"; + }; + }; + }; + + fragment@1 { + target = <&gpio>; + + __overlay__ { + ili9486_pins: ili9486_pins@0 { + brcm,pins = <17 25 24>; + brcm,function = <0 0 0>; + }; + }; + }; + + fragment@2 { + target = <&spi0>; + + __overlay__ { + #address-cells = <1>; + #size-cells = <0>; + + ili9486: ili9486@0 { + compatible = "ilitek,ili9486"; + reg = <0>; + pinctrl-names = "default"; + pinctrl-0 = <&ili9486_pins>; + + spi-max-frequency = <115000000>; + txbuflen = <0x8000>; + rotate = <90>; + bgr = <0>; + fps = <30>; + buswidth = <8>; + regwidth = <16>; + + reset-gpios = <&gpio 25 1>; + dc-gpios = <&gpio 24 0>; + debug = <0>; + + init = <0x10000f1 0x36 0x04 0x00 0x3c 0x0f 0x8f 0x10000f2 0x18 0xa3 0x12 0x02 0xb2 0x12 0xff 0x10 0x00 0x10000f8 0x21 0x04 0x10000f9 0x00 0x08 0x1000036 0x08 0x10000b4 0x00 0x10000c1 0x41 0x10000c5 0x00 0x91 0x80 0x00 0x10000e0 0x0f 0x1f 0x1c 0x0c 0x0f 0x08 0x48 0x98 0x37 0x0a 0x13 0x04 0x11 0x0d 0x00 0x10000e1 0x0f 0x32 0x2e 0x0b 0x0d 0x05 0x47 0x75 0x37 0x06 0x10 0x03 0x24 0x20 0x00 0x100003a 0x55 0x1000011 0x1000036 0x28 0x20000ff 0x1000029>; + }; + }; + }; + + __overrides__ { + speed = <&ili9486>,"spi-max-frequency:0"; + txbuflen = <&ili9486>,"txbuflen:0"; + rotate = <&ili9486>,"rotate:0", + <&ili9486>,"rotation:0"; + fps = <&ili9486>,"fps:0"; + bgr = <&ili9486>,"bgr:0"; + debug = <&ili9486>,"debug:0"; + }; + }; + ''; + } + ]; + }; +} diff --git a/pkgs/default.nix b/pkgs/default.nix index 7b8a61b..71a7d5c 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -9,4 +9,6 @@ jellyfin-prev = pkgs.jellyfin; jellyfin-web-prev = pkgs.jellyfin-web; }) jellyfin jellyfin-web; + + rpi-fbcp = pkgs.callPackage ./rpi-fbcp.nix {}; } diff --git a/pkgs/rpi-fbcp.nix b/pkgs/rpi-fbcp.nix new file mode 100644 index 0000000..4de2ea6 --- /dev/null +++ b/pkgs/rpi-fbcp.nix @@ -0,0 +1,28 @@ +{ stdenv, fetchFromGitHub, cmake, libraspberrypi, ... }: + +let + rev = "af8d32246c23cb23e4030e6588668a14341f5ddc"; +in +stdenv.mkDerivation { + pname = "rpi-fbcp"; + version = "unstable-${rev}"; + + src = fetchFromGitHub { + inherit rev; + owner = "tasanakorn"; + repo = "rpi-fbcp"; + hash = "sha256-herbC+rh7A8VBjuQjnCI3v4J1zN+PcxjqZ3FyaSonoM="; + }; + + nativeBuildInputs = [ cmake ]; + buildInputs = [ libraspberrypi ]; + + installPhase = '' + runHook preInstall + + mkdir -p $out/bin + cp ./fbcp $out/bin/fbcp + + runHook postInstall + ''; +} |
