Hello World kernel module on BeagleBone

I’ve posted on this before but I wanted to start a new topic about this because I’m missing something really basic I think.

So I install kernel-headers and kernel-dev as follows:

beaglebone:~/projects/modules/hello-world# opkg install kernel-headers
Installing kernel-headers (3.2-r7c+gitr09e9651bcf2ee8d86685f2a8075bc6557b1d3b91) to root…
Downloading http://feeds.angstrom-distribution.org/feeds/core/ipk/eglibc/armv7a/machine/beaglebone/kernel-headers_3.2-r7c+gitr09e9651bcf2ee8d86685f2a8075bc6557b1d3b91_beaglebone.ipk.
Configuring kernel-headers.
beaglebone:~/projects/modules/hello-world# opkg install kernel-dev
Installing kernel-dev (3.2-r7c+gitr09e9651bcf2ee8d86685f2a8075bc6557b1d3b91) to root…
Downloading http://feeds.angstrom-distribution.org/feeds/core/ipk/eglibc/armv7a/machine/beaglebone/kernel-dev_3.2-r7c+gitr09e9651bcf2ee8d86685f2a8075bc6557b1d3b91_beaglebone.ipk.
kernel-dev: unsatisfied recommendation for kernel-base-dev
Configuring kernel-dev.
beaglebone:~/projects/modules/hello-world#

Even after doing that, I am still missing header files in order to build modules:

beaglebone:~/projects/modules/hello-world# make
gcc -O2 -DMODULE -D__KERNEL__ -W -Wall -Wstrict-prototypes -Wmissing-prototypes -isystem /lib/modules/uname -r/build/include -c -o hello-1.o hello-1.c
hello-1.c:9:0: warning: “MODULE” redefined
:0:0: note: this is the location of the previous definition
hello-1.c:11:0: warning: “KERNEL” redefined
:0:0: note: this is the location of the previous definition
hello-1.c:13:55: fatal error: linux/module.h: No such file or directory
compilation terminated.
make: *** [hello-1.o] Error 1
beaglebone:~/projects/modules/hello-world#

I know that when I build the Angstrom kernel the missing header files are generated, but they seem to be generated in the wrong places. Here’s the folder that I copy:

~/projects/angstrom/setup-scripts/build/tmp-angstrom_2010_x-eglibc/sysroots/beaglebone/kernel

When I build I get a long list of nonsensical errors that tell me that it’s picking up the WRONG header files. For example, list.h includes:

/usr/src/linux-3.2.13/include/linux/types.h

but it looks like it should have included

/usr/src/linux-3.2.13/tools/perf/util/include/types.h

So, I’m assuming that I’m just copying the header to the wrong locations on the BeagleBone, but the question is:

“What are the CORRECT mapping from the Angstrom build folder to the BeagleBone file system that I need to have a correctly configured build environment?”

Am I even asking the right question, or am I way off base here?

Thanks,
Jerrill

[...]

Even after doing that, I am still missing header files in order to build
modules:

beaglebone:~/projects/modules/hello-world# make
gcc -O2 -DMODULE -D__KERNEL__ -W -Wall -Wstrict-prototypes
-Wmissing-prototypes -isystem /lib/modules/`uname -r`/build/include -c -o

Try with '-I' (capital 'i') instead of '-i' and add each path with its
own '-I' option:
gcc [...] -Isystem -I/lib/modules/`uname -r`/build/include [...]

j.

I am also trying to build simple hello.c kernel module. I am new this environment and have no past experience working on Device Drivers

Below are logs and Makefile.

