DRAFT ====== Generality ====== A side note, at the Kernel level soft (armel)/[[https://wiki.linaro.org/Linaro-arm-hardfloat|hard float]] (armhf) doesn't matter, it matters at the userspace space level when passing function arguments (in hard float they are passed via FPU registers). [[http://linaro.com|Linaro]] has made a [[https://wiki.linaro.org/OfficeofCTO/HardFloat/Benchmarks|benchmark]] about this subject. [[http://en.wikipedia.org/wiki/Nvidia_Tegra#Tegra_2_series|NVidia's Tegra2]]((http://www.nvidia.com/object/tegra-2.html)), which is dual-core [[http://arm.com|ARM]] [[http://en.wikipedia.org/wiki/Cortex-A9|Cortex-A9]], supports only [[http://en.wikipedia.org/wiki/ARM_architecture#VFP|VFPv3]] ((http://www.arm.com/products/processors/technologies/vector-floating-point.php)) and **not** [[http://en.wikipedia.org/wiki/ARM_architecture#Advanced_SIMD_.28NEON.29|NEON]] ((http://www.arm.com/products/processors/technologies/neon.php)) extensions which are more powerful. As of 2012/06/28, the most stable kernel is [[http://gitorious.org/~marvin24/ac100/marvin24s-kernel/commits/chromeos-ac100-3.0|3.0.19]]. This kernel is based on the original work made by [[http://git.chromium.org/gitweb/?p=chromiumos/third_party/kernel.git;a=summary|Google]]. Work has been started on a [[http://gitorious.org/ac100/marvin24s-kernel/trees/linux-tegra-nv-ac100-3.1-exp|3.1.10]] kernel for AC100, which is based on the work of [[http://nv-tegra.nvidia.com/gitweb/?p=linux-2.6.git;a=summary|NVIDIA]]. The next Ubuntu version 12.10 will be based upon this kernel. There also exists a very experimental version of a mainline kernel [[http://gitorious.org/~marvin24/ac100/marvin24s-kernel/commits/for-next|(for-next)]] with a minimal amount of patches. The most hotspot in kernel development is NVEC driver (incomplete implementation and marginal stability issue), sound driver (noise annoyance, automatic switch between Speaker/Headphone (not implemented at all in ASoC but can be easily done with a userspace daemon)) and ''rt2800usb'' Wifi driver (some stability issues and high stress on specific memory pool (reduced by **echo 32000 > /proc/sys/vm/min_free_kbytes**)). ====== Recompiling a Kernel ====== Before doing this operation, try an already compiled kernel for less harsh, here is some link to pick it: =====Ubuntu===== [[http://startx.ro/~jani/|Kernels cooked by Jani Monoses]] http://launchpadlibrarian.net/89568135/linux-image-3.0.8-4-ac100_3.0.8-4.3_armel.deb https://launchpad.net/ubuntu/+source/linux-ac100/3.0.19-1.2/+build/3219594/+files/linux-image-3.0.19-1-ac100_3.0.19-1.2_armhf.deb =====Debian===== [[http://lists.debian.org/debian-arm/2011/07/msg00049.html|http://people.debian.org/~jak/ac100/]] =====Fedora===== http://dmarlin.fedorapeople.org/yum/f15/arm/os/Packages/kernel-tegra-2.6.40.3-2.09.fc15.armv7hl.rpm [[http://zenit.senecac.on.ca/wiki/index.php/Fedora_ARM_Koji_Buildsystem|Fedora ARM Koji Buildsystem]] [[http://arm.koji.fedoraproject.org/koji/packageinfo?packageID=3547|Information for package kernel]] [[http://arm.koji.fedoraproject.org/packages/kernel/3.2.2/1.fc17/armv7hl/kernel-3.2.2-1.fc17.armv7hl.rpm|kernel-3.2.2-1.fc17.armv7hl.rpm]] =====RedSleeve===== TOO OLD ftp://ftp.redsleeve.org/pub/yum/os/Packages/kernel-2.6.32-220.2.1.el6.kirkwood.armv5tel.rpm =====Others===== You can extract zImage and corresponding modules from these packages. === From RPM === ==Using alien== * ''alien --to-tgz linux-image-XXX.rpm'' * ''tar xf linux-image-XXX.tgz'' === From DEB === Get a kernel deb, for example http://startx.ro/~jani/linux-image-3.0.19-1-ac100_3.0.19-1.1_armel.deb ==Using alien== * ''alien --to-tgz linux-image-3.0.19-1-ac100_3.0.19-1.1_armel.deb'' * ''tar xf linux-image-3.0.19-1-ac100-3.0.19.tgz'' ==Or using file-roller== * ''file-roller linux-image-3.0.19-1-ac100_3.0.19-1.1_armel.deb'' (Can non Ubuntu versions of file-roller also read debs?) ==Or using dpkg== * ''dpkg -X linux-image-3.0.19-1-ac100_3.0.19-1.1_armel.deb'' ===Afterwards=== * ''cp -Rp lib/modules/3.0.19-1-ac100 //lib/modules'' * ''abootimg -u /tmp/alien/part-6.img -k /tmp/alien/tgz/boot/vmlinuz-3.0.19-1-ac100'' ===== Compilation environment consideration ===== [[toolchain|Cross-compiling]] and native. ===== 2.6.38 Kernel series ===== git clone -b chromeos-ac100-2.6.38 git://gitorious.org/~marvin24/ac100/marvin24s-kernel.git cd marvin24s-kernel make paz00_defconfig zImage modules modules_install INSTALL_MOD_PATH=/mnt/mmcblk1p1 abootimg -u /tmp/part-6.img -k arch/arm/boot/zImage **/mnt/mmcblk1p1** is where is your rootfs, if it is your live system suppress **INSTALL_MOD_PATH=/mnt/mmcblk1p1** **/tmp/part-6.img** is your copy of your boot image (part 6 for nvflash, mmcblk0p2 device on eMMC for Linux) If you want to create a custom version of your kernel's config, run **make menuconfig** after **make paz00_defconfig**. === After code update in Gitorious repository === git pull make menuconfig zImage modules modules_install INSTALL_MOD_PATH=/mnt/mmcblk1p1 abootimg -u /tmp/part-6.img -k arch/arm/boot/zImage ===== 3.0.x Kernel series ===== TODO === From marvin24s git === To build the kernel native on the ac100, do the following: git clone -b chromeos-ac100-3.0 git://gitorious.org/~marvin24/ac100/marvin24s-kernel.git cd marvin24s-kernel make paz00_defconfig make zImage modules make modules_install You will find the kernel in arch/arm/boot/zImage, which you can flash with abootimg (see above). Cross-Compiling: If you don't have the time to wait for a build on the AC100 (~ 30 minutes), you can try with a cross-compiler on your favorit desktop machine. How to setup such an environment is out of scope of this article, but google is your friend. The procedure is similar to the native one: git clone -b chromeos-ac100-3.0 git://gitorious.org/~marvin24/ac100/marvin24s-kernel.git cd marvin24s-kernel make paz00_defconfig ARCH=arm make zImage modules INSTALL_MOD_PATH=/tmp INSTALL_MOD_STRIP=1 ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- make modules_install INSTALL_MOD_PATH=/tmp INSTALL_MOD_STRIP=1 ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- The INSTALL_MOD_PATH and INSTALL_MOD_STRIP arguments are optional, but convenient. After this, you will find the stripped modules under /tmp/lib/modules/. Similar procedures can be used for the 3.1 and for-next kernels. Some note on the needed kernel command lines: The 3.0 series uses a reserved video memory which is created by adding "mem=448M@0" to the kernel command line. Later kernels can reserve this memory by themself, thus adding "mem=512M@0" is required here. The for-next series is very special (you may have guessed that already). First, everything is setup by device-tree info (if you don't know what a device-tree is, yes, google is your friend again). This means that beside the kernel and the modules, you also have to compile the device-tree, which is done by the "dtbs" make target. After that, the compiled device-tree (in arch/arm/boot/tegra20-paz00.dtb) must be concatenated to the kernel image. So something like cat arch/arm/boot/tegra20-paz00.dtb >> arch/arm/boot/zImage should be sufficient. Make sure you used paz00_defconfig, because this kernel seems to ignore the parameters submitted by the bootloader. === Stock Ubuntu 12.04 Kernel === Step by step: Recompiling the Ubuntu stock kernel natively (for example to patch it) coming from a stock Ubuntu 12.04 install. As of writing the kernel-version is **3.0.27** and will have to be replaced when another kernel comes out/is used. The created files will be copied to a safe place (/home/turbo/Downloads/ in my case) Become root for all steps sudo su Install dependencies for the kernel and build it: apt-get build-dep linux-ac100 apt-get install build-essential lzop cd /usr/src/ apt-get source linux-ac100 cd linux-ac100-3.0.27/ Now if you want the original Ubuntu config do cp /boot/config-$(uname -r) .config If you want the standrad ac100 config instead do: make paz00_defconfig Apply patches if wanted. In this example I use gordans overclocking patches from [[http://www.altechnative.net/2011/12/31/overclocking-the-toshiba-ac100/|his site]]. patch -p1 < tegra_common.patch patch -p1 < tegra_1200.patch (Note that one patch didn't apply cleanly, but the errors were pretty obvious and easy to fix manually.) make -j3 INSTALL_MOD_STRIP=1 zImage modules make -j3 modules_install cp arm/boot/zImage /home/turbo/Downloads/zImage1200-3.0.27 cp .config /boot/config-3.0.27 Get the bootimg.cfg cd /boot/bootimg.cfg /home/turbo/Downloads/ Adjust the bootimg.cfg to your needs. Most importantly giving it a cool greeting text of course! Create the initrd cp .config /boot/config-3.0.27 update-initramfs -k 3.0.27 -c cp /boot/initrd.img-3.0.27 /home/turbo/Downloads/initrd1200-3.0.27.img Create the final image cd /home/turbo/Downloads/ abootimg --create part6_1200-3.0.27.img -f bootimg.cfg -k zImage1200-3.0.27 -r initrd1200-3.0.27.img In my case (10K, Android 2.2) the boot partition is partition 6 as seen by nvflash and /dev/mmcblk0p4 as seen from Ubuntu. Make sure you flash to the right partition, this means: `cat /proc/partitions` has to show the partition as 8.0 MiB and `sudo abootimg -i /dev/mmcblk0p4` has to show "Android boot Image" in the first line. Double-check and create a backup of the boot partition: dd if=/dev/mmcblk0p4 of=/home/turbo/Downloads/part6-$(uname -r).img Size of the original is 8388608 aka 8.0M. This backup wont help you if it's //on// your ac100, so: Be sure to copy this image somewhere else. Be sure to copy this image somewhere else. Really. Flash the image dd if=/home/turbo/Downloads/part6_1200-3.0.27.img of=/dev/mmcblk0p4 Reboot. ===== 3.10.x Kernel series ===== 3.10 build process is close to 3.0 for-next. Device-tree is mandatory, you need to build it and concatenate with a kernel: make dtbs cat arch/arm/boot/tegra20-paz00.dtb >> arch/arm/boot/zImage But 3.10 don't use paz00_defconfig anymore. Instead is uses tegra_defconfig (main idea of device-tree is to have all-in-one kernel and choose drivers on boot time using device-tree): make tegra_defconfig ===== Mainline Git Kernel ===== From 3.15, AC100 finally boots the official mainline kernel ! To succesfully cross-compile it, i used linaro precompiled toolchain [[http://releases.linaro.org/14.05/components/toolchain/binaries/gcc-linaro-arm-linux-gnueabihf-4.9-2014.05_linux.tar.xz]]: wget http://releases.linaro.org/14.05/components/toolchain/binaries/gcc-linaro-arm-linux-gnueabihf-4.9-2014.05_linux.tar.xz extract it somewhere, and export install path so the toolchain can be found: tar xvf gcc-linaro-arm-linux-gnueabihf-4.9-2014.05_linux.tar.xz export PATH=$PATH:gcc-linaro-arm-linux-gnueabihf-4.9-2014.05_linux/bin/ Now you have to clone the kernel git repository: git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git cd linux As already described above, configure && make && install and your kernel is ready! make tegra_defconfig ARCH=arm make zImage modules dtbs INSTALL_MOD_PATH=/tmp INSTALL_MOD_STRIP=1 ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make modules_install INSTALL_MOD_PATH=/tmp INSTALL_MOD_STRIP=1 ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- Copy everything you need in a folder (to copy on SD or USB key and put into AC100) mkdir ~/linux-3.16-0 mv /tmp/lib/ ~/linux-3.16-0/ cp arch/arm/boot/zImage ~/linux-3.16-0/ cp arch/arm/boot/dts/tegra20-paz00.dtb ~/linux-3.16-0/ ==== Kernel Debugging ==== TODO [[http://kernelnewbies.org/KernelHacking|Kernel Hacking]] === GDB and KGDB === TODO http://kgdb.sourceforge.net == Remote debugging session == TODO === SystemTap === TODO [[http://en.wikipedia.org/wiki/SystemTap|Wikipedia's SystemTap article]] [[http://sourceware.org/systemtap/wiki|SystemTap Wiki]] http://sourceware.org/systemtap/SystemTap_Beginners_Guide/cross-compiling.html http://sourceware.org/systemtap/SystemTap_Beginners_Guide/using-usage.html http://omappedia.org/wiki/Systemtap [[http://www.redbooks.ibm.com/redpapers/pdfs/redp4469.pdf|SystemTap: Instrumenting the Linux Kernel for Analyzing Performance and Functional Problems]] by IBM [[http://sourceware.org/systemtap/langref.pdf|Language reference]] [[http://www.ibm.com/developerworks/linux/library/l-systemtap/index.html|Linux introspection and SystemTap, An interface and language for dynamic kernel analysis]] by [[http://www.ibm.com/developerworks/linux/library/l-systemtap/index.html|M. Tim Jones]] [[http://dtrace.org/blogs/brendan/2011/10/15/using-systemtap/|Using SystemTap]] by [[http://dtrace.org/blogs/brendan/about/|Brendan Gregg]] [[http://sprocket.io/blog/2007/11/systemtap-its-like-dtrace-for-linux-yo/|SystemTap: It's like dtrace for linux, yo.]] by [[http://sprocket.io/blog/contact/|Thomas Strömberg]] [[http://sourceware.org/systemtap/examples/|SystemTap Examples]] Examples written by Paul Fertser for tracking [[hardware_specs?&#keyboard_touch_led_battery_controller|NVEC]] activities (this assumes you're crosscompiling and then manually scp'ing and staprun'ing modules) : - first, fetch the address of NVEC: stap -B CROSS_COMPILE=arm-none-linux-gnueabi- -a arm -r ~/openmoko/l/ -v -e 'probe kernel.function("nvec_write_async") { printf("hi, nvecs address is %p\n", $nvec) exit() }' **hi, nvecs address is 0xdf8ae000** - second, with this address, issue events for controlling sound amplifier (warning, guru mode allows arbitrary C code, you can crash a running system with that): stap -g -B CROSS_COMPILE=arm-none-linux-gnueabi- -a arm -r ~/openmoko/l/ -v -e '%{ #include <../drivers/staging/nvec/nvec.h> %} probe begin { %{ nvec_write_async((struct nvec_chip*)0xdf8ae000, "\x0d\x10\x59\x94", 4) %} exit() }' **\x0d\x10\x59\x94** mutes the amplifier, with **\x0d\x10\x59\x95** unmutes it. === DTrace === TODO [[http://dtrace.org/|DTrace's blog]] [[http://www.dtracebook.com/|the DTrace book of scripts and strategy, 1100 pages (2011)]] [[http://www.crisp.demon.co.uk/blog/index.html|Porting effort of DTrace on Linux]] blog of Paul FOX. [[http://sourceware.org/systemtap/wiki/SystemtapDtraceComparison|SystemTap vs. DTrace]] === ftrace === TODO [[http://lwn.net/Articles/365835/|Debugging the kernel using Ftrace - part 1]] [[http://lwn.net/Articles/366796/|Debugging the kernel using Ftrace - part 2]] http://elinux.org/Ftrace [[https://events.linuxfoundation.org/slides/2010/linuxcon_japan/linuxcon_jp2010_rostedt.pdf|Ftrace Linux Kernel Tracing]] by Steve Rostedt [[http://git.kernel.org/?p=linux/kernel/git/rostedt/trace-cmd.git;a=summary|Home of trace-cmd and kernelshark]] ===== Git-Fu ===== TODO [[http://www.eecs.harvard.edu/~cduan/technical/git/|A tutorial on Git]] by Charles Duan. [[http://schacon.github.com/git/gittutorial.html|official Git tutorial]] ====== Kernel Hot patching ====== [[http://www.ksplice.com/doc/ksplice.pdf|Ksplice paper]] [[http://en.wikipedia.org/wiki/Ksplice|Wikipedia's article]] [[https://wiki.ubuntu.com/Ksplice|Ubuntu's Ksplice]] [[http://and-developers.com/custom_recovery:alternative_methods#ksplice_attack|ksplice Attack]] ====== Support ====== [[https://lists.launchpad.net/ac100/|Mailing list]] [[irc://irc.freenode.net/#ac100|channel #ac100 on irc.freenode.net]]