Cross-compiling Custom Kernels for Little Linux Plug Computers - page 2
Configure and build
You're ready to start building! Change directory into the kernel source you just unpacked. You can make a default configuration that should work on most plug computers with:
$ make ARCH=arm kirkwood_defconfig
$ make ARCH=arm menuconfig
Do not forget the ARCH=arm! If you do, you'll end up overwriting your configuration with something that won't work at all on a plug computer. If you've built desktop kernels before, it's easy to forget and assume your configuration is all saved in .config. It's not: you need the ARCH=arm every time.
Most plugs use the ubifs filesystem, which is not enabled by default. You probably want to enable it, especially if you'll be re-using the old root partition. First enable UBI, the last item under Device Drivers->Memory Technology Device (MTD) support; then enable UBIFS, under Filesystems->Miscellaneous filesytems.
Finally, you're ready to build your kernel! Collect that CROSS_COMPILE value you figured out earlier, and use it now:
$ make -j4 ARCH=arm CROSS_COMPILE=/usr/local/CodeSourcery/Sourcery_G++_Lite/bin/arm-none-eabi- uImage $ make -j4 ARCH=arm CROSS_COMPILE=/usr/local/CodeSourcery/Sourcery_G++_Lite/bin/arm-none-eabi- modules $ make -j4 ARCH=arm CROSS_COMPILE=/usr/local/CodeSourcery/Sourcery_G++_Lite/bin/arm-none-eabi- INSTALL_MOD_PATH=modules_install modules_install
Assuming that worked, you now have a kernel image in arch/arm/boot/uImage and a directory of modules in modules_install.
You'll probably want to make a tarball of the modules:
$ cd modules_install; tar czvf modules.tar.gz .
Testing your new kernel
Install your kernel and modules as in part 2). The most reliable method is to copy the uImage and modules.tar.gz onto a thumb drive, connect to the plug over a serial cable and use fatload, nand erase and nand write, or run recover2. Or you can use an SD card or the tftp program, or a program like esia that uses JTAG (though I never had much luck with that myself).
Some plugs come configured to boot only the kernel that shipped with them. To use a different kernel, you may need to set a variable in uboot:
Marvell>> setenv mainlineLinux yes Marvell>> saveenvYou only need to do this once.
For all methods except run recover2, you'll need to copy the modules while the plug is up and running. You can do this either before or after installing the kernel image. Mount the thumb drive, and extract the modules at the root of the plug's filesystem:
# cd / # tar xvf /media/blahblah/modules.tar.gz
Don't forget to cross your fingers and sacrifice a chicken (vegetarians can sacrifice a zucchini instead). If you see "Bad magic number", it probably means either that you've copied the kernel to the wrong place, or you forgot the magic ARCH=arm somewhere along the line. Once the kernel boots, test all the devices you use: you may have trouble with some drivers, like wi-fi, in mainline kernels.
Sure, it would be nice if this were easier. As with much of the plug computing world, there are a lot of unknowns and a lot of things that don't work perfectly yet. But with a little fiddling, you'll probably be able to get a kernel booting fairly quickly. Good luck!
Akkana Peck is a longtime Linux programmer and is currently Chief Plug Wrangler at a small startup. She's also the author of Beginning GIMP: From Novice to Professional, and will be speaking this weekend at Scale9x.
Solid state disks (SSDs) made a splash in consumer technology, and now the technology has its eyes on the enterprise storage market. Download this eBook to see what SSDs can do for your infrastructure and review the pros and cons of this potentially game-changing storage technology.
- 1Linux Top 3: GNOME 3.12 and New Betas for Ubuntu 14.04 and OpenMandriva Lx 2014.0
- 2Linux Top 3: Linus Lashes out, Linux 3.14 Gets PIE and Ubuntu One is Done.
- 3Linux Top 3: Ubuntu 14.04, Debian Gives Squeeze More Life and Red Hat Goes Atomic
- 4Linux Top 3: CoreOS, Oracle Enterprise Linux 7 and Ubuntu 14.10
- 5Linux Top 3: Debian Dumps SPARC, Ubuntu Takes Over Linux 3.13 and the Core Infrastructure Initiative