§2023-08-20


By chatGPT

Installing Gentoo Linux on an Orange Pi 5 Plus involves a complex set of steps, and the process may require some Linux knowledge and experience with command-line operations. Here's a general guide to get you started, but keep in mind that the exact steps might vary based on hardware specifics and Gentoo's updates beyond my last training data in September 2021.

Using hc4lunar.yushei.net

¶ 1.0 Download stage 3 tarball, systemd

$ pwd
/home/alexlai/build/gentoo/src
$ wget https://distfiles.gentoo.org/releases/arm64/autobuilds/20230813T234643Z/stage3-arm64-systemd-20230813T234643Z.tar.xz

¶2. Pratition and Format the microSD Card:

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048         1050623   512.0 MiB   0700  Microsoft basic data
   2         1050624        59404287   27.8 GiB    8300  Linux filesystem

$ sudo mkfs.vfat /dev/sdc1
$ sudo mkfs.ext4 /dev/sdc2

¶2.1. Mount the partition to a directory,

[alexlai@n2Mnjaro gentoo]$ pwd
/home/alexlai/build/gentoo/src
$ mkdir root boot
$ ls
boot  root  stage3-arm64-systemd-20230813T234643Z.tar.xz
 
$ sudo mount /dev/sdc2 root

¶2.2 Extract Stage3 Tarball:

[alexlai@n2Mnjaro gentoo]$ ls -al
total 239880
drwxr-xr-x 3 alexlai alexlai        70 Aug 19 20:32 .
drwxr-xr-x 8 alexlai alexlai       151 Aug 19 20:14 ..
drwxr-xr-x 3 root    root         4096 Aug 19 20:31 root
-rw-r--r-- 1 alexlai alexlai 245630232 Aug 14 16:44 stage3-arm64-systemd-20230813T234643Z.tar.xz
[alexlai@n2Mnjaro gentoo]$ sudo tar xvf stage3-arm64-systemd-20230813T234643Z.tar.xz  -C root

[alexlai@n2Mnjaro gentoo]$ ls -l root
total 88
drwxr-xr-x  2 root root  4096 Aug 14 16:42 bin
drwxr-xr-x  2 root root  4096 Aug 14 15:48 boot
drwxr-xr-x  3 root root  4096 Aug 14 15:59 dev
drwxr-xr-x 35 root root  4096 Aug 14 16:44 etc
drwxr-xr-x  2 root root  4096 Aug 14 15:48 home
drwxr-xr-x  7 root root  4096 Aug 14 16:35 lib
drwxr-xr-x  4 root root  4096 Aug 14 16:42 lib64
drwx------  2 root root 16384 Aug 19 20:31 lost+found
drwxr-xr-x  2 root root  4096 Aug 14 15:48 media
drwxr-xr-x  2 root root  4096 Aug 14 15:48 mnt
drwxr-xr-x  2 root root  4096 Aug 14 15:48 opt
drwxr-xr-x  2 root root  4096 Aug 14 15:48 proc
drwx------  2 root root  4096 Aug 14 15:55 root
drwxr-xr-x  2 root root  4096 Aug 14 15:48 run
drwxr-xr-x  2 root root  4096 Aug 14 16:44 sbin
drwxr-xr-x  2 root root  4096 Aug 14 15:48 sys
drwxrwxrwt  2 root root  4096 Aug 14 16:44 tmp
drwxr-xr-x 12 root root  4096 Aug 14 15:59 usr
drwxr-xr-x  9 root root  4096 Aug 14 16:11 var

¶2.3. Mount Required Filesystems:

$ sudo mount -o bind /dev/ root/dev/ && sudo mount -t proc none root/proc && sudo mount -o bind /sys root/sys
$ sudo mount --types proc /proc root/proc && sudo mount --rbind /sys root/sys && sudo mount --make-rslave root/sys && sudo mount --rbind /dev  root/dev && sudo mount --make-rslave root/dev && sudo mount --bind /run root/run && sudo mount --make-slave root/run

¶ 2.4. check

$ mount |grep /home/alexlai/build/gentoo/
/dev/sdc2 on /home/alexlai/build/gentoo/src/root type ext4 (rw,relatime)
udev on /home/alexlai/build/gentoo/src/root/dev type devtmpfs (rw,nosuid,relatime,size=1454112k,nr_inodes=363528,mode=755)
none on /home/alexlai/build/gentoo/src/root/proc type proc (rw,relatime)
sysfs on /home/alexlai/build/gentoo/src/root/sys type sysfs (rw,nosuid,nodev,noexec,relatime)

¶ 3. Chroot into the New System:

$ sudo arch-chroot root /bin/bash
mount: /home/alexlai/build/gentoo/src/root/sys: sys already mounted or mount point busy.
       dmesg(1) may have more information after failed mount system call.
==> ERROR: failed to setup chroot root

