Pine Phone Kernel Build & Customization.
I had planned on building a new, customized kernel for my pine64 Pine Phone because, the kernel that came with the Mobian OS that I'm running, didn't have the more primitive mouse drivers installed. When I say primitive mouse drivers, I mean the drivers that allow one to use one's mouse in the console to do basic copying and pasting. Copying and pasting in the console is essential, because without it one will be doing copious amounts of typing, instead.
I started by downloading the kernel sources for the Pine Phone, from the phone itself. My was to copy the contents of the SD card and run it in a chroot and build the kernel within that environment. I had a few setbacks doing that so I decided to build the pine phone's kernel on my Raspberry Pi 4B. First, if this was going to work I had to make sure that both machines were binary compatible, meaning that if I compiled a program on my Pi, would it run on the pine phone with little or no fuss. Turns out They're very compatible, which gave me the confidence to attempt this. Since I use Debian and the pine phone is running Mobian which is essentially, Debian too, after I configured the kernel, instead of issuing the make command, I used the make bindeb-pkg option, which will basically, build me a Debian kernel complete with the .deb extension and should easily install on the phone, using the package manager apt or in this case dpkg. As I'm writing this, the kernel is being built. It will probably last an hour or two since I'm actually building it on a Raspberry Pi and those CPU's aren't the most powerful or the most fast. However, The kernel build process isn't placing any stress on the system. So far only 1.32G out of 8G is being used and there isn't any evidence that the system is being taxed in any way. The temperature is a little high though, around 41.381 °C/106.485 °F, totally acceptable, in my estimation.
The real test will be if the kernel is any good, that's the ultimate, desired goal. We never give up, so if there are any obstacles we'll do some more reading and eventually, progress will be made. However, I'm hopeful that this may actually work and I'll post the results right here as they progress.
Well I had a few kernel errors, so I had to alter the kernel configuration file and restart the build process. I have no doubt that further interruptions will occur. One thing is for certain, I must create newer chroot environments on my faster computers and build the kernels there, because the build process, on the Raspberry Pi, though mild on resources and hardly noticeable, takes quite a while even with 8G of RAM. I think I know why though. It seems that the kernels in the Pine Phones are all built with debugging information included, which will ultimately make for larger kernels and larger kernels take a longer time to build. Well now, a bit of good news now, I've successfully built the kernel and after I take a walk to the grocer and a little extra for exercise, I'll come back and see if this kernel will actually work. I'll make sure that the old kernel is all backed up just in case. Wish me luck. Wow, that kernel was three-quarters of Gigabyte, well unless I'm mad, it's 778M, no wonder it took four hours to build. However, my build included two kernel image files one weighing in at 778M the other at 47M, kernel headers and another named, linux-libc-dev5.10.13-rt24-1arm64.deb. The command I used was, make bindeb-pkg, if I had used make deb-pkg there would be a sources file reflecting the sources that I used to build this particular kernel. I'm going to install the smaller kernel image file, for obvious reasons, I'll let the developers install the big one. However before I install it I'm going to take it apart and look at the configuration file to make sure that the drivers I want, are included.
How does one take a .deb file apart you ask? Well it's simple, what I do is, this, I place the file in a directory that I call foo and within foo, I execute the command ar -x and split the .deb file into all it's components which are usually other compressed files, usually decompressed by using the tar command. Go ahead, try it, if you like. Especially if you're a Debian user, or any derivative, if this is your first time hearing or reading this try it for yourself. You may or may not wish to read the man pages or the ar command but it's not really necessary in this case. Just put your .deb file into an empty directory and issue the command ar -x whateverdebfile.deb and see what happens. There should be three new files plus your original .deb file in the directory now. One called control.tar.xz, data.tar.xz, debian-binary and your source .deb file.
Well my Pine Phone hated that kernel and it would not boot. I just realized that I could have saved myself loads of time by installing the headers for the kernel already installed and compile the modules for them there. It's been a long time, maybe two years ago, since I did this sort of thing on a regular basis and I have so much useless information in my head that I can't remember them all. Okay I'll attempt to recover this machine and find another way to get this pine phone, this computer, to bend to my will. So far so good, I'm not sure what went wrong with the kernel build if anything, I'm puzzled as to why the kernel was rejected by the device. Perhaps I need to go to the Mobian project page and see if they have their own tool kit for building kernels. Anyhow, we're up and running again, like it never happened. I'll just apt remove that failed kernel and go to plan B, which is download the headers and build the mouse modules I need. My memory is a little fuzzy on how I've done this in the past but I'll fail a few times before I get it right.
March 09, 2021
I've reconsidered, for the moment, if this next method fails, then I'll go back to plan B. If plan B is still the same, what plan nomenclature is this? I think I'll call this plan plan A one. Plan A one, is the native building of the kernel on the Pine Phone itself. Yes, I know it's mad but how is one to learn if one never does things worthy of learning? I don't expect it to work but what exactly do I have to lose? I'm going to do that next and if I fail, I'll document it and then I'll make the missing modules using the kernel headers located in /usr/src. Well I've done it and it's just begun. I've commenced the building of the Pine Phone kernel, on the phone itself, not many resources are being use which is a good thing, although, I'm afraid this could take several hours. However, I've used the kernel configuration file of the smaller kernel so I suspect it will not take as long as the last kernel I made earlier.
Another failure I'm afraid. There must be a special tool kit that the developers use to build kernels for Pine Phones and I need to seek it out. It took almost 24 hours to build those kernels on the Pine Phone, totally, unacceptable. I guess it's plan B then. Plan B is building the mouse modules using the kernel headers. First I'll have to refresh my memory on how that's done. I swear, I've forgotten so many things, that it's a good thing, I've started writing down, much of what I do now. Luckily all I have to do is take out the SD card and make some edits. Pretty much what I did yesterday. I knew, that I could have tried a quicker solution, namely plan B, however, I had to see if a natively built kernel would work. Now, I have my answer and I no longer have to guess. Well off I go then, I'll keep this page well documented and let my progress be known.
March 11, 2021
Finally, it's a success. All the methods I used were absolute failures, so I announced an appeal on the fediverse asking anyone who knew the correct procedure to compile pine-phone kernels to drop me a clue and someone actually did. Mobian, @email@example.com, gave me a most valuable resource via a link to where the repository for the Pine Phone kernels we being held captive. There were even some great instructions on how to get on. The entire kernel build too about twenty minutes, unbelievable. Especially since my methods were taking up the better part of this week, I am elated at the progress and success that occurs when all the tools are on hand. I'm a firm believer, that if I have the correct tools, I can get any job done. Anyway, I don't see why I should keep the knowledge that @mobian gave me, to my self here is the link to the Pine Phone's kernel sources right here. This is why I love using free and open source software, because once I have a clear instruction set and the right tools I can customize my computing environment. So, now sadly this seems to be the end of this specific topic on Pine Phones, since we have successfully completed our tasks. I'm sure there will be other things which I'd like to improve about my Pine Phone experience and I'll gladly document those events when they arise. Thanks for all those who helped making this happen and thanks for all who took time out of their busy schedules to read my rantings. The End.