User:Snake/Nintendo Wii U

From Gentoo Wiki
Jump to:navigation Jump to:search
Important
This guide already assumes you have a fair understanding of Linux systems and the terminal (enough to successfully boot a kernel using the resources available at the linux-wiiu) project. It also assumes that you are using a Linux/Linux-adjacent operating system, either on baremetal or in a virtual machine with access to device passthrough.

Formatting Disks

For this guide, it is assumed that an SD card and a USB flash drive will be used. You are welcome to use an SD card with 2 partitions, but this will not be explicitly covered in this guide, nor will SATA drives installed via hardware modification.

SD Card

If you already have an SD card that can successfully boot a linux system, congrats! The most configuration you will have to do here is pointing the kernel to your boot drive by editing the boot.cfg file. Here's an example:

FILE sdcard:/linux/boot.cfg
[loader]
default=gentoo

[profile:gentoo]
name=Gentoo
kernel=sdmc:/linux/dtbImage.wiiu
cmdline=root=PARTUUID=901cca45-01 rootwait

Otherwise, follow the instructions at Wii U Hacks Guide and linux-loader to create such an SD card.

Flash Drive

All that is needed for the root drive is a single partition formatted with your favourite POSIX-compliant file system (pick ext4!). An example of this process is found in Handbook:AMD64/Installation/Disks#Partitioning_the_disk_with_MBR_for_BIOS_.2F_legacy_boot, just ignore the swap and /boot partitions as you won't need those.

Installing and first boot

To install the kernel, simply download the latest version from linux-wiiu's github and place it at wherever your boot.cfg will be looking for it, which is more than likely /linux/dtbImage.wiiu on your SD card. Next, follow Handbook:PPC/Installation/Stage to install the latest stage 3 file to your flash drive. Unless you have access to another PPC system (QEMU or real), don't worry about progressing further in the handbook past that page for now.

Note
As of writing, there are no pre-built SMP-enabled kernels, and one must compile this manually.

Once the stage 3 is extracted onto the drive successfully, you now need to set a root password. Because we can't (or have chosen not to) chroot into the system we have, we need to instead override the root password. To do this, simply edit /etc/shadow on your drive, and replace the line starting with root to the following:

FILE /etc/shadow
root:$6$dUC/x0ijIAFvQfNE$Qv6nYMDAob6.5SbD5uUuMoK/VxveTlegAJut5LxouPILttSsKnrU/86FkwStsFqpKFD.FyRBrpgiakA1T3uDL1:20046:0:::::

This will allow logging in with the username root and password root on boot. From here, all that is needed is to plug the SD card and flash drive into your Wii U, and boot using a CFW launcher. From here, you can follow the PPC Handbook to finalise your installation.

Cross-compiling with distcc and crossdev

Important
The following section assumes you want to use the SMP capabilities of the Espresso processor, despite the reduced stability compared to a 1 core system. If not, disregard all talk of patches or masking, and simply use
root #crossdev -t powerpc-unknown-linux-(gnu/musl)
to get started with crossdev.

Considering the Espresso processor used in the Wii U has a 1.2 GHz clock speed and 1-3 cores, it is highly recommended to cross emerge as many packages as possible on a seperate and stronger machine. However, this is still optional, if you dare.

Crossdev

To do this, first create the directories required to apply patches to the crossdev-emerged packages.

Directories

Glibc
root #mkdir -p /etc/portage/patches/cross-powerpc-espresso-linux-gnu/gcc
root #mkdir -p /etc/portage/patches/cross-powerpc-espresso-linux-gnu/glibc
Musl
root #mkdir -p /etc/portage/patches/cross-powerpc-espresso-linux-musl/gcc

Target creation

Next, emerge crossdev. To specifically target the espresso processor, gcc and glibc need to be patched. Download the patches found at Espresso SMP Patches, and place them in the directories you just created as necessary. Now you can create your new crossdev target.

Glibc
root #crossdev --g 13.2.0 --l 2.38 --genv 'EXTRA_ECONF="--with-cpu=espresso"' -t powerpc-espresso-linux-gnu
Musl
root #crossdev --g 13.2.0 --genv 'EXTRA_ECONF="--with-cpu=espresso"' -t powerpc-espresso-linux-musl

Once the compilation finishes, make sure to mask updates to gcc and glibc within the crossdev environment until updated variants of the patches are available. This makes sure that no update overrides the SMP patches and breaks further packages, but sill allows for re-emerging these two if needed.

Masking

Glibc
FILE /etc/portage/package.mask/espresso-glibc
>cross-powerpc-espresso-linux-gnu/gcc-13.2.0
>cross-powerpc-espresso-linux-gnu/glibc-2.37-r10
Musl
FILE /etc/portage/package.mask/espresso-musl
>cross-powerpc-espresso-linux-musl/gcc-13.2.0

Copying the patches to the new crossdev environment is also required.

Copying patches

Glibc
root #mkdir -p /usr/powerpc-espresso-linux-gnu/etc/portage/patches/sys-devel
root #mkdir -p /usr/powerpc-espresso-linux-gnu/etc/portage/patches/sys-libs
root #cp -r /etc/portage/patches/cross-powerpc-espresso-linux-gnu/gcc /usr/powerpc-espresso-linux-gnu/etc/portage/patches/sys-devel/
root #cp -r /etc/portage/patches/cross-powerpc-espresso-linux-gnu/glibc /usr/powerpc-espresso-linux-gnu/etc/portage/patches/sys-libs/
Musl
root #mkdir -p /usr/powerpc-espresso-linux-musl/etc/portage/patches/sys-devel
root #cp -r /etc/portage/patches/cross-powerpc-espresso-linux-musl/gcc /usr/powerpc-espresso-linux-musl/etc/portage/patches/sys-devel/

Env configuration

Finally, we can simply create two files that enable gcc to be compiled with specific Espresso support every time.

FILE /usr/powerpc-espresso-linux-*/etc/portage/env/gcc-espresso
EXTRA_ECONF="--with-cpu=espresso"
FILE /usr/powerpc-espresso-linux-*/etc/portage/package.env
sys-devel/gcc gcc-espresso

Now that we have the necessary files installed for our Wii U to access, we can also set up Distcc to provide us with on-demand emerging from the U, instead of requiring binpkgs everywhere. However, this is only recommended with a reliable USB network adapter, as otherwise the fallback for a lost/spotty connection is simply compiling on the Wii U hardware. If this is unavailable, binary packages can now be made using the new crossdev installation instead.