Difference between revisions of "User:Oogwaymaki/Kernel Installation"

From PINE64
Jump to navigation Jump to search
m (Fxc moved page Kernel Installation to User:Oogwaymaki/Kernel Installation: Outdated and unmaintained user instructions moved to userspace)
 
(11 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{hint|This page is outdated. You're welcome to contribute.}}
{{warning|1= Megi has added Sameul's audio patches to his 5.9 kernel. This requires [https://xnux.eu/devices/feature/audio-pp.html special] configuration so that audio works.}}




===Why would you want to install a custom kernel?===
===Why would you want to install a custom kernel?===


The reasons why you'd want to instal a custom kernel is if there were fixes in the kernel
There are many reasons you may want to install a custom kernel. Perhaps there's a kernel that isn't yet packaged for your distribution with bug fixes or new features. There are also features that may be desirable to some, but aren't included in the default kernel since they might cause problems for other users.
that allows the device to function better than it was before, or if you want to deviate with probably better functionality that the mass user base isn't configured for.
You can experiment with new features that are not yet documented or ready but could provide a great functionality when using your phone or device or operating system


Other reason is that the newest rc kernel contains code that is closest to getting mainlined into the Linus' kernel tree, so giving it some testing helps with catching
You also might just want to help kernel developers by testing for bugs in the latest mainline kernel release.
issues prior to these issues potentially affecting more people than necessary. You'll be helping the development.


===Things to look out for when installing a custom kernel and problems that can happen===
===Things to look out for when installing a custom kernel and problems that can happen===
Line 23: Line 22:
===What to do if the kernel does not have all your functionality but you want the patch it fixes or address?===
===What to do if the kernel does not have all your functionality but you want the patch it fixes or address?===


You would want to compile the kernel from scratch, adding all the features and functionality you need, and using the patch utility and methods you need. This takes added time like 30 min to several hours.
You would want to compile the kernel from scratch, adding all the features and functionality you need, and using the patch utility and methods you need. This takes added time of around 30 minutes to several hours.


===Installing Megi's pre-compiled kernel===
===Installing Megi's pre-compiled kernel===


prereqs:  
Prerequisites:  


You'll need a uart or a way to connect to your device to call  
You'll need a uart or a way to connect to your device to call  
Line 227: Line 226:
</pre>
</pre>
boot up device.l
boot up device.l
== References ==  
== References ==  


* https://access.redhat.com/solutions/24029
* https://access.redhat.com/solutions/24029
* https://linux-sunxi.org/U-Boot
* https://linux-sunxi.org/U-Boot
* https://xff.cz/kernels/5.9/patches/
[https://megous.com/git/linux/log/?h=orange-pi-5.9 5.9 pinephone kernel source ]
[[Category:PinePhone]]

Latest revision as of 18:40, 1 November 2021

This page is outdated. You're welcome to contribute.
Warning: Megi has added Sameul's audio patches to his 5.9 kernel. This requires special configuration so that audio works.


Why would you want to install a custom kernel?

There are many reasons you may want to install a custom kernel. Perhaps there's a kernel that isn't yet packaged for your distribution with bug fixes or new features. There are also features that may be desirable to some, but aren't included in the default kernel since they might cause problems for other users.

You also might just want to help kernel developers by testing for bugs in the latest mainline kernel release.

Things to look out for when installing a custom kernel and problems that can happen

Some things to look out for when installing a custom kernel are the following:

  • Does the kernel have all the modules you need installed for the system to boot liked
   * Drivers
   * Functionality

If you don't have the proper drivers for your particular kernel such as if you use a particular file system or feature it will not work if not compiled into the kernel.

What to do if the kernel does not have all your functionality but you want the patch it fixes or address?

You would want to compile the kernel from scratch, adding all the features and functionality you need, and using the patch utility and methods you need. This takes added time of around 30 minutes to several hours.

Installing Megi's pre-compiled kernel

Prerequisites:

You'll need a uart or a way to connect to your device to call

depmod -a

Install dependencies:

  • u-boot-tools allows you to make images
  • rsync allows you to copy and backup
# apt-get update
# apt-get install rsync u-boot-tools

First, download the the PinePhone CE (1.2) Kernel:

# wget https://xff.cz/kernels/5.8/pp2.tar.gz


Extract the kernel:

Create a separate folder for organization and separation: Extract the a "tar" "gz" file using tar.

# tar -zxvf pp2.tar.gz 

A default Mobian Installation looks like this:

Device     Boot  Start     End Sectors   Size Id Type
/dev/sda1  *      1953  250000  248048 121.1M 83 Linux
/dev/sda2       250001 7421874 7171874   3.4G 83 Linux

Notice the small size on the /boot partition.

This means we probably will have to, either ignore the the first partition or resize both partitions so we can keep existing structure.

Easiest thing to do:

Please all all the new files on the /dev/sda2 (they'll probably be more than 121 M)

Next we need to update the initrd image, to have the new modules, (the initrd image is a RAM disk helping the system to boot and needs kernel drivers while booting):

How to get and update initrd image:

Mount Mobian boot image: Make sure your the root user for this for ease of installation: Delete the old kernel modules and put the new latest ones there

# mkdir debianboot
# mount /dev/sda1 /media/debianboot
# cd /usr/src
# mkdir initrd
# cd /usr/src/initrd
# cp /media/debianboot/initrd.img-5.7-pinephone  .
# zcat initrd.img-5.7-pinephone | cpio -idmv 
# rm initrd.img-5.7-pinephone 
# cd /usr/src/initrd/lib/modules
# rm -rf /usr/src/initrd/lib/modules/5.7-pinephone
# rsync -avh pp2-5.8/modules/lib/modules/ initrd/lib/modules/

Repackage the Mobian Boot Image after new kernel modules installed and copy over to main mobian image now


# find . | cpio -o -c | gzip -9 > initrd.img-5.8-pinephone
# mkdir /media/mobianroot
# mount /dev/sda2 /media/mobianroot
# cp initrd/initrd.img-5.8-pinephone /media/mobianroot/boot/


Copy the pp 2.8 kernel and dab definition files to Mobian boot folder and update the boot.scr

# cp pp2-5.8/board.dtb /media/mobianroot/boot/
# cp pp2-5.8/Image /media/mobianroot/boot/

Change the old boot.cmd to the new settings:

if test ${mmc_bootdev} -eq 0; then
	echo "Booting from SD"
	setenv linux_mmcdev 0
else
	echo "Booting from eMMC"
	setenv linux_mmcdev 2
fi

# If we have at least 2 partitions, then the 1st one is /boot, and / is #2
if fstype mmc ${mmc_bootdev}:2; then
	setenv rootpart 2
else
	setenv rootpart 1
	setenv bootdir "/boot"
fi

setenv bootargs console=ttyS0,115200 no_console_suspend panic=10 consoleblank=0 loglevel=7 root=/dev/mmcblk${linux_mmcdev}p${rootpart} rw splash plymouth.ignore-serial-consoles vt.global_cursor_default=0

led 1 on

echo "Loading kernel..."
load mmc ${mmc_bootdev}:1 ${ramdisk_addr_r} ${bootdir}/Image.gz

echo "Uncompressing kernel..."
unzip ${ramdisk_addr_r} ${kernel_addr_r}

echo "Loading initramfs..."
load mmc ${mmc_bootdev}:1 ${ramdisk_addr_r} ${bootdir}/initrd.img
setenv ramdisk_size ${filesize}

echo "Loading dtb..."
load mmc ${mmc_bootdev}:1 ${fdt_addr_r} ${bootdir}/dtb/${fdtfile}

led 2 on

echo "Booting..."
booti ${kernel_addr_r} ${ramdisk_addr_r}:0x${ramdisk_size} ${fdt_addr_r}

Remove the old boot.cmd


# rm boot.cmd

to this, we removed the configuration of the first disk we won't be using it we also pointed everything to second disk for kernel and boot images


if test ${mmc_bootdev} -eq 0; then
	echo "Booting from SD"
	setenv linux_mmcdev 0
else
	echo "Booting from eMMC"
	setenv linux_mmcdev 2
fi

# If we have at least 2 partitions, then the 1st one is /boot, and / is #2
if fstype mmc ${mmc_bootdev}:2; then
	setenv rootpart 2
	setenv bootdir "/boot"
else
	setenv rootpart 2
	setenv bootdir "/boot"
fi

setenv bootargs console=ttyS0,115200 no_console_suspend panic=10 consoleblank=0 loglevel=7 root=/dev/mmcblk${linux_mmcdev}p${rootpart} rw splash plymouth.ignore-serial-consoles vt.global_cursor_default=0 initrd=/boot/initrd.img-5.8-pinephone

led 1 on

echo "Loading kernel..."
load mmc ${mmc_bootdev}:2 ${kernel_addr_r} ${bootdir}/Image

echo "Loading dtb..."
load mmc ${mmc_bootdev}:2 ${fdt_addr_r} /boot/board.dtb

led 2 on

echo "Booting..."
booti ${kernel_addr_r} - ${fdt_addr_r}

Save new boot.cmd to /dev/sda1 root folder (where the old boot.cmd was)

  1. cd /media/mobianboot
#  mkimage -C none -A arm64 -T script -d boot.cmd boot.scr
root@wifirouter:/media/mobianboot#  mkimage -C none -A arm64 -T script -d boot.cmd boot.scr
Image Name:   
Created:      Mon Jun 29 19:13:19 2020
Image Type:   AArch64 Linux Script (uncompressed)
Data Size:    876 Bytes = 0.86 KiB = 0.00 MiB
Load Address: 00000000
Entry Point:  00000000
Contents:
   Image 0: 868 Bytes = 0.85 KiB = 0.00 MiB
# e2label /dev/sda2 ROOT
# make fstab look like this:
LABEL=ROOT	/	ext4	defaults	0	0

boot up device.l

References

5.9 pinephone kernel source