Difference between revisions of "User:Aarondabomb/PineNote Development/Building Kernel new"
Aarondabomb (talk | contribs) (Created page with "= Building the Kernel = After followed [https://github.com/DorianRudolph/pinenotes#starter-guide Dorian's directions] to get Arch installed you've seen someone [https://github.com/m-weigand/mw_pinenote_misc/blob/main/videos/20220808_bw_dither_mode_picture_doom_video_small.mp4 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 major kern...") |
m (Fxc moved page PineNote Development/Building Kernel new to User:Aarondabomb/PineNote Development/Building Kernel new: User draft, please integrate into main article or edit it in the user space, otherwise this creates chaos) |
||
(2 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
= Building the Kernel = | = Building the Kernel = | ||
To get your PN running this smoothly, we'll need to build our own kernel. There are two major kernel efforts: | |||
# pgwipeout: https://gitlab.com/pgwipeout/linux-next | # pgwipeout: https://gitlab.com/pgwipeout/linux-next | ||
Line 10: | Line 9: | ||
# maximilian: https://github.com/m-weigand/linux | # maximilian: https://github.com/m-weigand/linux | ||
Most of the kernel work has been in creating a DRM driver for the eink display. You can learn more about the driver by reading [https://lore.kernel.org/linux-rockchip/20220413221916.50995-1-samuel@sholland.org/T/ Smaeul's RFC]. | |||
=== A small warning === | === A small warning === | ||
Line 19: | Line 18: | ||
== What you should have already done == | == What you should have already done == | ||
This guide will help you build the latest kernel and move it to your PineNote, but it does not cover installing an operating system. You should either already have a linux distro in place, or you should be following Dorian's guide to get Arch installed and use this guide to replace the steps described in [https://github.com/DorianRudolph/pinenotes#compile-the-kernel Compiling the Kernel]. | |||
Some steps from his guide (especially the commands to build the kernel) were borrowed from Dorian's guide. Thanks to Dorian for his work. | |||
TODO: rewrite this guide in the wiki. | TODO: rewrite this guide in the wiki. | ||
Line 25: | Line 26: | ||
== What do you need to know? == | == What do you need to know? == | ||
Compiling a kernel is not very complicated compared to some of the other steps required to put an operating system on the PineNote. You'll be fine :) If you are intimidated, that's okay! I'd still encourage you to try -- you will learn a lot. Just be patient and back up any data you're worried you might lose. If you run into trouble, ask for help in the [https://discord.com/invite/pine64 Discord]/[https://matrix.to/#/#pinenote:matrix.org 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 == | == Steps to build == | ||
Line 32: | Line 33: | ||
<li> Clone Maximilian's repository: </li> | <li> Clone Maximilian's repository: </li> | ||
<pre> $ git clone https://github.com/m-weigand/linux.git </pre> | <pre> $ git clone https://github.com/m-weigand/linux.git </pre> | ||
<li> </li> | <li> If this is your first Kernel, download the arm toolchain. Which version you want depends on your host machine (the machine which will do the compiling). The target machine is the PineNote, which is a <pre>AArch64 GNU/Linux target (aarch64-none-linux-gnu)</pre> target. | ||
<li> Compile the kernel: </li> | </li> | ||
<pre> $ | <li> Compile the kernel: | ||
<ol> | |||
<li> Set the necessary environment variables: | |||
<pre> | |||
export CROSS_COMPILE="<PATH_TO_TOOLCHAIN>/arm-gnu-toolchain-11.3.rel1-x86_64-aarch64-none-linux-gnu/bin/aarch64-none-linux-gnu-" | |||
export ARCH=arm64 | |||
</li> | |||
<li> Build the kernel: | |||
<pre> | |||
make clean | |||
make pinenote_defconfig | |||
make -j $(nproc) all | |||
</pre> | |||
</li> | |||
</ol> | |||
</li> | |||
<li> Next we want to perform the work captured in <code>install_to_pn.sh</code>, but the work may vary slightly from person to person. For example, I believe Maximilian is running Debian 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 <code>extlinux.conf</code> to point at it, things will be okay. Looking at <code>install_to_pn.sh</code>, we can see that there are three pieces to installing the kernel: the kernel image (called <code>Image</code>), the device tree (<code>rk3566-pinenote-v1.2.dtb</code>), and the modules. All of these files have been compiled and placed into the <code>linux/pack</code> 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. | <li> Next we want to perform the work captured in <code>install_to_pn.sh</code>, but the work may vary slightly from person to person. For example, I believe Maximilian is running Debian 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 <code>extlinux.conf</code> to point at it, things will be okay. Looking at <code>install_to_pn.sh</code>, we can see that there are three pieces to installing the kernel: the kernel image (called <code>Image</code>), the device tree (<code>rk3566-pinenote-v1.2.dtb</code>), and the modules. All of these files have been compiled and placed into the <code>linux/pack</code> 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. | ||
<ol><li>If it helps, I installed my dtb like this: <code>$ scp rk3566-pinenote-v1.2.dtb root@pinenote:/boot/dtbs/rockchip/</code></li> | <ol><li>If it helps, I installed my dtb like this: <code>$ scp rk3566-pinenote-v1.2.dtb root@pinenote:/boot/dtbs/rockchip/</code></li> |
Latest revision as of 19:02, 12 January 2023
Building the Kernel
To get your PN running this smoothly, we'll need to build our own kernel. There are two major kernel efforts:
- pgwipeout: https://gitlab.com/pgwipeout/linux-next
- smaeul: https://github.com/smaeul/linux/tree/rk35/pinenote-next
And then there is a third effort adding to smaeul's efforts by incorporating various community patches and several new features:
- maximilian: https://github.com/m-weigand/linux
Most of the kernel work has been in creating a DRM driver for the eink display. You can learn more about the driver by reading Smaeul's RFC.
A small warning
These changes are all experimental and may damage your panel. However, there have been no confirmed instances of damage from this work and only a few mysterious hardware issues that may be entirely unrelated.
What you should have already done
This guide will help you build the latest kernel and move it to your PineNote, but it does not cover installing an operating system. You should either already have a linux distro in place, or you should be following Dorian's guide to get Arch installed and use this guide to replace the steps described in Compiling the Kernel.
Some steps from his guide (especially the commands to build the kernel) were borrowed from Dorian's guide. Thanks to Dorian for his work.
TODO: rewrite this guide in the wiki.
What do you need to know?
Compiling a kernel is not very complicated compared to some of the other steps required to put an operating system on the PineNote. You'll be fine :) If you are intimidated, that's okay! I'd still encourage you to try -- you will learn a lot. Just be patient and back up any data you're worried you might lose. 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
- Clone Maximilian's repository:
- If this is your first Kernel, download the arm toolchain. Which version you want depends on your host machine (the machine which will do the compiling). The target machine is the PineNote, which is a
AArch64 GNU/Linux target (aarch64-none-linux-gnu)
target. - Compile the kernel:
- Set the necessary environment variables:
export CROSS_COMPILE="<PATH_TO_TOOLCHAIN>/arm-gnu-toolchain-11.3.rel1-x86_64-aarch64-none-linux-gnu/bin/aarch64-none-linux-gnu-" export ARCH=arm64 </li> <li> Build the kernel: <pre> make clean make pinenote_defconfig make -j $(nproc) all
- Set the necessary environment variables:
- 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 Debian 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 yourextlinux.conf
to point at it, things will be okay. Looking atinstall_to_pn.sh
, we can see that there are three pieces to installing the kernel: the kernel image (calledImage
), the device tree (rk3566-pinenote-v1.2.dtb
), and the modules. All of these files have been compiled and placed into thelinux/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.- If it helps, I installed my dtb like this:
$ scp rk3566-pinenote-v1.2.dtb root@pinenote:/boot/dtbs/rockchip/
- 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). - (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
- 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:
- 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?) - For networking (and I imagine more as well), you may need to change
/lib/firmware/pinenote.bin
to/lib/firmware/pinenote-v1.2.bin
- For display, you may need to change
- 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: If you frequently update your system with something `pacman -Syu`, you will end up updating these packages and losing the patches. Add this line to your
/etc/pacman.conf
to prevent them from being updated:IgnorePkg = libva-mesa-driver mesa mesa-debug mesa-vdpau opencl-mesa vulkan-mesa-layers vulkan-broadcom vulkan-panfrost vulkan-radeon vulkan-swrast
- 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/
, runsudo systemctl daemon-reload
to make sure systemd knows it exists, then executesudo systemctl enable mweigand_eglinfo.service
.
That should be it! Now are equipped with the freshest kernel + patches.
Next Steps
Configuring the driver
The driver has several options that can improve performance. These can be read about here. Personally, I use
rockchip_ebc.bw_mode=1 rockchip_ebc.default_waveform=1 rockchip_ebc.refresh_threshold=30 rockchip_ebc.auto_refresh=1
to make the image lower quality, but much faster to update. The auto_refresh setting is also essential to clear ghosting which will otherwise accrue on screen. I added the above settings theAPPEND
line in myextlinux.conf
to make sure they are applied on boot.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.
Booting Linux instead of Android
PineNote Development/Booting Linux
Fixing Bluetooth
Some users have noticed instability with their wireless driver. Upgrading the driver to the version provided by LibreELEC may help! To do this, download the BCM4345C0.hcd, brcmfmac43455-sdio.bin, and brcmfmac43455-sdio.txt from the libreELEC repositories and place them in the same location as your previous firmware. Then rename brcmfmac43455-sdio.{txt,bin} as `brcmfmac43455-sdio.pine64,pinenote-v1.2.{txt,bin}`. If this doesn't help, ask about it in the matrix chat!
Autoconnect to your Bluetooth devices
This bluetooth-autoconnect project may help.
- If it helps, I installed my dtb like this:
$ git clone https://github.com/m-weigand/linux.git