NixOS on ARM/ODROID-HC4: Difference between revisions

From NixOS Wiki
imported>Erdnaxe
No edit summary
imported>Artemislena
Updated the U-Boot build, which means SATA is working, also added information on the fan
Line 48: Line 48:
# Uncompress the .zst file. One may use the <code>unzstd</code> command (equivalent to <code>zstd -d</code>) on supported machines. The zstd commands can be accessed from the <code>zstd</code> package.
# Uncompress the .zst file. One may use the <code>unzstd</code> command (equivalent to <code>zstd -d</code>) on supported machines. The zstd commands can be accessed from the <code>zstd</code> package.
# Patch this image (.img file) with U-Boot for Odroid HC4. <syntaxhighlight lang="bash">
# Patch this image (.img file) with U-Boot for Odroid HC4. <syntaxhighlight lang="bash">
# Clone content of pull request https://github.com/NixOS/nixpkgs/pull/101454 and build
# Clone content of samueldr's wip/odroidc4 branch, edit the defconfig file, and build
git clone https://github.com/arapov/nixpkgs --depth 1 -b hardkernel && cd nixpkgs
git clone https://github.com/samueldr/nixpkgs --depth 1 -b wip/odroidc4 && cd nixpkgs
test "$(uname)" '==' 'Darwin' && sed -i '' 's/defconfig = "odroid-c4_defconfig"/defconfig = "odroid-hc4_defconfig"/' pkgs/misc/uboot/default.nix || sed -i 's/defconfig = "odroid-c4_defconfig"/defconfig = "odroid-hc4_defconfig"/' pkgs/misc/uboot/default.nix
nix-build -I "nixpkgs=$PWD" -A pkgsCross.aarch64-multiplatform.ubootOdroidC4
nix-build -I "nixpkgs=$PWD" -A pkgsCross.aarch64-multiplatform.ubootOdroidC4
sudo dd if=result/u-boot.bin of=PATH/TO/nixos-sd-image-21.05.XXXX.XXXXXXXX-aarch64-linux.img  conv=fsync,notrunc bs=512 seek=1
sudo dd if=result/u-boot.bin of=PATH/TO/nixos-sd-image-21.05.XXXX.XXXXXXXX-aarch64-linux.img  conv=fsync,notrunc bs=512 seek=1
Line 55: Line 56:
# Flash the modified SD image file (.img) to a microSD card. '''This will erase all the data on the card!'''
# Flash the modified SD image file (.img) to a microSD card. '''This will erase all the data on the card!'''


== Known Problems ==
== Known issues ==
 
=== Fan doesn't work by default ===
=== SATA is not working ===
You need to use software fan control (via <syntaxhighlight>fancontrol</syntaxhighlight>) for this. Add the following to your <syntaxhighlight>configuration.nix</syntaxhighlight>:
 
<syntaxhighlight>
SATA is working on Armbian with mainline kernel and u-boot but not on NixOS 21.05: lspci returns nothing.
# Based on the config from https://www.armbian.com/odroid-hc4/. Made MINTEMP and MAXTEMP a bit more relaxed so the fan doesn't run on idle.
WIP
hardware.fancontrol = {
    enable = true;
    config = ''
    INTERVAL=10
    DEVPATH=hwmon0=devices/virtual/thermal/thermal_zone0 hwmon2=devices/platform/pwm-fan
    DEVNAME=hwmon0=cpu_thermal hwmon2=pwmfan
    FCTEMPS=hwmon2/pwm1=hwmon0/temp1_input
    MINTEMP=hwmon2/pwm1=55
    MAXTEMP=hwmon2/pwm1=65
    MINSTART=hwmon2/pwm1=20
    MINSTOP=hwmon2/pwm1=28
    MINPWM=hwmon2/pwm1=0
    MAXPWM=hwmon2/pwm1=255
    '';
};
</syntaxhighlight>


== Resources ==
== Resources ==

Revision as of 16:27, 14 June 2022

Hardkernel ODROID-HC4
Manufacturer Hardkernel
Architecture ARMv7
Bootloader U-Boot
Boot options SD (SATA?)

Status

Mostly working, but some manual steps needed to get it running.

U-boot support in NixPkgs is currently in review: NixPkgs Pull Request #101454

Board-specific installation notes

Petitboot removal

Petitboot is installed on the SPI memory of the Odroid HC4 from factory. To be able to load an upstreamed version of U-Boot without having to press a hardware button at each boot, you may remove it. Please proceed with caution, this will make Hardkernel images unbootable!

From the Petitboot, go for “Exit to shell” and enter these commands to remove Petitboot:

flash_eraseall /dev/mtd0
flash_eraseall /dev/mtd1
flash_eraseall /dev/mtd2
flash_eraseall /dev/mtd3

This will make your SPI flash memory empty and the device will now start from SD on next boot.

See this Odroid forum topic to restore Petitboot.

NixOS installation

  1. First follow the generic installation steps to get the 21.05 (Latest kernel) installer image.
  2. Uncompress the .zst file. One may use the unzstd command (equivalent to zstd -d) on supported machines. The zstd commands can be accessed from the zstd package.
  3. Patch this image (.img file) with U-Boot for Odroid HC4.
    # Clone content of samueldr's wip/odroidc4 branch, edit the defconfig file, and build
    git clone https://github.com/samueldr/nixpkgs --depth 1 -b wip/odroidc4 && cd nixpkgs
    test "$(uname)" '==' 'Darwin' && sed -i '' 's/defconfig = "odroid-c4_defconfig"/defconfig = "odroid-hc4_defconfig"/' pkgs/misc/uboot/default.nix || sed -i 's/defconfig = "odroid-c4_defconfig"/defconfig = "odroid-hc4_defconfig"/' pkgs/misc/uboot/default.nix
    nix-build -I "nixpkgs=$PWD" -A pkgsCross.aarch64-multiplatform.ubootOdroidC4
    sudo dd if=result/u-boot.bin of=PATH/TO/nixos-sd-image-21.05.XXXX.XXXXXXXX-aarch64-linux.img  conv=fsync,notrunc bs=512 seek=1
    
  4. Flash the modified SD image file (.img) to a microSD card. This will erase all the data on the card!

Known issues

Fan doesn't work by default

You need to use software fan control (via

fancontrol

) for this. Add the following to your

configuration.nix

:

# Based on the config from https://www.armbian.com/odroid-hc4/. Made MINTEMP and MAXTEMP a bit more relaxed so the fan doesn't run on idle.
hardware.fancontrol = {
    enable = true;
    config = ''
    INTERVAL=10
    DEVPATH=hwmon0=devices/virtual/thermal/thermal_zone0 hwmon2=devices/platform/pwm-fan
    DEVNAME=hwmon0=cpu_thermal hwmon2=pwmfan
    FCTEMPS=hwmon2/pwm1=hwmon0/temp1_input
    MINTEMP=hwmon2/pwm1=55
    MAXTEMP=hwmon2/pwm1=65
    MINSTART=hwmon2/pwm1=20
    MINSTOP=hwmon2/pwm1=28
    MINPWM=hwmon2/pwm1=0
    MAXPWM=hwmon2/pwm1=255
    '';
};

Resources