arm-angstrom-linux-gnueabi-gcc -O2 -DMODULE -D__KERNEL__ -W -Wall -Wstrict-prototypes -Wmissing-prototypes -isystem /home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/include -isystem /home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/arch/arm/include -isystem /home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/arch/arm/mach-omap2/include -isystem /home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/arch/arm/plat-omap/include -c -o hello-1.o hello-1.c
hello-1.c:9:1: warning: “MODULE” redefined
: warning: this is the location of the previous definition
hello-1.c:11:1: warning: “KERNEL” redefined
: warning: this is the location of the previous definition
In file included from /home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/arch/arm/include/asm/system.h:165,
from /home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/arch/arm/include/asm/bitops.h:27,
from /home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/include/linux/bitops.h:22,
from /home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/include/linux/kernel.h:17,
from /home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/include/linux/cache.h:4,
from /home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/include/linux/time.h:7,
from /home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/include/linux/stat.h:60,
from /home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/include/linux/module.h:10,
from hello-1.c:13:
/home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/arch/arm/include/asm/memory.h: In function ‘virt_to_phys’:
/home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/arch/arm/include/asm/memory.h:236: error: ‘CONFIG_DRAM_BASEUL’ undeclared (first use in this function)
/home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/arch/arm/include/asm/memory.h:236: error: (Each undeclared identifier is reported only once
/home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/arch/arm/include/asm/memory.h:236: error: for each function it appears in.)
/home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/arch/arm/include/asm/memory.h: In function ‘phys_to_virt’:
/home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/arch/arm/include/asm/memory.h:241: error: ‘CONFIG_DRAM_BASEUL’ undeclared (first use in this function)
/home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/arch/arm/include/asm/memory.h: In function ‘virt_to_bus’:
/home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/arch/arm/include/asm/memory.h:266: error: ‘CONFIG_DRAM_BASEUL’ undeclared (first use in this function)
/home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/arch/arm/include/asm/memory.h: In function ‘bus_to_virt’:
/home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/arch/arm/include/asm/memory.h:271: error: ‘CONFIG_DRAM_BASEUL’ undeclared (first use in this function)
In file included from /home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/include/linux/time.h:9,
from /home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/include/linux/stat.h:60,
from /home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/include/linux/module.h:10,
from hello-1.c:13:
/home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/include/linux/math64.h: In function ‘div_u64_rem’:
/home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/include/linux/math64.h:51: error: ‘LINUX_ARM_ARCH’ undeclared (first use in this function)
In file included from /home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/include/linux/notifier.h:14,
from /home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/include/linux/memory_hotplug.h:6,
from /home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/include/linux/mmzone.h:657,
from /home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/include/linux/gfp.h:4,
from /home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/include/linux/kmod.h:22,
from /home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/include/linux/module.h:13,
from hello-1.c:13:
/home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/include/linux/rwsem.h:41:23: error: asm/rwsem.h: No such file or directory
In file included from /home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/include/linux/ktime.h:25,
from /home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/include/linux/timer.h:5,
from /home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/include/linux/workqueue.h:8,
from /home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/include/linux/kmod.h:26,
from /home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/include/linux/module.h:13,
from hello-1.c:13:
/home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/include/linux/jiffies.h:39:3: error: #error Invalid value of HZ.
/home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/include/linux/jiffies.h:257:31: error: division by zero in #if
/home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/include/linux/jiffies.h:257:31: error: division by zero in #if
/home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/include/linux/jiffies.h:257:31: error: division by zero in #if
/home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/include/linux/jiffies.h:257:31: error: division by zero in #if
/home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/include/linux/jiffies.h:257:31: error: division by zero in #if
/home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/include/linux/jiffies.h:257:31: error: division by zero in #if
/home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/include/linux/jiffies.h:257:31: error: division by zero in #if
/home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/include/linux/jiffies.h:257:31: error: division by zero in #if
/home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/include/linux/jiffies.h:257:31: error: division by zero in #if
/home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/include/linux/jiffies.h:257:31: error: division by zero in #if
/home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/include/linux/jiffies.h:257:31: error: division by zero in #if
/home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/include/linux/jiffies.h:257:31: error: division by zero in #if
/home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/include/linux/jiffies.h:257:31: error: division by zero in #if
/home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/include/linux/jiffies.h:257:31: error: division by zero in #if
/home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/include/linux/jiffies.h:257:31: error: division by zero in #if
/home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/include/linux/jiffies.h:257:31: error: division by zero in #if
/home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/include/linux/jiffies.h:257:31: error: division by zero in #if
/home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/include/linux/jiffies.h:257:31: error: division by zero in #if
/home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/include/linux/jiffies.h:257:31: error: division by zero in #if
/home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/include/linux/jiffies.h:257:31: error: division by zero in #if
/home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/include/linux/jiffies.h:257:31: error: division by zero in #if
/home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/include/linux/jiffies.h:257:31: error: division by zero in #if
/home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/include/linux/jiffies.h:257:31: error: division by zero in #if
/home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/include/linux/jiffies.h:257:31: error: division by zero in #if
/home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/include/linux/jiffies.h:257:31: error: division by zero in #if
/home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/include/linux/jiffies.h:257:31: error: division by zero in #if
/home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/include/linux/jiffies.h:257:31: error: division by zero in #if
/home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/include/linux/jiffies.h:257:31: error: division by zero in #if
/home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/include/linux/jiffies.h:257:31: error: division by zero in #if
/home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/include/linux/jiffies.h:257:31: error: division by zero in #if
/home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/include/linux/jiffies.h:257:31: error: division by zero in #if
In file included from /home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/include/linux/sysctl.h:933,
from /home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/include/linux/kmod.h:27,
from /home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/include/linux/module.h:13,
from hello-1.c:13:
/home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/include/linux/rcupdate.h:160:2: error: #error “Unknown RCU implementation specified to kernel configuration”
make: *** [hello-1.o] Error 1

Makefile

TARGET := hello-1
WARN := -W -Wall -Wstrict-prototypes -Wmissing-prototypes
#INCLUDE := -Isystem /lib/modules/uname -r/build/include
INCLUDE := -isystem /home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/include -isystem /home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/arch/arm/include -isystem /home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/arch/arm/mach-omap2/include -isystem /home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/arch/arm/plat-omap/include
CFLAGS := -O2 -DMODULE -D__KERNEL__ ${WARN} ${INCLUDE}
#CC := gcc-3.0
KDIR := /home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel

${TARGET}.o: ${TARGET}.c

all:
make -C $(KDIR) M=$(PWD) modules

.PHONY: clean

clean:
rm -rf ${TARGET}.o

Look like few #defines are missing. It seems I am missing few steps. Please help

Thanks,
Ashish Deshpande

I am also trying to build simple hello.c kernel module. I am new this
environment and have no past experience working on Device Drivers

You might be interested to take a look at the following article:

I am also trying to build simple hello.c kernel module. I am new this
environment and have no past experience working on Device Drivers

[...]

INCLUDE := -isystem /home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/include
-isystem /home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/arch/arm/include
-isystem /home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/arch/arm/mach-omap2/include
-isystem /home/ashishd/work_beaglebone/tools/setup-scripts.bkp/setup-scripts.bkp/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/arch/arm/plat-omap/include

I think you should start from fixing your makefile:

j.

Ashish,

git clone git://github.com/Angstrom-distribution/setup-scripts.git

MACHINE=beaglebone ./oebb.sh config beaglebone
MACHINE=beaglebone ./oebb.sh update
MACHINE=beaglebone ./oebb.sh bitbake virtual/kernel

And copy the kernel source from:

setup-scripts/build/tmp-angstrom_2010_x-eglibc/sysroots/beaglebone/kernel/

to the following:

/usr/src/linux-3.2.13

NOTE: You’ll need to create the following symlink to the destination folder for the build to complete:

/lib/modules/3.2.13/build

I was able to compile the following on the BeagleBone after running the following in the kernel source folder to build the required executables (i.e. modpost)

make modules
make scripts

And then build the following with make:

Makefile

Thanks for your Help

I tried to create fresh git repository using below commands

git clone git://github.com/Angstrom-distribution/setup-scripts.git

MACHINE=beaglebone ./oebb.sh config beaglebone
MACHINE=beaglebone ./oebb.sh update
MACHINE=beaglebone ./oebb.sh bitbake virtual/kernel

This worked earlier for me but from last 3-4 days I am getting error “fatal: read error: Connection reset by peer”

Is it server issue?

I had successfully compiled this last month and hence I have kernel files (which I compiled last month) but now I face another issue

On my BeagleBone there is not linux folder in /usr/src/
I programmed SD card with below two images from http://www.angstrom-distribution.org/demo/beaglebone/archive/

Angstrom-Cloud9-IDE-eglibc-ipk-v2011.11-core-beaglebone-2011.11.16.img.gz
Angstrom-Cloud9-IDE-eglibc-ipk-v2012.01-core-beaglebone-2012.01.27.img.xz

and in both image contains debug folder in /usr/src/ but there is no linux folder. Does it mean that my SD card is not programmed properly?
My BeagleBone boots properly and I can access it from terminal.

Regards,
Ashish Deshpadne

The “reset by peer” issue sounds like a server problem to me. I haven’t run into it personally. I’m doing a new build presently and it seems to be running smoothly.

You should add the the following to your list of items to “bitbake” as well.

MACHINE=beaglebone ./oebb.sh bitbake systemd-image

The BeagleBone images don’t include the kernel source folder at all. You can get some of the headers (and that missing folder) by runnning the following:

opkg install kernel-headers

Then copy the files from the full kernel source tree you built on your machine over those.

You still may have to create that build symlink if your driver or module make file needs it. My wlan module driver did.

BTW, it looks like they are up to 3.2.14 now!

Jerrill,

Thanks for reply.
After installing kernel-headers I see include directory at /usr/src/linux-3.2.14. But when I linux/modules.h file is missing in that include dir. This is same error which you mentioned in your first post.
Then I copied kernel tree setup-scripts/build/tmp-angstrom_2010_x-eglibc/sysroots/beagleboard/kernel/ to beaglebone and I also got a long list of nonsensical errors ==> How did you fix this? Am I missing anything?
Even this kernel tree doesn’t contain modules.h.

Regards,
Ashish Deshpande

Ashish,

I have the following file in my Angstrom build:

setup-scripts/build/tmp-angstrom_2010_x-eglibc/sysroots/beaglebone/kernel/include/linux/module.h

That’s module.h not modules.h.

I realized that there are a lot of hello world kernel modules on the web that just don’t work as written. When I was getting the nonsensical errors I think I just had used a bad example source file. I’ve posted the final working module I used a couple of posts back. Are these the files you used?

Jerrill

Jerrill,

I am using same Makefile and hello.c which you posted in Aprl 10. I think module.h is causing issue and I need to build kernel again.

It seems git repo url changed for a few layers which might be causing issue for me
https://groups.google.com/forum/?fromgroups#!searchin/beagleboard/reset$20to$20peer/beagleboard/N4XTYv5vHwY/wand3rC0jB0J

I will try to rebuild it.
Thanks,
Ashish Deshpande

I’m kind of jumping in midstream here, but this looks a little suspect. If you are building on a host machine and cross compiling for the beagle, the call to ‘uname’ will use the kernel directory of your host, not the kernel directory of your beagle kernel source.

I make my Beagle kernel source directory an environmental variable and reference it in my module Makefile.

Here’s a makefile I wrote. It compiles, but I haven’t installed the module on the target yet.

`
ifneq ($(KERNELRELEASE),)
obj-m += nkkfb.o
else
KDIR := $(SIG_KERNEL_DIR)
IDIR := /home/dave/blah/blah/blah

default: module
all: default

module:
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- -C $(KDIR) M=pwd modules

install:
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- -C $(KDIR) INSTALL_MOD_PATH=$(IDIR)
SUBDIRS=$(PWD) DEPMOD=TRUE modules_install

clean:
rm -f modules.order .tmp_versions/*.mod *.mod *.ko *.o .*cmd *.cmd *~ 2>/dev/null
endif

`

Sorry, $SIG_KERNEL_DIR =/home/dave/bone/linux-dev/KERNEL

I am not using Angstrom. I’m using the Ubuntu distro for Beagle found here:

http://elinux.org/BeagleBoardUbuntu#Demo_Image

Still, your module makefile should point to the kernel source of your target.

David,

And copy the kernel source from:

setup-scripts/build/tmp-angstrom_2010_x-eglibc/sysroots/beaglebone/kernel/

The above is located on the host machine.

to the following:

/usr/src/linux-3.2.13

The above folder is located on the BeagleBone and all the steps following this are performed on the BeagleBone.

I’m sorry for the confusion.

Jerrill

Wesley,

Hey Jerrill,

I’m trying to follow your setup and right now I’m getting an error of:

make[1]: *** No rule to make target kernel/bounds.c', needed by kernel/bounds.s’. Stop.
make: *** [prepare0] Error 2

when I try to “make modules”

I’ve copied the setup-scripts/build/tmp-angstrom_2010_x-eglibc/sysroots/beaglebone/kernel/ to the directory /usr/src/linux-3.2.13 and I’ve created a symlink though I’m not sure if I created it correctly. I don’t think the symlink is the error though. Any ideas?

~Wesley

I’m not sure about the error since I didn’t get the error myself. Just to clarify, you are copying the source from the host machine at:

setup-scripts/build/tmp-angstrom_2010_x-eglibc/sysroots/beaglebone/kernel/

to the following folder on the BeagleBone:

/usr/src/linux-x.y.zz

(NOTE: where x.y.zz is the kernel version of the source).

However, the following link appears resolve a similar problem…

http://ubuntuforums.org/showthread.php?t=1047374

Jerrill

So first off I’m pretty sure I correctly got the source from the host machine and I have linux-3.2.18 in my /usr/src/

I tried looking at the link and one thing I notice when I do the following command:

$ find /usr/src -name “bounds.*” -ls

35312 4 -rw-r–r-- 1 root root 270 Jun 18 07:22 /usr/src/linux-3.2.18/include/generated/bounds.h

Should that be the only bounds file found? So I’m wondering if I have the correct files in my /usr/src/linux-3.2.18/kernel folder:

Kconfig.freezer gcov/ rcutiny_plugin.h sched_features.h
Kconfig.hz irq/ rcutree.h sched_stats.h
Kconfig.locks lockdep_internals.h rcutree_plugin.h time/
Kconfig.preempt lockdep_states.h rtmutex-debug.h timeconst.pl
Makefile mutex-debug.h rtmutex.h trace/
audit.h mutex.h rtmutex_common.h workqueue_sched.h
debug/ power/ sched_autogroup.h
events/ rcu.h sched_cpupri.h

Thanks!
Wesley

Wesley,

Ah, so I think I’ve solved my problem. I hadn’t done the bitbake systemd-image that you had said to do in a later post and I also did a MACHINE=beaglebone bitbake virtual/kernel -c compile -f. After that I found a new kernel source that contained the bounds.c file but it was in a different location.

It was at ./build/tmp-angstrom_vYYYY_MM-eglibc/work/beaglebone-angstrom-linux-gnueabi/linux-ti33x-psp-X.X-rXXX-gitreNNN…NN/git/ as mentioned on this site http://www.cemetech.net/forum/viewtopic.php?t=7814.

I’m running the make modules now and it seems to running smoothly!

Thanks for the responses!
~Wesley

Ashish,

git clone git://github.com/Angstrom-distribution/setup-scripts.git
MACHINE=beaglebone ./oebb.sh config beaglebone
MACHINE=beaglebone ./oebb.sh update
MACHINE=beaglebone ./oebb.sh bitbake virtual/kernel

And copy the kernel source from:

setup-scripts/build/tmp-angstrom_2010_x-eglibc/sysroots/beaglebone/kernel/

to the following:

/usr/src/linux-3.2.13

NOTE: You'll need to create the following symlink to the destination folder
for the build to complete:

/lib/modules/3.2.13/build

I was able to compile the following on the BeagleBone after running the
following in the kernel source folder to build the required executables
(i.e. modpost)

make modules
make scripts

And then build the following with make:

Makefile
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
obj-m := hello.o

KDIR := /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)

default:
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

hello.c
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#include <linux/module.h> /* Needed by all modules */
#include <linux/kernel.h> /* Needed for KERN_INFO */
#include <linux/init.h> /* Needed for the macros */

static int __init hello_start(void)
{
printk(KERN_INFO "Loading hello module...\n");
printk(KERN_INFO "Hello world\n");
return 0;
}

static void __exit hello_end(void)
{
printk(KERN_INFO "Goodbye Mr.\n");
}

module_init(hello_start);
module_exit(hello_end);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Jerrill

I think the idea of building natively could indeed simplify
development for many users, but I will try to document some steps for
this a bit more spelled out, since this has clearly become a
frequently asked question.

I've placed my instructions at [1]

[1] GitHub - beagleboard/kernel: Kernel for the beagleboard.org boards

There are some obvious potential issues that need to be addressed. For
one, if you are using the default Angstrom image that comes with the
board, my instructions point you to a different toolchain. While I am
not aware of any incompatibilities, there is some potential (that
seems highly unlikely to me). The split between kernel and userspace
makes toolchain incompatibilities seem even less likely to me. I'll
look for experts to weigh in on how much of an issue this could be.

Hey,

So in case anyone is interested or still having problems I’ve done a little documentation on how I set up the kernel module and also some code on user ioctl interaction with the kernel module here:

https://groups.google.com/forum/#!topic/beagleboard/dyuax5415dc

Thanks for all the help though!
~Wesley