Orange Pi PC 2: diferenças entre revisões

De WikiPeida
Ir para a navegação Ir para a procura
Sem resumo de edição
 
(Há 40 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.


== Requisitos ==
== Requisitos ==
Linha 5: Linha 4:
=== Gentoo ===
=== Gentoo ===


<console>
<syntaxhighlight lang="bash">
##r#####!r## crossdev -t aarch64-unknown-linux-gnu --g 7.2.0 -v
crossdev -P -v -t aarch64-unknown-linux-gnu
##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
</console>
</syntaxhighlight>


== Preparar o cartão  ==
== Preparar o cartão  ==
Linha 22: Linha 21:
Escrever zeros no inicio do cartão para ter a certeza que não tem restos de outro bootloader.
Escrever zeros no inicio do cartão para ter a certeza que não tem restos de outro 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 ==  
== Criar Partição ==  
Linha 30: Linha 29:
Criar a partição com o inicio a partir do sector '''4096'''.
Criar a partição com o inicio a partir do sector '''4096'''.


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


== Filesystem ==
== Filesystem ==
Linha 38: Linha 37:
Criar o filesystem com esta opção hacker que ripei de outro artigo.
Criar o filesystem com esta opção hacker que ripei de outro artigo.


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


== Copiar o Userland ==
== Copiar o Userland ==


<console>
<syntaxhighlight lang="bash">
##r#####!r## mkdir /mnt/opipc
mkdir /mnt/opipc2
##r#####!r## mount /dev/sdX1 /mnt/opipc
mount /dev/sdX1 /mnt/opipc2
##g##$##!g## mkdir ~/opipc
mkdir ~/opipc2
##g##$##!g## cd ~/opipc
cd ~/opipc2
</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/opipc
bsdtar -xpf ArchLinuxARM-aarch64-latest.tar.gz -C /mnt/opipc2
</console>
</syntaxhighlight>


=== Gentoo ===
=== Gentoo ===
Linha 62: Linha 62:
Sacar o mais recente de http://distfiles.gentoo.org/releases/arm/autobuilds/current-stage3-arm64/
Sacar o mais recente de http://distfiles.gentoo.org/releases/arm/autobuilds/current-stage3-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/releases/arm/autobuilds/current-stage3-arm64/stage3-arm64-????????.tar.bz2
##g##$##!g## tar xfa stage3-arm64-????????.tar.bz2 -C /mnt/opipc
tar xfa stage3-arm64-????????.tar.bz2 -C /mnt/opipc2
</console>
</syntaxhighlight>


== fstab ==  
== fstab ==  


Editar o '''/mnt/opipc/etc/fstab''' e usar o seguinte, ou então editar conforme necessario (tipo adicionar swap).
Editar o '''/mnt/opipc2/etc/fstab''' e usar o seguinte.


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


== boot.scr ==
== boot.scr ==


Criar o ficheiro '''/mnt/opipc/boot/boot.cmd''' com o seguinte conteudo:
Criar o ficheiro '''/mnt/opipc2/boot/boot.cmd''' com o seguinte conteúdo:


<pre>
<pre>
part uuid ${devtype} ${devnum}:${bootpart} uuid
part uuid ${devtype} ${devnum}:${bootpart} uuid
#setenv console tty0
setenv bootargs console=${console} root=PARTUUID=${uuid} rw rootwait
setenv bootargs console=${console} root=PARTUUID=${uuid} rw rootwait
setenv fdtfile allwinner/sun50i-h5-orangepi-pc2.dtb
setenv fdtfile allwinner/sun50i-h5-orangepi-pc2.dtb
Linha 95: Linha 97:
   fi;
   fi;
fi
fi
# Generate with:
# mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n "Orange Pi PC 2 boot script" -d boot.cmd boot.scr
</pre>
</pre>


E correr o mkimage para criar o '''boot.scr'''.
E correr o mkimage para criar o '''boot.scr'''.


<console>
<syntaxhighlight lang="bash">
##g##$##!g## cd /mnt/opipc/boot
cd /mnt/opipc2/boot
##g##$##!g## mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n "Orange Pi PC 2 boot script" -d boot.cmd boot.scr
mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n "Orange Pi PC 2 boot script" -d boot.cmd boot.scr
</console>
</syntaxhighlight>
 
== Sources ==
 
Sacar o source de tudo necessario para bootar, o '''Armbian''' é usado para ripar o config do kernel e os patches adicionais.
 
<console>
##g##$##!g## cd ~/opipc
##g##$##!g## git clone https://github.com/armbian/build.git armbian
##g##$##!g## git clone git://git.denx.de/u-boot.git -b v2017.07 u-boot
##g##$##!g## git clone https://github.com/apritzel/arm-trusted-firmware -b allwinner-stable arm-trusted-firmware-sunxi-main
##g##$##!g## git clone https://github.com/Icenowy/linux/ -b sunxi64-4.13.y linux-sun50i-dev
</console>


== ARM Trusted Firmware ==
== ARM Trusted Firmware ==


<console>
<syntaxhighlight lang="bash">
##g##$##!g## cd ~/opipc
cd ~/opipc2
##g##$##!g## cd arm-trusted-firmware-sunxi-main
git clone https://github.com/apritzel/arm-trusted-firmware -b allwinner arm-trusted-firmware
##g##$##!g## make CROSS_COMPILE=aarch64-unknown-linux-gnu- PLAT=sun50iw1p1 DEBUG=1 bl31
cd arm-trusted-firmware
##g##$##!g## cp build/sun50iw1p1/debug/bl31.bin ../u-boot/
make CROSS_COMPILE=aarch64-unknown-linux-gnu- PLAT=sun50iw1p1 DEBUG=1 bl31
</console>
cp build/sun50iw1p1/debug/bl31.bin ../u-boot/
</syntaxhighlight>


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


<console>
<syntaxhighlight lang="bash">
##g##$##!g## cd ~/opipc
cd ~/opipc2
##g##$##!g## cd u-boot
git clone git://git.denx.de/u-boot.git -b v2018.05 u-boot
##g##$##!g## make ARCH=arm CROSS_COMPILE=aarch64-unknown-linux-gnu- -j4 orangepi_pc2_defconfig
cd u-boot
##g##$##!g## make ARCH=arm CROSS_COMPILE=aarch64-unknown-linux-gnu- -j4  
export BL31=~/opipc2/u-boot/bl31.bin
##g##$##!g## cat spl/sunxi-spl.bin u-boot.itb > u-boot-sunxi-with-spl.bin
make ARCH=arm CROSS_COMPILE=aarch64-unknown-linux-gnu- -j4 orangepi_pc2_defconfig
</console>
make ARCH=arm CROSS_COMPILE=aarch64-unknown-linux-gnu- -j4  
</syntaxhighlight>


E gravar o bootloader no cartão com:
E gravar o bootloader no cartão com:


<console>
<syntaxhighlight lang="bash">
##r#####!r## dd if=u-boot-sunxi-with-spl.bin of=/dev/sdX bs=8k seek=1
dd if=u-boot-sunxi-with-spl.bin of=/dev/sdX bs=8k seek=1
</console>
</syntaxhighlight>


== Kernel ==
== Kernel ==


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


##g##$##!g## for i in ../armbian/patch/kernel/sun50i-dev/*.patch; do patch -p1 < $i; done
make ARCH=arm64 CROSS_COMPILE=aarch64-unknown-linux-gnu- Image dtbs modules -j4
##g##$##!g## for i in ../armbian/patch/kernel/sun50i-dev/scpi/*.patch; do patch -p1 < $i; done
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- -j4
cp arch/arm64/boot/Image /mnt/opipc2/boot
##g##$##!g## make ARCH=arm64 CROSS_COMPILE=aarch64-unknown-linux-gnu- INSTALL_MOD_PATH=/mnt/opipc  -j4 modules_install
cp arch/arm64/boot/dts/allwinner/sun50i-h5-orangepi-pc2.dtb /mnt/opipc2/boot/dtbs/allwinner
##g##$##!g## cp arch/arm64/boot/Image /mnt/opipc/boot
</syntaxhighlight>
##g##$##!g## cp arch/arm64/boot/dts/allwinner/sun50i-h5-orangepi-pc2.dtb /mnt/opipc/boot/dtbs/allwinner/sun50i-h5-orangepi-pc2.dtb
 
</console>
== MALI ==
 
<syntaxhighlight lang="bash">
cd ~/opipc2
git clone https://github.com/mripard/sunxi-mali.git
cd sunxi-mali
export ARCH=arm64
export CROSS_COMPILE=aarch64-unknown-linux-gnu-
export KDIR=/root/opipc2/linux
export INSTALL_MOD_PATH=/mnt/opipc2
./build.sh -r r6p2 -b
./build.sh -r r6p2 -i
 
cd ~/opicp2
git clone https://github.com/free-electrons/mali-blobs.git
cd mali-blobs
cp r6p2/arm64/fbdev/lib* /mnt/opipc2/usr/lib/
</syntaxhighlight>


== Finalizar ==
== Finalizar ==


<console>
<syntaxhighlight lang="bash">
##r#####!r## sync
sync
##r#####!r## umount /mnt/opipc
umount /mnt/opipc2
##r#####!r## eject /dev/sdX
eject /dev/sdX
</console>
</syntaxhighlight>
 
== Patches HDMI ==
 
Tentar este libMali.so https://github.com/rockchip-linux/libmali/blob/29mirror/lib/aarch64-linux-gnu/libmali-utgard-450-r7p0-x11-fbdev.so
 
Adicionar mali ao DTS [[File:mali-dts-h5.patch]]


== Ligações externas ==
== Ligações externas ==
Linha 169: Linha 189:
* [https://wiki.gentoo.org/wiki/Orange_Pi_PC/Quick_Start Orange Pi PC Quick Start @ GentooWiki]
* [https://wiki.gentoo.org/wiki/Orange_Pi_PC/Quick_Start Orange Pi PC Quick Start @ GentooWiki]


[[Category:Servidores]]
[[Category:SBC]]

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

Requisitos

Gentoo

crossdev -P -v -t aarch64-unknown-linux-gnu
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

Preparar o cartão

Limpar

Escrever zeros no inicio do cartão para ter a certeza que não tem restos de outro bootloader.

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

Criar Partição

Criar a partição com o inicio a partir do sector 4096.

fdisk /dev/sdX

Filesystem

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

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

Copiar o Userland

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

ArchLinux

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

Gentoo

Sacar o mais recente de http://distfiles.gentoo.org/releases/arm/autobuilds/current-stage3-arm64/

wget http://distfiles.gentoo.org/releases/arm/autobuilds/current-stage3-arm64/stage3-arm64-????????.tar.bz2
tar xfa stage3-arm64-????????.tar.bz2 -C /mnt/opipc2

fstab

Editar o /mnt/opipc2/etc/fstab e usar o seguinte.

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

boot.scr

Criar o ficheiro /mnt/opipc2/boot/boot.cmd com o seguinte conteúdo:

part uuid ${devtype} ${devnum}:${bootpart} uuid
#setenv console tty0

setenv bootargs console=${console} root=PARTUUID=${uuid} rw rootwait
setenv fdtfile allwinner/sun50i-h5-orangepi-pc2.dtb

if load ${devtype} ${devnum}:${bootpart} ${kernel_addr_r} /boot/Image; then
  if load ${devtype} ${devnum}:${bootpart} ${fdt_addr_r} /boot/dtbs/${fdtfile}; then
    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

# Generate with:
# mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n "Orange Pi PC 2 boot script" -d boot.cmd boot.scr

E correr o mkimage para criar o boot.scr.

cd /mnt/opipc2/boot
mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n "Orange Pi PC 2 boot script" -d boot.cmd boot.scr

ARM Trusted Firmware

cd ~/opipc2
git clone https://github.com/apritzel/arm-trusted-firmware -b allwinner arm-trusted-firmware
cd arm-trusted-firmware
make CROSS_COMPILE=aarch64-unknown-linux-gnu- PLAT=sun50iw1p1 DEBUG=1 bl31
cp build/sun50iw1p1/debug/bl31.bin ../u-boot/

U-Boot

cd ~/opipc2
git clone git://git.denx.de/u-boot.git -b v2018.05 u-boot
cd u-boot
export BL31=~/opipc2/u-boot/bl31.bin
make ARCH=arm CROSS_COMPILE=aarch64-unknown-linux-gnu- -j4 orangepi_pc2_defconfig
make ARCH=arm CROSS_COMPILE=aarch64-unknown-linux-gnu- -j4

E gravar o bootloader no cartão com:

dd if=u-boot-sunxi-with-spl.bin of=/dev/sdX bs=8k seek=1

Kernel

cd ~/opipc2
git clone https://github.com/megous/linux -b orange-pi-4.17 linux
cd linux
cp linux-4.17-64 .config
make ARCH=arm64 CROSS_COMPILE=aarch64-unknown-linux-gnu- Image dtbs -j4

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/opipc2 modules_install -j4

cp arch/arm64/boot/Image /mnt/opipc2/boot
cp arch/arm64/boot/dts/allwinner/sun50i-h5-orangepi-pc2.dtb /mnt/opipc2/boot/dtbs/allwinner

MALI

cd ~/opipc2
git clone https://github.com/mripard/sunxi-mali.git
cd sunxi-mali
export ARCH=arm64
export CROSS_COMPILE=aarch64-unknown-linux-gnu-
export KDIR=/root/opipc2/linux
export INSTALL_MOD_PATH=/mnt/opipc2
./build.sh -r r6p2 -b
./build.sh -r r6p2 -i

cd ~/opicp2
git clone https://github.com/free-electrons/mali-blobs.git
cd mali-blobs
cp r6p2/arm64/fbdev/lib* /mnt/opipc2/usr/lib/

Finalizar

sync
umount /mnt/opipc2
eject /dev/sdX

Patches HDMI

Tentar este libMali.so https://github.com/rockchip-linux/libmali/blob/29mirror/lib/aarch64-linux-gnu/libmali-utgard-450-r7p0-x11-fbdev.so

Adicionar mali ao DTS Ficheiro:Mali-dts-h5.patch

Ligações externas