Skip to content

Building the Kernel

pingflood edited this page Nov 12, 2020 · 9 revisions

The RetroFW kernel is maintained at http://kernel.retrofw.com. The kernel is fully open source and easily buildable by anyone with even the slightest interest. Minor knowledge of the Linux command line is required.

Requirements

In order to build the kernel, you will need a reasonably modern x86-based Linux machine with the following packages installed:

  • bzip2
  • curl
  • git
  • make
  • gcc
  • tar
  • u-boot-tools
  • 32-bit Linux libraries
  • python2 (only for uboot)

These packages can typically be installed using a local packaging tool such as apt-get or yum. Check the documentation for your OS for more information.

Note that the automatic method below is able to automatically add requirements on Ubuntu systems. For that reason, Ubuntu is generally recommended for the build.

Build Options

There are two separate options for building RetroFW; automatic and manual. The automatic method is very simple and provides a toolchain for getting to writable SD Card images in a single command. This method is recommended for casual developers. The scripts can still be useful if you're interested in serious kernel development work. However, serious kernel developers would be recommended to learn more about the build process by learning the manual method.

Automatic

Download the RetroFW Kernel Tools and install. Then run the dist-all.sh script to build all supported versions of the kernel. For example:

cd /opt

curl -L -o retrofw-kernel-tools.tar.bz2 https://github.com/retrofw/kernel/releases/download/tools/retrofw-kernel-tools.tar.bz2

tar -xjf retrofw-kernel-tools.tar.bz2

cd retrofw-kernel-tools

./dist-all.sh

You may need to run as root in order to modify your /opt directory.

The package contains a readme.txt file with a full explanation of all the tools available. The kernel sources will be installed to /opt/retrofw-kernel/kernel where they can be modified.

Manual

  1. Download the Ingenic GCC 4.12 compiler from Ingenic's website or the toolchain release mirror. e.g.

curl -L -o /tmp/mipseltools-gcc412-glibc261.tar.bz2 https://github.com/retrofw/kernel/releases/download/tools/mipseltools-gcc412-glibc261.tar.bz2

  1. Extract the toolchain from the root directory of your Linux system. Make sure you add the toolchain to your PATH so the kernel build can find the compiler. e.g.

cd /

tar -xjf /tmp/mipseltools-gcc412-glibc261.tar.bz2

export PATH="/opt/mipseltools-gcc412-glibc261/bin:$PATH"

  1. Create a directory in which you want to work with the kernel. e.g.

mkdir -p /opt/retrofw-kernel

  1. Clone the kernel from GitHub into your new working directory. e.g.

cd /opt/retrofw-kernel

git clone https://github.com/retrofw/kernel

  1. Create a separate directory to build your kernel into. You can have different directories for different kernel configurations without interference. e.g.

cd /opt/retrofw-kernel

mkdir RetroFW_5B

  1. You will need to configure your kernel with the make ARCH=mips O=<build dir> RetroFW_<model>_defconfig command. Just replace <build dir> with the directory path you created in step 5 and <model> with the screen model you wish to build for. See the RetroFW release page and documentation for details on the different device models available. For example, the following command will configure a build for IPS enabled devices like the RG-300:

cd /opt/retrofw-kernel/kernel

make ARCH=mips O=/opt/retrofw-kernel/RetroFW_5B RetroFW_5B_defconfig

  1. Change your directory to the build directory you created in Step 5. Then run the make ARCH=mips CROSS_COMPILE=mipsel-linux- uImage command to build your very own kernel! e.g.

cd /opt/retrofw-kernel/RetroFW_5B

make ARCH=mips CROSS_COMPILE=mipsel-linux- uImage

  1. Congratulations! You've just built your very own kernel! You will find the kernel image under arch/mips/boot/uImage. To use this kernel, you will need to integrate it with a boot disk. Copy the uImage file to a convenient location and obtain a RetroFW.img file by downloading and extracting a recent RetroFW release. You can then use the dd command to install your kernel into the image:

dd if=uImage of=RetroFW.img bs=1M seek=4194304 conv=notrunc iflag=skip_bytes oflag=seek_bytes

sync

You can then write the RetroFW.img file to an SD Card using a tool like balenaEtcher. Pop the card into your device, and enjoy your new kernel!

Note that the RetroFW.img file you obtain must contain the appropriate U-Boot for your system in order to boot. To overcome this, you will need to build your own U-Boot (check the Building U-Boot page).