Angstrom package to natively compile kernel modules

Hi,

I am trying to configure my Angstrom in such a way that it would be
possible to compile kernel modules *natively* on the BB. Despite all
my attempts (installing kernel-dev, kernel-headers, and some other
packages) I am still missing a lot of kernel headers such as for
example linux/module.h, linux/kmod.h and so on. /lib/modules/`uname
-r`/build directory is also not there.

I would be very thanksful if somebody could suggest the package
name(s) or any other way to properly install native kernel development
environment with Angstrom on BB.

Thank you,
Andrey.

This worked for me:

http://www.elinux.org/BeagleBoardLinuxKernel

Briefly, you clone the linux-omap repo, checkout the git commit of the
kernel version you are interested in, and apply the necessary patches
for that kernel version. Clone the Angstrom setup scripts and have a
look in the recipes. Also install u-boot-mkimage to generate uImage.

On the Beagleboard it takes ~6-7 hours to compile the kernel from a
clean tree, and about 10 mins when compiling after a small change to a
driver.

This worked for me:

BeagleBoardLinuxKernel - eLinux.org

Briefly, you clone the linux-omap repo, checkout the git commit of the
kernel version you are interested in, and apply the necessary patches
for that kernel version. Clone the Angstrom setup scripts and have a
look in the recipes. Also install u-boot-mkimage to generate uImage.

On the Beagleboard it takes ~6-7 hours to compile the kernel from a
clean tree, and about 10 mins when compiling after a small change to a
driver.

Thank you very much for the hint! I almost lost the hope to get any
reply to my question :slight_smile: .

Ideally, I would prefer to avoid compiling kernel itself natively. The
only thing I need is to compile my own small driver natively. But if I
would not find the way to do it I will definitely try your suggestion.

Thank you once again for the response!

Regards,
Andrey.

This worked for me:

BeagleBoardLinuxKernel - eLinux.org

Briefly, you clone the linux-omap repo, checkout the git commit of the
kernel version you are interested in, and apply the necessary patches
for that kernel version. Clone the Angstrom setup scripts and have a
look in the recipes. Also install u-boot-mkimage to generate uImage.

On the Beagleboard it takes ~6-7 hours to compile the kernel from a
clean tree, and about 10 mins when compiling after a small change to a
driver.

Thank you very much for the hint! I almost lost the hope to get any
reply to my question :slight_smile: .

Ideally, I would prefer to avoid compiling kernel itself natively. The
only thing I need is to compile my own small driver natively. But if I
would not find the way to do it I will definitely try your suggestion.

If it is a loadable kernel module, you should need only the kernel
headers (opkg install kernel-headers), then
a Makefie similar to this one is sufficient to compile natively:

obj-m := yourmodule.o
KDIR := /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
default:
        $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules

Hi Sam,

I will try it and and post the conclusion. Thank you.

Thank you Maksym. You, your post, and that link are awesome. I was eventually able to get that to work, below are the problems I had. This did work, however, this kernel it builds doesn’t include ALSA audio support, so I was not able to use ALSA, which was a requirement for me. I attempted to compile the ALSA driver natively but couldn’t get it to work. Any ideas on how I could get ALSA added to this kernel?? For now I’m going to try the OpenEmbedded route again. Here are the problems I ran into in the how-to:

The command 'cross make -j16 uImage modules’ seemed to work but actually didn’t create an image. I re-ran the command it was complaining about 2 missing commands: lzma and makeimage. In Ubuntu 11.10 I installed them with apt-get install lzma and apt-get install u-boot-tools.

The command 'sudo_cross make -j16 modules_install’ complained about not being able to find the command arm-angstrom-linux-gnueabi-gcc, even though the cross compiler directory was in my path. Not sure why it couldn’t find it, but I created the link /usr/bin/arm-angstrom-linux-gnueabi-gcc which pointed to the cross-comipler gcc to fix: ‘ln -s ~/cross-compiler-directory/arm-angstrom-linux-gnueabi-gcc /usr/bin/arm-angstrom-linux-gnueabi-gcc’

I didn’t want to do a network boot, so I zipped the contents of rootfs to an archive, and extracted that archive to an SD card, (see below on how I made a 2 partion card) (you don’t have to tar, I did it to have a backup of the root file system): sudo tar -zcvf archive.tar.gz rootfs && sudo tar -zxvf archive.tar.gz /media/rootfs/ --strip=1

I wanted to boot from the mini-SD card instead of a network boot, so I used the following for uEnv.txt instead of what he had posted (some of these parameters may not be correct, not sure about dvimode, omapfb.vram, vram, optargs, but this worked for me):

dvimode=“hd720 omapfb.vram=0:8M,1:4M,2:4M”
vram=16M
optargs=“consoleblank=0”
console=ttyO2,115200n8
mpurate=800
mmcroot=/dev/mmcblk0p2 rw
nfsargs=setenv bootargs console=${console} mpurate=${mpurate}

After booting the newly built kernel, you will have to get the necessary packages to compile natively.

opkg update && opkg install gcc binutils make pkgconfig automake autoconf libc6-dev cpp gcc-symlinks

ln -s /usr/bin/arm-angstrom-linux-gnueabi-objdump /usr/bin/objdump
ln -s /usr/bin/arm-angstrom-linux-gnueabi-ld /usr/bin/ld
cd /usr/src/linux
make modules_prepare

Compile your kernel module, there are several examples online, and insmod it. Voila.

I think it’s crazy for someone to put this much time into this when it’s already been done a thousand times. Following is a link to my root file system, boot files, and an example kernel driver in the home directory of the file system. Username and password is root and password. Also included is a script to create a 2 partition SD card. The script creates a FAT32 and an ext3 partition. Put the boot files in the FAT32 partition titled boot. Extract the root file system to the partition titled rootfs, using tar as described above. NOTE: The make 2 partition card script creates a 1GB Linux partition, I expanded this partition to the remaining space on my card using gParted in Ubuntu 11.10, the Linux root file system is about 1.2GB.

http://dl.dropbox.com/u/91277089/angstrom_2.6.38_kernel_compile.zip

Following is the script I used to make an SD card with 2 partitions. The Linux partition it creates is less than 1GB, I used gParted in Ubuntu 11.10 to resize/expand the Linux partition. The scripts expects one parameter to passed to it, and that parameter is the name of the SD card under the /dev directory. Be careful not to pass your hard drive device name into the script.

#!/bin/sh

mk2PartSDCard.sh v0.1

Licensed under terms of GPLv2

DRIVE=$1

dd if=/dev/zero of=$DRIVE bs=1024 count=1024

SIZE=fdisk -l $DRIVE | grep Disk | awk '{print $5}'

echo DISK SIZE - $SIZE bytes

CYLINDERS=echo $SIZE/255/63/512 | bc

sfdisk -D -H 255 -S 63 -C $CYLINDERS $DRIVE << EOF
,9,0x0C,*
10,114,
EOF

mkfs.vfat -F 32 -n “boot” ${DRIVE}1
umount ${DRIVE}1
mkfs.ext3 -L “rootfs” ${DRIVE}