truxnell / nix-config

My nix & nixos home setup
https://truxnell.github.io/nix-config/
MIT License
27 stars 2 forks source link

raspi firmware updater #39

Open truxnell opened 5 months ago

truxnell commented 5 months ago

Enable modular functionality to automatically update raspi eeprom firmware. This should go into /boot along with a config IIRC

truxnell commented 5 months ago

Tried the below but it, and doing it with raspi-eeprom-updater -a -d didnt persist on boot.

  system.activationScripts.firmware-update =
    let
      configTxt = pkgs.writeText "config.txt" ''
        [pi4]
        disable_overscan=1
        [all]
        arm_64bit=1
        enable_uart=1
        avoid_warnings=1
      '';
      bootdir = "/boot";
    in
    ''
      (cd ${pkgs.raspberrypifw}/share/raspberrypi/boot && cp bootcode.bin fixup*.dat start*.elf ${bootdir}/)
      # Add the config
      cp ${configTxt} ${bootdir}/config.txt
      # Add pi4 specific files
      cp ${pkgs.ubootRaspberryPi4_64bit}/u-boot.bin ${bootdir}/u-boot-rpi4.bin
      cp ${pkgs.raspberrypi-armstubs}/armstub8-gic.bin ${bootdir}/armstub8-gic.bin
      cp ${pkgs.raspberrypifw}/share/raspberrypi/boot/bcm2711-rpi-4-b.dtb ${bootdir}/
      # https://github.com/NixOS/nixpkgs/issues/254921
      # BOOTFS=${bootdir} ${pkgs.raspberrypi-eeprom}/bin/rpi-eeprom-update -a
    '';