Hi everyone
I am new to linux, trying to build helloworld module for my pandaboard running linux-3.8.8. I am using toolchain from codesourcery. Below are the step I had followed
1. export PATH=$PATH:/home/work/mgc/mel-kit/arm-2011.03/bin/
2. export CROSS_COMPILE=arm-none-linux-gnueabi-
3. export ARCH=arm
4. created helloworld.c with contects
#define MODULE
#include <linux/module.h> /* Needed by all modules */
#include <linux/kernel.h> /* Needed for KERN_ALERT */
#include <linux/init.h> /* Needed for the macros */
MODULE_LICENSE("GPL");
MODULE_AUTHOR("SKM");
MODULE_DESCRIPTION("HW");
int init_module(void)
{
printk("<1>Hello world\n");
return 0;
}
void cleanup_module(void)
{
printk(KERN_ALERT "Goodbye world\n");
}
module_init(init_module);
module_exit(cleanup_module);
5.created Makefile with contents
obj-m +=helloworld.o
all:
make ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C /home/work/kernel/linux-3.8.10/ M=$(PWD) modules
clean:
make ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C /home/work/kernel/linux-3.8.10/ M=$(PWD) clean
--------------
6. I am getting errors as
make
make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- -C /home/work/kernel/linux-3.8.10/ M=/home/work/application modules
make[1]: Entering directory `/home/work/kernel/linux-3.8.10'
CC [M] /home/work/application/helloworld.o
/home/work/application/helloworld.c:1:0: warning: "MODULE" redefined
<command-line>:0:0: note: this is the location of the previous definition
In file included from include/linux/irqflags.h:15:0,
from /home/work/kernel/linux-3.8.10/arch/arm/include/asm/bitops.h:27,
from include/linux/bitops.h:22,
from include/linux/kernel.h:10,
from include/linux/cache.h:4,
from include/linux/time.h:4,
from include/linux/stat.h:18,
from include/linux/module.h:10,
from /home/work/application/helloworld.c:2:
/home/work/kernel/linux-3.8.10/arch/arm/include/asm/irqflags.h:11:5: warning: "__LINUX_ARM_ARCH__" is not defined
In file included from include/linux/bitops.h:22:0,
from include/linux/kernel.h:10,
from include/linux/cache.h:4,
from include/linux/time.h:4,
from include/linux/stat.h:18,
from include/linux/module.h:10,
from /home/work/application/helloworld.c:2:
/home/work/kernel/linux-3.8.10/arch/arm/include/asm/bitops.h:217:5: warning: "__LINUX_ARM_ARCH__" is not defined
In file included from /home/work/kernel/linux-3.8.10/arch/arm/include/asm/bitops.h:220:0,
from include/linux/bitops.h:22,
from include/linux/kernel.h:10,
from include/linux/cache.h:4,
from include/linux/time.h:4,
from include/linux/stat.h:18,
from include/linux/module.h:10,
from /home/work/application/helloworld.c:2:
include/asm-generic/bitops/__fls.h: In function '__fls':
include/asm-generic/bitops/__fls.h:17:2: warning: left shift count >= width of type
include/asm-generic/bitops/__fls.h:19:3: warning: left shift count >= width of type
include/asm-generic/bitops/__fls.h:22:2: warning: left shift count >= width of type
include/asm-generic/bitops/__fls.h:26:2: warning: left shift count >= width of type
include/asm-generic/bitops/__fls.h:30:2: warning: left shift count >= width of type
include/asm-generic/bitops/__fls.h:34:2: warning: left shift count >= width of type
include/asm-generic/bitops/__fls.h:38:2: warning: left shift count >= width of type
In file included from /home/work/kernel/linux-3.8.10/arch/arm/include/asm/bitops.h:221:0,
from include/linux/bitops.h:22,
from include/linux/kernel.h:10,
from include/linux/cache.h:4,
from include/linux/time.h:4,
from include/linux/stat.h:18,
from include/linux/module.h:10,
from /home/work/application/helloworld.c:2:
include/asm-generic/bitops/__ffs.h: In function '__ffs':
include/asm-generic/bitops/__ffs.h:19:3: warning: right shift count >= width of type
In file included from /home/work/kernel/linux-3.8.10/arch/arm/include/asm/swab.h:18:0,
from include/uapi/linux/swab.h:6,
from include/linux/swab.h:4,
from include/uapi/linux/byteorder/little_endian.h:12,
from include/linux/byteorder/little_endian.h:4,
from /home/work/kernel/linux-3.8.10/arch/arm/include/uapi/asm/byteorder.h:21,
from include/asm-generic/bitops/le.h:5,
from /home/work/kernel/linux-3.8.10/arch/arm/include/asm/bitops.h:308,
from include/linux/bitops.h:22,
from include/linux/kernel.h:10,
from include/linux/cache.h:4,
from include/linux/time.h:4,
from include/linux/stat.h:18,
from include/linux/module.h:10,
from /home/work/application/helloworld.c:2:
/home/work/kernel/linux-3.8.10/arch/arm/include/uapi/asm/swab.h: At top level:
/home/work/kernel/linux-3.8.10/arch/arm/include/uapi/asm/swab.h:26:29: warning: "__LINUX_ARM_ARCH__" is not defined
In file included from include/uapi/linux/swab.h:6:0,
from include/linux/swab.h:4,
from include/uapi/linux/byteorder/little_endian.h:12,
from include/linux/byteorder/little_endian.h:4,
from /home/work/kernel/linux-3.8.10/arch/arm/include/uapi/asm/byteorder.h:21,
from include/asm-generic/bitops/le.h:5,
from /home/work/kernel/linux-3.8.10/arch/arm/include/asm/bitops.h:308,
from include/linux/bitops.h:22,
from include/linux/kernel.h:10,
from include/linux/cache.h:4,
from include/linux/time.h:4,
from include/linux/stat.h:18,
from include/linux/module.h:10,
from /home/work/application/helloworld.c:2:
/home/work/kernel/linux-3.8.10/arch/arm/include/asm/swab.h:20:5: warning: "__LINUX_ARM_ARCH__" is not defined
In file included from /home/work/kernel/linux-3.8.10/arch/arm/include/asm/thread_info.h:16:0,
from include/linux/thread_info.h:54,
from include/linux/preempt.h:9,
from include/linux/spinlock.h:50,
from include/linux/seqlock.h:29,
from include/linux/time.h:5,
from include/linux/stat.h:18,
from include/linux/module.h:10,
from /home/work/application/helloworld.c:2:
/home/work/kernel/linux-3.8.10/arch/arm/include/asm/fpstate.h:32:5: warning: "__LINUX_ARM_ARCH__" is not defined
In file included from /home/work/kernel/linux-3.8.10/arch/arm/include/asm/domain.h:14:0,
from /home/work/kernel/linux-3.8.10/arch/arm/include/asm/thread_info.h:28,
from include/linux/thread_info.h:54,
from include/linux/preempt.h:9,
from include/linux/spinlock.h:50,
from include/linux/seqlock.h:29,
from include/linux/time.h:5,
from include/linux/stat.h:18,
from include/linux/module.h:10,
from /home/work/application/helloworld.c:2:
/home/work/kernel/linux-3.8.10/arch/arm/include/asm/barrier.h:9:5: warning: "__LINUX_ARM_ARCH__" is not defined
/home/work/kernel/linux-3.8.10/arch/arm/include/asm/barrier.h:10:3: warning: "__LINUX_ARM_ARCH__" is not defined
/home/work/kernel/linux-3.8.10/arch/arm/include/asm/barrier.h:16:5: warning: "__LINUX_ARM_ARCH__" is not defined
/home/work/kernel/linux-3.8.10/arch/arm/include/asm/barrier.h:20:35: warning: "__LINUX_ARM_ARCH__" is not defined
In file included from /home/work/kernel/linux-3.8.10/arch/arm/include/asm/atomic.h:18:0,
from include/linux/atomic.h:4,
from include/linux/debug_locks.h:5,
from include/linux/lockdep.h:23,
from include/linux/spinlock_types.h:18,
from include/linux/spinlock.h:81,
from include/linux/seqlock.h:29,
from include/linux/time.h:5,
from include/linux/stat.h:18,
from include/linux/module.h:10,
from /home/work/application/helloworld.c:2:
/home/work/kernel/linux-3.8.10/arch/arm/include/asm/cmpxchg.h: In function '__xchg':
/home/work/kernel/linux-3.8.10/arch/arm/include/asm/cmpxchg.h:33:5: warning: "__LINUX_ARM_ARCH__" is not defined
/home/work/kernel/linux-3.8.10/arch/arm/include/asm/cmpxchg.h:40:5: warning: "__LINUX_ARM_ARCH__" is not defined
In file included from /home/work/kernel/linux-3.8.10/arch/arm/include/asm/atomic.h:18:0,
from include/linux/atomic.h:4,
from include/linux/debug_locks.h:5,
from include/linux/lockdep.h:23,
from include/linux/spinlock_types.h:18,
from include/linux/spinlock.h:81,
from include/linux/seqlock.h:29,
from include/linux/time.h:5,
from include/linux/stat.h:18,
from include/linux/module.h:10,
from /home/work/application/helloworld.c:2:
/home/work/kernel/linux-3.8.10/arch/arm/include/asm/cmpxchg.h: At top level:
/home/work/kernel/linux-3.8.10/arch/arm/include/asm/cmpxchg.h:108:5: warning: "__LINUX_ARM_ARCH__" is not defined
/home/work/kernel/linux-3.8.10/arch/arm/include/asm/cmpxchg.h:112:2: error: #error "SMP is not supported on this platform"
In file included from include/linux/atomic.h:4:0,
from include/linux/debug_locks.h:5,
from include/linux/lockdep.h:23,
from include/linux/spinlock_types.h:18,
from include/linux/spinlock.h:81,
from include/linux/seqlock.h:29,
from include/linux/time.h:5,
from include/linux/stat.h:18,
from include/linux/module.h:10,
from /home/work/application/helloworld.c:2:
/home/work/kernel/linux-3.8.10/arch/arm/include/asm/atomic.h:32:5: warning: "__LINUX_ARM_ARCH__" is not defined
/home/work/kernel/linux-3.8.10/arch/arm/include/asm/atomic.h:155:2: error: #error SMP not supported on pre-ARMv6 CPUs
/home/work/kernel/linux-3.8.10/arch/arm/include/asm/atomic.h:242:3: error: conflicting types for 'atomic64_t'
include/linux/types.h:182:3: note: previous declaration of 'atomic64_t' was here
In file included from include/linux/spinlock.h:87:0,
from include/linux/seqlock.h:29,
from include/linux/time.h:5,
from include/linux/stat.h:18,
from include/linux/module.h:10,
from /home/work/application/helloworld.c:2:
/home/work/kernel/linux-3.8.10/arch/arm/include/asm/spinlock.h:4:5: warning: "__LINUX_ARM_ARCH__" is not defined
/home/work/kernel/linux-3.8.10/arch/arm/include/asm/spinlock.h:5:2: error: #error SMP not supported on pre-ARMv6 CPUs
In file included from /home/work/kernel/linux-3.8.10/arch/arm/include/asm/spinlock.h:8:0,
from include/linux/spinlock.h:87,
from include/linux/seqlock.h:29,
from include/linux/time.h:5,
from include/linux/stat.h:18,
from include/linux/module.h:10,
from /home/work/application/helloworld.c:2:
/home/work/kernel/linux-3.8.10/arch/arm/include/asm/processor.h:82:5: warning: "__LINUX_ARM_ARCH__" is not defined
/home/work/kernel/linux-3.8.10/arch/arm/include/asm/processor.h:97:5: warning: "__LINUX_ARM_ARCH__" is not defined
In file included from include/linux/spinlock.h:87:0,
from include/linux/seqlock.h:29,
from include/linux/time.h:5,
from include/linux/stat.h:18,
from include/linux/module.h:10,
from /home/work/application/helloworld.c:2:
/home/work/kernel/linux-3.8.10/arch/arm/include/asm/spinlock.h: In function 'dsb_sev':
/home/work/kernel/linux-3.8.10/arch/arm/include/asm/spinlock.h:47:5: warning: "__LINUX_ARM_ARCH__" is not defined
/home/work/kernel/linux-3.8.10/arch/arm/include/asm/spinlock.h: In function 'arch_spin_lock':
/home/work/kernel/linux-3.8.10/arch/arm/include/asm/spinlock.h:91:3: error: implicit declaration of function 'wfe'
In file included from include/linux/mmzone.h:20:0,
from include/linux/gfp.h:4,
from include/linux/kmod.h:22,
from include/linux/module.h:13,
from /home/work/application/helloworld.c:2:
/home/work/kernel/linux-3.8.10/arch/arm/include/asm/page.h: At top level:
/home/work/kernel/linux-3.8.10/arch/arm/include/asm/page.h:107:2: error: #error Unknown user operations model
In file included from /home/work/kernel/linux-3.8.10/arch/arm/include/asm/page.h:161:0,
from include/linux/mmzone.h:20,
from include/linux/gfp.h:4,
from include/linux/kmod.h:22,
from include/linux/module.h:13,
from /home/work/application/helloworld.c:2:
/home/work/kernel/linux-3.8.10/arch/arm/include/asm/memory.h:58:1: warning: "CONFIG_PAGE_OFFSETUL" is not defined
/home/work/kernel/linux-3.8.10/arch/arm/include/asm/memory.h:58:1: warning: "CONFIG_PAGE_OFFSETUL" is not defined
/home/work/kernel/linux-3.8.10/arch/arm/include/asm/memory.h:52:46: warning: the right operand of ">" changes sign when promoted
/home/work/kernel/linux-3.8.10/arch/arm/include/asm/memory.h: In function 'virt_to_phys':
/home/work/kernel/linux-3.8.10/arch/arm/include/asm/memory.h:220:1: error: 'CONFIG_PAGE_OFFSETUL' undeclared (first use in this function)
/home/work/kernel/linux-3.8.10/arch/arm/include/asm/memory.h:220:1: note: each undeclared identifier is reported only once for each function it appears in
/home/work/kernel/linux-3.8.10/arch/arm/include/asm/memory.h:220:1: error: 'CONFIG_PHYS_OFFSETUL' undeclared (first use in this function)
/home/work/kernel/linux-3.8.10/arch/arm/include/asm/memory.h: In function 'phys_to_virt':
/home/work/kernel/linux-3.8.10/arch/arm/include/asm/memory.h:225:1: error: 'CONFIG_PHYS_OFFSETUL' undeclared (first use in this function)
/home/work/kernel/linux-3.8.10/arch/arm/include/asm/memory.h:225:1: error: 'CONFIG_PAGE_OFFSETUL' undeclared (first use in this function)
/home/work/kernel/linux-3.8.10/arch/arm/include/asm/memory.h: In function 'virt_to_bus':
/home/work/kernel/linux-3.8.10/arch/arm/include/asm/memory.h:250:1: error: 'CONFIG_PAGE_OFFSETUL' undeclared (first use in this function)
/home/work/kernel/linux-3.8.10/arch/arm/include/asm/memory.h:250:1: error: 'CONFIG_PHYS_OFFSETUL' undeclared (first use in this function)
/home/work/kernel/linux-3.8.10/arch/arm/include/asm/memory.h: In function 'bus_to_virt':
/home/work/kernel/linux-3.8.10/arch/arm/include/asm/memory.h:255:1: error: 'CONFIG_PHYS_OFFSETUL' undeclared (first use in this function)
/home/work/kernel/linux-3.8.10/arch/arm/include/asm/memory.h:255:1: error: 'CONFIG_PAGE_OFFSETUL' undeclared (first use in this function)
In file included from include/linux/gfp.h:4:0,
from include/linux/kmod.h:22,
from include/linux/module.h:13,
from /home/work/application/helloworld.c:2:
include/linux/mmzone.h: At top level:
include/linux/mmzone.h:97:3: error: 'CONFIG_ARM_L1_CACHE_SHIFT' undeclared here (not in a function)
include/linux/mmzone.h:97:1: error: requested alignment is not a constant
include/linux/mmzone.h:506:1: error: requested alignment is not a constant
In file included from include/linux/notifier.h:14:0,
from include/linux/memory_hotplug.h:6,
from include/linux/mmzone.h:761,
from include/linux/gfp.h:4,
from include/linux/kmod.h:22,
from include/linux/module.h:13,
from /home/work/application/helloworld.c:2:
include/linux/rwsem.h:40:23: fatal error: asm/rwsem.h: No such file or directory
compilation terminated.
make[2]: *** [/home/work/application/helloworld.o] Error 1
make[1]: *** [_module_/home/work/application] Error 2
make[1]: Leaving directory `/home/work/kernel/linux-3.8.10'
make: *** [all] Error 2
Can any one help me build my first module. I also tried building manually with " arm-none-linux-gnueabi-gcc -I ../kernel/linux-3.8.10/include/ -I ../kernel/linux-3.8.10/arch/arm/include/ -I ../kernel/linux-3.8.10/ -M='$PWD' -o helloworld.ko helloworld.c " , it give the same error.
Regards
Khalid