Building Kernel Guide: Difference between revisions

From Wii-Linux Wiki
Jump to navigation Jump to search
A semi-simple guide to help compile wii-linux kernel's
 
Try to clean up this absolute mess
Line 1: Line 1:
This Guide will teach you how to compile the Wii-Linux kernel for Wii-Linux.
This Guide will teach you how to cross-compile the [[Wii-Linux]] kernel and supporting elements.


== Requirements ==
== Requirements ==


* A PC
* An x86 or AArch64 device running GNU/Linux




Line 9: Line 9:
# Install Crosstool-NG via package manager or compile it by cloning <code>git clone https://github.com/crosstool-ng/crosstool-ng</code>.
# Install Crosstool-NG via package manager or compile it by cloning <code>git clone https://github.com/crosstool-ng/crosstool-ng</code>.
# Make a directory to have all the files/folders to be in
# Make a directory to have all the files/folders to be in
# In that directory clone the Wii-Linux-Toolchain <code>https://github.com/Wii-Linux/wii-linux-toolchain.git</code>.
# In that directory clone the Wii-Linux-Toolchain <code>https://github.com/Wii-Linux/wii-linux-toolchain</code>.
# cd into the wii-linux-toolchain folder and run <code>mv ct-ng.config .config</code> and run <code>ct-ng build</code>.
# cd into the wii-linux-toolchain folder and run <code>mv ct-ng.config .config</code> and run <code>ct-ng build</code>.
#* The process will take a while depending on how shit your computer is.
#* The process will take a while depending on how bad your computer is.
# Once it's installed it should make a directory in your home folder called x-tools run <code>echo 'PATH="$PATH:~/x-tools/powerpc-unknown-linux-gnu/bin"' >> ~/.bashrc && source ~/.bashrc</code>.
# Once it's installed, it should make a directory in your home folder called <code>x-tools</code>.
# After you ran the previous command go back to the main directory folder and run <code>git clone https://github.com/Wii-Linux/build-stack</code> and cd into it.
#* You can optionally move this directory elsewhere first, if you don't find <code>x-tools</code> appealing.
# Once your in the build-stack folder run setup.sh and follow its instructions and make sure you have all the things u have installed, and if it asks to clone and build stuff always answer with Y.
# You must now add it to your PATH.  This varies per shell, and based on where you put it, but as an example:
# After setup.sh finishes successfully go back to the main directory and now finally run <code>https://github.com/Wii-Linux/wii-linux-ngx.git --branch <Branch You want></code>.
#* for bash: <code>echo 'PATH="$PATH:~/<path to ct-ng output>/powerpc-unknown-linux-gnu/bin"' >> ~/.bashrc && source ~/.bashrc</code>.
#* The branch you clone is the kernel you are going to compile, the following kernel's are the ones currently supported.
# After you have added it to your path, go back to the main directory and run <code>git clone https://github.com/Wii-Linux/build-stack && cd build-stack</code>.
#** wii-v4.5
# Once you're in the build-stack folder, run <code>./setup.sh</code> and follow it's instructions, to make sure that you have all the necessary requirements installed.  If it asks to clone and build various requirements, answer Yes unless you have a very specific reason not to.
#** wii-v4.6
# After setup.sh finishes successfully, go back to the main directory, and now finally run <code>https://github.com/Wii-Linux/wii-linux-ngx -b <Branch You want></code>.
#** wii-v4.9
#* The branch you clone is the source code to the kernel branch you are going to compile (this could be specialized kernels (like for [[OpenWRT]], or just various versions of the main one). The following kernel branches are the ones currently supported:
#** wii-v4.14
#** <code>wii-v4.5</code>
#** wii-v4.19
#** <code>wii-v4.14-openwrt</code>
# After you cloned the kernel you want to build go back into build-stack and run <code>./build-kernel.sh [name of your kernel directory will most likely be wii-linux-ngx if you kept it default] <kernelversion>-wii+</code>.
#** <code>wii-v4.19</code>
#* Example: <code>./build-kernel.sh wii-linux-ngx 4.19.325-wii+</code>.
# After you cloned the kernel that you want to build go back into <code>build-stack</code> and run <code>./build-kernel.sh [name of your kernel directory]</code>.
# After the Kernel compiles you have to build the loader in order to run your kernel so in the build-stack run <code>./build-loader.sh ../v<Kernel Version>.ldr</code>.
#* Example: <code>./build-kernel.sh wii-linux-ngx</code>.
#* Example: <code>./build-loader.sh ../v4_19_325.ldr</code>.
# After the kernel compiles, you have to build the loader (small squashfs that the kernel boots, provides the boot menu).  In the build-stack run <code>./build-loader.sh ../v<kernel version short>.ldr</code>.
# After the loader is done go to your main directory and run <code>cp <kernedir>/arch/powerpc/boot/zImage . && mv zImage v<Kernel Version>.krn</code> and <code>cp <kerneldir>/modules.tar.gz .</code>.
#* Example: <code>./build-loader.sh ../v4_19325.ldr</code>.
#* Example: <code>cp <kernedir>/arch/powerpc/boot/zImage . && mv zImage v4_19325.krn</code> and <code>cp wii-linux-ngx/modules.tar.gz .</code>
# After the loader is done, you need to go install it.  This consists of 2 parts:
# Finally after all of that in your main directory you should have 1 ldr file, 1 krn file, and modules.tar.gz file, put the ldr and krn file in the wiilinux folder in your sd card (preassumed that u had the sd card files/folders zip already in there extracted) and extract the modules.tar.gz onto your rootfs under <code>lib/modules</code>.
#* '''Installing the kernel+loader'''.  A script has been provided to make this easier, <code>build-stack/copy-ssh.sh</code>. This provides an easy way to copy the kernel+loader to a remote machine in any directory.  This could even be a Wii-Linux install.
#** Example 1 (copy to local machine's SD Card on /mnt): <code>./copy-ssh.sh root@localhost /mnt v4_19325 4.19.325-wii+ kernel v4_19325.ldr</code>
#** Example 2 (copy to Wii with SD Card on /boot): <code>./copy-ssh.sh root@wii.local /boot v4_19325 4.19.325-wii+ kernel v4_19325.ldr</code>
#* ''''Installing the kernel modules''.  The kernel modules are output as <code>modules.tar.gz</code> in your kernel directory.  You will need to safely extract these to your Wii-Linux distro's rootfs.  ''WARNING'': Extracting directly to the rootfs ''WILL HOSE YOUR PERMISSIONS - DO NOT DO THAT''.  It will set the UID/HID of the root directory, and /usr, and /usr/lib, to the UID/GID of the user who built the kernel.  Instead, you can extract it to a temporary directory, then <code>mv</code> or <code>cp -r</code> the modules (<code>temp_dir/usr/lib/modules/[kernel version]-wii+</code> into your rootfs.

