Skip to content

Instantly share code, notes, and snippets.

@HelloWorld017
Last active June 7, 2025 17:44
Show Gist options
  • Save HelloWorld017/fe7649dd5e2f69c1a99bd60aa842b795 to your computer and use it in GitHub Desktop.
Save HelloWorld017/fe7649dd5e2f69c1a99bd60aa842b795 to your computer and use it in GitHub Desktop.

Radxa ROCK 5B+

์…‹์—…์„ ์‹œ๋„ํ•˜๋ฉด์„œ ์ฐพ์•„๋ณธ ๋‚ด์šฉ์„ ์ •๋ฆฌํ•ด๋ณธ๋‹ค.
์˜ค๊ฐœ๋…์ด ์žˆ์„ ์ˆ˜ ์žˆ๋‹ค.

๋ถ€ํŒ… ๊ด€๋ จ

๋ถ€ํŒ… ๋งค์ฒด

์ง์ ‘ ๋ถ€ํŒ…์„ ํ—ˆ์šฉํ•˜๋Š” ์ €์žฅ์†Œ: MicroSD / SPI NOR Flash / eMMC (ํ•ด๋‹น ์—†์Œ)

  • MicroSD ์— U-Boot์„ ํฌํ•จํ•œ ์‹œ์Šคํ…œ ์ด๋ฏธ์ง€๋ฅผ ์ ์–ด๋†“์€ ์ƒํƒœ๋กœ ๊ทธ๋ฆฌ๋กœ ๋ฐ”๋กœ ๋ถ€ํŒ…ํ•˜๋Š” ๋ฐฉ๋ฒ•
  • SPI ์— ๋ถ€ํŠธ๋กœ๋” (U-Boot or EDK2)๋ฅผ ์˜ฌ๋ ค์„œ NVMe or MicroSD๋กœ ๋ถ€ํŒ…ํ•˜๋Š” ๋ฐฉ๋ฒ•
  • ๋ถ€ํŒ… ์šฐ์„ ์ˆœ์œ„๋Š” SPI > MicroSD

Maskrom ๋ชจ๋“œ

  • AP ๋‚ด๋ถ€์— ๋ฏธ๋ฆฌ ์ €์žฅ๋œ ์ฝ”๋“œ๋กœ ๋ถ€ํŒ…ํ•˜๋Š” ๋ชจ๋“œ
  • ์ฃผ๋กœ SPI์— ํ”Œ๋ž˜์‹œ ํ•˜๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉํ•˜๋Š” ๋“ฏ ํ•จ
  • ํ”Œ๋ž˜์‹œ ์ˆœ์„œ
    1. rkdeveloptool db๋ฅผ ํ†ตํ•ด SPL Loader๋ฅผ ๋กœ๋”ฉ์‹œ์ผœ์„œ ํ”Œ๋ž˜์‹œ๋ฅผ ํ•  ์ˆ˜ ์žˆ๋Š” ์ƒํƒœ๋กœ ๋งŒ๋“  ํ›„
    2. rkdeveloptool wl ๋กœ SPI์— ํ”Œ๋ž˜์‹œํ•  ์ˆ˜ ์žˆ์Œ

