ROCKPro64: diferenças entre revisões

De WikiPeida
Ir para a navegação Ir para a procura
Sem resumo de edição
 
(Há 22 edições intermédias do mesmo utilizador que não estão a ser apresentadas)
Linha 3: Linha 3:
=== Gentoo ===
=== Gentoo ===


<console>
<syntaxhighlight lang="bash">
##r#####!r## crossdev -P -v -t aarch64-unknown-linux-gnu
crossdev -P -v -t aarch64-unknown-linux-gnu
##r#####!r## crossdev -P -v -t arm-none-eabi
crossdev -P -v -t arm-none-eabi
##r#####!r## PYTHON=python2 emerge u-boot-tools
PYTHON=python2 emerge u-boot-tools
</console>
</syntaxhighlight>


=== ArchLinux ===
=== ArchLinux ===


<console>
<syntaxhighlight lang="bash">
##r#####!r## 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
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
</console>
</syntaxhighlight>


== Prepare card  ==
== Prepare card  ==


== Clean ==  
=== Clean ===


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


<console>
<syntaxhighlight lang="bash">
##r#####!r## dd if=/dev/zero of=/dev/sdX bs=1M count=8
dd if=/dev/zero of=/dev/sdX bs=1M count=8
</console>
</syntaxhighlight>


== Create partition ==  
=== Create partitions ===  


Use '''32768''' as the first sector for the first partition.
Use '''32768''' as the first sector for the first partition.


<console>
<syntaxhighlight lang="bash">
##r#####!r## fdisk /dev/sdX
fdisk /dev/sdX
</console>
</syntaxhighlight>


== Filesystem ==
=== Create filesystem ===


<console>
<syntaxhighlight lang="bash">
##r#####!r## mkfs.ext4 -O ^metadata_csum /dev/sdX1
mkfs.ext4 -O ^metadata_csum /dev/sdX1
</console>
mkswap /dev/sdX2
</syntaxhighlight>


== Copy Userland ==
== Copy Userland ==


<console>
=== Mount filesystem ===
##r#####!r## mkdir /mnt/rockpro64
 
##r#####!r## mount /dev/sdX1 /mnt/rockpro64
<syntaxhighlight lang="bash">
##g##$##!g## mkdir ~/rockpro64
mkdir /mnt/rockpro64
##g##$##!g## cd ~/rockpro64
mount /dev/sdX1 /mnt/rockpro64
</console>
mkdir ~/rockpro64
cd ~/rockpro64
</syntaxhighlight>


=== ArchLinux ===
=== ArchLinux ===


<console>
<syntaxhighlight lang="bash">
##g##$##!g## wget http://archlinuxarm.org/os/ArchLinuxARM-aarch64-latest.tar.gz
wget http://archlinuxarm.org/os/ArchLinuxARM-aarch64-latest.tar.gz
##g##$##!g## bsdtar -xpf ArchLinuxARM-aarch64-latest.tar.gz -C /mnt/rockpro64
bsdtar -xpf ArchLinuxARM-aarch64-latest.tar.gz -C /mnt/rockpro64
</console>
</syntaxhighlight>


=== Gentoo ===
=== Gentoo ===
Linha 59: Linha 62:
Download the most recent from http://distfiles.gentoo.org/experimental/arm64/
Download the most recent from http://distfiles.gentoo.org/experimental/arm64/


<console>
<syntaxhighlight lang="bash">
##g##$##!g## wget http://distfiles.gentoo.org/experimental/arm64/stage3-arm64-????????.tar.bz2
wget http://distfiles.gentoo.org/experimental/arm64/stage3-arm64-????????.tar.bz2
##g##$##!g## tar xfa stage3-arm64-????????.tar.bz2 -C /mnt/rockpro64
tar xfa stage3-arm64-????????.tar.bz2 -C /mnt/rockpro64
</console>
</syntaxhighlight>


== fstab ==  
== fstab ==  
Linha 71: Linha 74:
<file system>          <dir>  <type>  <options>              <dump>  <pass>
<file system>          <dir>  <type>  <options>              <dump>  <pass>
/dev/mmcblk0p1          /      ext4    defaults,noatime        0      1
/dev/mmcblk0p1          /      ext4    defaults,noatime        0      1
#/dev/mmcblk0p2          none    swap    defaults                0      0
/dev/mmcblk0p2          none    swap    defaults                0      0
</pre>
</pre>


Linha 83: Linha 86:


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


Linha 102: Linha 105:
And run mkimage to create '''boot.scr'''.
And run mkimage to create '''boot.scr'''.


<console>
<syntaxhighlight lang="bash">
##g##$##!g## cd /mnt/rockpro64/boot
cd /mnt/rockpro64/boot
##g##$##!g## mkimage -A arm -O linux -T script -C none -n "ROCKPro64 boot script" -d boot.cmd boot.scr
mkimage -A arm -O linux -T script -C none -n "ROCKPro64 boot script" -d boot.cmd boot.scr
</console>
</syntaxhighlight>
 
== rkbin ==
 
Create '''trust.img'''.
 
<console>
##g##$##!g## cd ~/rockpro64
##g##$##!g## https://github.com/rockchip-linux/rkbin.git rkbin
##g##$##!g## cd rkbin
##g##$##!g## ./tools/trust_merger RKTRUST/RK3399TRUST.ini
</console>


== ARM Trusted Firmware ==
== ARM Trusted Firmware ==
Linha 122: Linha 114:
Create '''bl31.elf'''.
Create '''bl31.elf'''.


