Welcome! Log In Create A New Profile

Advanced

Howto: Build a new Debian kernel with LED support

Posted by Jeff 
Howto: Build a new Debian kernel with LED support
September 04, 2010 05:40PM
Note: Newer Debian kernels include support for the Dockstar LED. Make sure you're running a newer uBoot and set arcNumber to 2998.

The rest of this is just here for posterity:

Here are steps for building your own patched Debian kernel. The resulting kernel is configured exactly the same as the 'official' 2.6.32-5-kirkwood kernel but with Dockstar specific support for LEDs and the MTD partitions.

This assumes you have a cross-compile build environment configure as described here.

From your build box:

# Get the Kernel sources
cd /usr/src
apt-get install linux-source-2.6.32
tar -xjvf linux-source-2.6.32.tar.bz2
cd /usr/src/linux-source-2.6.32

# Get the config from your current Dockstar kernel
scp root@YOUR.DOCKSTAR.IP.ADDRESS:/boot/config-2.6.32-5-kirkwood .config

# Accept default options for any new kernel configs
yes "" | make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- oldconfig

# Add Dockstar patch
cat<<EOF>dockstar-kernel.patch
+++ a/arch/arm/mach-kirkwood/sheevaplug-setup.c
+++ b/arch/arm/mach-kirkwood/sheevaplug-setup.c
@@ -62,11 +62,17 @@
 
 static struct gpio_led sheevaplug_led_pins[] = {
 	{
-		.name			= "plug:green:health",
-		.default_trigger	= "default-on",
-		.gpio			= 49,
+		.name			= "dockstar:green:health",
+		.default_trigger	= "none",
+		.gpio			= 46,
 		.active_low		= 1,
 	},
+  {
+		.name			= "dockstar:orange:health",
+		.default_trigger	= "default-on",
+		.gpio			= 47,
+		.active_low		= 1,
+  }
 };
 
 static struct gpio_led_platform_data sheevaplug_led_data = {
@@ -84,7 +90,8 @@
 
 static unsigned int sheevaplug_mpp_config[] __initdata = {
 	MPP29_GPIO,	/* USB Power Enable */
-	MPP49_GPIO,	/* LED */
+	MPP46_GPIO,	/* LED green */
+	MPP47_GPIO,	/* LED orange */
 	0
 };
EOF

patch -p1 < dockstar-kernel.patch
make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- oldconfig

codesourcery-arm-2009q3.sh
make-kpkg --rootcmd fakeroot --arch armel  --cross-compile arm-none-linux-gnueabi- --append-to-version=-dockstar --revision=1.1 --initrd kernel_image

Copy the resulting linux-image-2.6.32-dockstar_1.1_armel.deb image file to your dockstar, and run the following commands to install it:
dpkg -i linux-image-2.6.32-dockstar_1.1_armel.deb
cd /boot

# Create the images for uBoot
/usr/bin/mkimage -A arm -O linux -T kernel  -C none -a 0x00008000 -e 0x00008000 -n Linux-2.6.32-5 -d /boot/vmlinuz-2.6.32-dockstar /boot/uImage

/usr/bin/mkimage -A arm -O linux -T ramdisk -C gzip -a 0x00000000 -e 0x00000000 -n initramfs -d /boot/initrd.img-2.6.32-dockstar /boot/uInitrd

# Configure rc.local to turn off the orange LED and turn on the green LED
sed -i 's|^exit 0|echo none > /sys/class/leds/dockstar\:orange\:health/trigger\necho default-on > /sys/class/leds/dockstar\:green\:health/trigger\nexit 0|' /etc/rc.local

After you reboot, the LED on the front of your dockstar should turn orange after the kernel is loaded and then turn green after the system has fully booted. See here for details on triggering the LEDs.

If you're happy with the new kernel, you can free up some space by removing the old kernel:

apt-get remove linux-image-2.6-kirkwood

-- Jeff



Edited 8 time(s). Last edit at 04/27/2012 10:19AM by Jeff.
ecc
Re: Building a patched Debian kernel
September 04, 2010 06:37PM
I was pleased to see that uboot handles symlinks correctly when booting from ubifs root. So I've started making versioned uImage-NNN and uInitrd-NNN files with mkimage, and then keeping uImage and uInitrd as symlinks to those.

There is a Debian proposal for a new hook directory that mkinitramfs will use, so eventually the initrd -> uInitrd conversion can be automated. And there is already an /etc/kernel/postinst.d directory for installing a new kernel, where the vmlinuz -> uImage script can be placed.
Re: Building a patched Debian kernel
September 04, 2010 07:05PM
I'd welcome any contributions with the scripts or anything else. I'm no expert in Debian packaging. My goal is to have a 'drop in' replacement for the standard Debian kernel. Assuming this works for everyone, I will adjust my Debian install scripts to use this in place of the current linux-image-2.6-kirkwood package.

-- Jeff
Hi Jeff

Would you please describe your host cross-compile build environment. Such as, which version of Linux you are using, and any particular steps you took to achieve a successful compile of the Dockstar kernel package.

Thank you
Re: Howto: Build a new Debian kernel with LED support
September 07, 2010 10:20AM
I'm using a Debian desktop to build. All the steps you need are explicitly mentioned in the original post.
hapeba
Re: Howto: Build a new Debian kernel with LED support
September 07, 2010 01:42PM
Hi Jeff,

in your image "linux-image-2.6.32-dockstar_1.1_armel.deb" the cammand "echo heartbeat" never works.

Is this an error ?

MfG
Re: Howto: Build a new Debian kernel with LED support
September 07, 2010 02:37PM
It's not an error, since the LED control still works. This kernel is meant to be as close as possible to the original Debian kernel. It's possible that the 'heartbeat' command requires an additional definition or was added in a later kernel revision.

If you need to blink the LED, use the 'delay_on' and 'delay_off' settings.

-- Jeff
hapeba
Re: Howto: Build a new Debian kernel with LED support
September 07, 2010 03:07PM
Thanks,

it is not really important. But i wait for a new revision, because i like it blinking (Joke).

Thank for your work.

MfG
Jeff Wrote:
-------------------------------------------------------
> I'm using a Debian desktop to build. All the
> steps you need are explicitly mentioned in the
> original post.


Thank you. Dockstar image compiles cleanly when Debian “squeeze” is used as the build environment. Previously was trying to build the image under Ubuntu and previous versions of Debian. Should receive a couple of Dockstars in a few days.

Have you incorporated the "Scan all USB devices and boot from the first bootable drive" or any extra functionality into linux-image-2.6.32-dockstar_1.1_armel.deb?
ecc
Re: Howto: Build a new Debian kernel with LED support
September 07, 2010 04:17PM
Jeff Wrote:
-------------------------------------------------------
> It's possible that the 'heartbeat' command requires an
> additional definition or was added in a later kernel revision.

On my system it's compiled as a module (ledtrig-heartbeat) which must be loaded first. Similarly for ledtrig-timer to get the 'timer' mode.

And here's how to use iptables to blink the LED based on network activity.

I also cherry-picked the OpenWrt patch for "netdev" LED support, which is an easier way (for the user at least) to get blinking lights for any combination of link, tx, and rx activity. I can post it or upload it if there's any interest.
Re: Howto: Build a new Debian kernel with LED support
September 07, 2010 05:14PM
Wouldn't it be possible to compile a kernel right on the Dockstar itself and save some hassle of having to mess with a cross-compiler or is the 1.2Ghz ARM proc in the Dockstar too slow? Mine just came in today and I'll be playing with it quite a bit tonight.
ecc
Re: Howto: Build a new Debian kernel with LED support
September 07, 2010 08:01PM
dethl Wrote:
-------------------------------------------------------
> Wouldn't it be possible to compile a kernel right
> on the Dockstar itself and save some hassle of
> having to mess with a cross-compiler or is the
> 1.2Ghz ARM proc in the Dockstar too slow?

It's certainly possible. I'd recommend an NFS-mounted chroot for this -- plenty of space for installing the toolchain, and much faster than writing to a USB flash drive.

But the Linux kernel (and Debian's kernel-package) are about as cross-compiler-friendly as you can get. It's just one extra command-line argument to cross-compile ...
Re: Howto: Build a new Debian kernel with LED support
September 07, 2010 08:41PM
ecc Wrote:
>
> It's certainly possible. I'd recommend an
> NFS-mounted chroot for this -- plenty of space for
> installing the toolchain, and much faster than
> writing to a USB flash drive.
>
> But the Linux kernel (and Debian's kernel-package)
> are about as cross-compiler-friendly as you can
> get. It's just one extra command-line argument to
> cross-compile ...

The reason why I'd build the kernel on the Dockstar itself is to avoid having to deal with a cross-compiling environment. I don't see why installing gcc and whatnot on the Dockstar itself would be a problem - I'm using an 8GB USB flash drive myself so I don't see a problem with storage and speed isn't an issue for me.

EDIT: Kernel is building as we speak on my Dockstar. Still not sure what I'm going to use this little box for (I already have an Atom-based WHS, an Ubuntu desktop, and a Windows 7 gaming machine).



Edited 1 time(s). Last edit at 09/07/2010 10:13PM by dethl.
Re: Howto: Build a new Debian kernel with LED support
September 08, 2010 12:59AM
Jeff Wrote:
-----------------------------------------------------------------
> # Accept default options for any new kernel
> configs
> yes "" | make ARCH=arm
> CROSS_COMPILE=arm-none-linux-gnueabi- oldconfig

I'm going to work on a new .config that only builds USB drivers and any drivers needed for the actual system. Opting to build all modules as well as anything/everything into the kernel itself is a tad wasteful. I don't think we'll need ISDN drivers and whatnot :P

Edited to sound less rude. I'm quite glad that Jeff made a lot of this really easy to do.



Edited 1 time(s). Last edit at 09/08/2010 07:23AM by dethl.
Re: Howto: Build a new Debian kernel with LED support
September 08, 2010 06:04AM
root@debian:/usr/src/linux-source-2.6.32# codesourcery-arm-2009q3.sh
-bash: codesourcery-arm-2009q3.sh: command not found

where i can get the Script ? it is not in the folder ?

root@debian:/usr/src/linux-source-2.6.32# ls -a
.            Documentation   crypto                 kernel    tools
..           Kbuild          dockstar-kernel.patch  lib       usr
.config      MAINTAINERS     drivers                mm        version.Debian
.config.old  Makefile        firmware               net       virt
.gitignore   README          fs                     samples
.mailmap     REPORTING-BUGS  include                scripts
COPYING      arch            init                   security
CREDITS      block           ipc                    sound
root@debian:/usr/src/linux-source-2.6.32#



Edited 1 time(s). Last edit at 09/08/2010 06:08AM by anne.
Re: Howto: Build a new Debian kernel with LED support
September 08, 2010 07:35AM
hello jeff if u want tobuild a actual kernel i made my changes in patchfiles include the module load fix for the makefile
Kernel Patches for 2.6.35.4 vanilla

simply

patch -Np1 -i ../*.patch
Re: Howto: Build a new Debian kernel with LED support
September 08, 2010 12:03PM
anne Wrote:
-------------------------------------------------------
> > root@debian:/usr/src/linux-source-2.6.32#
> codesourcery-arm-2009q3.sh
> -bash: codesourcery-arm-2009q3.sh: command not
> found
>
>
> where i can get the Script ? it is not in the
> folder ?
>
>
> root@debian:/usr/src/linux-source-2.6.32# ls -a
> . Documentation crypto
> kernel tools
> .. Kbuild dockstar-kernel.patch
> lib usr
> .config MAINTAINERS drivers
> mm version.Debian
> .config.old Makefile firmware
> net virt
> .gitignore README fs
> samples
> .mailmap REPORTING-BUGS include
> scripts
> COPYING arch init
> security
> CREDITS block ipc
> sound
> root@debian:/usr/src/linux-source-2.6.32#
>
>

Looks like you're trying to build off the Dockstar itself correct? You can ignore the codesorcery bit and move on to make oldconfig. Just make sure you leave out the CROSS_COMPILE directive.
Hello again,

I have tried to compile a new image, but i have some problems and i do not know where i can start searching for the problem. Everything looks okay until codesourcery-arm-2009q3.sh, but make-kpkg produced an error:

sysadmin@symbiosoft:~/linux-source-2.6.32$ codesourcery-arm-2009q3.sh
Type 'exit' to return to non-crosscompile environment
NOW in crosscompile environment for arm (arm-none-linux-gnueabi-)
sysadmin@symbiosoft:~/linux-source-2.6.32$ make-kpkg --rootcmd fakeroot --arch armel  --cross-compile arm-none-linux-gnueabi- --append-to-version=-dockstar --revision=1.1 --initrd kernel_image
Warning: The file include/linux/version.h exists
The contained UTS_VERSION string:
                        ""
does not match expectations:
                        "2.6.32-dockstar"
I'll try and recover
exec debian/rules  DEBIAN_REVISION=1.1  APPEND_TO_VERSION=-dockstar  KPKG_ARCH=armel  CROSS_COMPILE=arm-none-linux-gnueabi-  INITRD=YES  ROOT_CMD=fakeroot  kernel_image
dpkg-architecture: warning: Specified GNU system type arm-linux-gnueabi does not match gcc system type i486-linux-gnu.
dpkg-architecture: warning: Specified GNU system type arm-linux-gnueabi does not match gcc system type i486-linux-gnu.
dpkg-architecture: warning: Specified GNU system type arm-linux-gnueabi does not match gcc system type i486-linux-gnu.
dpkg-architecture: warning: Specified GNU system type arm-linux-gnueabi does not match gcc system type i486-linux-gnu.
[: 1: 2: unexpected operator
[: 1: 2: unexpected operator
[: 1: 2: unexpected operator
[: 1: 2: unexpected operator
[: 1: 2: unexpected operator
[: 1: 2: unexpected operator
[: 1: 2: unexpected operator
[: 1: 2: unexpected operator
[: 1: 2: unexpected operator
[: 1: 2: unexpected operator
Not in correct source directory
make: *** [testdir] Error 1
Okay - I have setup a virtual maschine with Debian Lenny and switch to Squeeze. It takes some times to compile the image, but it works. :-)
Re: Howto: Build a new Debian kernel with LED support
September 15, 2010 01:19PM
gorgone Wrote:
-------------------------------------------------------
> hello jeff if u want tobuild a actual kernel i
> made my changes in patchfiles include the module
> load fix for the makefile
> Kernel Patches for 2.6.35.4 vanilla

Hello,

I've just finished reading your patches. You mention a module load fix for the Makefile. I came across this, where you add "fwrapv" and disable DWARF2. Could you please explain, why this is needed? I don't see the magic in it. Or is it a dirty hack for the problems with libdwarf and arm from april?

Thank you
Re: Howto: Build a new Debian kernel with LED support
September 15, 2010 04:38PM
its a arm hack from the android team
if u dont use this hack u cant load module with 2.6.35 on arm
u can also leave this patch and build a static kernel without module



Edited 2 time(s). Last edit at 09/15/2010 04:41PM by gorgone.
ecc
Re: Howto: Build a new Debian kernel with LED support
September 15, 2010 07:09PM
gorgone Wrote:
-------------------------------------------------------
> its a arm hack from the android team
> if u dont use this hack u cant load module with 2.6.35 on arm

I'm running an almost-vanilla 2.6.35 kernel from kernel.org (patched for LED support and DOCKSTAR machine ID recognition), and it loads modules just fine. Did something break between 2.6.35 and 2.6.35.4?
Re: Howto: Build a new Debian kernel with LED support
September 16, 2010 05:31AM
please add your .config and i will try it
ecc
Re: Howto: Build a new Debian kernel with LED support
September 16, 2010 07:51AM
gorgone Wrote:
-------------------------------------------------------
> please add your .config and i will try it

I've attached it to this post.
Attachments:
open | download - config-2.6.35 (42.9 KB)
Re: Howto: Build a new Debian kernel with LED support
September 17, 2010 04:58AM
Hello,

I'm trying to build a kernel image for server use from 2.6.35.4 vanilla using Debian GNU/Linux "lenny" with a patched kernel-package (to build kernels > 2.6.33 successfully, essentially the version from "squeeze"). I used your howto and sticked to it to the word. I now get in the final stage the following error:

objcopy --add-gnu-debuglink=/usr/local/src/linux-2.6.35.4/debian/linux-image-2.6.35.4-dockstar/usr/lib/debug/lib/modules/2.6.35.4-dockstar
_user.ko /usr/local/src/linux-2.6.35.4/debian/linux-image-2.6.35.4-dockstar/lib/modules/2.6.35.4-dockstar/kernel/net/xfrm/xfrm_user.ko
objcopy: Unable to recognise the format of the input file `/usr/local/src/linux-2.6.35.4/debian/linux-image-2.6.35.4-dockstar/lib/modules/
nel/net/xfrm/xfrm_user.ko'
make[1]: *** [debian/stamp/install/linux-image-2.6.35.4-dockstar] Error 1
make[1]: Leaving directory `/usr/local/src/linux-2.6.35.4'
make: *** [kernel_image] Error 2
You have new mail in /var/mail/josen

Is this the error the patch from gorgone solved? Or is the codesourcery environment not used by kernel-package here?
I would be very grateful, if any of you have run into this problem or have any hints, how to solve it.

Compiling the vanilla kernel directly on the dockstar using a 20GB tmpfs mounted via NFS (Yes, this should be blazingly fast) or on an attached usb harddisk fails too. I would like to get this cross-compiling working, so I can finally start hacking some code for the dockstar.

Thank you all in advance and

Greets



Edited 1 time(s). Last edit at 09/17/2010 04:59AM by josen.
Re: Howto: Build a new Debian kernel with LED support
September 17, 2010 05:40AM
My stop is in the first row:
root@debian:/usr/src# apt-get install linux-source-2.6.32
Reading package lists... Done
Building dependency tree
Reading state information... Done
linux-source-2.6.32 is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
root@debian:/usr/src# ls
root@debian:/usr/src#

2.stop:
root@debian:/usr/src# scp root@192.168.2.88:/boot/config-2.6.32-5-kirkwood
usage: scp [-1246BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file]
           [-l limit] [-o ssh_option] [-P port] [-S program]
           [[user@]host1:]file1 ... [[user@]host2:]file2
root@debian:/usr/src#
root@debian:/usr/src# ls /boot
System.map-2.6.32-5-kirkwood  initrd.img-2.6.32-5-kirkwood  uImage-org  vmlinuz-2.6.32-5-kirkwood
config-2.6.32-5-kirkwood      uImage                        uInitrd
root@debian:/usr/src#

what is wrong, what can i do ?



Edited 1 time(s). Last edit at 09/17/2010 05:43AM by anne.
Re: Howto: Build a new Debian kernel with LED support
September 17, 2010 07:00AM
Hey anne,

Jeff got the tutorial right, but missed a small dot slash. Try this:

scp root@YOUR.DOCKSTAR.IP.ADDRESS:/boot/config-2.6.32-5-kirkwood ./

Please don't try to build a kernel for a device without console access as your first kernel, try kernel building on a normal x86/amd64 first :)

Falk
ecc
Re: Howto: Build a new Debian kernel with LED support
September 17, 2010 12:55PM
The patch I submitted to linux-arm-kernel has been accepted, so that's one step closer to having DockStar support "out of the box" in the official kernel.

This uses the new DOCKSTAR machine ID (2998). If you upgraded your u-boot with one of Jeff's improved versions, you will eventually need to re-flash it with one that knows this ID. The original Cloud Engines version lets you set it with the arcNumber environment variable.
Re: Howto: Build a new Debian kernel with LED support
September 17, 2010 03:30PM
ecc Wrote:
-------------------------------------------------------
> This uses the new DOCKSTAR machine ID (2998). If
> you upgraded your u-boot with one of Jeff's
> improved versions, you will eventually need to
> re-flash it with one that knows this ID. The
> original Cloud Engines version lets you set it
> with the arcNumber environment variable.


Probably the wrong thread, but since you raised it here: Will you and/or Jeff be making one of Jeff's improved U-boot's with this ID?

Thanks again.
ecc
Re: Howto: Build a new Debian kernel with LED support
September 17, 2010 04:46PM
dinlaca Wrote:
-------------------------------------------------------
> Will you and/or Jeff be making one of Jeff's improved U-boot's with this ID?

I described the version of u-boot that I built in this post.
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: