add config.txt docs

This commit is contained in:
Travis Staton 2023-03-11 13:14:07 -05:00
parent e7513ab173
commit ed2df925d5
No known key found for this signature in database
GPG key ID: 431DD911A00DAE49

124
README.md
View file

@ -98,6 +98,130 @@ partition.
As noted, the `config.txt` file is generated by the NixOS
configuration and automatically updated on system activation.
The relevant nixos option is
`hardware.raspberry-pi.config`. Configuration is partitioned into
three sections:
1. Base device tree parameters `base-dt-params`
2. Device tree overlays `dt-overlays`
3. Firmware options `options`
Other than that, the format follows pretty closely to the config.txt
format. For example:
```nix
hardware.raspberry-pi.config = {
cm4 = {
options = {
otg_mode = {
enable = true;
value = true;
};
};
};
pi4 = {
options = {
arm_boost = {
enable = true;
value = true;
};
};
dt-overlays = {
vc4-kms-v3d = {
enable = true;
params = { cma-512 = { enable = true; }; };
};
};
};
all = {
options = {
# The firmware will start our u-boot binary rather than a
# linux kernel.
kernel = {
enable = true;
value = "u-boot-rpi-arm64.bin";
};
arm_64bit = {
enable = true;
value = true;
};
enable_uart = {
enable = true;
value = true;
};
avoid_warnings = {
enable = true;
value = true;
};
camera_auto_detect = {
enable = true;
value = true;
};
display_auto_detect = {
enable = true;
value = true;
};
disable_overscan = {
enable = true;
value = true;
};
};
dt-overlays = {
vc4-kms-v3d = {
enable = true;
params = { };
};
};
base-dt-params = {
krnbt = {
enable = true;
value = "on";
};
spi = {
enable = true;
value = "on";
};
};
};
};
```
generates the following config.txt:
```
# This is a generated file. Do not edit!
[all]
arm_64bit=1
avoid_warnings=1
camera_auto_detect=1
disable_overscan=1
display_auto_detect=1
enable_uart=1
kernel=u-boot-rpi-arm64.bin
dtparam=krnbt=on
dtparam=spi=on
dtoverlay=vc4-kms-v3d
dtoverlay=
[cm4]
otg_mode=1
[pi4]
arm_boost=1
dtoverlay=vc4-kms-v3d
dtparam=cma-512
dtoverlay=
```
If you want to preview the generated `config.txt`, you can find
it at the path `config.hardware.raspberry-pi.config-output`. For
example, if you had the above configuration then you could build the
`config.txt` file with:
```
nix build '.#nixosConfigurations.rpi-example.config.hardware.raspberry-pi.config-output'
```
## Firmware partition implementation notes