ROCKPro64: diferenças entre revisões

Fonte: WikiPeida
Saltar para a navegação Saltar para a pesquisa
Sem resumo de edição
Sem resumo de edição
 
(Há 37 edições intermédias do mesmo utilizador que não estão a ser apresentadas)
Linha 15: Linha 15:
</console>
</console>


== 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>
<console>
Linha 25: Linha 25:
</console>
</console>


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


Criar a partição com o inicio a partir do sector '''32768'''.
Use '''32768''' as the first sector for the first partition.


<console>
<console>
Linha 33: Linha 33:
</console>
</console>


== Filesystem ==
=== Create filesystem ===
 
Criar o filesystem com esta opção hacker que ripei de outro artigo.


<console>
<console>
Linha 42: Linha 40:
</console>
</console>


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


<console>
<console>
Linha 60: Linha 60:
=== 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>
<console>
##g##$##!g## wget http://distfiles.gentoo.org/releases/arm/autobuilds/current-stage3-arm64/stage3-arm64-????????.tar.bz2
##g##$##!g## wget http://distfiles.gentoo.org/experimental/arm64/stage3-arm64-????????.tar.bz2
##g##$##!g## tar xfa stage3-arm64-????????.tar.bz2 -C /mnt/rockpro64
##g##$##!g## tar xfa stage3-arm64-????????.tar.bz2 -C /mnt/rockpro64
</console>
</console>
Linha 69: Linha 69:
== fstab ==  
== fstab ==  


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


<pre>
<pre>
Linha 79: 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 86: 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 103:
</pre>
</pre>


E correr o mkimage para criar o '''boot.scr'''.
And run mkimage to create '''boot.scr'''.


<console>
<console>
Linha 110: Linha 110:
</console>
</console>


== rkbin ==
== ARM Trusted Firmware ==
 
<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 ==
Create '''bl31.elf'''.


<console>
<console>
Linha 126: Linha 119:
##g##$##!g## cd 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## make CROSS_COMPILE=aarch64-unknown-linux-gnu- PLAT=rk3399 DEBUG=1 bl31
##g##$##!g## cp build/rk3399/debug/bl31/bl31.elf ../u-boot/
</console>
</console>


== U-Boot ==
== U-Boot ==
Clone the repository.


<console>
<console>
##g##$##!g## cd ~/opipc2
##g##$##!g## cd ~/rockpro64
##g##$##!g## git clone git://git.denx.de/u-boot.git u-boot
##g##$##!g## git clone git://git.denx.de/u-boot.git u-boot
##g##$##!g## cd u-boot
##g##$##!g## cd u-boot
</console>
Copy '''bl31.elf''' from ARM Trusted Firmware.
<console>
##g##$##!g## cp ../arm-trusted-firmware/build/rk3399/debug/bl31/bl31.elf .
</console>
Build U-boot.
<console>
##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 rockpro64-rk3399_defconfig
##g##$##!g## make ARCH=arm CROSS_COMPILE=aarch64-unknown-linux-gnu- -j4  
##g##$##!g## make ARCH=arm CROSS_COMPILE=aarch64-unknown-linux-gnu- -j4  
</console>
Build '''idbloader.img'''.
<console>
##g##$##!g## ./tools/mkimage -n rk3399 -T rksd -d tpl/u-boot-tpl.bin idbloader.img
##g##$##!g## cat spl/u-boot-spl.bin >> idbloader.img
</console>
Build '''uboot.itb'''.


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


E gravar o bootloader no cartão com:
Flash '''idbloader.img''' and '''u-boot.itb''' to the card.


<console>
<console>
##r#####!r## dd if=u-boot-sunxi-with-spl.bin of=/dev/sdX bs=8k seek=1
##r#####!r## 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
</console>
</console>


Linha 149: Linha 167:


<console>
<console>
##g##$##!g## cd ~/opipc2
##g##$##!g## cd ~/rockpro64
##g##$##!g## git clone https://github.com/megous/linux -b orange-pi-4.17 linux
##g##$##!g## git clone https://github.com/ayufan-rock64/linux-mainline-kernel.git linux
##g##$##!g## cd linux
##g##$##!g## cd linux
##g##$##!g## cp linux-4.17-64 .config
##g##$##!g## 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 -j4
 
##g##$##!g## make ARCH=arm64 CROSS_COMPILE=aarch64-unknown-linux-gnu- Image dtbs modules -j4
##g##$##!g## 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/opipc2 modules_install -j4
##g##$##!g## 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/opipc2/boot
##g##$##!g## cp arch/arm64/boot/Image /mnt/rockpro64/boot
##g##$##!g## cp arch/arm64/boot/dts/allwinner/sun50i-h5-orangepi-pc2.dtb /mnt/opipc2/boot/dtbs/allwinner
##g##$##!g## cp arch/arm64/boot/dts/rockchip/rk3399-rockpro64.dtb /mnt/rockpro64/boot/dtbs/rockchip
</console>
</console>


 
== Finalize ==
== Finalizar ==


<console>
<console>
##r#####!r## sync
##r#####!r## sync
##r#####!r## umount /mnt/opipc2
##r#####!r## umount /mnt/rockpro64
##r#####!r## eject /dev/sdX
##r#####!r## eject /dev/sdX
</console>
</console>
Linha 173: Linha 188:




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

Edição atual desde as 17h55min de 10 de abril de 2021

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