New user's registration have been closed due to high spamming and low trafic on this forum. Please contact forum admins directly if you need an account. Thanks !

Compiling Kernel and/or modules using Crosstool

A collection of tips on howto tweak your Bubba.
Post Reply
bjorn
Posts: 88
Joined: 03 Jan 2007, 09:02

Compiling Kernel and/or modules using Crosstool

Post by bjorn »

NOTE: the following is a rough walkthrough, and might not be the best way of doing things. Crosstools could probably be set up much nicer than this. And it was a while back i did this myself, so i might missed some step, this particular "howto" is NOT verified to work by me. Use at your own risk.

If you find anything wrong, please let me know and i'll edit this post. :-)

Read through the whole thing before starting.


Compile kernel modules for Bubba on a x86-linux workstation using crosstool:

Get, configure and install crosstool
wget http://kegel.com/crosstool/crosstool-0.43.tar.gz
tar zxvf crosstool-0.43.tar.gz

edit crosstool-0.43/demo-arm.sh
set path for where to store crosstool, example: /opt/crosstool

uncomment all "eval"-strings except:
eval `cat arm.dat gcc-4.0.2-glibc-2.3.2-tls.dat` sh all.sh --notest

run script demo-arm.sh

This could possibly take several hours, if you run into problems. Consult manuals at http://kegel.com/crosstool/

Read documentation on crosstool and verify that your crosscompiler is working for ARM-platform.




Get kernel source
wget http://ftp.sunet.se/pub/Linux/kernels/v ... 16.tar.bz2

Get at91patch
wget http://download.excito.net/kernel/2.6.1 ... 1.patch.gz

Get Excito patches and config
wget http://download.excito.net/kernel/2.6.1 ... .16.tar.gz

Create build directory
mkdir build

Move into that
cd build

Extract kernel source
tar jxvf ../linux-2.6.16.16.tar.bz2

Move into the kernel directory
cd linux-2.6.16.16/

Apply atmel patch
zcat ../../2.6.16-at91.patch.gz | patch -p1

Apply Excito patch
cat ../../linux26/excito.patch | patch -p1

Add excito config
cp ../../linux26/excito.config .config


NOTE: in the following you will need to change the "/opt/arm/bin/arm-linux-" path to whatever path you choose
to install crosstools in, for example: "/opt/crosstool/gcc-4.0.2-glibc-2.3.2/arm-unknown-linux-gnu/bin/arm-linux-"

Build initial config
make ARCH=arm CROSS_COMPILE=/opt/arm/bin/arm-linux- oldconfig

Change config as needed
make ARCH=arm CROSS_COMPILE=/opt/arm/bin/arm-linux- menuconfig

NOTE: This step is not necessary if you only want modules!
Build the kernel
make ARCH=arm CROSS_COMPILE=/opt/arm/bin/arm-linux- zImage

Build modules
make ARCH=arm CROSS_COMPILE=/opt/arm/bin/arm-linux- modules

Install modules locally
make ARCH=arm CROSS_COMPILE=/opt/arm/bin/arm-linux- INSTALL_MOD_PATH=`pwd`/tmpinstall modules_install

Make archive of modules
cd tmpinstall
tar zcvf modules.tar.gz *

Copy modules.tar.gz over to Bubba
Log in to bubba and become root.

Install modules:
cd /
tar zxvf /"path/to/modules"/modules.tar.gz
depmod -a

load the modules you want, for example:
modprobe ip_tables
osa
Posts: 29
Joined: 11 Feb 2007, 21:24

Post by osa »

I'm just curious, how to store compiled kernel to nvram on bubba.

Is it enough to dd if=/my-kernel.gz of=/dev/mtd1 (or /dev/mtdblock1??)

Upgrading kernel can screw up bubba, so how to restore original kernel?
I've found, that it is possible to boot arm board using serial port or usb, when nvram if clear. How about bubba?
johannes
Posts: 1470
Joined: 31 Dec 2006, 07:12
Location: Sweden
Contact:

Post by johannes »

