Thursday 15 July 2010

Making a MeeGo kernel package for the Joggler

This is a guide to how to make a kernel package for MeeGo for a given device, in this example we are using the Joggler, a Atom-based 7" touchscreen computer and hackable to run Linux.

This is highly technical and you're supposed to know what you're doing :) It is expected you know at least about git and have a OBS account with access to MeeGo weekly or daily Trunk. It is also assumed we cannot send these patches for official inclusion (let's play that we're under NDA) or get help to add new configurations to the MeeGo kernel packaging from the kernel guys.

This text is similarly licensed with that of wiki.meego.com as to enable inclusion of things from here eventually.

Starting out - we have a device, some patches to add board support and a kernel config.

First off, clone the MeeGo kernel source (this git tree represents what is in MeeGo trunk at this instant) on gitorious:

http://meego.gitorious.org/meego-os-base/kernel-source

Now that we have cloned it (and I assume you have it in your kernel-source directory in your homedir), we can start adding support. The important thing to remember is that *.spec is automatically generated in this repository. If it was up to me, these wouldn't be part of the git tree, and just automatically generated.

First, we have to add the joggler specific kernel package. You have to do this in multiple places.

You can see how I did this for the Joggler in this commit and this errata commit and another errata commit.

Now you can do 'make joggler' to get a kernel-joggler.spec. You'll need to regenerate this in a bit, but take a look if it's been done right.

We have a configuration for the Joggler kernel, let's call it joggler-defconfig. What we now need to do is to find the differences between the generic configuration (config-generic) and our Joggler specific configuration.

In the git tree there is a tool called configdiff.pl which is excellent for this kind of thing.

Run: perl configdiff.pl config-generic joggler-defconfig > config-joggler

Then go through it and see if there's any options that really needs to be there.

Then you have to add your new configuration file to the system. In a small bunch of places, where, you can see in this commit. After this, make generic joggler; make -f Makefile.config kernel-joggler.config and verify everything looks fine in kernel.spec, kernel-joggler.spec and kernel-joggler.config.

Now, we want to try to make our first test compile in OBS. Make a package 'kernel-joggler' in your OBS, point the build target towards something containing MeeGo Trunk/Core. Check out your kernel-joggler project and grep Source kernel.spec.

These files are the ones (along with everything in patches/, kernel.spec and kernel-joggler.spec), you will want to drop into your OBS package. Grab a Linux kernel version while you're at it and put it there, URL is in Source0.

osc addremove; osc commit -m "Initial commit"

Kernel starts building.. Occasionally you might run into things like:

CONFIG_CFG80211_INTERNAL_REGDB
CONFIG_RT2800USB_RT30XX
CONFIG_RT2800USB_RT35XX
CONFIG_RT2800USB_UNKNOWN
CONFIG_TOUCHSCREEN_USB_NEXIO
CONFIG_HID_PICOLCD_LCD
make[1]: *** [nonint_oldconfig] Error 6

This usually means there is some kernel options in the resulting merge that aren't set - ordinarily this would be asked interactively, but since we're building inside a OBS, this isn't happening.

I fixed this in my config-joggler like in this commit.

With this fixed, I was able to have my first kernel-joggler built :)

In order to add patches, this is another tale, but scripts/sequence-patch.sh --quilt will set up a tree for you. The 'series' file is the one you need to use, and then re-make *.spec files. There is a guide in README.workflow how to deal with this.

If you git pull from the kernel source, you might get conflicts in *.spec, - just get everything that comes from kernel-source upstream and re-make. kernel.spec.in is what is important.

Have fun porting MeeGo to your device! If you can, work upstream in Linux kernel and submit patches mainline. Work as if you would eventually include patches in upstream.

For ARM devices, you can come by and contribute to the effort in #meego-arm on irc.freenode.net. Approach on ARM to kernel packages there is quite similar.

Sunday 25 April 2010

Joggler as DVB-T mini TV

Just a little eyecatcher: Joggler with Ubuntu and fully configured dvb-t stick.



There's no big howto. Just compile the modules for your tv stick, install an app like kaffeine and let it rock!

Saturday 24 April 2010

Running the original Software out from your linux distro!

Ok another smart how to, so you will be able to start the original software from your linux distro:

starting here:

1. mount mmcblk0p2 somewhere, if not already done:
"sudo mount /dev/mmcblk0p2 /mnt"

2. copy the whole openpeak folder to your root:
"sudo mkdir /openpeak"
"sudo cp -r /mnt/openpeak/* /openpeak"

3. unmount (if you want..)
"sudo umount /mnt"

4. mount mmcblk0p4, if not yet done:
"sudo mount /dev/mmcblk0p4 /mnt"

5. copy all its contents to /media:
"sudo cp -r /mnt/* /media"

