====== OrangePi 800 ====== It comes pre-installed with OrangePi branded Ubuntu on the emmc. Unfortunately you cannot boot from the tf card if the emmc has uboot installed on it. You have to use dd an zero out the first 30 meg or so of the emmc in order to boot from tf. This means if you want to dual boot you are going to be swapping tf cards and the emmc cannot be used for any OS which is a bummer as its slightly faster access. I wiped the emmc and have it mounted to /home. ===== Gentoo Install(so far) ===== * boot a tf card with an official image * write a tf card with another official image(usb attached) * I used the debian image which puts everything in one partition * you could probably just write the first sectors which have two binary blobs written to them for booting (wrote the whole image, in the future I will recreate the boot stuff) ^Item^Contents^SD location^ |idbloader.img|TPL & SPL|LBA 64| |u_boot.itb|U-Boot & ATF|LBA 16384| * mkfs.ext4 the partition to wipe it * mount the partition and cd into it * grab the latest arm64 stage3 tarball and extract it on the clean parition * copy /boot /lib/firmware /lib/modules to the partition * use blkid to get the UUID of the partition * place the proper UUID in boot/orangepiEnv.txt for rootdev * I also changed bootlogo to false so that I can see output onscreen once the kernel takes over * set the root password openssl passwd -1 vim etc/shadow * at this point you can probably shutdown, swap tf cards and boot into the gentoo system * it's a good idea have a uart cable hooked up so you can see what the booting process is === configuring portage === * portage didn't work, grabbed the latest portage snapshot wget https://distfiles.gentoo.org/snapshots/portage-latest.tar.bz2 * extract this to /var/db/repos/gentoo tar -xf portage-latest.tar.bz2 * setup your profile cd /etc/portage ln -s ../../var/db/repos/gentoo/profiles/default/linux/arm64/17.0 make.profile * set your system and hwclock * edit your make.conf COMMON_FLAGS="-march=armv8-a+crc+crypto -mtune=cortex-a72.cortex-a53 -mfix-cortex-a53-835769 -mfix-cortex-a53-843419" * now portage should work * update ca's emerge --ask app-misc/ca-certificates === wifi setup === * for whatever reason even after following symlinks and copying the correct regulatory.db files it still failed to load kmod cfg80211 which is one of two modules required for the wifi, so I emerged the gentoo ebuild that contains the same emerge --ask app-misc/wireless-regdb * then you can load the second module modprobe sprdwl_ng * I then created a file /etc/modules-load.d/networking.conf with "sprdwl_ng" as the contents * at this point you can install wpa_supplicant and configure per the usual === odds and ends === * create a swapfile fallocate -l 4G /swapfile chmod 600 /swapfile mkswap /swapfile swapon /swafile * setup /etc/fstab blkid >> /etc/fstab vim /etc/fstab UUID=blahblah / ext4 /defaults 0 1 /swapfile swap swap sw 0 0 * create a normal user useradd -m -G users,wheel,audio -s /bin/bash foobar passwd foobar ===== connecting UART ===== To enable serial console in gentoo edit inittab: f0:12345:respawn:/sbin/agetty 1500000 ttyS2 vt100 {{:screenshot_2024-01-24_at_8.08.17 am.png?400|pi800 uart connection}} ^DTECH UART Cable^^ |White|RXD| |Green|TXD| |Black|GND| |Red|VCC +5V| su - screen /dev/ttyUSB0 1500000 ===== Kernel... ===== Existing kernel doesn't have required settings for GPU!!! Really this is the kernel from vendor supplied image. It's really old, 5.10 so working an updated kernel. # CONFIG_DRM_PANFROST is not set The reason it is not set is the code is broken. [[https://github.com/orangepi-xunlong/linux-orangepi/tree/orange-pi-5.10-rk3399/arch/arm64/boot/dts/rockchip|Source]] drivers/gpu/drm/panfrost/panfrost_mmu.c:359:10: error: 'const struct iommu_flush_ops' has no member named 'tlb_flush_leave'; did you mean'tlb_flush_all'? Looking at a newer kernel that line doesn't exist so I removed it. static const struct iommu_flush_ops mmu_tlb_ops = { .tlb_flush_all = mmu_tlb_inv_context_s1, .tlb_flush_walk = mmu_tlb_flush_walk, }; It compiles now, but I wonder if I should remove this function as well(I guess I'll do some testing and decide): static void mmu_tlb_flush_leaf(unsigned long iova, size_t size, size_t granule, void *cookie) { mmu_tlb_sync_context(cookie); } The module compiles and loads but isn't really functional now. The orangepi ubuntu based image uses this [[https://github.com/orangepi-xunlong/linux-orangepi/tree/orange-pi-5.18|kernel(5.18)]]. Its slightly newer. I couldn't get it to work with module compression(enabled with XZ compression in the image). It threw an error whenever trying to load a module. Which is really weird as I initially just copied the kernel and modules from the image and it works fine with their image. Something must prevent this from working with the openrc-stage3 from Gentoo but I didn't dig real deep into this. After recompiling without module compression it works other than rfkill.ko appears to hang when loading on boot (required by sprdwl_ng) but eventually completes loading and works fine so I've switched to this kernel for the time being. Found more recent [[https://github.com/zhangn1985/linux-stable|source(6.8-rc2)]]. It compiles and I get video output but it hangs on first daemon load. This is going to require some more work. ===== references ===== [[https://github.com/orangepi-xunlong/orangepi-build/tree/next|Linux Source]] {{ :methods_of_writing_images_on_opi800.pdf |Orange Pi800 sad excuse for a manual}} [[https://opensource.rock-chips.com/wiki_Boot_option|Rockchip Wiki - Booting]] [[https://wiki.gentoo.org/wiki/User:PeterL/Rockpro64|Gentoo Doc for Rockpro64(same soc)]] [[https://github.com/ARM-software/arm-trusted-firmware|Arm Trusted Firmware]]