์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ ๋ถ€ํŠธ๋กœ๋”

  • EDK2-rk3588

    • ๊ฐ€์žฅ ์ผ๋ฐ˜์ ์ธ ์ปดํ“จํŒ… ํ™˜๊ฒฝ์— ๊ทผ์ ‘ํ•ด๋ณด์ž„.
    • Rock 5B+ ๋Š” ์•„์ง Bronze Support์ž„.
      • ์ด์Šˆ๋ฅผ ์ฐพ์•„๋ณด๋‹ˆ DMC (Dynamic Memory Controller์ธ ๋“ฏ)๊ฐ€ ์ž‘๋™ํ•˜์ง€ ์•Š๋Š”๋‹ค๋Š” ๋ง์ด ์žˆ์Œ
  • Vendor U-Boot (Download)

    • U-Boot ๋ฒ„์ „์ด ๋‚ฎ๋‹ค๊ณ  ํ•จ
      • ์ปค๋„ ์ด๋ฆ„ ๊ธธ์ด๋‚˜ ์ด๋Ÿฐ ๋ฐ์—์„œ ๋ฌธ์ œ๊ฐ€ ์กฐ๊ธˆ์”ฉ ์žˆ์„ ์ˆ˜ ์žˆ๋‹ค๊ณ  ํ•จ
    • ์ตœ๊ทผ์— ์—…๋ฐ์ดํŠธ๊ฐ€ ๋œ ๊ฒƒ์œผ๋กœ ๋ณด์ž„ (ํ™•์‹ค์น˜ ์•Š์Œ)
  • Close-to-Mainline U-Boot (Artifacts)

    • Collabora ์ธก์—์„œ Upstreaming์„ ์‹œ๋„ํ•˜๊ณ  ์žˆ๋Š” U-Boot

๊ธฐํƒ€ ๋…ธํŠธ

  • MicroSD์— U-Boot์„ ์„ค์น˜ํ•˜๋Š” ๋ฐฉ๋ฒ•๋„ ์žˆ๋‹ค๋Š” ๋“ฏ ํ•˜๋‹ค.
  • U-Boot๋„ UEFI ์ŠคํŽ™์˜ ์ผ๋ถ€๋ฅผ ๊ตฌํ˜„ํ•˜๊ณ  ์žˆ์–ด UEFI๋กœ์„œ ๋ถ€ํŒ…์ด ๊ฐ€๋Šฅํ•˜๋‹ค๋Š” ๋“ฏ ํ•˜๋‹ค.
  • ์‹œ๋ฆฌ์–ผ ์ฝ˜์†”์— ๋ฌธ์ œ๊ฐ€ ์žˆ๋‹ค๋ฉด ์ผ€์ด๋ธ”์„ ์ฒดํฌํ•˜์ž
    • ๊ธฐ๋ณธ baudrate๊ฐ€ 1.5M์ด๋ผ ๊ฐ€์ง€๊ณ  ์žˆ๋Š” ์ผ€์ด๋ธ”๋กœ๋Š” ์•ˆ๋์—ˆ๋‹ค.

์ฐธ์กฐ ๋งํฌ

์ปค๋„ ๊ด€๋ จ

์ž‘์—… ์ˆœ์„œ

U-Boot ์˜ฌ๋ฆฌ๊ธฐ

  1. ๋ ˆํฌ๋ฅผ ํด๋ก ํ•œ๋‹ค.
$ git clone https://gitlab.collabora.com/hardware-enablement/rockchip-3588/u-boot.git
$ git clone https://gitlab.collabora.com/hardware-enablement/rockchip-3588/rkbin.git
  1. ํฌ๋กœ์Šค๋นŒ๋“œ ํ™˜๊ฒฝ์„ ๊ตฌ์ถ•ํ•œ๋‹ค.
let
  nixpkgs = import <nixpkgs> {};
  crosspkgs = import <nixpkgs> {
    crossSystem = { config = "aarch64-unknown-linux-gnu"; };
  };
in
  nixpkgs.mkShell {
    nativeBuildInputs = (with crosspkgs.buildPackages; [
      binutils
      bison
      flex
      gcc
    ]) ++ (with nixpkgs; [
      gnutls
      openssl
      python312
      python312Packages.pip
      python312Packages.pyelftools
      python312Packages.virtualenv
      python312Packages.setuptools
      swig
    ]);
  }
  1. u-boot๋ฅผ ๋นŒ๋“œํ•œ๋‹ค.
$ nix-shell
$ cd u-boot
$ make rock5b-rk3588_defconfig