osa:

I don't know how to copy the compiled kernel to FLASH (nvram), Tor should answer this, but it is possible to boot Bubba using USB or serial port, probably just as your ARM board, when the FLASH is empty (or destroyed).

Using serial port is the simplest, you can use windows hyperterminal (xmodem protocol), but you'll have to do some soldering to gain access to the serial port. Read more about this here.
The serial port is the most useful when doing this kind of stuff, since it presents a terminal connection to the boot loader and to Linux.

Using USB is also an option, but there isn't any host software available as far as I know. The DFU (Device Firmware Upgrade) USB class is used. If this option is of interest, we may be able to share some more infrormation with you on this.
/Johannes (Excito co-founder a long time ago, but now I'm just Johannes)
limpo
Posts: 59
Joined: 24 Mar 2007, 06:50

Post by limpo »

Hi,

I am having trouble getting crosstools installed on ubundu feisty fawn,
I can do all of the following:

Get, configure and install crosstool
wget http://kegel.com/crosstool/crosstool-0.43.tar.gz
tar zxvf crosstool-0.43.tar.gz

edit crosstool-0.43/demo-arm.sh
set path for where to store crosstool, example: /opt/crosstool

uncomment all "eval"-strings except:
eval `cat arm.dat gcc-4.0.2-glibc-2.3.2-tls.dat` sh all.sh --notest

run script demo-arm.sh

then after a while i get the following error:
applying patch /tmp/crosstool-0.43/patches/glibc-2.1.3/arm-ctl_bus_isa.patch
getandpatch.sh: 1: patch: not found
patch /tmp/crosstool-0.43/patches/glibc-2.1.3/arm-ctl_bus_isa.patch failed

I guess this could be because of the wrong version of gcc compiler or something similar.

/Limpo
osa
Posts: 29
Joined: 11 Feb 2007, 21:24

Post by osa »

Try this precompiled crosstool http://download.excito.net/kernel/arm-g ... 2-1.tar.gz

I managed to compile crosstool (gcc 4.0.2 glibc 2.3.2) on gentoo and to compile kernel and working modules.
limpo
Posts: 59
Joined: 24 Mar 2007, 06:50

Post by limpo »

THX OSA,

You saved the day!


/Limpo
PeterTuson
Posts: 39
Joined: 22 Apr 2007, 03:01
Location: Great Britain

re Crosscompiling Modules for Bubba

Post by PeterTuson »

I successfully followed bjorn's guide on Compiling Kernel and/or modules using Crosstool to compile and load the ftdi_sio module so that Bubba would drive a USB-Serial Adaptor.
Updates to bjorn's guide are:

Modules will only load is they are compiled with the same version of GCC as the kernel on Bubba, currently this appears to be 4.0.2. So when editing crosstool-0.43/demo-arm.sh

comment all "eval" strings except
eval `cat arm.dat gcc-4.0.2-glibc-2.3.6.dat` sh all.sh --notest

Before applying the Excito patch and config extract from the source.

edit excito.config
enable experimental modules
CONFIG_EXPERIMENTAL=y

then

Apply Excito patch
cat ../../excito.patch | patch -p1

Add excito config
cp ../../excito.config .config

The change config as needed
make ARCH=arm CROSS_COMPILE=/opt/arm/bin/arm-linux- menuconfig
didn't work for me but that didn't matter for modules.
peter
tor
Posts: 703
Joined: 06 Dec 2006, 12:24
Contact:

Post by tor »

Hi,

A late comment on reinstalling the kernel.

osa, you are on the right track. With a zImage for bubba. Installing it is "as simple as"

Code: Select all

dd if=/path/to/zImage of=/dev/mtd1
A big WARNINIG here. If the kernel image is not correct. Your bubba will not boot again since a working kernel is essential for operation. And getting the unit operational is complicatede and involves some HW tweaks. (Maybe time for a howto on this as well, if any of the HW guys have time for it)

/Tor
Co-founder OpenProducts and Ex Excito Developer
Post Reply