<console>
<syntaxhighlight lang="bash">
##g##$##!g## cd ~/rockpro64
cd ~/rockpro64
##g##$##!g## git clone https://github.com/ARM-software/arm-trusted-firmware.git arm-trusted-firmware
git clone https://github.com/ARM-software/arm-trusted-firmware.git arm-trusted-firmware
##g##$##!g## cd arm-trusted-firmware
cd arm-trusted-firmware
##g##$##!g## make CROSS_COMPILE=aarch64-unknown-linux-gnu- PLAT=rk3399 DEBUG=1 bl31
make CROSS_COMPILE=aarch64-unknown-linux-gnu- PLAT=rk3399 DEBUG=1 bl31
##g##$##!g## cp build/rk3399/debug/bl31/bl31.elf ../u-boot/
</syntaxhighlight>
</console>


== U-Boot ==
== U-Boot ==


Build u-boot.
Clone the repository.
 
<syntaxhighlight lang="bash">
cd ~/rockpro64
git clone git://git.denx.de/u-boot.git u-boot
cd u-boot
</syntaxhighlight>
 
Copy '''bl31.elf''' from ARM Trusted Firmware.


<console>
<syntaxhighlight lang="bash">
##g##$##!g## cd ~/opipc2
cp ../arm-trusted-firmware/build/rk3399/debug/bl31/bl31.elf .
##g##$##!g## git clone git://git.denx.de/u-boot.git u-boot
</syntaxhighlight>
##g##$##!g## cd u-boot
##g##$##!g## make ARCH=arm CROSS_COMPILE=aarch64-unknown-linux-gnu- -j4 rockpro64-rk3399_defconfig
##g##$##!g## make ARCH=arm CROSS_COMPILE=aarch64-unknown-linux-gnu- -j4
</console>


Build the boot images.
Build U-boot.


<console>
<syntaxhighlight lang="bash">
##g##$##!g## ./tools/mkimage -n rk3399 -T rksd -d ../rkbin/bin/rk33/rk3399pro_ddr_800MHz_v1.23.bin idbloader.img
make ARCH=arm CROSS_COMPILE=aarch64-unknown-linux-gnu- -j4 rockpro64-rk3399_defconfig
##g##$##!g## cat ../rkbin/bin/rk33/rk3399pro_miniloader_v1.15.bin >> idbloader.img
make ARCH=arm CROSS_COMPILE=aarch64-unknown-linux-gnu- -j4
##g##$##!g## ../rkbin/tools/loaderimage --pack --uboot u-boot-dtb.bin uboot.img 0x200000
</syntaxhighlight>
##g##$##!g## cp u-boot-dtb.bin /mnt/rockpro64/boot
</console>


Flash them to the card:
Build '''idbloader.img'''.


<console>
<syntaxhighlight lang="bash">
##r#####!r## dd if=idbloader.img of=/dev/sdX seek=64 conv=notrunc
./tools/mkimage -n rk3399 -T rksd -d tpl/u-boot-tpl.bin idbloader.img
##r#####!r## dd if=uboot.img of=/dev/sdX seek=16384 conv=notrunc
cat spl/u-boot-spl.bin >> idbloader.img
##r#####!r## dd if=../rkbin/trust.img of=/dev/sdX seek=24576 conv=notrunc
</syntaxhighlight>
</console>


== Kernel ==
Build '''uboot.itb'''.


<console>
<syntaxhighlight lang="bash">
##g##$##!g## cd ~/opipc2
make ARCH=arm CROSS_COMPILE=aarch64-unknown-linux-gnu- -j4 u-boot.itb
##g##$##!g## git clone https://github.com/megous/linux -b orange-pi-4.17 linux
</syntaxhighlight>
##g##$##!g## cd linux
##g##$##!g## cp linux-4.17-64 .config
##g##$##!g## make ARCH=arm64 CROSS_COMPILE=aarch64-unknown-linux-gnu- Image dtbs -j4


##g##$##!g## make ARCH=arm64 CROSS_COMPILE=aarch64-unknown-linux-gnu- Image dtbs modules -j4
Flash '''idbloader.img''' and '''u-boot.itb''' to the card.
##g##$##!g## make ARCH=arm64 CROSS_COMPILE=aarch64-unknown-linux-gnu- INSTALL_MOD_PATH=/mnt/opipc2 modules_install -j4


##g##$##!g## cp arch/arm64/boot/Image /mnt/opipc2/boot
<syntaxhighlight lang="bash">
##g##$##!g## cp arch/arm64/boot/dts/allwinner/sun50i-h5-orangepi-pc2.dtb /mnt/opipc2/boot/dtbs/allwinner
dd if=idbloader.img of=/dev/sdX seek=64 conv=notrunc
</console>
dd if=u-boot.itb of=/dev/sdX seek=16384 conv=notrunc
</syntaxhighlight>


== Kernel ==


== Finalizar ==
<syntaxhighlight lang="bash">
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


<console>
cp arch/arm64/boot/Image /mnt/rockpro64/boot
##r#####!r## sync
cp arch/arm64/boot/dts/rockchip/rk3399-rockpro64.dtb /mnt/rockpro64/boot/dtbs/rockchip
##r#####!r## umount /mnt/opipc2
</syntaxhighlight>
##r#####!r## eject /dev/sdX
</console>


== Finalize ==


<syntaxhighlight lang="bash">
sync
umount /mnt/rockpro64
eject /dev/sdX
</syntaxhighlight>


[[Category:Linux]]
[[Category:SBC]]

Edição atual desde as 21h12min de 7 de março de 2026

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