NixOS on ARM/ODROID-HC4: Difference between revisions

From NixOS Wiki
imported>Artemislena
m Fixed a mistake regarding the architecture
imported>Erdnaxe
Link to nixos-hardware
 
(4 intermediate revisions by 2 users not shown)
Line 14: Line 14:
|-
|-
!Boot options
!Boot options
|SD (SATA?)
|microSD (SATA?)
|}
|}
</div>
</div>
Line 45: Line 45:
=== NixOS installation ===
=== NixOS installation ===


# First follow the [[NixOS_on_ARM#Installation|generic installation steps]] to get the '''21.05 (Latest kernel)''' installer image.
# First follow the [[NixOS_on_ARM#Installation|generic installation steps]] to get the latest stable installer image.
# 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">
Line 57: Line 57:


== Known issues ==
== Known issues ==
=== Fan doesn't work by default ===
=== Fan doesn't work by default ===
You need to use software fan control (via <syntaxhighlight>fancontrol</syntaxhighlight>) for this. Add the following to your <syntaxhighlight>configuration.nix</syntaxhighlight>:
You need to use software fan control (via <code>fancontrol</code>) for this.
<syntaxhighlight>
You may refer to [[https://github.com/NixOS/nixos-hardware/blob/master/hardkernel/odroid-hc4/default.nix nixos-hardware Odroid HC4 module]] for <code>fancontrol</code> configuration.
# 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 = {
== No HDMI audio by default ==
    enable = true;
 
    config = ''
After enabling ALSA you should see a sound card named "ODROID-HC4". Audio is not correctly routed by default so you might need to open alsa-mixer and change:
    INTERVAL=10
* <code>FRDDR_A SINK 1 SEL</code> to <code>OUT 1</code>
    DEVPATH=hwmon0=devices/virtual/thermal/thermal_zone0 hwmon2=devices/platform/pwm-fan
* <code>FRDDR_A SRC 1 EN</code> to on
    DEVNAME=hwmon0=cpu_thermal hwmon2=pwmfan
* <code>TDMOUT_B SRC SEL</code> to <code>IN 0</code>
    FCTEMPS=hwmon2/pwm1=hwmon0/temp1_input
* <code>TOHDMITX</code> to on
    MINTEMP=hwmon2/pwm1=55
* <code>TOHDMITX I2S SRC</code> to <code>I2S B</code>
    MAXTEMP=hwmon2/pwm1=65
 
    MINSTART=hwmon2/pwm1=20
After these changes, <code>speaker-test -c 2</code> should output white noise.
    MINSTOP=hwmon2/pwm1=28
    MINPWM=hwmon2/pwm1=0
    MAXPWM=hwmon2/pwm1=255
    '';
};
</syntaxhighlight>


== Resources ==
== Resources ==

Latest revision as of 10:15, 9 April 2023

Hardkernel ODROID-HC4
Manufacturer Hardkernel
Architecture AArch64
Bootloader U-Boot
Boot options microSD (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 latest stable 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. You may refer to [nixos-hardware Odroid HC4 module] for fancontrol configuration.

No HDMI audio by default

After enabling ALSA you should see a sound card named "ODROID-HC4". Audio is not correctly routed by default so you might need to open alsa-mixer and change:

  • FRDDR_A SINK 1 SEL to OUT 1
  • FRDDR_A SRC 1 EN to on
  • TDMOUT_B SRC SEL to IN 0
  • TOHDMITX to on
  • TOHDMITX I2S SRC to I2S B

After these changes, speaker-test -c 2 should output white noise.

Resources