Hello World kernel module on BeagleBone

6,818 views
Skip to first unread message

Jerrill

unread,
Apr 6, 2012, 6:17:42 PM4/6/12
to beagl...@googlegroups.com
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...
Configuring kernel-headers.
beaglebone:~/projects/modules/hello-world# opkg install kernel-dev
Installing kernel-dev (3.2-r7c+gitr09e9651bcf2ee8d86685f2a8075bc6557b1d3b91) to root...
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
<command-line>:0:0: note: this is the location of the previous definition
hello-1.c:11:0: warning: "__KERNEL__" redefined
<command-line>: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

Jacek Radzikowski

unread,
Apr 6, 2012, 7:15:30 PM4/6/12
to beagl...@googlegroups.com
On Fri, Apr 6, 2012 at 18:17, Jerrill <jer...@gmail.com> wrote:
[...]

> 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.


--
Given a choice between two theories, take the one which is funnier

Ashish Deshpande

unread,
Apr 8, 2012, 7:25:29 AM4/8/12
to beagl...@googlegroups.com

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
<command-line>: warning: this is the location of the previous definition
hello-1.c:11:1: warning: "__KERNEL__" redefined
<command-line>: 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
CC      := arm-angstrom-linux-gnueabi-gcc
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

Andrey Nechypurenko

unread,
Apr 9, 2012, 4:46:24 PM4/9/12
to beagl...@googlegroups.com
> 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:
http://veter-project.blogspot.de/2012/03/comfortable-kernel-workflow-on.html

Jacek Radzikowski

unread,
Apr 9, 2012, 5:10:03 PM4/9/12
to beagl...@googlegroups.com
On Sun, Apr 8, 2012 at 07:25, Ashish Deshpande
<ashishvd...@gmail.com> wrote:
>
> 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:
http://gcc.gnu.org/onlinedocs/gcc-4.7.0/gcc/Directory-Options.html#Directory-Options

Jerrill

unread,
Apr 9, 2012, 11:31:57 PM4/9/12
to beagl...@googlegroups.com
Ashish,

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

Ashish Deshpande

unread,
Apr 10, 2012, 10:47:44 AM4/10/12
to beagl...@googlegroups.com
Thanks for your Help

I tried to create fresh git repository using below commands
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

Jerrill

unread,
Apr 12, 2012, 10:57:45 PM4/12/12
to beagl...@googlegroups.com
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!

Ashish Deshpande

unread,
Apr 15, 2012, 1:22:43 PM4/15/12
to beagl...@googlegroups.com
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

Jerrill

unread,
Apr 15, 2012, 10:10:43 PM4/15/12
to beagl...@googlegroups.com
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

Ashish Deshpande

unread,
Apr 16, 2012, 2:44:41 AM4/16/12
to beagl...@googlegroups.com
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

I will try to rebuild it.
Thanks,
Ashish Deshpande

Dave H.

unread,
Aug 3, 2012, 7:20:56 PM8/3/12
to beagl...@googlegroups.com

On Monday, April 9, 2012 8:31:57 PM UTC-7, Jerrill wrote:
Ashish,

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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 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



Dave H.

unread,
Aug 3, 2012, 7:23:12 PM8/3/12
to beagl...@googlegroups.com
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.

Jerrill Johnson

unread,
Aug 3, 2012, 10:36:36 PM8/3/12
to beagl...@googlegroups.com
David,

On Fri, Aug 3, 2012 at 7:20 PM, Dave H. <pkpd...@gmail.com> wrote:


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

Jerrill Johnson

unread,
Aug 3, 2012, 10:46:09 PM8/3/12
to beagl...@googlegroups.com
Wesley,

On Fri, Aug 3, 2012 at 3:09 PM, Wesley <wesley...@gmail.com> wrote:
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...


Jerrill



Wesley

unread,
Aug 6, 2012, 1:48:25 PM8/6/12
to beagl...@googlegroups.com


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

Jerrill Johnson

unread,
Aug 7, 2012, 10:55:45 PM8/7/12
to beagl...@googlegroups.com
Wesley,

On Mon, Aug 6, 2012 at 1:48 PM, Wesley <wesley...@gmail.com> wrote:




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

-- To join: http://beagleboard.org/discuss
To unsubscribe from this group, send email to:
beagleboard...@googlegroups.com
Frequently asked questions: http://beagleboard.org/faq

I haven't tried this in a few weeks. The latest demo images / kernel module packages have included all the modules I needed for my project so far.

Even then, when I was doing this I didn't have any trouble with a bounds file.

Maybe someone else can jump in with the answer?

Jerrill

Wesley

unread,
Aug 15, 2012, 2:53:43 PM8/15/12
to beagl...@googlegroups.com

 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
 
 

Jason Kridner

unread,
Aug 16, 2012, 3:32:27 AM8/16/12
to beagl...@googlegroups.com
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] https://github.com/beagleboard/kernel

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.

Wesley

unread,
Aug 30, 2012, 5:07:41 PM8/30/12
to beagl...@googlegroups.com
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

maurya emb

unread,
Nov 26, 2012, 9:25:25 AM11/26/12
to beagl...@googlegroups.com, robert...@gmail.com
Jerril,

After completing

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

 
I am not getting  /setup-scripts/build/tmp-angstrom_v2012_05-eglibc/kernel/ directory, but I get in /setup-scripts/build/tmp-angstrom_v2012_05-eglibc/sysroots/beaglebone/usr/src/kernel, may you explain.

Therefore, I copy /setup-scripts/build/tmp-angstrom_v2012_05-eglibc/sysroots/beaglebone/usr/src/kernel from host pc to /usr/src/linux-3.2.30/ on beaglebone sd card.

After that, I go to  /usr/src/linux-3.2.30/kernel directory of beaglebone, then enter following command on beaglebone:

make modules

But I am getting many warnings and following error:

scripts/kconfig/conf --silentoldconfig Kconfig
  CHK     include/linux/version.h
  CHK     include/generated/utsrelease.h
  Generating include/generated/mach-types.h

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


Plaese anyone can explain where am I wrong, very helping for me.

Any suggestion is welcome.

Regards
Awadhesh

sebastie...@gmail.com

unread,
Aug 26, 2013, 6:02:43 PM8/26/13
to beagl...@googlegroups.com, robert...@gmail.com
Hi, have you found a solution for your problem ?

In my case too, it seems that bounds.c not in /usr/src/kernel ... I've not found any answer.

I copied my /boot/.config to this directory ... and same error.

Thanks

Brandon I

unread,
Aug 27, 2013, 1:46:12 PM8/27/13
to beagl...@googlegroups.com
For the hello world, you can compile them right on the beaglebone with the demo image after installing two packages.


And, the kernel kernel-headers and kernel-dev packages are complete enough that I wrote and compiled my own, complete, kernel modules with all sorts of fancy features.

These packages were completely broken a while ago, but I believe they're working again.
Reply all
Reply to author
Forward
0 new messages