PineNote Development/Building Kernel

From PINE64
Jump to navigation Jump to search

Building the Kernel

After followed Dorian's directions to get Arch installed you've seen someone playing DOOM and you want to learn how to get the features that enable that kind of performance. To get your PN running this smoothly, we'll need to build our own kernel. There are two kernel efforts underway right now:

  1. pgwipeout: https://gitlab.com/pgwipeout/linux-next
  2. smaeul: https://github.com/smaeul/linux/tree/rk35/pinenote-next

We'll be using smaeul's kernel + some additional patches provided by DorianRudolph, pgwipeout, Maximilian Weigand, occam_razor, and hrdl. Thanks so much to them, and all the other users who have worked on piecing together drivers, twiddling configs, answering questions, and sharing their work in other ways. Brava!

A small warning

This guide is completely based off of the scripts provided by Maximilian. We'll be cloning and running them, but he owns them and he -- or others -- might change them. It's smart to have a look at what's going on, check when this page was last updated vs when his scripts were last updated, etc. Be nimble!

Additionally, as Maximilian warns here, these changes are all experimental and may damage your panel.

Note: If anyone reading this has recommended reading for how we can understand what may damage our panels (IE is the risk in fast updates? The types of updates? something more complicated?), please add it here!

What you should have already done

I assume you've already got an operating system installed on your Pinenote other than the stock Android. Doing this isn't trivial, but it is well understood -- you will be following the footsteps of many others. Dorian Rudolph made a guide for doing this, available here.

What do you need to know?

If you followed Dorian's guide to get here and felt semi-comfortable, you'll be fine. This is no more complicated than that. If you are intimidated, that's okay! I'll still encourage you to try :) you will learn a lot, just be patient and don't put any data on your PineNote that you wouldn't be okay losing. If you run into trouble, ask for help in the Discord/Matrix. Please try to solve problems on your own first, and then ask for help -- if nobody replies, please be patient and ask again soon.

Steps to build

  1. Clone Maximilian's scripts:
  2.  $ git clone https://github.com/m-weigand/mw_pinenote_misc.git 
  3. Make a separate directory for patching the kernel. Then run Maximilian's clone_and_prepare_git.sh. This will clone smaeul's kernel and a number of patches. Read the script to see which patches it is using. Feel free to open the patches too -- it's helpful to get a slim idea of what's going on, if only looking at the commit messages in them:
  4.  $ cd ../
     $ sh mw_pinenote_misc/custom_kernel/clone_and_prepare_git.sh
    
  5. Compile the kernel:
  6.  $ sh ../mw-pinenote_misc/custom_kernel/compile.sh 
  7. Next we want to perform the work captured in install_to_pn.sh, but the work may vary slightly from person to person. For example, I believe Maximilian is running Arch Sid, and I am running Manjaro -- because of this, and personal preference, some of our files live at different places. As long as you put them somewhere and configure your extlinux.conf to point at it, things will be okay. Looking at install_to_pn.sh, we can see that there are three pieces to installing the kernel: the kernel image (called Image), the device tree (rk3566-pinenote-v1.2.dtb), and the modules. All of these files have been compiled and placed into the linux/pack folder. The easiest way to send these over is by using scp or rsync -- read the script and decide how you would like to get your files in the correct location. You may need to install rsync on your PineNote if it doesn't already have it.
    1. If it helps, I installed my dtb like this: $ scp rk3566-pinenote-v1.2.dtb root@pinenote:/boot/dtbs/rockchip/
    2. After installing the dtb as above, I updated my /boot/extlinux/extlinux.conf to point to this new file (previously, my dtb did not have the -v1.2 on the end).
    3. (Perhaps not necessary?) The last step is to generate a new initrd image. (If you're like me and don't know what initrd is, the wiki is very enlightening.) This is done on the PineNote itself. Send Maximilian's installation script over and run it. Then place the generated image (from the last step of the shell script) into your boot partition and update extlinux.conf if needed to point at this new file.
       $ scp initrd/gen_uboot_image.sh root@pinenote:/root # Do this part on local to put script on PN
       $ ssh root@pinenote # Or use UART, the dongle + picocom, and change to root
       $ cd /root
       $ ./gen_uboot_image.sh
       $ mv initrd.img /boot/initrd.img
       $ vim /boot/extlinux/extlinux.conf # Update this to reference this new initrd image
      
    4. At this point your kernel is in place! However, there are a few more steps you may need to complete to ensure the display and networking continue to work:
      1. For display, you may need to change /lib/firmware/waveform.bin to /lib/firmware/rockchip/ebc.wbf (TODO is this a difference between PG and smaeul's kernel? or a patch?)
      2. For networking (and I imagine more as well), you may need to change /lib/firmware/pinenote.bin to /lib/firmware/pinenote-v1.2.bin
    5. This part technically isn't kernel specific, but we need to install a patched version of Mesa. If you are running an Arch based system, you're in luck! occam_razor provides prebuilt patched packages (say that 5 times fast) here. Simply extract these files, send them to PN, and install them using the package manager. You can also patch it yourself by looking at Maximilian's compile_mesa.sh.
      Note: that you should be careful when upgrading your packages from now on -- it's possible your package manager will want to upgrade these, but we don't want it to do this (TODO include section on how to tell package manager not to upgrade these).
    6. To ensure the GPU stays on, we need to use Maximilian's mweigand_eglinfo.service. The Readme.md in that same directory has instructions for how to install this, but basically we need to copy it to /etc/systemd/system/, run sudo systemctl daemon-reload to make sure systemd knows it exists, then execute sudo systemctl enable mweigand_eglinfo.service
    7. .

    That should be it! Now are equipped with the freshest kernel + patches.

    Next Steps

    Fixing Suspend

    If you're using a logind system, edit your /etc/systemd/logind.conf config. More information on what to do in Arch's documentation.

    Configuring your apps

    See this page.