ROCKPro64: diferenças entre revisões

De WikiPeida
Ir para a navegação Ir para a procura
Sem resumo de edição
 
(Há 39 edições intermédias do mesmo utilizador que não estão a ser apresentadas)
Linha 1: Linha 1:
As linhas começadas por # são para correr como root e as $ como user.
== Requirements ==
 
== Requisitos ==


=== 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
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>


== Preparar o cartão ==
== Prepare card ==


== Limpar ==  
=== Clean ===


Escrever zeros no inicio do cartão para ter a certeza que não tem restos de outro 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>


== Criar Partição ==  
=== Create partitions ===  


Criar a partição com o inicio a partir do sector '''4096'''.
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 ===


Criar o filesystem com esta opção hacker que ripei de outro artigo.
<syntaxhighlight lang="bash">
mkfs.ext4 -O ^metadata_csum /dev/sdX1
mkswap /dev/sdX2
</syntaxhighlight>


<console>
== Copy Userland ==
##r#####!r## mkfs.ext4 -O ^metadata_csum /dev/sdX1
##r#####!r## mkswap /dev/sdX2
</console>


== Copiar o Userland ==
=== Mount filesystem ===


<console>
<syntaxhighlight lang="bash">
##r#####!r## mkdir /mnt/rockpro64
mkdir /mnt/rockpro64
##r#####!r## mount /dev/sdX1 /mnt/rockpro64
mount /dev/sdX1 /mnt/rockpro64
##g##$##!g## mkdir ~/rockpro64
mkdir ~/rockpro64
##g##$##!g## cd ~/rockpro64
cd ~/rockpro64
</console>
</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 ===


Sacar o mais recente de http://distfiles.gentoo.org/releases/arm/autobuilds/current-stage3-arm64/
Download the most recent from http://distfiles.gentoo.org/experimental/arm64/


<console>
<syntaxhighlight lang="bash">
##g##$##!g## wget http://distfiles.gentoo.org/releases/arm/autobuilds/current-stage3-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 ==  


Editar o '''/mnt/rockpro64/etc/fstab''' e usar o seguinte.
Edit '''/mnt/rockpro64/etc/fstab''' and use the following:


<pre>
<pre>
Linha 81: Linha 79:
== boot.scr ==
== boot.scr ==


Criar o ficheiro '''/mnt/rockpro64/boot/boot.cmd''' com o seguinte conteúdo:
Create the file '''/mnt/rockpro64/boot/boot.cmd''' with:


<pre>
<pre>
Linha 88: 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 105: Linha 103:
</pre>
</pre>


E correr o mkimage para criar o '''boot.scr'''.
And run mkimage to create '''boot.scr'''.
 
<syntaxhighlight lang="bash">
cd /mnt/rockpro64/boot
mkimage -A arm -O linux -T script -C none -n "ROCKPro64 boot script" -d boot.cmd boot.scr
</syntaxhighlight>
 
== ARM Trusted Firmware ==
 
Create '''bl31.elf'''.


<console>
<syntaxhighlight lang="bash">
##g##$##!g## cd /mnt/rockpro64/boot
cd ~/rockpro64
##g##$##!g## mkimage -A arm -O linux -T script -C none -n "ROCKPro64 boot script" -d boot.cmd boot.scr
git clone https://github.com/ARM-software/arm-trusted-firmware.git arm-trusted-firmware
</console>
cd arm-trusted-firmware
make CROSS_COMPILE=aarch64-unknown-linux-gnu- PLAT=rk3399 DEBUG=1 bl31
</syntaxhighlight>


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


<console>
Clone the repository.
##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 ==
<syntaxhighlight lang="bash">
cd ~/rockpro64
git clone git://git.denx.de/u-boot.git u-boot
cd u-boot
</syntaxhighlight>


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


== U-Boot ==
<syntaxhighlight lang="bash">
cp ../arm-trusted-firmware/build/rk3399/debug/bl31/bl31.elf .
</syntaxhighlight>


<console>
Build U-boot.
##g##$##!g## cd ~/opipc2
##g##$##!g## git clone git://git.denx.de/u-boot.git u-boot
##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>
<syntaxhighlight lang="bash">
make ARCH=arm CROSS_COMPILE=aarch64-unknown-linux-gnu- -j4 rockpro64-rk3399_defconfig
make ARCH=arm CROSS_COMPILE=aarch64-unknown-linux-gnu- -j4
</syntaxhighlight>


E gravar o bootloader no cartão com:
Build '''idbloader.img'''.


<console>
<syntaxhighlight lang="bash">
##r#####!r## dd if=u-boot-sunxi-with-spl.bin of=/dev/sdX bs=8k seek=1
./tools/mkimage -n rk3399 -T rksd -d tpl/u-boot-tpl.bin idbloader.img
</console>
cat spl/u-boot-spl.bin >> idbloader.img
</syntaxhighlight>


== 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