# ๋นŒ๋“œํ•œ๋‹ค.
$ export ROCKCHIP_TPL=../rkbin/bin/rk35/rk3588_ddr_lp4_2112MHz_lp5_2400MHz_v1.18.bin
$ export BL31=../rkbin/bin/rk35/rk3588_bl31_v1.47.elf
$ make CROSS_COMPILE="aarch64-unknown-linux-gnu-"
$ ls -alh u-boot.idb idbloader.img
-rw-r--r-- 1 nenw nenw 216K May  6 03:33 idbloader.img
-rw-r--r-- 1 nenw nenw 1.5M May  6 03:33 u-boot.itb

# ๊ธฐ์กด ์ด๋ฏธ์ง€์— ๋ฎ์–ด์”Œ์šด๋‹ค.
$ cp ~/rock-5b-spi-image-gd1cf491-20240523-debug.img ./rock-5b-plus-bootloader-20250506.img
$ dd if=idbloader.img of=rock-5b-plus-bootloader-20250506.img seek=64 conv=notrunc
$ dd if=u-boot.itb of=rock-5b-plus-bootloader-20250506.img seek=16384 conv=notrunc

NixOS ์„ค์น˜ ๋””์Šคํฌ ๋งŒ๋“ค๊ธฐ

  1. NixOS Download ์—์„œ Minimal ISO (64-bit ARM) ์„ ๋‹ค์šด๋กœ๋“œํ•œ๋‹ค.
  2. USB์— ์“ด๋‹ค.
$ lsblk

# ์ฃผ์˜! `/dev/sdX` ๋ฅผ ์ด์ „ `lsblk` ์—์„œ ์•Œ์•„๋‚ธ USB์˜ ๋””๋ฐ”์ด์Šค ํŒŒ์ผ๋กœ ๊ต์ฒดํ•œ๋‹ค.
#       ์ž˜๋ชป ์ˆ˜ํ–‰ ์‹œ ์—‰๋šฑํ•œ ๋””์Šคํฌ๊ฐ€ ๋‚ ์•„๊ฐˆ ์ˆ˜ ์žˆ์œผ๋ฏ€๋กœ ์ฃผ์˜ํ•  ๊ฒƒ
$ dd if=nixos-minimal-25.05.802674.7848cd8c982f-aarch64-linux.iso of=/dev/sdX bs=4M status=progress conv=fdatasync
  1. u-boot์˜ ์ด๋ฏธ์ง€๊ฐ€ ํ”Œ๋ž˜์‹œ๋œ SD์นด๋“œ์™€ NixOS ์„ค์น˜ ์ด๋ฏธ์ง€๊ฐ€ ํ”Œ๋ž˜์‹œ๋œ USB๋ฅผ ๊ฝ‚๊ณ  ๋ถ€ํŒ…ํ•˜๋ฉด ๊น”๋”ํ•˜๊ฒŒ ์„ค์น˜ ์ด๋ฏธ์ง€ ๋ถ€ํŒ…์— ์„ฑ๊ณตํ•œ๋‹ค. image
@breuhan
Copy link

breuhan commented May 29, 2025

I followed your instructions, but I end up in a boot loop:

U-Boot SPL 2025.07-rc2-gcf6b761a8782 (Jan 01 1980 - 00:00:00 +0000)
Trying to boot from SPI
Error: -22
Trying to boot from MMC2
spl: mmc init failed with error: -95
Error: -95
Trying to boot from MMC1
Card did not respond to voltage select! : -110
spl: mmc init failed with error: -95
Error: -95
SPL: failed to boot from all boot devices
### ERROR ### Please RESET the board ###

@HelloWorld017
Copy link
Author

HelloWorld017 commented May 30, 2025

@breuhan
You should not follow this guide as this is not a complete guide. I also did not finish all the setup yet.
I'll update the guide whenever there is more progression.


For your error message:
I think your message states the first-stage bootloader (= U-Boot SPL) has been loaded but it had not found the second-stage bootloader (= U-Boot). I've uploaded my build artifact here, so try flashing it directly to the SD Card using balenaEtcher or other tools.

@breuhan
Copy link

breuhan commented May 30, 2025

I was able to resolve my issue by flashing u-boot-rockchip-spi.bin in the same directory into the SPI. Thanks! I'm now able to boot NixOS