Revision as of 19:33, 18 May 2025

This Guide will teach you how to cross-compile the Wii-Linux kernel and supporting elements.

Requirements

  • An x86 or AArch64 device running GNU/Linux


Setup and Compile

  1. Install Crosstool-NG via package manager or compile it by cloning git clone https://github.com/crosstool-ng/crosstool-ng.
  2. Make a directory to have all the files/folders to be in
  3. In that directory clone the Wii-Linux-Toolchain https://github.com/Wii-Linux/wii-linux-toolchain.
  4. cd into the wii-linux-toolchain folder and run mv ct-ng.config .config and run ct-ng build.
    • The process will take a while depending on how bad your computer is.
  5. Once it's installed, it should make a directory in your home folder called x-tools.
    • You can optionally move this directory elsewhere first, if you don't find x-tools appealing.
  6. You must now add it to your PATH. This varies per shell, and based on where you put it, but as an example:
    • for bash: echo 'PATH="$PATH:~/<path to ct-ng output>/powerpc-unknown-linux-gnu/bin"' >> ~/.bashrc && source ~/.bashrc.
  7. After you have added it to your path, go back to the main directory and run git clone https://github.com/Wii-Linux/build-stack && cd build-stack.
  8. Once you're in the build-stack folder, run ./setup.sh and follow it's instructions, to make sure that you have all the necessary requirements installed. If it asks to clone and build various requirements, answer Yes unless you have a very specific reason not to.
  9. After setup.sh finishes successfully, go back to the main directory, and now finally run https://github.com/Wii-Linux/wii-linux-ngx -b <Branch You want>.
    • The branch you clone is the source code to the kernel branch you are going to compile (this could be specialized kernels (like for OpenWRT, or just various versions of the main one). The following kernel branches are the ones currently supported:
      • wii-v4.5
      • wii-v4.14-openwrt
      • wii-v4.19
  10. After you cloned the kernel that you want to build go back into build-stack and run ./build-kernel.sh [name of your kernel directory].
    • Example: ./build-kernel.sh wii-linux-ngx.
  11. After the kernel compiles, you have to build the loader (small squashfs that the kernel boots, provides the boot menu). In the build-stack run ./build-loader.sh ../v<kernel version short>.ldr.
    • Example: ./build-loader.sh ../v4_19325.ldr.
  12. After the loader is done, you need to go install it. This consists of 2 parts:
    • Installing the kernel+loader. A script has been provided to make this easier, build-stack/copy-ssh.sh. This provides an easy way to copy the kernel+loader to a remote machine in any directory. This could even be a Wii-Linux install.
      • Example 1 (copy to local machine's SD Card on /mnt): ./copy-ssh.sh root@localhost /mnt v4_19325 4.19.325-wii+ kernel v4_19325.ldr
      • Example 2 (copy to Wii with SD Card on /boot): ./copy-ssh.sh root@wii.local /boot v4_19325 4.19.325-wii+ kernel v4_19325.ldr
    • ''Installing the kernel modules. The kernel modules are output as modules.tar.gz in your kernel directory. You will need to safely extract these to your Wii-Linux distro's rootfs. WARNING: Extracting directly to the rootfs WILL HOSE YOUR PERMISSIONS - DO NOT DO THAT. It will set the UID/HID of the root directory, and /usr, and /usr/lib, to the UID/GID of the user who built the kernel. Instead, you can extract it to a temporary directory, then mv or cp -r the modules (temp_dir/usr/lib/modules/[kernel version]-wii+ into your rootfs.