New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Finish stage-0 boot features #300
Finish stage-0 boot features #300
Conversation
But why? Multiple reasons: - generation kernel does not work as expected - booting a boot.img with an experimental kernel I'm sure there's other reasons too. Fixes NixOS#266
For now, device-name... but see following commit.
The tool is intended to be used to produce a list of "compatible strings", mapped to their dtb paths.
Will be used by stage-0 to forward nodes that are required.
Otherwise array values forwarded using the `fdt-forward` helper will be broken when items are > 127 due to the sign.
%Q{/ { mobile-nixos,stage-0,timestamp = #{Time.now.to_s.to_json}; };}, | ||
%Q{/ { mobile-nixos,stage-0,uname = #{`uname -a`.to_json}; };}, | ||
%Q{/ { mobile-nixos,stage-0,uptime = #{`uptime`.to_json}; };}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to_json
?
Because it will produce and escape strings well enough for use inside DTS files. The required escapes are basically compatible.
Why shell script for Why shell script for |
In NixOS#300 I "fixed" stage-0 by adding a switch to toggle between it being enabled and disabled in the recovery menu. *That* works as expected. In 2a46962 one can observe that the `#will_kexec?` method will use data that will only come from the `choice` made from the recovery interface. The `@use_generation_kernel` member is not set at any other point. With ruby semantics, this means that the `if` is false, so *unless* you choose to boot using the recovery menu, it will never trigger `kexec`. Why has this gone through this way? Most likely because my main testing target was configured so it *always* went to the recovery menu at the time, meaning that I never saw the default behaviour.
In NixOS#300 I "fixed" stage-0 by adding a switch to toggle between it being enabled and disabled in the recovery menu. *That* works as expected. In 2a46962 one can observe that the `#will_kexec?` method will use data that will only come from the `choice` made from the recovery interface. The `@use_generation_kernel` member is not set at any other point. With ruby semantics, this means that the `if` is false, so *unless* you choose to boot using the recovery menu, it will never trigger `kexec`. Why has this gone through this way? Most likely because my main testing target was configured so it *always* went to the recovery menu at the time, meaning that I never saw the default behaviour.
In NixOS#300 I "fixed" stage-0 by adding a switch to toggle between it being enabled and disabled in the recovery menu. *That* works as expected. In 2a46962 one can observe that the `#will_kexec?` method will use data that will only come from the `choice` made from the recovery interface. The `@use_generation_kernel` member is not set at any other point. With ruby semantics, this means that the `if` is false, so *unless* you choose to boot using the recovery menu, it will never trigger `kexec`. Why has this gone through this way? Most likely because my main testing target was configured so it *always* went to the recovery menu at the time, meaning that I never saw the default behaviour.
In NixOS#300 I "fixed" stage-0 by adding a switch to toggle between it being enabled and disabled in the recovery menu. *That* works as expected. In 2a46962 one can observe that the `#will_kexec?` method will use data that will only come from the `choice` made from the recovery interface. The `@use_generation_kernel` member is not set at any other point. With ruby semantics, this means that the `if` is false, so *unless* you choose to boot using the recovery menu, it will never trigger `kexec`. Why has this gone through this way? Most likely because my main testing target was configured so it *always* went to the recovery menu at the time, meaning that I never saw the default behaviour.
We were left with the following issues to deal with:
kexec --dtb
parameter #264This PR implements both features.
Skip generation kernel
It is possible to continue booting with the kernel used to boot the stage-0 bootloader. It will be useful for the three following scenarios:
Use generation DTB
Self-explanatory... Or is it?
Each generation could have their own DTB, sometimes with fixes. Re-installing the bootloader to use the fresher DTB is not really a nice thing to have to do.
This change makes it so the call to
kexec
uses the--dtb
flag.But wait, there's more!
The kernel assumes some entries will be added to the FDT (in-memory device tree), like the
/memory
node.kexec
does nothing to help you forward required entries.This is where
fdt-forward
comes into play. It is used to get the nodes and properties from the running system.For the pinephone, you can observe it forwards a property for the Wi-Fi adapter mac address. The bootloader is expected to add a few properties like this depending on the device.
Finally, since we can, let's add some nodes about the current stage-0 boot. This is not strictly needed, but it the basic boolean node can be used as a method to confirm kexec was used. We can also add other properties if it ends up being useful.
fdt-forward?
Are you concerned about what seems like a weird script? I understand. In the end it is much easier to deal with than having to work with libfdt in C or with other language bindings.
I am open to contributions that allows doing the same kind of manipulations. The basic requirements are:
The header and to_dtb features are only for convenience.
For the time being, this is not perfect, but totally does what is needed.