-
-
Notifications
You must be signed in to change notification settings - Fork 664
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
Add Odroid M1 #1269
base: master
Are you sure you want to change the base?
Add Odroid M1 #1269
Changes from all commits
3c45c1e
bea09d6
9b55aa9
8b9cbf8
16e4e72
1fd8cd7
a002c11
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Based on kboot-conf by original authors povik and sstent. | ||
# I'm just porting things over. the original work can be viewed at: | ||
# https://github.com/sstent/nixos-on-odroid-m1 | ||
# https://github.com/povik/nixos-on-odroid-n2 | ||
{ config, pkgs, lib, ... }: | ||
|
||
{ | ||
imports = [ | ||
./kboot-conf | ||
]; | ||
|
||
#boot.loader.grub.enable = false; | ||
boot.loader.kboot-conf.enable = true; | ||
# Use kernel >6.6 The devicetree is missing from kernel versions older than this. | ||
boot.kernelPackages = lib.mkIf (lib.versionOlder pkgs.linux.version "6.6") (lib.mkDefault pkgs.linuxPackages_latest); | ||
boot.supportedFilesystems = lib.mkForce ["btrfs" "cifs" "f2fs" "jfs" "ntfs" "reiserfs" "vfat" "xfs"]; | ||
# I'm not completely sure if some of these could be omitted, | ||
# but want to make sure disk access works | ||
boot.initrd.availableKernelModules = [ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you run There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will try and get back to you. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I ran |
||
"nvme" | ||
"nvme-core" | ||
"phy-rockchip-naneng-combphy" | ||
"phy-rockchip-snps-pcie3" | ||
]; | ||
|
||
# Petitboot uses this port and baud rate on the boards serial port, | ||
# it's probably good to keep the options same for the running | ||
# kernel for serial console access to work well | ||
boot.kernelParams = ["console=ttyS2,1500000"]; | ||
hardware.deviceTree.name = "rockchip/rk3568-odroid-m1.dtb"; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
{ | ||
config, | ||
lib, | ||
pkgs, | ||
... | ||
}: | ||
with lib; let | ||
cfg = config.boot.loader.kboot-conf; | ||
|
||
# The builder used to write during system activation | ||
builder = pkgs.substituteAll { | ||
src = ./generate-kboot-conf.sh; | ||
isExecutable = true; | ||
path = [pkgs.coreutils pkgs.gnused pkgs.gnugrep]; | ||
inherit (pkgs) bash; | ||
}; | ||
# The builder exposed in populateCmd, which runs on the build architecture | ||
populateBuilder = pkgs.buildPackages.substituteAll { | ||
src = ./generate-kboot-conf.sh; | ||
isExecutable = true; | ||
path = with pkgs.buildPackages; [coreutils gnused gnugrep]; | ||
inherit (pkgs.buildPackages) bash; | ||
}; | ||
in { | ||
options = { | ||
boot.loader.kboot-conf = { | ||
enable = mkOption { | ||
default = false; | ||
type = types.bool; | ||
description = '' | ||
Whether to create petitboot-compatible /kboot.conf | ||
''; | ||
}; | ||
configurationLimit = mkOption { | ||
default = 10; | ||
example = 5; | ||
type = types.int; | ||
description = '' | ||
Maximum number of configurations in the generated kboot.conf. | ||
''; | ||
}; | ||
populateCmd = mkOption { | ||
type = types.str; | ||
readOnly = true; | ||
description = '' | ||
Contains the builder command used to populate an image, | ||
honoring all options except the <literal>-c <path-to-default-configuration></literal> | ||
argument. | ||
Useful to have for sdImage.populateRootCommands | ||
''; | ||
}; | ||
}; | ||
}; | ||
config = let | ||
args = "-g ${toString cfg.configurationLimit} -n ${config.hardware.deviceTree.name}"; | ||
in | ||
mkIf cfg.enable { | ||
system.build.installBootLoader = lib.mkForce "${builder} ${args} -c"; | ||
system.boot.loader.id = "kboot-conf"; | ||
boot.loader.kboot-conf.populateCmd = "${populateBuilder} ${args}"; | ||
}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#! @bash@/bin/sh -e | ||
|
||
shopt -s nullglob | ||
|
||
export PATH=/empty | ||
for i in @path@; do PATH=$PATH:$i/bin; done | ||
|
||
usage() { | ||
echo "usage: $0 -c <path-to-default-configuration> -n <dtbName> [-g <num-generations>] [-d <target>]" >&2 | ||
exit 1 | ||
} | ||
|
||
target=/kboot.conf | ||
default= # Default configuration | ||
numGenerations=0 # Number of other generations to include in the menu | ||
|
||
while getopts "t:c:d:g:n:" opt; do | ||
case "$opt" in | ||
c) default="$OPTARG" ;; | ||
g) numGenerations="$OPTARG" ;; | ||
d) target="$OPTARG" ;; | ||
n) dtbName="$OPTARG" ;; | ||
\?) usage ;; | ||
esac | ||
done | ||
|
||
[ "$default" = "" -o "$dtbName" = "" ] && usage | ||
|
||
tmp=$target.tmp | ||
|
||
# Echo out an kboot.conf menu entry | ||
addEntry() { | ||
local path=$(readlink -f "$1") | ||
local tag="$2" # Generation number or 'default' | ||
|
||
if ! test -e $path/kernel -a -e $path/initrd; then | ||
return | ||
fi | ||
|
||
timestampEpoch=$(stat -L -c '%Z' $path) | ||
timestamp=$(date "+%Y-%m-%d %H:%M" -d @$timestampEpoch) | ||
nixosLabel="$(cat $path/nixos-version)" | ||
extraParams="$(cat $path/kernel-params)" | ||
|
||
local kernel=$(readlink -f "$path/kernel") | ||
local initrd=$(readlink -f "$path/initrd") | ||
local dtbs=$(readlink -f "$path/dtbs") | ||
|
||
local id="nixos-$tag--$nixosLabel" | ||
|
||
if [ "$tag" = "default" ]; then | ||
echo "default=$id" | ||
fi | ||
|
||
echo -n "$id='" | ||
echo -n "$kernel initrd=$initrd dtb=$dtbs/$dtbName " | ||
echo -n "systemConfig=$path init=$path/init $extraParams" | ||
echo "'" | ||
} | ||
|
||
addEntry $default default >> $tmp | ||
|
||
if [ "$numGenerations" -gt 0 ]; then | ||
# Add up to $numGenerations generations of the system profile to the menu, | ||
# in reverse (most recent to least recent) order. | ||
for generation in $( | ||
(cd /nix/var/nix/profiles && ls -d system-*-link) \ | ||
| sed 's/system-\([0-9]\+\)-link/\1/' \ | ||
| sort -n -r \ | ||
| head -n $numGenerations); do | ||
link=/nix/var/nix/profiles/system-$generation-link | ||
addEntry $link $generation | ||
done >> $tmp | ||
fi | ||
|
||
mv -f $tmp $target |
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.
This can be potentially dangerous if other module try to add something. Why is it needed for
linuxPackages_latest
? Nothing should add zfs by default.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.
I don't think it'd be necessary for
linuxPackages_latest
, I'll do some tests and removeboot.supportedFilesystems
.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.
Removing the
boot.supportedFilesystems
line breaks the boot flow and unfortunately I haven't figured out why yet. So I've put it back for the time being.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.
Can you describe what breaks?