Failed in arch-chroot

n2Mnjaro / # source /etc/profile
n2Mnjaro / # export PS1="(chroot) ${PS1}"
(chroot) n2Mnjaro / # 

n2Mnjaro / # source /etc/profile n2Mnjaro / # export PS1="(chroot) ${PS1}" (chroot) n2Mnjaro / #


¶ 4. Continue with Configuration:
- Configuring compile options
- orange pi5 plus 
    - SoC	Rockchip RK3588 (8nm LP process)
    - CPU	8-core 64-bit processor; 4 x Cortex-A76(2.4GHz), 4 x Cortex-A55(1.8GHz) and separate NEON co-processors
    - GPU	Arm Mali-G610; Built-in 3D GPU; Compatible with OpenGL ES1.1/2.0/3.2, OpenCL 2.2 and Vulkan 1.2
- Edit /etc/portage/make.conf to set your preferred compiler flags and other system options.

(chroot) n2Mnjaro / # cp -v /etc/portage/make.conf /etc/portage/make.conf.ori '/etc/portage/make.conf' -> '/etc/portage/make.conf.ori' (chroot) n2Mnjaro / # nano /etc/portage/make.conf # as suggested by chatGPT

- /etc/portage/make.conf
```toml
# Set the target architecture
CHOST="aarch64-unknown-linux-gnu"

# Set the number of CPU cores for parallel compilation (adjust as needed)
MAKEOPTS="-j4"

# Set the CPU flags based on the Cortex-A76 and Cortex-A55 architecture
COMMON_FLAGS="-march=armv8-a+crc -mtune=cortex-a76.cortex-a55 -mfpu=neon-fp-armv8 -mfloat-abi=hard"

# Set any additional flags or optimizations you want
CFLAGS="${COMMON_FLAGS} -O2 -pipe"
CXXFLAGS="${COMMON_FLAGS} -O2 -pipe"

# GPU-related variables (if applicable)
VIDEO_CARDS="mali"
INPUT_DEVICES="evdev"

# Set the desired USE flags (customize as needed)
USE="X opengl vulkan"

# Set the system timezone (adjust as needed)
TIMEZONE="Your/Timezone"

# Set the desired locale (adjust as needed)
LINGUAS="en_US"

# Set the desired Python interpreter (adjust as needed)
PYTHON_TARGETS="python3_7 python3_8"

# Set the desired Portage sync server (choose one that is geographically close)
SYNC="https://your-mirror-server/gentoo-portage"

# Set the portage file and directory locations (adjust as needed)
PORTDIR="/usr/portage"
DISTDIR="/usr/portage/distfiles"
PKGDIR="/usr/portage/packages"

¶4. Update Portage Configuration:

After modifying make.conf, you should update the Portage configuration to apply the changes:

!!! Section 'gentoo' in repos.conf has location attribute set to nonexistent directory: '/usr/portage'
!!! SYNC setting found in make.conf.
    This setting is Deprecated and no longer used.  Please ensure your 'sync-type' and 'sync-uri' are set correctly in /etc/portage/repos.conf/gentoo.conf
!!! Invalid Repository Location (not a dir): '/usr/portage'
WARNING: One or more repositories have missing repo_name entries:

        /usr/portage/profiles/repo_name

NOTE: Each repo_name entry should be a plain text file containing a
unique name for the repository on the first line.


Portage 3.0.49 (python 3.11.4-final-0, unavailable, gcc-12, glibc-2.37-r3, 6.3.9-1-MANJARO-ARM aarch64)
=================================================================
System uname: Linux-6.3.9-1-MANJARO-ARM-aarch64-with-glibc2.37
KiB Mem:     3757180 total,   3399648 free
KiB Swap:   14024372 total,  14024372 free
sh bash 5.1_p16-r6
ld GNU ld (Gentoo 2.40 p5) 2.40.0
dev-lang/python:          3.11.4::gentoo
sys-devel/autoconf:       2.71-r6::gentoo
sys-devel/automake:       1.16.5::gentoo
sys-devel/binutils:       2.40-r5::gentoo
sys-devel/libtool:        2.4.7-r1::gentoo
sys-kernel/linux-headers: 6.1::gentoo (virtual/os-headers)
Repositories:

ACCEPT_LICENSE="* -@EULA"
CFLAGS="-march=armv8-a+crc -mtune=cortex-a76.cortex-a55 -mfpu=neon-fp-armv8 -mfloat-abi=hard -O2 -pipe"
CHOST="aarch64-unknown-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/gentoo-release /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-march=armv8-a+crc -mtune=cortex-a76.cortex-a55 -mfpu=neon-fp-armv8 -mfloat-abi=hard -O2 -pipe"
DISTDIR="/usr/portage/distfiles"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs binpkg-multi-instance buildpkg-live config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync multilib-strict network-sandbox news parallel-fetch pid-sandbox preserve-libs protect-owned qa-unresolved-soname-deps sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
PKGDIR="/usr/portage/packages"
PORTAGE_TMPDIR="/var/tmp"
USE="X opengl vulkan"
Unset:  ACCEPT_KEYWORDS, EMERGE_DEFAULT_OPTS, ENV_UNSET, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND
(chroot) n2Mnjaro /etc/portage # emerge --sync
!!! SYNC setting found in make.conf.
    This setting is Deprecated and no longer used.  Please ensure your 'sync-type' and 'sync-uri' are set correctly in /etc/portage/repos.conf/gentoo.conf
>>> Syncing repository 'gentoo' into '/usr/portage'...
 * Using keys from /usr/share/openpgp-keys/gentoo-release.asc
 * Refreshing keys via WKD ...                                                                                                                     [ !! ]
 * Refreshing keys from keyserver hkps://keys.gentoo.org ...OpenPGP keyring refresh failed:
gpg: refreshing 4 keys from hkps://keys.gentoo.org
gpg: keyserver refresh failed: Try again later

OpenPGP keyring refresh failed:
gpg: refreshing 4 keys from hkps://keys.gentoo.org
gpg: keyserver refresh failed: Try again later

OpenPGP keyring refresh failed:
gpg: refreshing 4 keys from hkps://keys.gentoo.org
gpg: keyserver refresh failed: Try again later
....

chroot) n2Mnjaro / # ping keys.gentoo.org
ping: keys.gentoo.org: Temporary failure in name resolution
(chroot) n2Mnjaro / # nano /etc/resolve.conf
(chroot) n2Mnjaro / # 
(chroot) n2Mnjaro / # cat /etc/resolve.conf
nameserver 8.8.8.8
nameserver 8.8.4.4
(chroot) n2Mnjaro / # dig  keys.gentoo.org
bash: dig: command not found
(chroot) n2Mnjaro / # ping   keys.gentoo.org
ping: keys.gentoo.org: Temporary failure in name resolution

emerge --sync

Proceed with the configuration steps mentioned in the previous response, such as configuring the system, updating Portage, setting up the kernel, installing the bootloader, configuring networking, creating user accounts, setting timezone and locale, and finalizing the configuration.

Exit Chroot and Reboot:

Once you've finished configuring the system, exit the chroot environment:

bash

exit umount -l /mnt/gentoo/dev{/shm,/pts,} umount -R /mnt/gentoo

Reboot your Orange Pi 5 Plus:

    reboot

Remember, while the process remains conceptually the same, certain Arch Linux-specific tools and package names might differ. Always refer to the official Gentoo documentation and adapt the steps as needed based on your specific Linux distribution.


¶ 1. Preparation:

n2Mnjaro.yushei.net

$ pwd
/opt/xfs/home/alexlai/build/gentoo
$ wget https://distfiles.gentoo.org/releases/arm64/autobuilds/20230813T234643Z/stage3-arm64-systemd-20230813T234643Z.tar.xz

¶2. Prepare the microSD

Chroot into the New System:

Mount required filesystems:

bash

mount -t proc none /mnt/gentoo/proc mount -o bind /dev /mnt/gentoo/dev mount -o bind /sys /mnt/gentoo/sys

Chroot into the new system:

bash

chroot /mnt/gentoo /bin/bash
source /etc/profile
export PS1="(chroot) ${PS1}"

Configure System:

Edit /etc/portage/make.conf to set your preferred compiler flags and other system options.

Update Portage:

Update Portage, the package manager:

bash

emerge --sync

Kernel Configuration:

Configure and compile the kernel for your Orange Pi 5 Plus hardware. You can use the kernel sources provided by Orange Pi or use the mainline ARM64 kernel sources.

Install Kernel and Bootloader:

Install the kernel and bootloader (such as U-Boot):

bash

emerge sys-kernel/linux-firmware
emerge sys-boot/uboot-tools
emerge sys-boot/uboot-orangepi5plus

Configure Networking:

Set up network configuration in /etc/conf.d/net or use tools like net-setup or systemctl.

User Accounts:

Create user accounts and set passwords.

Timezone and Locale:

Set the timezone and locale in /etc/locale.gen.

Finalize Configuration:

Install additional software packages as needed.
Configure services to start at boot using rc-update.

Exit Chroot and Reboot:

Exit the chroot environment:

bash

    exit
    umount -l /mnt/gentoo/dev{/shm,/pts,}
    umount -R /mnt/gentoo

Reboot your Orange Pi 5 Plus:

reboot

Remember that this is just a high-level guide, and the process might involve additional steps or troubleshooting depending on your specific hardware and Gentoo's updates. Always refer to the official Gentoo documentation and any Orange Pi-specific resources for the most accurate and up-to-date instructions. User but I am doing the preparation of this SDram on an archlinux though ChatGPT