Kernel: Difference between revisions

From OLPC
Jump to navigation Jump to search
No edit summary
 
(29 intermediate revisions by 3 users not shown)
Line 10: Line 10:
* http://dev.laptop.org/git/olpc-kernel
* http://dev.laptop.org/git/olpc-kernel


Current maintainers: Chris Ball, Daniel Drake, Paul Fox
Current maintainers: James Cameron.


We work on specific git branches for each operating system release.
We work on specific git branches, which vary by hardware and operating system release.


{| border="1" cellspacing="0" cellpadding="2" width="100%" class="wikitable"
{| border="1" cellspacing="0" cellpadding="2" width="100%" class="wikitable"
Line 18: Line 18:
! git branches
! git branches
|-
|-
| (none) ARM XO-1.75
| [[12.1.0]] i386
| [http://dev.laptop.org/git/olpc-kernel/log/?h=olpc-5.0 olpc-5.0]
| x86-3.3
|-
|-
| (none) i386 XO-1 XO-1.5
| [[11.3.1]] ARM
| olpc-4.6
| [http://dev.laptop.org/git/olpc-3.0/log/?h=arm-3.0-ramp arm-3.0-ramp]
|-
| [[14.1.0]] i386 XO-1 XO-1.5
| olpc-3.10
|-
| [[Android]] 5.x ARM XO-4
| arm-3.5-android
|-
| [[Android]] 4.x ARM XO-4
| arm-3.5-android-4.x
|-
| [[14.1.0]] [[13.2.1]] [[13.2.0]] [[13.1.0]] ARM XO-4
| arm-3.5
|-
| [[13.2.1]] [[13.2.0]] [[13.1.0]] [[12.1.0]] i386 XO-1 XO-1.5
| x86-3.3
|-
|-
| [[14.1.0]] [[13.2.1]] [[13.2.0]] [[13.1.0]] [[12.1.0]] [[11.3.1]] ARM XO-1.75
| [[11.3.1]] i386
| [http://dev.laptop.org/git/olpc-3.0/log/?h=arm-3.0-wip arm-3.0-wip]
| unknown
|-
|-
| [[11.2.0]] i386
| [[11.2.0]] i386
Line 36: Line 51:
Or looking at git history may identify which branches we are actively working on, and looking at the version of each branch compared to the kernel shipped in each release will help you identify which branch corresponds to which release(s).
Or looking at git history may identify which branches we are actively working on, and looking at the version of each branch compared to the kernel shipped in each release will help you identify which branch corresponds to which release(s).


OLPC-specific configurations can be found at arch/x86/configs/, these are what we use for automated builds and official releases. This configuration is also installed in /boot in our software releases.
OLPC-specific configurations can be found at arch/x86/configs/ and arch/arm/configs/, these are what we use for automated builds and official releases. This configuration is also installed in /boot in our software releases.


Questions and contributions should be sent to the devel [[Mailing lists|mailing list]].
Questions and contributions should be sent to the devel [[Mailing lists|mailing list]].


=== Installing kernel RPMs ===
=== Installing kernel RPMs ===

<b>The following section only applies to pre-13.2 OS releases. On 13.2.0 and newer, installing a new kernel RPM on an XO will automatically activate it on the boot partition as well.</b>


Due to OLPC's versioned filesystem layout, installing a new kernel RPM is not enough for it to become active on reboot. This is explained in detail in /boot/README. To summarise, after installing a kernel you must copy it to a special place:
Due to OLPC's versioned filesystem layout, installing a new kernel RPM is not enough for it to become active on reboot. This is explained in detail in /boot/README. To summarise, after installing a kernel you must copy it to a special place:
Line 53: Line 70:
cp -a /boot/* /versions/boot/current/boot/
cp -a /boot/* /versions/boot/current/boot/


=== Building an OLPC kernel ===
=== Building a kernel RPM ===


If starting from an OLPC build, first install general development packages needed for kernel compiling: git rpmdevtools gcc make ncurses-devel m4 redhat-rpm-config
* If using OLPC OS on your build host, install general development packages needed for kernel compiling:
yum install -y git rpmdevtools gcc make ncurses-devel m4 redhat-rpm-config
# Install build prerequisites: unifdef, lzop, dracut-modules-olpc (be careful with this last one.)
* Install build prerequisites:
# Clone the git repository: <tt>git clone git://dev.laptop.org/olpc-kernel</tt> (you will need at least 1.5 GBytes free)
yum install -y unifdef lzop dracut-modules-olpc
# Checkout the appropriate branch: git checkout olpc-2.6.35 (XO-1.5, for example)
:* On Fedora 14 and older, [[Dracut-modules-olpc#Special considerations for Fedora 14 and older|be careful with dracut-modules-olpc]].
# Run <tt>make clean distclean</tt>
* Install kernel prerequisites:
# Make your changes (updating the configs under arch/x86/configs/ if changes are needed)
yum install -y libertas-usb8388-olpc-firmware \
# Commit all your changes
libertas-sd8686-firmware \
# Run <tt>make xo_1-kernel-rpm</tt> for XO-1, or <tt>make xo_1_5-kernel-rpm</tt> for XO-1.5, or <tt>./olpc/buildrpm 1.75</tt> for XO-1.75
libertas-sd8787-firmware
* Clone the git repository; you will need at least 1.5 GBytes free:
git clone git://dev.laptop.org/olpc-kernel
* Checkout the appropriate branch:
git checkout x86-3.3
* Clean the source tree:
make clean distclean
* Make your source changes,
* Make any defconfig changes, for the laptop model,
** XO-1: arch/x86/configs/xo_1_defconfig
** XO-1.5: arch/x86/configs/xo_1.5_defconfig
** XO-1.75: arch/arm/configs/xo_175_defconfig
** XO-4: arch/arm/configs/xo_4_defconfig
* Commit all your changes,
* Run {{code|olpc/buildrpm}}, for the laptop model;
** XO-1: {{code|olpc/buildrpm 1.0}}
** XO-1.5: {{code|olpc/buildrpm 1.5}}
** XO-1.75: {{code|olpc/buildrpm 1.75}}
** XO-4: {{code|olpc/buildrpm 4}}


RPM files will be output (in olpc/RPMS/) which you can install on an XO (with the above versioned filesystem layout issues in mind).
The output RPM files will be in olpc/RPMS/ which you can install on an XO, with the above versioned filesystem layout issues in mind.


====Note on kernel configuration====
=== Cross compiling ===
When using the kernel rpm build tools, the kernel configuration used is specified by the rpm spec file (in olpc/SPECS). That is the file you must change, as any <tt>.config</tt> file in the top level directory will be ignored. Well, not quite, as its absence is noted. You will get the following error message which can be ignored:


Compiling ARM kernels on ARM is sloooow. It's very easy to cross-compile from a faster box.
*** You have not yet configured your kernel!
*** (missing kernel config file ".config")
***
*** Please run some configurator (e.g. "make oldconfig" or
*** "make menuconfig" or "make xconfig").


Another option (a little more tricky) would be to use [http://crosstool-ng.org/ crosstool-ng] to build and install a cross-compiler.
=== Cross compiling ===

==== Fedora ====


On Fedora 16 or later, you can install an ARM cross compiler with:
Compiling ARM kernels on ARM is sloooow. It's very easy to cross-compile from a faster box. Install an ARM cross compiler (using e.g. [http://crosstool-ng.org/ crosstool-ng]) then adjust your environment so that your cross compiler is included in your PATH, set the CROSS_COMPILE variable to the architecture prefix, and set ARCH=arm. For example:
yum install gcc-arm-linux-gnu binutils-arm-linux-gnu


To build the kernel, set these environment variables:
export PATH=/opt/xcc/gcc-4.6.0/bin:$PATH
export ARCH=arm
export ARCH=arm
export CROSS_COMPILE=armv7-unknown-linux-gnueabi-
export CROSS_COMPILE=armv7-linux-gnu-

==== Ubuntu ====

On Ubuntu 13.04 or later, you can install an ARM cross compiler with:
apt-get install gcc-arm-linux-gnueabi

To build the kernel, set these environment variables:
export ARCH=arm
export CROSS_COMPILE=arm-linux-gnueabi-



Now you can compile kernels in the normal way. Here is a recipe:
Now you can compile kernels in the normal way. Here is a recipe:
Line 98: Line 142:
=== Automatic RPM generation ===
=== Automatic RPM generation ===


Some branches are automatically built every 30 minutes (but only when there are new changes), the results are published at http://dev.laptop.org/~kernels/
During development some branches are automatically built every 30 minutes (but only when there are new changes), the results are published at http://dev.laptop.org/~kernels/


The directories you see there are also linked to [[RPM Dropbox|RPM dropboxes]], therefore are automatically published for inclusion in development builds. In other words, to get your kernel changes included in the current software release development efforts, you simply have to push your changes to the correct branch of olpc-2.6.
The directories you see there are also linked to [[RPM Dropbox|RPM dropboxes]], therefore are automatically published for inclusion in development builds. In other words, to get your kernel changes included in the current software release development efforts, you simply have to push your changes to the correct branch.


The utility behind this magic is olpc-kernel-builder:
The utility behind this magic is olpc-kernel-builder:
Line 106: Line 150:
* git://dev.laptop.org/projects/olpc-kernel-builder
* git://dev.laptop.org/projects/olpc-kernel-builder
* Maintainer: Chris Ball
* Maintainer: Chris Ball

When used under OLPC OS 13.2.0 on an XO-4, change the rpm_target to armv7hl in olpc/buildrpm, otherwise an armv7l rpm is generated, resulting in refusal to install with ''is intended for a different architecture''. This is only a packaging architecture and does not affect how the kernel is compiled.

Install mock to use olpc-kernel-builder
yum install -y mock
:Does not work under OLPC OS 13.2.0, mock fails to mount /proc in the chroot. --[[User:Quozl|Quozl]] 05:32, 21 February 2014 (UTC)

== Running development kernels ==

Starting with 13.1.0 development builds, the /boot (or /bootpart/boot) area of the OS images has changed layout slightly. The kernel and initramfs are now <em>only</em> shipped in zip files, in order to reduce duplication for signed builds, and to remove duplication of firmware code in the olpc.fth boot script.

Dropping your own vmlinuz in place (or booting one from USB as described below, pointing at the internal disk for the initrd.img initramfs) will no longer work as standard, since this will cause the system to start looking for an unzipped initramfs too. The story is similar for initramfs development - if you drop a "raw" initramfs in place, you will need to ensure that an unzipped kernel is also installed. Just run, once, as root:

# olpc-dev-kernel

This will unzip the initramfs from the zip file and save it as <tt>initrd.img</tt>, and similarly it will unzip the kernel from its zip file and save it as <tt>vmlinuz</tt>. In both cases, if an existing initrd.img/vmlinuz file is present, it will not be overwritten.

Now drop your files in place as you have done so before, and the system will pick up the "unzipped" partner initramfs/kernel file.

One more detail to be aware of: if you put "unzipped" initramfs/kernel files in place using this method, you will no longer receive automatic firmware updates from bootfw.zip. This should only affect cases where you drop your own development kernel/initramfs in place, <em>then</em> upgrade the olpc-firmware RPM package, <em>and</em> expect that firmware upgrade to be automatically installed.

For more details, read the original proposal: [http://lists.laptop.org/pipermail/devel/2012-March/034439.html Removing duplication in /boot - affects kernel development].


== Running vanilla kernels ==
== Running vanilla kernels ==


In late 2010, OLPC started a focused effort to upstream its kernel patches so that unmodified "vanilla" kernels run with complete functionality on the XO.
In late 2010, OLPC started a focused effort to upstream its kernel patches so that unmodified "vanilla" kernels run with complete functionality on the XO-1 and XO-1.5.


As of Linux-3.5 these efforts are mostly concluded - OLPC only carries a small number of patches, which will be upstreamed as time permits.
As of 2.6.38 this is coming along nicely, and these efforts will continue til everything is upstream. Unmodified kernels run reasonably well with most functionality available.


You may have to hunt around a bit to satisfy the configuration options so that the relevant drivers get built, and the XO-1.5 needs some special kernel parameters to boot (you can find them in a recent olpc-2.6 branch in the XO-1.5 defconfig as CONFIG_CMDLINE). If in doubt, feel free to ask on the devel [[mailing lists|mailing list]] for someone's recent .config file.
You may have to hunt around a bit to satisfy the configuration options so that the relevant drivers get built. Start with our defconfig in the appropriate branch. If in doubt, feel free to ask on the devel [[mailing lists|mailing list]] for someone's recent .config file.


== Boot your development kernel from USB ==
== Boot your development kernel from USB ==
Line 121: Line 187:
On your development system, prepare a USB disk as follows:
On your development system, prepare a USB disk as follows:


<b>XO-1.75:</b>
<b>XO-1.75 and XO-4:</b>
* /boot/olpc.fth (download from [http://dev.laptop.org/~dsd/20111013/olpc.fth here])
* /boot/olpc.fth (download from [http://dev.laptop.org/~dsd/20111013/olpc.fth here])
* /boot/zImage (your kernel that you want to test)
* /boot/zImage (your kernel that you want to test)

Latest revision as of 08:04, 20 April 2019


The OLPC kernel

OLPC OS Releases use our OLPC-modified version of the Linux kernel.

The OLPC kernel is maintained in git:

Current maintainers: James Cameron.

We work on specific git branches, which vary by hardware and operating system release.

operating system release git branches
(none) ARM XO-1.75 olpc-5.0
(none) i386 XO-1 XO-1.5 olpc-4.6
14.1.0 i386 XO-1 XO-1.5 olpc-3.10
Android 5.x ARM XO-4 arm-3.5-android
Android 4.x ARM XO-4 arm-3.5-android-4.x
14.1.0 13.2.1 13.2.0 13.1.0 ARM XO-4 arm-3.5
13.2.1 13.2.0 13.1.0 12.1.0 i386 XO-1 XO-1.5 x86-3.3
14.1.0 13.2.1 13.2.0 13.1.0 12.1.0 11.3.1 ARM XO-1.75 arm-3.0-wip
11.2.0 i386 olpc-2.6.35
10.1.3 i386 olpc-2.6.31

Or looking at git history may identify which branches we are actively working on, and looking at the version of each branch compared to the kernel shipped in each release will help you identify which branch corresponds to which release(s).

OLPC-specific configurations can be found at arch/x86/configs/ and arch/arm/configs/, these are what we use for automated builds and official releases. This configuration is also installed in /boot in our software releases.

Questions and contributions should be sent to the devel mailing list.

Installing kernel RPMs

The following section only applies to pre-13.2 OS releases. On 13.2.0 and newer, installing a new kernel RPM on an XO will automatically activate it on the boot partition as well.

Due to OLPC's versioned filesystem layout, installing a new kernel RPM is not enough for it to become active on reboot. This is explained in detail in /boot/README. To summarise, after installing a kernel you must copy it to a special place:

If running a software release that uses partitions, first check to ensure that /bootpart is mounted (it should have several directories in it). If it isn't, mount it:

mount /dev/mmcblk0p1 /bootpart

Then:

rsync --delete-before -av /boot/ /bootpart/boot/

If running a software release that does not use partitions:

cp -a /boot/* /versions/boot/current/boot/

Building a kernel RPM

  • If using OLPC OS on your build host, install general development packages needed for kernel compiling:
yum install -y git rpmdevtools gcc make ncurses-devel m4 redhat-rpm-config
  • Install build prerequisites:
yum install -y unifdef lzop dracut-modules-olpc
  • Install kernel prerequisites:
yum install -y libertas-usb8388-olpc-firmware \
               libertas-sd8686-firmware \
               libertas-sd8787-firmware
  • Clone the git repository; you will need at least 1.5 GBytes free:
git clone git://dev.laptop.org/olpc-kernel
  • Checkout the appropriate branch:
git checkout x86-3.3
  • Clean the source tree:
make clean distclean
  • Make your source changes,
  • Make any defconfig changes, for the laptop model,
    • XO-1: arch/x86/configs/xo_1_defconfig
    • XO-1.5: arch/x86/configs/xo_1.5_defconfig
    • XO-1.75: arch/arm/configs/xo_175_defconfig
    • XO-4: arch/arm/configs/xo_4_defconfig
  • Commit all your changes,
  • Run olpc/buildrpm, for the laptop model;
    • XO-1: olpc/buildrpm 1.0
    • XO-1.5: olpc/buildrpm 1.5
    • XO-1.75: olpc/buildrpm 1.75
    • XO-4: olpc/buildrpm 4

The output RPM files will be in olpc/RPMS/ which you can install on an XO, with the above versioned filesystem layout issues in mind.

Cross compiling

Compiling ARM kernels on ARM is sloooow. It's very easy to cross-compile from a faster box.

Another option (a little more tricky) would be to use crosstool-ng to build and install a cross-compiler.

Fedora

On Fedora 16 or later, you can install an ARM cross compiler with:

yum install gcc-arm-linux-gnu binutils-arm-linux-gnu

To build the kernel, set these environment variables:

export ARCH=arm
export CROSS_COMPILE=armv7-linux-gnu-

Ubuntu

On Ubuntu 13.04 or later, you can install an ARM cross compiler with:

apt-get install gcc-arm-linux-gnueabi

To build the kernel, set these environment variables:

export ARCH=arm
export CROSS_COMPILE=arm-linux-gnueabi-


Now you can compile kernels in the normal way. Here is a recipe:

mkdir -p /tmp/xo/lib/modules
mkdir -p /tmp/xo/bootpart/boot
cp arch/arm/configs/xo*fig .config
make oldconfig zImage
make modules
INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=/tmp/xo make modules_install
cp arch/arm/boot/zImage /tmp/xo/bootpart/boot/
(cd /tmp/xo/bootpart/boot/ && ln -sf zImage vmlinuz)

After this, /tmp/xo can be tar'd up and extracted on the XO, on USB media, or on an NFS mount point.

Automatic RPM generation

During development some branches are automatically built every 30 minutes (but only when there are new changes), the results are published at http://dev.laptop.org/~kernels/

The directories you see there are also linked to RPM dropboxes, therefore are automatically published for inclusion in development builds. In other words, to get your kernel changes included in the current software release development efforts, you simply have to push your changes to the correct branch.

The utility behind this magic is olpc-kernel-builder:

When used under OLPC OS 13.2.0 on an XO-4, change the rpm_target to armv7hl in olpc/buildrpm, otherwise an armv7l rpm is generated, resulting in refusal to install with is intended for a different architecture. This is only a packaging architecture and does not affect how the kernel is compiled.

Install mock to use olpc-kernel-builder

yum install -y mock
Does not work under OLPC OS 13.2.0, mock fails to mount /proc in the chroot. --Quozl 05:32, 21 February 2014 (UTC)

Running development kernels

Starting with 13.1.0 development builds, the /boot (or /bootpart/boot) area of the OS images has changed layout slightly. The kernel and initramfs are now only shipped in zip files, in order to reduce duplication for signed builds, and to remove duplication of firmware code in the olpc.fth boot script.

Dropping your own vmlinuz in place (or booting one from USB as described below, pointing at the internal disk for the initrd.img initramfs) will no longer work as standard, since this will cause the system to start looking for an unzipped initramfs too. The story is similar for initramfs development - if you drop a "raw" initramfs in place, you will need to ensure that an unzipped kernel is also installed. Just run, once, as root:

# olpc-dev-kernel

This will unzip the initramfs from the zip file and save it as initrd.img, and similarly it will unzip the kernel from its zip file and save it as vmlinuz. In both cases, if an existing initrd.img/vmlinuz file is present, it will not be overwritten.

Now drop your files in place as you have done so before, and the system will pick up the "unzipped" partner initramfs/kernel file.

One more detail to be aware of: if you put "unzipped" initramfs/kernel files in place using this method, you will no longer receive automatic firmware updates from bootfw.zip. This should only affect cases where you drop your own development kernel/initramfs in place, then upgrade the olpc-firmware RPM package, and expect that firmware upgrade to be automatically installed.

For more details, read the original proposal: Removing duplication in /boot - affects kernel development.

Running vanilla kernels

In late 2010, OLPC started a focused effort to upstream its kernel patches so that unmodified "vanilla" kernels run with complete functionality on the XO-1 and XO-1.5.

As of Linux-3.5 these efforts are mostly concluded - OLPC only carries a small number of patches, which will be upstreamed as time permits.

You may have to hunt around a bit to satisfy the configuration options so that the relevant drivers get built. Start with our defconfig in the appropriate branch. If in doubt, feel free to ask on the devel mailing list for someone's recent .config file.

Boot your development kernel from USB

When doing kernel development, it is time consuming to commit each small change, make an RPM, install RPM on the XO, reboot, and test. Instead, you can follow this procedure:

On your development system, prepare a USB disk as follows:

XO-1.75 and XO-4:

  • /boot/olpc.fth (download from here)
  • /boot/zImage (your kernel that you want to test)

XO-1.5 and XO-1

  • /boot/olpc.fth (download for XO-1 or XO-1.5, be sure to rename to olpc.fth)
  • /boot/irfs.img (download here - this is a hacked OLPC initramfs which doesn't require /ofw support)
  • /boot/bzImage (your kernel that you want to test)

Now plug this disk into your XO, turn it on, and the system will load the kernel from USB while booting the rest of the system as normal. If your new kernel crashes badly, just unplug the USB disk and boot the system again - it will revert to booting the "good" kernel from local disk.

Note: for XO-1 this only works with JFFS2. (small tweaks to olpc.fth or the hacked initramfs would be needed for ubifs).