ROCKPro64: diferenças entre revisões

De WikiPeida
Ir para a navegação Ir para a procura
Sem resumo de edição
 
(Há 5 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
##r#####!r## mkswap /dev/sdX2
mkswap /dev/sdX2
</console>
</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 60: 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 84: 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 103: 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>


== ARM Trusted Firmware ==
== ARM Trusted Firmware ==
Linha 112: 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
</console>
</syntaxhighlight>


== U-Boot ==
== U-Boot ==
Linha 123: Linha 125:
Clone the repository.
Clone the repository.


<console>
<syntaxhighlight lang="bash">
##g##$##!g## cd ~/rockpro64
cd ~/rockpro64
##g##$##!g## git clone git://git.denx.de/u-boot.git u-boot
git clone git://git.denx.de/u-boot.git u-boot
##g##$##!g## cd u-boot
cd u-boot
</console>
</syntaxhighlight>


Copy '''bl31.elf''' from ARM Trusted Firmware.
Copy '''bl31.elf''' from ARM Trusted Firmware.


<console>
<syntaxhighlight lang="bash">
##g##$##!g## cp ../arm-trusted-firmware/build/rk3399/debug/bl31/bl31.elf .
cp ../arm-trusted-firmware/build/rk3399/debug/bl31/bl31.elf .
</console>
</syntaxhighlight>


Build U-boot.
Build U-boot.


<console>
<syntaxhighlight lang="bash">
##g##$##!g## make ARCH=arm CROSS_COMPILE=aarch64-unknown-linux-gnu- -j4 rockpro64-rk3399_defconfig
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  
make ARCH=arm CROSS_COMPILE=aarch64-unknown-linux-gnu- -j4  
</console>
</syntaxhighlight>


Build '''idbloader.img'''.
Build '''idbloader.img'''.


<console>
<syntaxhighlight lang="bash">
##g##$##!g## ./tools/mkimage -n rk3399 -T rksd -d tpl/u-boot-tpl.bin idbloader.img
./tools/mkimage -n rk3399 -T rksd -d tpl/u-boot-tpl.bin idbloader.img
##g##$##!g## cat spl/u-boot-spl.bin >> idbloader.img
cat spl/u-boot-spl.bin >> idbloader.img
</console>
</syntaxhighlight>


Build '''uboot.itb'''.
Build '''uboot.itb'''.


<console>
<syntaxhighlight lang="bash">
##g##$##!g## make ARCH=arm CROSS_COMPILE=aarch64-unknown-linux-gnu- -j4 u-boot.itb
make ARCH=arm CROSS_COMPILE=aarch64-unknown-linux-gnu- -j4 u-boot.itb
</console>
</syntaxhighlight>


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


<console>
<syntaxhighlight lang="bash">
##r#####!r## dd if=idbloader.img of=/dev/sdX seek=64 conv=notrunc
dd if=idbloader.img of=/dev/sdX seek=64 conv=notrunc
##r#####!r## dd if=u-boot.itb of=/dev/sdX seek=16384 conv=notrunc
dd if=u-boot.itb of=/dev/sdX seek=16384 conv=notrunc
</console>
</syntaxhighlight>


== Kernel ==
== Kernel ==


<console>
<syntaxhighlight lang="bash">
##g##$##!g## cd ~/rockpro64
cd ~/rockpro64
##g##$##!g## git clone https://github.com/ayufan-rock64/linux-mainline-kernel.git linux
git clone https://github.com/ayufan-rock64/linux-mainline-kernel.git linux
##g##$##!g## cd linux
cd linux
##g##$##!g## make ARCH=arm64 CROSS_COMPILE=aarch64-unknown-linux-gnu- rockchip_linux_defconfig
make ARCH=arm64 CROSS_COMPILE=aarch64-unknown-linux-gnu- rockchip_linux_defconfig
##g##$##!g## make ARCH=arm64 CROSS_COMPILE=aarch64-unknown-linux-gnu- Image dtbs modules -j4
make ARCH=arm64 CROSS_COMPILE=aarch64-unknown-linux-gnu- Image dtbs modules -j4
##g##$##!g## make ARCH=arm64 CROSS_COMPILE=aarch64-unknown-linux-gnu- INSTALL_MOD_PATH=/mnt/rockpro64 modules_install -j4
make ARCH=arm64 CROSS_COMPILE=aarch64-unknown-linux-gnu- INSTALL_MOD_PATH=/mnt/rockpro64 modules_install -j4


##g##$##!g## cp arch/arm64/boot/Image /mnt/rockpro64/boot
cp arch/arm64/boot/Image /mnt/rockpro64/boot
##g##$##!g## cp arch/arm64/boot/dts/rockchip/rk3399-rockpro64.dtb /mnt/rockpro64/boot/dtbs/rockchip
cp arch/arm64/boot/dts/rockchip/rk3399-rockpro64.dtb /mnt/rockpro64/boot/dtbs/rockchip
</console>
</syntaxhighlight>


== Finalize ==
== Finalize ==


<console>
<syntaxhighlight lang="bash">
##r#####!r## sync
sync
##r#####!r## umount /mnt/rockpro64
umount /mnt/rockpro64
##r#####!r## eject /dev/sdX
eject /dev/sdX
</console>
</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