|
#1
|
|||
|
|||
|
kernel-power extends the capabilities of the N900 kernel by a lot, but sometimes you'd like to have some features that don't exist even in kernel-power, which means we need to compile a custom kernel. It is generally a good idea to base your custom kernel on kernel-power rather than the stock kernel in order to retain (or gain) all the nice features that it already has while adding your own.
As I spent the last week trying to compile my own kernel based on kernel-power (and adding CD-ROM drivers) and ran into virtually any possible problem, here's my definite A-Z guide for recompiling kernel-power. So here goes: Step 1 - Setting up your environment You will need a Linux machine with Scratchbox and the Maemo SDK installed. If you only have Windows machines then too bad. You will need to repartition your HD and install Linux or use virtualization utilities like VMWare to have a Linux instance running. I used Debian GNU/Linux as my platform but most people recommend using Ubuntu, which is supposedly a lot more user-friendly. Anyway, It's just according to taste. Go to the Maemo 5 SDK installation for beginners on Nokia's website and install Scratchbox, the SDK and the Nokia binaries according to the instructions. Stop just before the "Running Maemo 5 SDK" paragraph. If installing the SDK crashes with the "Error opening terminal" message: Exit scratchbox if you're in it and perform the solution discussed here. If you're working from an X terminal, type the following commands as root: Code:
mkdir -p /usr/share/terminfo/x cd /usr/share/terminfo/x ln -s /lib/terminfo/x/xterm xterm Important: From now on, all commands specified are to be entered inside scratchbox, not directly on your Linux machine. Entering these commands directly on your Linux machine (especially as root) will cause problems. Step 2 - Adjust Scratchbox for kernel compilation Create a new target called MaemoKernel with qemu-arm CPU transparency. The second command installs the armel rootstraps to the target. The last command installs the C-library, /etc, devkits and fakeroot. Code:
[sbox-FREMANTLE_ARMEL: ~] > sb-conf setup MaemoKernel \ -c cs2007q3-glibc2.5-arm7 \ -d qemu:perl:svn:apt-https -t /scratchbox/devkits/qemu/bin/qemu-arm-sb [sbox-FREMANTLE_ARMEL: ~] > sb-conf select MaemoKernel [sbox-MaemoKernel: ~] > sb-conf rs MaemoKernel \ /home/<username>/maemo-sdk-rootstrap_5.0_armel.tgz [sbox-MaemoKernel: ~] > sb-conf in MaemoKernel -edFL Unfortunately in many cases the MaemoKernel target will end-up broken (i.e. with a lot of missing dependencies). To make sure that we have all of the required packages, perform the following commands: Code:
fakeroot apt-get update fakeroot apt-get -f install Code:
fakeroot apt-get -o APT::Architecture=armel update fakeroot apt-get -o APT::Architecture=armel -f install Code:
fakeroot apt-get install ncurses-dev Finally, install the Nokia binaries as mentioned in step 1. Our environment is ready. Step 3 - Obtain kernel-power sources Add the extra repositories to scratchbox by adding the following lines to /etc/sources.list Code:
deb http://repository.maemo.org/extras/ fremantle free non-free deb-src http://repository.maemo.org/extras/ fremantle free Code:
deb http://repository.maemo.org/extras-testing/ fremantle free non-free deb-src http://repository.maemo.org/extras-testing/ fremantle free Code:
deb http://repository.maemo.org/extras-devel/ fremantle free non-free deb-src http://repository.maemo.org/extras-devel/ fremantle free Code:
fakeroot apt-get update fakeroot apt-get install kernel-power-source Create a new directory for the kernel sources and switch to it: Code:
mkdir ~/maemo_kernel cd ~/maemo_kernel Code:
bzip2 -d < /usr/src/kernel-power-source.tar.bz2 | tar -x Important: Other guides use the following command to obtain the kernel-power sources: Code:
apt-get source kernel-power Step 4 - Configure the kernel First of all, enter the kernel sources directory using: Code:
cd kernel-power-source Code:
scripts/kconfig/lxdialog/check-lxdialog.sh Code:
# What library to link
ldflags()
{
for ext in so a dylib ; do
Code:
# What library to link
ldflags()
{
# XXX autodetection fails in scratchbox
echo -lncurses
exit
for ext in so a dylib ; do
Code:
make EXTRAVERSION=<extraversion> menuconfig <extraversion> for the stock kernel is: -omap1 <extraversion> for kernel-power it is: .10power46 I used the following: .10power46-niq The configuration utility should now load. It should already have the default configuration of kernel-power so you can modify whatever you want. If it doesn't seem to have the kernel-power configuration, type the following command: Code:
make EXTRAVERSION=<extraversion> rx51power_defconfig Step 5 - Compiling the kernel Edit the following file with your favorite editor: Code:
arch/arm/plat-omap/bootreason.c Code:
len += sprintf(page + len, "%s\n", boot_reason); Code:
// len += sprintf(page + len, "%s\n", boot_reason); len += sprintf(page + len, "pwr_key\n"); Compile the kernel using the following command Code:
make EXTRAVERSION=<extraversion> bzImage Code:
arch/arm/boot/zImage Code:
include/linux/autoconf.h:556:1: fatal error: /drivers/gpu/pvr/pvrconfig.h: No such file or directory Code:
ln -s /home/<username>/maemo_kernel/kernel-power-source/drivers /drivers Step 6 - Compiling and assembling the kernel modules: Compile the modules with the following command: Code:
make EXTRAVERSION=<extraversion> modules Code:
mkdir ../modules
find . -name "*.ko" -exec cp '{}' ../modules/ \;
cd ../modules
Code:
strip --strip-debug * You can now exit scratchbox. Step 7 - Copying module files to the phone Note: Before you begin this step, make sure you already have kernel-power installed. If not, install it now from the app manager or by typing the following command in a root shell on the phone: Code:
apt-get install kernel-power-settings Code:
2.6.28.10power46-niq Copy all the .ko files from the modules directory of your development machine (the scratchbox directory hierarchy is located inside /scratchbox on the development machine) to the directory you've just created on your phone. Make sure the directory and all files in it are owned by root (otherwise due to security concerns the kernel won't load them). Enter the following commands as root on the phone in the /lib/modules directory: Code:
chown -R root:root <version><extraversion> Code:
chmod 644 <version><extraversion>/* Code:
depmod <version><extraversion> Code:
depmod 2.6.28.10power46-niq It is now time to test our new kernel on the phone. Note that we use a special method to boot the new kernel on the phone without actually flashing it, which means that if it doesn't work, it takes nothing more than a single reboot to revert back to the previous kernel. Obtain the Maemo Flasher-3.5 from here and install it. Copy the zImage file containing the kernel image to the machine on which you have the flasher installed. Now shut-down your phone (give it a little time to rest because if you touch it in the few seconds after you shut down it boots right back up). Take the USB data cable that came with your phone and connect it to your computer. Now hold the letter 'U' on your phone and while holding it, connect the cable to the phone. If everything went OK, you should be seeing a Nokia logo on your phone screen with the USB symbol in the upper-right corner. This means that the device is now in flashing mode (don't worry, we don't flash yet). If the machine from which your're running the flasher is a Windows machine you will have to wait a while for Windows to install the appropriate driver if this is the first time you connect your phone in flashing mode. Now it's time to test your new kernel. Type the following command on your machine where the flasher is installed in the flasher's directory: Code:
flasher-3.5 -l -b -k <path-to>/zImage Extremely important: If your new kernel does not boot or your device immediately shuts down / restarts or you experience any other problem that you have not experienced earlier DO NOT PROCEED to the next step!!! Reboot the phone immediately to revert to your previous kernel and ask here for advice. Step 9 - Flashing the new kernel So now it's the time to permanently install your new kernel on the phone. First, return to scratchbox and edit the following file: Code:
arch/arm/plat-omap/bootreason.c Code:
make EXTRAVERSION=<extraversion> bzImage Code:
cd /lib/modules rm current ln -s <version><extraversion> current Copy the newly created zImage from the development machine to the flashing machine (if they are not the same one). Now put the phone into USB flashing mode as described in step 8 and then flash it uing the following command: Code:
flasher-3.5 -f -k <path-to>/zImage Congratulations, you now have a new kernel. Please write back if you found this useful.
Last edited by NiQ; 2011-03-21 at 17:35. Reason: Added changing permissions / ownership of the module files. |
| The Following 49 Users Say Thank You to NiQ For This Useful Post: | ||
anapospastos, arora.rohan, bingomion, blue_led, cfh11, cheve, chrget, Chrome, clasificado, debernardis, Fabry, Flynx, futtawuh, fw190, Halftux, handaxe, hardkorek, ivgalvez, jj0, joerg_rw, JorgeFX, jstokes, jurop88, laasonen, maacruz, MaddogG, Magik, Megaltariak, Mentalist Traceur, misiak, mr id, MyNokiaN900, Netweaver, Nikem, noorallah, peterleinchen, reinob, rfranz, sinaisix, slender, Switch_, ThomasAH, Tiboric, traysh, trompkins, tuminoid, vi_, woody14619 | ||
|
#2
|
||||
|
|
||||
|
This is awesome.. but wouldn't it be better as a Wiki page? That would allow people to update it as things change over time. (And linking that wiki page here would be great too.
)
|
| The Following User Says Thank You to woody14619 For This Useful Post: | ||
|
#3
|
||||
|
||||
|
awesome is the exact word, Thanks NiQ
|
|
#4
|
|||
|
|||
|
Thanks to everyone who replied.
woody14619 - good idea. I'll turn it into a wiki page once I'm confident I haven't forgotten anything (just edited the post and added a thing that I forgot). |
|
#5
|
||||
|
|
||||
|
Quote:
Please to put a link to it in the first post when you add it to the wiki, and thanks again for putting this very important document to writing!
|
|
#6
|
|||
|
|||
|
Great tutorial. Thanks for posting.
Putting it in wiki is good idea. |
|
#7
|
||||
|
||||
|
I'm not all convinced about the "wiki, so everybody can mess around with it" idea. NiQ's approach is rather sane. I've seen too many wiki pages going bonkers by edits of users that tried to add the useless detours they took, or simply "correcting" things they didn't understand. This is more unlikely to happen if the tutorial is really good and easy to understand, but in early stages you learn to hate when that happens. So "wiki - YES! But not immediately" :-)
Thanks NiQ! Great work. /j
__________________
Maemo Community Council member [2012-10, 2013-05, 2013-11, 2014-06 terms] Hildon Foundation Council inaugural member. MCe.V. foundation member EX Hildon Foundation approved Maemo Administration Coordinator (stepped down due to bullying 2014-04-05) aka "techstaff" - the guys who keep your infra running - Devotion to Duty http://xkcd.com/705/ IRC(freenode): DocScrutinizer* First USB hostmode fanatic, father of H-E-N |
![]() |
|
|