NixOS on ARM/Raspberry Pi 5: Difference between revisions

m Highlight important sentences
m Fix formatting
Line 42: Line 42:
[https://de.wikipedia.org/wiki/One_Time_Programmable One-Time-Programmable memory (OTP)]
[https://de.wikipedia.org/wiki/One_Time_Programmable One-Time-Programmable memory (OTP)]
so it cannot be changed anymore. It's '''only able to load the next second-stage boot loader below''', and reset it in case you have messed up.
so it cannot be changed anymore. It's '''only able to load the next second-stage boot loader below''', and reset it in case you have messed up.
See the [https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#first-stage-bootloader official documentation].
See the [https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#first-stage-bootloader official documentation].


Nothing to adapt here.
Nothing to adapt here.


2. '''EEPROM boot loader''': The second-stage boot loader comes built-in on the Pi in a bit larger, rewriteable
2. '''EEPROM boot loader''': The second-stage boot loader comes built-in on the Pi in a bit larger, rewriteable
[https://en.wikipedia.org/wiki/EEPROM EEPROM] memory
[[wikipedia:EEPROM|EEPROM]] memory
'''This loader is also very limited is only able to search for and start yet another, third-stage boot loader from other  
'''This loader is also very limited is only able to search for and start yet another, third-stage boot loader from other '''
storage hardware like an SD card, an NVME SSD''', an USB disk, or from the network.
storage hardware like an SD card, an NVME SSD''', an USB disk, or from the network.'''
 
This loader (as many other second-stage boot loaders of other devices) is so size-constraint that it only contains  
This loader (as many other second-stage boot loaders of other devices) is so size-constraint that it only contains  
the bare mimum code to be able to read from an FAT formatted partition. That's why you see and want a separate small
the bare mimum code to be able to read from an FAT formatted partition. That's why you see and want a separate small
Line 56: Line 59:


See the [https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#second-stage-bootloader official documentation].
See the [https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#second-stage-bootloader official documentation].
See [https://github.com/raspberrypi/rpi-eeprom/releases EEPROM image releases] for improved and wider hardware support.
See [https://github.com/raspberrypi/rpi-eeprom/releases EEPROM image releases] for improved and wider hardware support.
This boot loader can be updated via the <code>rpi-eeprom-update</code> terminal tool
This boot loader can be updated via the <code>rpi-eeprom-update</code> terminal tool
Line 65: Line 69:
[https://github.com/raspberrypi/firmware/issues/1857 feature request to support smaller
[https://github.com/raspberrypi/firmware/issues/1857 feature request to support smaller
third-stage boot loaders in this second-stage].
third-stage boot loaders in this second-stage].


3. '''Firmware boot loader''': The third-stage boot loader is loaded from the first partition (usually called <code>/boot</code>)
3. '''Firmware boot loader''': The third-stage boot loader is loaded from the first partition (usually called <code>/boot</code>)
Line 101: Line 103:
and a <code>config.txt</code> file with a line <code>armstub=RPI_EFI.fd</code>
and a <code>config.txt</code> file with a line <code>armstub=RPI_EFI.fd</code>
which instructs the EEPROM boot loader to load our EDK2 boot loader instead.
which instructs the EEPROM boot loader to load our EDK2 boot loader instead.
See the [https://github.com/worproject/rpi5-uefi EDK2 for Pi 5 Github project]; the releases already
 
contain both these files.
See the [https://github.com/worproject/rpi5-uefi EDK2 for Pi 5 Github project]; the releases already contain both of these files.
 
See a [https://github.com/NixOS/nixpkgs/issues/260754#issuecomment-1908664693 guide on how to setup partitions and these files].
See a [https://github.com/NixOS/nixpkgs/issues/260754#issuecomment-1908664693 guide on how to setup partitions and these files].


2. '''Install systemd-boot, kernel and NixOS''':
2. '''Install systemd-boot, kernel and NixOS''':
The rest is usual NixOS installation on a second partition with the caveat to select a Linux kernel that supports the Pi 5;
 
The rest is usual NixOS installation on a second partition with the caveat to '''select a Linux kernel that supports the Pi 5''';
a suitable kernel can be created using [https://gitlab.com/vriska/nix-rpi5/-/blob/main/linux-rpi.nix leo60228's flake] until
a suitable kernel can be created using [https://gitlab.com/vriska/nix-rpi5/-/blob/main/linux-rpi.nix leo60228's flake] until
that [https://github.com/NixOS/nixpkgs/pull/284391 Pi 5 compatible Linux kernel is available in Nixos-hardware].
that [https://github.com/NixOS/nixpkgs/pull/284391 Pi 5 compatible Linux kernel is available in Nixos-hardware].
Follow [https://github.com/NixOS/nixpkgs/issues/260754#issuecomment-1936211154 this guide] to build
Follow [https://github.com/NixOS/nixpkgs/issues/260754#issuecomment-1936211154 this guide] to build
a NixOS system closure that you can install manually onto the Pi with a <code>nixos-install</code> call.
a NixOS system closure that you can install manually onto the Pi with a <code>nixos-install</code> call.
Line 118: Line 123:
the [https://docs.kernel.org/admin-guide/binfmt-misc.html binfmt] kernel feature
the [https://docs.kernel.org/admin-guide/binfmt-misc.html binfmt] kernel feature
(enabled with setting <code>boot.binfmt.emulatedSystems = [ "aarch64-linux" ];</code>) using QEMU virtualization
(enabled with setting <code>boot.binfmt.emulatedSystems = [ "aarch64-linux" ];</code>) using QEMU virtualization
on any NixOS computer(veeeeerry slow)  
on any NixOS computer(veeeeerry slow)


Missing:
Missing: