|
| 1 | +# Creating an installation SD card image |
| 2 | + |
| 3 | +Create and customize a `flake.nix` file: |
| 4 | + |
| 5 | +```nix |
| 6 | +{ |
| 7 | + inputs = { |
| 8 | + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; |
| 9 | + nixos-hardware.url = "github:nixos/nixos-hardware"; |
| 10 | + }; |
| 11 | +
|
| 12 | + outputs = { nixpkgs, nixos-hardware, ... }: |
| 13 | + let |
| 14 | + supportedSystems = [ |
| 15 | + "x86_64-linux" |
| 16 | + "aarch64-linux" |
| 17 | + "riscv64-linux" |
| 18 | + "x86_64-darwin" |
| 19 | + "aarch64-darwin" |
| 20 | + ]; |
| 21 | + forAllSupportedSystems = nixpkgs.lib.genAttrs supportedSystems; |
| 22 | + in |
| 23 | + { |
| 24 | + packages = forAllSupportedSystems (system: rec { |
| 25 | + default = sd-image; |
| 26 | + sd-image = (import "${nixpkgs}/nixos" { |
| 27 | + configuration = { |
| 28 | + imports = [ |
| 29 | + "${nixos-hardware}/orange-pi/5-max/sd-image-installer.nix" |
| 30 | + ]; |
| 31 | +
|
| 32 | + nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (nixpkgs.lib.getName pkg) [ |
| 33 | + "orangepi-firmware" |
| 34 | + "mali-g610-firmware" |
| 35 | + ]; |
| 36 | +
|
| 37 | + # If you want to use ssh set a password |
| 38 | + # users.users.nixos.password = "super secure password"; |
| 39 | + # OR add your public ssh key |
| 40 | + # users.users.nixos.openssh.authorizedKeys.keys = [ "ssh-rsa ..." ]; |
| 41 | +
|
| 42 | + nixpkgs.buildPlatform.system = system; |
| 43 | + nixpkgs.hostPlatform.system = "aarch64-linux"; |
| 44 | +
|
| 45 | + system.stateVersion = "24.11"; |
| 46 | + }; |
| 47 | + inherit system; |
| 48 | + }).config.system.build.sdImage; |
| 49 | + }); |
| 50 | + }; |
| 51 | +} |
| 52 | +``` |
| 53 | + |
| 54 | +Then build the image by running `nix build .#` in the same folder. |
| 55 | + |
| 56 | +## Flashing image |
| 57 | +Replace `/dev/sdX` with the device name of your sd card. |
| 58 | +```sh |
| 59 | +zstdcat result/sd-image/nixos-sd-image-*-orange-pi-5-max.img.zst | sudo dd status=progress bs=8M of=/dev/sdX |
| 60 | +``` |
| 61 | + |
| 62 | +# Updating the bootloader |
| 63 | +Install the enable the update scripts |
| 64 | +```nix |
| 65 | +hardware.orange-pi."5-max".uboot.updater.enable = true; |
| 66 | +``` |
| 67 | + |
| 68 | +uart debugging options are applied to the bootloader installed by the firmware update script |
| 69 | +```nix |
| 70 | +hardware.orange-pi."5-max".uartDebug = { |
| 71 | + enable = true; # enabled by default for debugging |
| 72 | + baudRate = 57600; # default is 1500000 |
| 73 | +}; |
| 74 | +``` |
| 75 | + |
| 76 | +## SD-Card |
| 77 | +Run as root |
| 78 | +``` sh |
| 79 | +orangepi5max-firmware-update-sd |
| 80 | +``` |
| 81 | +## SPI Flash |
| 82 | +Run as root |
| 83 | +``` sh |
| 84 | +orangepi5max-firmware-update-flash |
| 85 | +``` |
0 commit comments