# _bag_'s Rapid Guide to Hacking Your Own Kernel



## _bag_ (Mar 27, 2012)

*Important Information*
Toolchain: http://smp-on-qemu.g...nux-gnu.tar.bz2
RHCP's Kernel: https://github.com/r...i405_kernel.git
RHCP's Initramfs: https://github.com/r...t_initramfs.git
Stock commit for kernel: 86b6d46
Stock commit for initramfs: 35ca3a4

*Introduction*
Hello guys, I figured I'd slam this quick guide together to give a good starting point for hacking on the Stratosphere kernel. The posts by lecapitan got me curious about the Stratosphere kernel, and given my past history working with third-party kernel patches for Linux, I figured I'd lay some information out about kernel hacking.

First, you must have either a Linux virtual machine (not recommended, it's much slower) or have Linux installed on your computer in order to do this. Having Linux installed on your computer gives you a big advantage in terms of compile times, and it's much nicer for Android development in general.

Second, the above links are git repositories, so make sure you have git installed. Once installed, fire up a terminal, create a directory and do a _git clone_ of each repository. Make sure the directory for strat_initramfs is named strat_initramfs and is in the same folder as the sch-i405_kernel directory.

If you're interested in working on the stock kernel/initramfs, do a _git reset --hard <COMMIT>_, where <COMMIT> is the commit listed above for the kernel or initramfs. Once you've done that, you have a working kernel/initramfs tree. You're ready to start hacking away!

*Start hacking!*
Now, you can begin integrating different kernel patches/changes, as well as modifying the kernel config to suit your needs. This part is basically up to you, whatever pieces you want to modify or change are in your hands. Once you've completed all your changes, you're ready to build!

*Building your kernel*
Make sure you have the toolchain downloaded and unpacked somewhere. /opt/toolchains/ is a good choice, but you could also use a directory under your home directory if you want. Once you've done this, be sure to change the path that TOOLCHAIN is set to in build.sh. Building is as simple as doing _sh build.sh_, which will handle the whole build process for you and generate a handy-dandy flashable zip.

*Managing your changes*
Since you cloned the kernel from a git repository, you can track your changes using git as well! Simply ensure that you have git configured and then use git commit to track changes once you've got them working.

If you've got any questions or flames, feel free to scream at me on here or irc.andirc.net #stratosphere. I'm more than happy to help out.


----------

