Hey y’all. Just realized NixOS has “support” for the RPi 4, and have devised a plan as to what my board’s fate will be - nixification.
Until, of course, it didn’t work.
I followed the configuration.nix on the RPi4 wiki page, but am now given the following error:
Waiting for device /dev/disk/by-label/NIXOS_SD to appear...
* lots of irrelevant logs here about xhci_hcd and usb 1-1.3 *
Timed out waiting for device /dev/disk/by-label/NIXOS_SD, trying to mount anyway.
An error occured in stage 1 of the boot process, which must mount the
root filesystem on `/mnt-root` and then start stage 2. Press one
of the following keys:
r) to reboot immediately
*) to ignore the error and continue
After some research, it seems like others have had a similar error even on non-RPi devices - but a lot of the time, they get a few more options: namely, to enter an interactive shell, in which you can just mount /mnt-root yourself and carry on with your day/boot process/evil plan for your nixification.
Unfortunately, I don’t have these options. What makes this even funnier is that when I do try to press r for reboot, nothing happens at all - the key isn’t echoed into stdout, and the device stays exactly how it is. A few seconds ago I was typing away with this keyboard plugged directly into the Pi, but now it seems to not see it.
Thanks for the help in advance, I’d really like to proceed with my evil plan of Pi nixification.
As for the boot problem it seems like the media you are booting from isn’t configured how the configuration.nix you are using is expecting. Or the kernel is having problems finding the media. Is it on USB or SD?
I am curious how you got here. Am I correct in this sequence of events?
You booted the raspberry pi 4 special image
You copied the configuration.nix from the wiki and ran nixos-rebuild switch
The reboot after that failed
Because if that is the case there are only two possible causes.
The special image does not contain a partition with label NIXOS_SD and you need to adjust the configuration.nix
There is a problem with the media. Like the kernel can’t find it which might mean that it is bad or there is some difference in the kernel of special image and the one used by configuration.nix
Re: missing shell option: Perfect. Booted up, reverted to before the broken rebuild, added to my configuration.nix and rebuilt. Time for some juicy answers.
Re: sequence of events: yes precisely. RPi 4 special built image from Hydra, grabbed the configuration.nix from the RPi 4 wiki page, and switched. If I tried to use sudo, I’d get something along the lines of “User is not in the password database”. A quick logout and login would fix it, and it makes sense why. Sadly, a reboot after this came up with this error.
Now, I added these params to my config and rebuilt - now I have two more options!
i) to launch an interactive shell
f) to start an interactive shell having pid 1 (needed if you want to
start stage 2's init manually)
r) ... the usual options ...
The problem is, the system doesn’t seem to be handling my input - no matter what letters I press, nothing happens.
Above the error there are some dmesg-like logs along the lines of:
[ 2.xxxxxx] xhci_hcd error: unexpected setup context command completion code 0x11.
[ 2.yyyyyy] usb 1-1.1: hub failed to enable device, error -22
... the same error a few times ...
[ 4.zzzzzz] usb 1-1-port1: unable to enumerate USB device
... Timed out waiting for device /dev/disk/by-label/NIXOS_SD on /mnt-root/ failed ...
If I unplug and re-plug in my USB receiver, the same log is spat out.
Once I get input and am able to get to a shell, I’ll just ls /dev/disk/by-label and work our way from there.
I am having the exact same problem.
I would like to add that /dev/disk/by-label/NIXOS_SD exists while in the initial system. The error does not occur when on the initial system state, but only after running nixos-rebuild switch for the first time.
Replacing the by-label path with by-uuid or even /dev/mmcblk0p2 does not work either.
It seems like the system cannot even see the devices at that boot stage.
I have also tried adding the /dev/disk/by-label/FIRMWARE partition to my config, but that does not change anything.
Fortunately it is possible to revert to the initial system config using u-boot.
I have also previously tried flashing the image to a usb stick, but it failed in u-boot.
Please note that the line "console=ttyAMA0,115200" in the above config does not enable getty on the gpio serial port because in Raspberry Pi 4 those get the device /dev/ttyS0. (/dev/ttyAMA0 is now something bluetooth related)
Do not enable the kernel console on that device if you want to use it for something else.
Tried this three times now :). Seems fairly similar to the bootstrapping process we used in Gentoo, so I understand the concept. However, I do have a question: how does the first partition get its boot files?
Basically, I followed through the process, but when I unplug my USB and leave my SD in and turn her on, the screen stays blank, and the red light is solid on (green light flashes for a quarter of a second). After some Googling advanced research, it seems like this is because boot can’t be found.
I’m no RPi master, but it seems like we created /dev/mmcblk0p1 but didn’t populate it with boot files?
Oh gosh, I wish this were simpler, I came to Nix so that everything could be done for me, but instead I have to do everything by hand :).
Did you set the boot flag for the efi partition? I always thought that it wouldn’t be necessary for efi types, but I cannot remember if I did it or not.
Sorry, I forgot that in the original post.
i had the same issue.
After 2 days of trying differ things, but then i notice that in the configuration.nix from the wiki page (NixOS on ARM/Raspberry Pi 4 - NixOS Wiki) there is no import of the hardware-configuration.nix like
imports = [
./hardware-configuration.nix
];
so removed the import of hardware-configuration.nix and the pi is booting successfully