6. copy and edit localrun:
"sudo cp /openpeak/tango/localrun /openpeak/tango/starto2"

7. edit starto2:
"sudo vi /openpeak/tango/starto2"

8. uncomment "export SDL_AUDIODRIVER=alsa":
move to the concerning line,
type "i" for insert mode,
type an "#"
type ESC, type ":wq" to save&quit

9. now you can run the software by double clicking on "starto2".
You can also create a shortcut to this. Quit the app typing "ALT+F4"

Note, that also mouse + keyboard are working this way :-)
No way yet to quit the app withouht keyboard.

-gforums-

Dual Boot on the Joggler

How-To Setup a Dual Boot on the Jogger!


I prepared a little package for you to have a nice dual boot screen at bootup on your Joggler.

Without a USB stick plugged in, it boots the internal System after 5 seconds.

With a USB stick on the Joggler, the boot screen shows you two icons, one for the o2 Software and one for your USB linux, which will then be the default system!

All this can be controlled by a plugged kayboard after the 2nd boot!

Here we go:

1. Grab the following archive:
http://daten.gforums.de/joggler/efi_mmcblk0p1.tar.gz

2. Start your distro on the joggler, then mount mmcblk0p1, e.g.
"sudo mount /dev/mmcblk0p1 /mnt"

3. Copy and extract the archive onto /mnt, make a backup of your mmcblk0p1 partition if you want!
"sudo cp efi_mmcblk0p1.tar.gz /mnt"
"tar -xzvf efi_mmcblk0p1.tar.gz"
"sudo rm efi_mmcblk0p1.tar.gz"
"sudo mv boot.efi boot.efi.bak"

4. Reboot.

5. On booting, press several times "ESC" to stop autoboot. Now enter "fs0:boot" blindly and you should see refit coming up.

6. Choose the icon "EFI shell", press Enter, then ESC.

7. Now type:
bcfg boot add 01 fs0:\efi\refit\refit.efi "Refit"

(thanks to: TonyHoyle, http://hackthejoggler.freeforums.org/booting-from-different-sources-t72.html)

This way, Refit is added to the internal (nvram) bootloader list. That's needed to have a working keyboard.

8. Type "bcfg boot dump" and look if Refit is located on top.

9. Type "exit"

That's it - Refit now should always load automatically. In case, you have a USB stick plugged in, you can choose between USB and internal system. Otherwise, it just shows the internal system and boots it after 5 seconds!

Good luck :-)

-gforums-

A patch for the IEGD kernel part to make it build and work in 2.6.33.2

I just spent some time getting IEGD kernel module working on 2.6.33.2 and got some fancy glxgears on my Xorg now.

For patching into a kernel:

Kernel patch

A patch against IEGD original sources (10.3.2) to make it work and build on 2.6.33.2

Have fun with it!

Tuesday 6 April 2010

GRUB2 on Joggler

We have been having some issues with ELILO and large initrds in the #mer channel on irc.freenode.net, so we started investigating GRUB2.

The problem with GRUB2 was that it did not initialize video correctly and hence did now show the framebuffer console when booting. Another problem was that it did not have a TextModeHack.

For the technical side of these problems: GRUB2 did not pass correct video information in the linux kernel parameters due to it only supporting UGA video. Thanks to 'bean''s patch, I was able to construct a working GRUB2. UPDATE: now with adq's updated patch, we no longer need to use screen.efi as it contains a TextModeHack now - thanks to him for the great hack!

To compile GRUB2:

  • Grab the source and untar it
  • Patch it with this patch (grub-gop-video-v1.patch, patch -p1 it)
  • ./configure --with-platform=efi
  • Run 'make'
  • Make a .efi file: ./grub-mkimage -d . -o grub.efi part_msdos hfsplus fat ext2 normal sh chain boot configfile linux
  • If you're too lazy or incapable of building, use this grub.efi

To use it in practice:
  • Make a efi\grub directory and put grub.efi in there
  • Put in the root of the FAT partition, file boot.nsh:

    fs1:
    cd \efi\grub
    grub

    And file startup.nsh:

    fs1:boot2
    fs0:boot
  • Put in a grub.cfg file in \efi\tools (sample one linked, not working, you need to edit it). See elilo config in the other post for inspiration.
  • If you do not need interactivity with the menu (letting it time out to the default item), you do not have to press ESC at bootup.

Enjoy - if you're a Joggler hacker, come to #mer on irc.freenode.net, a good bunch of us there by now. Webchat here.

Sunday 4 April 2010

From the past: How to dump the BIOS (EFI) on Joggler

This was originally discovered by JimboJones. You will need to be on 2.6.24 (the original OS).

modprobe fh
dd if=/dev/fh of=/tmp/bios.bin