@breuhan
Copy link

breuhan commented Jun 7, 2025

Maybe you are interested in that. I created a pkgs/uboot.nix that create a rock-5b-plus-spi.img . This file can be directly flashed to SPI flash.
sudo dd if=rock-5b-plus-spi.img of=/dev/mtd0 bs=1M
It is as close to the vendor firmware as possible.
It can also be flashed via USB-C in maskrom mode.


{
  lib,
  fetchgit,
  src,
  pkgs,
  buildUBoot,
  rkbin,
  ...
}@args:
{
  rock5b_plus_uboot = (
    buildUBoot {
      version = "2025.07";

      src = fetchgit {
        url = "https://gitlab.collabora.com/hardware-enablement/rockchip-3588/u-boot.git";
        branchName = "rockchip";
        hash = "sha256-vTUxTMEwk0RgbLyDF3KhmLJHdKTItS7YKHXRFheRuZs=";
      };

      rkbin = fetchgit {
        url = "https://gitlab.collabora.com/hardware-enablement/rockchip-3588/rkbin.git";
        branchName = "master";
        hash = "sha256-KBmO++Z1AfIKvAmx7CzXScww16Stvq2BWr2raPiR6Q8=";
      };

      patches = [ ];

      extraConfig = ''
        CONFIG_DISPLAY_CPUINFO=y
        CONFIG_DISPLAY_BOARDINFO=y
        CONFIG_DISABLE_CONSOLE=n
        CONFIG_CMD_NVME=y
        CONFIG_BOOTDELAY=5
        CONFIG_CMD_LOG=y
        CONFIG_ENV_IS_NOWHERE=n
        CONFIG_ENV_IS_IN_SPI_FLASH=y
        CONFIG_ENV_SECT_SIZE_AUTO=y
        CONFIG_ENV_OVERWRITE=y
        CONFIG_ENV_SIZE=0x8000
        CONFIG_ENV_OFFSET=0x3F8000
        CONFIG_SYS_SPI_U_BOOT_OFFS=0x800000
        CONFIG_NETCONSOLE=y
      '';
      extraMeta.platforms = [ "aarch64-linux" ];

      defconfig = "rock5b-rk3588_defconfig";
      BL31 = "${rkbin}/bin/rk35/rk3588_bl31_v1.47.elf";
      ROCKCHIP_TPL = rkbin.TPL_RK3588;

      postBuild = ''

        SPI_IMAGE="rock-5b-plus-spi.img"

        dd if=/dev/zero of=$SPI_IMAGE bs=1M count=0 seek=16
        ${pkgs.parted}/bin/parted -s $SPI_IMAGE mklabel gpt
        ${pkgs.parted}/bin/parted -s $SPI_IMAGE unit s mkpart idbloader 64 7167
        ${pkgs.parted}/bin/parted -s $SPI_IMAGE unit s mkpart vnvm 7168 7679
        ${pkgs.parted}/bin/parted -s $SPI_IMAGE unit s mkpart reserved_space 7680 8063
        ${pkgs.parted}/bin/parted -s $SPI_IMAGE unit s mkpart reserved1 8064 8127
        ${pkgs.parted}/bin/parted -s $SPI_IMAGE unit s mkpart uboot_env 8128 8191
        ${pkgs.parted}/bin/parted -s $SPI_IMAGE unit s mkpart reserved2 8192 16383
        ${pkgs.parted}/bin/parted -s $SPI_IMAGE unit s mkpart uboot 16384 32734

        dd if=idbloader.img of=$SPI_IMAGE seek=64 conv=notrunc
        dd if=u-boot.itb of=$SPI_IMAGE seek=16384 conv=notrunc
      '';

      filesToInstall = [
        "idbloader.img"
        "u-boot.itb"
        "rock-5b-plus-spi.img"
        "u-boot-rockchip-spi.bin"
      ];
    }
  );
}

@HelloWorld017
Copy link
Author

Nice work! ๐Ÿ‘ Thank you for reproducible builds!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment