Merge pull request #1747 from joshbuker/hardkernel/odroid-m1

Add ODroid M1
This commit is contained in:
Jörg Thalheim 2026-02-15 15:49:46 +00:00 committed by GitHub
commit f9b0314599
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 286 additions and 0 deletions

View file

@ -400,6 +400,7 @@ See code for all available configurations.
| [Hardkernel Odroid HC4](hardkernel/odroid-hc4/default.nix) | `<nixos-hardware/hardkernel/odroid-hc4>` | `hardkernel-odroid-hc4` |
| [Hardkernel Odroid H3](hardkernel/odroid-h3/default.nix) | `<nixos-hardware/hardkernel/odroid-h3>` | `hardkernel-odroid-h3` |
| [Hardkernel Odroid H4](hardkernel/odroid-h4/default.nix) | `<nixos-hardware/hardkernel/odroid-h4>` | `hardkernel-odroid-h4` |
| [Hardkernel Odroid M1](hardkernel/odroid-m1/default.nix) | `<nixos-hardware/hardkernel/odroid-m1>` | `hardkernel-odroid-m1` |
| [Olimex TERES-I](olimex/teres_i) | `<nixos-hardware/olimex/teres_i>` | `olimex-teres_i` |
| [Omen 14-fb0798ng](omen/14-fb0798ng) | `<nixos-hardware/omen/14-fb0798ng>` | `omen-14-fb0798ng` |
| [Omen 15-ce002ns](omen/15-ce002ns) | `<nixos-hardware/omen/15-ce002ns>` | `omen-15-ce002ns` |

View file

@ -374,6 +374,7 @@
hardkernel-odroid-hc4 = import ./hardkernel/odroid-hc4;
hardkernel-odroid-h3 = import ./hardkernel/odroid-h3;
hardkernel-odroid-h4 = import ./hardkernel/odroid-h4;
hardkernel-odroid-m1 = import ./hardkernel/odroid-m1;
omen-14-fb0798ng = import ./omen/14-fb0798ng;
omen-15-ce002ns = import ./omen/15-ce002ns;
omen-15-en0010ca = import ./omen/15-en0010ca;

View file

@ -0,0 +1,100 @@
# ODroid M1
Hardware support for the Hardkernel ODroid M1: https://www.hardkernel.com/shop/odroid-m1-with-8gbyte-ram/
## Building an SD Card Image
To create an initial SD card image for installation:
```nix
# flake.nix
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
nixos-hardware.url = "github:nixos/nixos-hardware/master";
};
outputs = { self, nixpkgs, nixos-hardware }: rec {
nixosConfigurations.m1 = nixpkgs.lib.nixosSystem {
modules = [
"${nixpkgs}/nixos/modules/installer/sd-card/sd-image-aarch64.nix"
nixos-hardware.nixosModules.hardkernel-odroid-m1
./sdimage.nix
{
nixpkgs.hostPlatform.system = "aarch64-linux";
# Uncomment if cross-compiling from x86_64:
# nixpkgs.buildPlatform.system = "x86_64-linux";
}
];
};
images.m1 = nixosConfigurations.m1.config.system.build.sdImage;
};
}
```
```nix
# sdimage.nix
{ config, ... }:
{
imports = [ ./common.nix ];
sdImage = {
compressImage = false;
# Required for the system to boot
populateRootCommands = ''
${config.boot.loader.petitboot.populateCmd} -c ${config.system.build.toplevel} -d ./files/kboot.conf
'';
};
}
```
```nix
# common.nix
{ pkgs, ... }:
{
services.openssh.enable = true;
environment.systemPackages = [ pkgs.git ];
users.users.odroid = {
isNormalUser = true;
extraGroups = [ "wheel" ];
initialPassword = "odroid";
# openssh.authorizedKeys.keys = [ "ssh-ed25519 AAAA..." ];
};
}
```
Build with:
```sh
nix build .#images.m1
```
## Ongoing Configuration
After booting the SD card image, run `nixos-generate-config` to generate
`hardware-configuration.nix` for your system. Then set up your configuration
flake:
```nix
# flake.nix
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
nixos-hardware.url = "github:nixos/nixos-hardware/master";
};
outputs = { nixpkgs, nixos-hardware, ... }: {
nixosConfigurations.m1 = nixpkgs.lib.nixosSystem {
modules = [
nixos-hardware.nixosModules.hardkernel-odroid-m1
./common.nix
./configuration.nix
./hardware-configuration.nix
];
};
};
}
```
The module configures petitboot as the boot loader, so `nixos-rebuild switch`
works as usual.

View file

@ -0,0 +1,31 @@
{
config,
pkgs,
lib,
...
}:
{
imports = [
./petitboot
];
# Enable petitboot support.
boot.loader.petitboot.enable = lib.mkForce true;
# `nixos-rebuild` fails unless grub is explicitly disabled.
boot.loader.grub.enable = lib.mkForce false;
boot.initrd.availableKernelModules = [
"nvme"
];
# Petitboot uses this port and baud rate on the board's 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";
# FIXME: The serial terminal does seem to throw random errors still, but that
# doesn't appear to crash anything. May need adjusted if you're
# actually using the GPIO.
}

View file

@ -0,0 +1,77 @@
{
config,
lib,
pkgs,
...
}:
let
cfg = config.boot.loader.petitboot;
args = "-g ${toString cfg.configurationLimit} -n ${config.hardware.deviceTree.name}";
# The installer used when running nixos-rebuild switch or similar
installer = pkgs.replaceVarsWith {
src = ./install-petitboot.sh;
replacements = {
bash = pkgs.bash;
path = lib.makeBinPath [
pkgs.coreutils
pkgs.gnused
pkgs.gnugrep
];
};
name = "install-petitboot";
isExecutable = true;
};
# The installer used to write to SD card images
sdImageInstaller = pkgs.buildPackages.replaceVarsWith {
src = ./install-petitboot.sh;
replacements = {
bash = pkgs.buildPackages.bash;
path = lib.makeBinPath [
pkgs.buildPackages.coreutils
pkgs.buildPackages.gnused
pkgs.buildPackages.gnugrep
];
};
name = "install-petitboot-sd-image";
isExecutable = true;
};
in
{
options = {
boot.loader.petitboot = {
enable = lib.mkOption {
default = false;
type = lib.types.bool;
description = ''
Whether to enable the Petitboot bootloader.
'';
};
configurationLimit = lib.mkOption {
default = 10;
example = 5;
type = lib.types.int;
description = ''
Maximum number of configurations to display when booting.
'';
};
populateCmd = lib.mkOption {
type = lib.types.str;
readOnly = true;
description = ''
Contains the script used to populate petitboot when building an image.
Primarily used for sdImage.populateRootCommands.
'';
};
};
};
config = lib.mkIf cfg.enable {
system.build.installBootLoader = lib.mkForce "${installer} ${args} -c";
system.boot.loader.id = "petitboot";
boot.loader.petitboot.populateCmd = "${sdImageInstaller} ${args}";
};
}

View file

@ -0,0 +1,76 @@
#! @bash@/bin/bash -e
shopt -s nullglob
export PATH="/empty:@path@"
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 "'"
}
echo "# Auto-generated by install-petitboot.sh, do not edit or remove" > $tmp
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