The file /tmp/bios.bin will then be the BIOS.

Modifying your initrd

In the 'mer-efi.tar.gz' which gforums provided, there is a file in efi\elilo, named initrd-2.6.30.

This file is essentially a initramfs, or translated: a gzipped cpio archive. It is referred to in the elilo.conf and provides modules and a script to boot up the system.

However, this initramfs is very tied to a certain kernel version. So, how do you modify it?

To extract the archive, do the following in a directory called initfs, do this as root:

gzip -dc initrd-2.6.30 | cpio -id

This will extract the archive into the current directory (We'll call this /initfs from now on).

You can then modify it as you'd like.

To take a new kernel and update the kernel modules in the initramfs, you can make modules; make modules_install INSTALL_MOD_PATH=/initfs in the kernel source. This will install the updated modules into /lib/modules/ on your initfs and /lib/firmware.

The modules might be a bit big, so thin out any unneeded ones or old modules for kernel versions.

Then, from the same directory, find | cpio -H newc -o | gzip -c > initrd-newname

And you can put this initrd in your efi\elilo directory and change your elilo.conf initrd= line to point to it.

A kernel config for 2.6.33, for Joggler

I just succeeded in building Linux kernel 2.6.33.1 and booting it from Joggler.

For future reference, do -not-, I repeat, do NOT have CONFIG_RELOCATABLE in your .config. ELILO will not boot your kernel after 2.6.30 (such as 2.6.31+) with it.

You can download the config here, copy it to .config in your build directory and run make oldconfig and make bzImage and make modules. You'll need ELILO 3.12.

Saturday 3 April 2010

Building and using ELILO for the Joggler

One of the initial problems I had with Joggler was the source-less ELILO, which I could not seem to replicate. I've succeeded in doing that now, thanks to a patch from TonyHoyle.

First off, you will need at least GCC 4.3.3 (what I tested with), as well as gnu-efi 3.0i from http://sourceforge.net/projects/gnu-efi/files/ (This is a toolchain for EFI binaries)

In gnu-efi 3.0i you will need to edit Make.defaults:

INSTALLROOT=/usr/local

to

INSTALLROOT=/usr

and then make; make install

Then you need to grab elilo-3.12-source.tar.gz from http://sourceforge.net/projects/elilo/files/ and apply (patch -p1) this patch against it (patch -p1) I have provided a elilo.efi that works on my Joggler (not in the 'screen.efi' trick), downloadable here.

You need to after putting elilo.efi in place, in your boot.nsh put the following lines (only lines in the file):

fs1:
cd \efi\elilo
elilo

And provide in \efi\elilo , a elilo.conf not unlike the following. legacy-free is a VERY IMPORTANT OPTION and is required because there is no 'real' BIOS on the joggler. Hope this works for you, otherwise, show up on #mer at irc.freenode.net :)


# Command line options understood here are
#
# fixup - Apply fixups so the default joggler OS can boot the new kernel.
# recovery - Instead of booting stop in a diagnostic shell

legacy-free
default=usb

image=vmlinuz-2.6.30
label=linux2
read-only
initrd=initrd-2.6.30
append="acpi=force root=/dev/mmcblk0p2 fixup"
description="Standard joggler OS with new kernel"

image=vmlinuz-2.6.30
label=usb
initrd=initrd-2.6.30
append="acpi=force root=/dev/sda2"
description="Boot from USB"

image=vmlinuz
label=testing
read-only
append="acpi=force root=/dev/mmcblk0p2"
description="Test vmlinuz, no initrd"

image=vmlinuz-2.6.24-19-lpia
label=test
initrd=initrd-2.6.30
append="acpi=force root=/dev/sda2"
description="Boot from Test"

Getting into the EFI shell on the device

Requirements: USB stick, keyboard, hub

Make a USB stick with a FAT partition on it first.

Put in the root of the partition, file boot.nsh:

fs1:
cd \efi\screen
screen

And file startup.nsh:

fs1:boot2
fs0:boot

You will then need to make a directory 'efi' and underneath this, directories 'screen' and 'tools'.
>
In the 'screen' directory, put the file screen.efi and under 'tools', put the file 'Shell.efi'. Additional tools can be downloaded here (tools folder). Thanks to TonyHoyle for making these tools available and making them.

Now, because the Joggler does not load the USB keyboard driver automatically, you need to upon boot, to follow the following procedure:

* Plug in keyboard, USB stick into USB hub
* Plug USB hub into the Joggler
* Turn on the Joggler, press ESC several times on the until it is obvious the startup has stalled completely.
* Type blind, without quotes, 'fs1:boot'
* You will now see text, press ESC again, and you'll be in a shell.
* You should then see a shiny EFI shell with keyboard working.


Enjoy!