ROCKPro64

De WikiPeida
Revisão em 21h12min de 7 de março de 2026 por Falso (discussão | contribuições)
(dif) ← Revisão anterior | Revisão atual (dif) | Revisão seguinte → (dif)
Ir para a navegação Ir para a procura

Requirements

Gentoo

crossdev -P -v -t aarch64-unknown-linux-gnu
crossdev -P -v -t arm-none-eabi
PYTHON=python2 emerge u-boot-tools

ArchLinux

pacman -S uboot-tools aarch64-linux-gnu-binutils aarch64-linux-gnu-gcc aarch64-linux-gnu-glibc aarch64-linux-gnu-linux-api-headers arm-none-eabi-binutils arm-none-eabi-gcc arm-none-eabi-newlib

Prepare card

Clean

Write zeros to the start of the card to make sure it doesn't have stuff from another bootloader.

dd if=/dev/zero of=/dev/sdX bs=1M count=8

Create partitions

Use 32768 as the first sector for the first partition.

fdisk /dev/sdX

Create filesystem

mkfs.ext4 -O ^metadata_csum /dev/sdX1
mkswap /dev/sdX2

Copy Userland

Mount filesystem

mkdir /mnt/rockpro64
mount /dev/sdX1 /mnt/rockpro64
mkdir ~/rockpro64
cd ~/rockpro64

ArchLinux

wget http://archlinuxarm.org/os/ArchLinuxARM-aarch64-latest.tar.gz
bsdtar -xpf ArchLinuxARM-aarch64-latest.tar.gz -C /mnt/rockpro64

Gentoo

Download the most recent from http://distfiles.gentoo.org/experimental/arm64/

wget http://distfiles.gentoo.org/experimental/arm64/stage3-arm64-????????.tar.bz2
tar xfa stage3-arm64-????????.tar.bz2 -C /mnt/rockpro64

fstab

Edit /mnt/rockpro64/etc/fstab and use the following:

<file system>          <dir>   <type>  <options>               <dump>  <pass>
/dev/mmcblk0p1          /       ext4    defaults,noatime        0       1
/dev/mmcblk0p2          none    swap    defaults                0       0

boot.scr

Create the file /mnt/rockpro64/boot/boot.cmd with:

# MAC address (use spaces instead of colons)
setenv macaddr da 19 c8 7a 6d f4

part uuid ${devtype} ${devnum}:${bootpart} uuid
setenv bootargs console=ttyS2,1500000 root=PARTUUID=${uuid} rw rootwait earlycon=uart8250,mmio32,0xff1a0000
setenv fdtfile rockchip/rk3399-rockpro64.dtb

if load ${devtype} ${devnum}:${bootpart} ${kernel_addr_r} /boot/Image; then
  if load ${devtype} ${devnum}:${bootpart} ${fdt_addr_r} /boot/dtbs/${fdtfile}; then
    fdt addr ${fdt_addr_r}
    fdt resize
    fdt set /ethernet@ff540000 local-mac-address "[${macaddr}]"
    if load ${devtype} ${devnum}:${bootpart} ${ramdisk_addr_r} /boot/initramfs-linux.img; then
      booti ${kernel_addr_r} ${ramdisk_addr_r}:${filesize} ${fdt_addr_r};
    else
      booti ${kernel_addr_r} - ${fdt_addr_r};
    fi;
  fi;
fi

And run mkimage to create boot.scr.

cd /mnt/rockpro64/boot
mkimage -A arm -O linux -T script -C none -n "ROCKPro64 boot script" -d boot.cmd boot.scr

ARM Trusted Firmware

Create bl31.elf.

cd ~/rockpro64
git clone https://github.com/ARM-software/arm-trusted-firmware.git arm-trusted-firmware
cd arm-trusted-firmware
make CROSS_COMPILE=aarch64-unknown-linux-gnu- PLAT=rk3399 DEBUG=1 bl31

U-Boot

Clone the repository.

cd ~/rockpro64
git clone git://git.denx.de/u-boot.git u-boot
cd u-boot

Copy bl31.elf from ARM Trusted Firmware.

cp ../arm-trusted-firmware/build/rk3399/debug/bl31/bl31.elf .

Build U-boot.

make ARCH=arm CROSS_COMPILE=aarch64-unknown-linux-gnu- -j4 rockpro64-rk3399_defconfig
make ARCH=arm CROSS_COMPILE=aarch64-unknown-linux-gnu- -j4

Build idbloader.img.

./tools/mkimage -n rk3399 -T rksd -d tpl/u-boot-tpl.bin idbloader.img
cat spl/u-boot-spl.bin >> idbloader.img

Build uboot.itb.

make ARCH=arm CROSS_COMPILE=aarch64-unknown-linux-gnu- -j4 u-boot.itb

Flash idbloader.img and u-boot.itb to the card.

dd if=idbloader.img of=/dev/sdX seek=64 conv=notrunc
dd if=u-boot.itb of=/dev/sdX seek=16384 conv=notrunc

Kernel

cd ~/rockpro64
git clone https://github.com/ayufan-rock64/linux-mainline-kernel.git linux
cd linux
make ARCH=arm64 CROSS_COMPILE=aarch64-unknown-linux-gnu- rockchip_linux_defconfig
make ARCH=arm64 CROSS_COMPILE=aarch64-unknown-linux-gnu- Image dtbs modules -j4
make ARCH=arm64 CROSS_COMPILE=aarch64-unknown-linux-gnu- INSTALL_MOD_PATH=/mnt/rockpro64 modules_install -j4

cp arch/arm64/boot/Image /mnt/rockpro64/boot
cp arch/arm64/boot/dts/rockchip/rk3399-rockpro64.dtb /mnt/rockpro64/boot/dtbs/rockchip

Finalize

sync
umount /mnt/rockpro64
eject /dev/sdX