도와주세요!!
안녕하세요 저번에 질문 드렸는데요
linux-2.6.35-s5pv210 리눅스 커널 디렉토리에서 상단위치에서
make_s5pv210.sh 파일을 이용해 커널을 컴파일을 했더니,
linux-2.6.35-s5pv210 디렉토리와 같은 위치에 build_s5pv210 이라는 폴더가 생성됩니다.
전에 조언과 같이 ,
test 폴더에 있는 make 파일을
다음과같이 KDIR 를 바꾸어서 컴파일 한 결과 ,,
root@spao-VirtualBox:/home/work/test# make
make -C /home/work/build_s5pv210 SUBDIRS=/home/work/test modules
make[1]: Entering directory `/home/work/build_s5pv210'
make -C /home/work/linux-2.6.35-s5pv210 O=/home/work/build_s5pv210/. modules
CC [M] /home/work/test/test_module.o
In file included from /home/work/linux-2.6.35-s5pv210/arch/x86/include/asm/bitops.h:447:0,
from /home/work/linux-2.6.35-s5pv210/include/linux/bitops.h:22,
from /home/work/linux-2.6.35-s5pv210/include/linux/kernel.h:17,
from /home/work/test/test_module.c:9:
/home/work/linux-2.6.35-s5pv210/arch/x86/include/asm/arch_hweight.h: In function ‘__arch_hweight64’:
/home/work/linux-2.6.35-s5pv210/arch/x86/include/asm/arch_hweight.h:53:7: error: expected ‘:’ or ‘)’ before ‘POPCNT64’
In file included from /home/work/linux-2.6.35-s5pv210/include/linux/prefetch.h:14:0,
from /home/work/linux-2.6.35-s5pv210/include/linux/list.h:6,
from /home/work/linux-2.6.35-s5pv210/include/linux/module.h:9,
from /home/work/test/test_module.c:11:
/home/work/linux-2.6.35-s5pv210/arch/x86/include/asm/processor.h: At top level:
/home/work/linux-2.6.35-s5pv210/arch/x86/include/asm/processor.h:116:30: error: ‘CONFIG_X86_L1_CACHE_SHIFT’ undeclared here (not in a function)
/home/work/linux-2.6.35-s5pv210/arch/x86/include/asm/processor.h:116:1: error: requested alignment is not a constant
/home/work/linux-2.6.35-s5pv210/arch/x86/include/asm/processor.h:159:0: warning: "cache_line_size" redefined [enabled by default]
/home/work/linux-2.6.35-s5pv210/include/linux/cache.h:64:0: note: this is the location of the previous definition
/home/work/linux-2.6.35-s5pv210/arch/x86/include/asm/processor.h:239:1: error: requested alignment is not a constant
/home/work/linux-2.6.35-s5pv210/arch/x86/include/asm/processor.h:270:1: error: requested alignment is not a constant
/home/work/linux-2.6.35-s5pv210/arch/x86/include/asm/processor.h: In function ‘native_get_debugreg’:
/home/work/linux-2.6.35-s5pv210/arch/x86/include/asm/processor.h:502:3: error: invalid application of ‘sizeof’ to incomplete type ‘struct bug_entry’
/home/work/linux-2.6.35-s5pv210/arch/x86/include/asm/processor.h: In function ‘native_set_debugreg’:
/home/work/linux-2.6.35-s5pv210/arch/x86/include/asm/processor.h:529:3: error: invalid application of ‘sizeof’ to incomplete type ‘struct bug_entry’
In file included from /home/work/linux-2.6.35-s5pv210/arch/x86/include/asm/atomic.h:319:0,
from /home/work/linux-2.6.35-s5pv210/arch/x86/include/asm/thread_info.h:24,
from /home/work/linux-2.6.35-s5pv210/include/linux/thread_info.h:56,
from /home/work/linux-2.6.35-s5pv210/include/linux/preempt.h:9,
from /home/work/linux-2.6.35-s5pv210/include/linux/spinlock.h:50,
from /home/work/linux-2.6.35-s5pv210/include/linux/seqlock.h:29,
from /home/work/linux-2.6.35-s5pv210/include/linux/time.h:8,
from /home/work/linux-2.6.35-s5pv210/include/linux/stat.h:60,
from /home/work/linux-2.6.35-s5pv210/include/linux/module.h:10,
from /home/work/test/test_module.c:11:
/home/work/linux-2.6.35-s5pv210/arch/x86/include/asm/atomic64_64.h: At top level:
/home/work/linux-2.6.35-s5pv210/arch/x86/include/asm/atomic64_64.h:19:1: error: unknown type name ‘atomic64_t’
/home/work/linux-2.6.35-s5pv210/arch/x86/include/asm/atomic64_64.h: In function ‘atomic64_read’:
/home/work/linux-2.6.35-s5pv210/arch/x86/include/asm/atomic64_64.h:21:32: error: request for member ‘counter’ in something not a structure or union
/home/work/linux-2.6.35-s5pv210/arch/x86/include/asm/atomic64_64.h: At top level:
/home/work/linux-2.6.35-s5pv210/arch/x86/include/asm/atomic64_64.h:31:33: error: unknown type name ‘atomic64_t’
/home/work/linux-2.6.35-s5pv210/arch/x86/include/asm/atomic64_64.h:43:41: error: unknown type name ‘atomic64_t’
/home/work/linux-2.6.35-s5pv210/arch/x86/include/asm/atomic64_64.h:57:41: error: unknown type name ‘atomic64_t’
/home/work/linux-2.6.35-s5pv210/arch/x86/include/asm/atomic64_64.h:73:49: error: unknown type name ‘atomic64_t’
/home/work/linux-2.6.35-s5pv210/arch/x86/include/asm/atomic64_64.h:89:33: error: unknown type name ‘atomic64_t’
/home/work/linux-2.6.35-s5pv210/arch/x86/include/asm/atomic64_64.h:102:33: error: unknown type name ‘atomic64_t’
/home/work/linux-2.6.35-s5pv210/arch/x86/include/asm/atomic64_64.h:117:41: error: unknown type name ‘atomic64_t’
/home/work/linux-2.6.35-s5pv210/arch/x86/include/asm/atomic64_64.h:135:41: error: unknown type name ‘atomic64_t’
/home/work/linux-2.6.35-s5pv210/arch/x86/include/asm/atomic64_64.h:154:49: error: unknown type name ‘atomic64_t’
/home/work/linux-2.6.35-s5pv210/arch/x86/include/asm/atomic64_64.h:171:48: error: unknown type name ‘atomic64_t’
/home/work/linux-2.6.35-s5pv210/arch/x86/include/asm/atomic64_64.h:180:48: error: unknown type name ‘atomic64_t’
/home/work/linux-2.6.35-s5pv210/arch/x86/include/asm/atomic64_64.h:188:37: error: unknown type name ‘atomic64_t’
/home/work/linux-2.6.35-s5pv210/arch/x86/include/asm/atomic64_64.h:193:34: error: unknown type name ‘atomic64_t’
/home/work/linux-2.6.35-s5pv210/arch/x86/include/asm/atomic64_64.h:207:39: error: unknown type name ‘atomic64_t’
/home/work/linux-2.6.35-s5pv210/arch/x86/include/asm/atomic64_64.h:231:45: error: unknown type name ‘atomic64_t’
In file included from /home/work/linux-2.6.35-s5pv210/include/linux/seqlock.h:29:0,
from /home/work/linux-2.6.35-s5pv210/include/linux/time.h:8,
from /home/work/linux-2.6.35-s5pv210/include/linux/stat.h:60,
from /home/work/linux-2.6.35-s5pv210/include/linux/module.h:10,
from /home/work/test/test_module.c:11:
/home/work/linux-2.6.35-s5pv210/include/linux/spinlock.h: In function ‘assert_spin_locked’:
/home/work/linux-2.6.35-s5pv210/include/linux/spinlock.h:379:2: error: invalid application of ‘sizeof’ to incomplete type ‘struct bug_entry’
In file included from /home/work/linux-2.6.35-s5pv210/include/linux/mmzone.h:16:0,
from /home/work/linux-2.6.35-s5pv210/include/linux/gfp.h:4,
from /home/work/linux-2.6.35-s5pv210/include/linux/kmod.h:22,
from /home/work/linux-2.6.35-s5pv210/include/linux/module.h:13,
from /home/work/test/test_module.c:11:
/home/work/linux-2.6.35-s5pv210/include/linux/nodemask.h: In function ‘__first_node’:
/home/work/linux-2.6.35-s5pv210/include/linux/nodemask.h:237:2: error: implicit declaration of function ‘find_first_bit’ [-Werror=implicit-function-declaration]
/home/work/linux-2.6.35-s5pv210/include/linux/nodemask.h: In function ‘__next_node’:
/home/work/linux-2.6.35-s5pv210/include/linux/nodemask.h:243:2: error: implicit declaration of function ‘find_next_bit’ [-Werror=implicit-function-declaration]
/home/work/linux-2.6.35-s5pv210/include/linux/nodemask.h: In function ‘__first_unset_node’:
/home/work/linux-2.6.35-s5pv210/include/linux/nodemask.h:266:2: error: implicit declaration of function ‘find_first_zero_bit’ [-Werror=implicit-function-declaration]
In file included from /home/work/linux-2.6.35-s5pv210/include/linux/elf.h:7:0,
from /home/work/linux-2.6.35-s5pv210/include/linux/module.h:14,
from /home/work/test/test_module.c:11:
/home/work/linux-2.6.35-s5pv210/arch/x86/include/asm/elf.h: In function ‘elf_common_init’:
/home/work/linux-2.6.35-s5pv210/arch/x86/include/asm/elf.h:167:3: error: ‘struct thread_struct’ has no member named ‘fs’
In file included from /home/work/linux-2.6.35-s5pv210/include/linux/module.h:21:0,
from /home/work/test/test_module.c:11:
/home/work/linux-2.6.35-s5pv210/arch/x86/include/asm/module.h: At top level:
/home/work/linux-2.6.35-s5pv210/arch/x86/include/asm/module.h:59:2: error: #error unknown processor family
/home/work/test/test_module.c:18:13: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘test_init’
/home/work/test/test_module.c:28:13: warning: function declaration isn’t a prototype [-Wstrict-prototypes]
/home/work/test/test_module.c: In function ‘__inittest’:
/home/work/test/test_module.c:38:1: error: ‘test_init’ undeclared (first use in this function)
/home/work/test/test_module.c:38:1: note: each undeclared identifier is reported only once for each function it appears in
/home/work/test/test_module.c: At top level:
/home/work/test/test_module.c:38:1: error: ‘init_module’ aliased to undefined symbol ‘test_init’
cc1: some warnings being treated as errors
make[4]: *** [/home/work/test/test_module.o] Error 1
make[3]: *** [_module_/home/work/test] Error 2
make[2]: *** [sub-make] Error 2
make[1]: *** [all] Error 2
make[1]: Leaving directory `/home/work/build_s5pv210'
make: *** [all] Error 2
root@spao-VirtualBox:/home/work/test#
이런 에러 메시지를 찍더군요 , 헤더파일을 못찾는거같기도하구..;
다른분께서는 커널 디렉토리 하위에 build_xxxxxx 가 생길거라고 하셨는데 ,
커널 디렉토리 하위에는 따로 생성되는게 없더라구요 ㅠ
어떻게 해야할까요? ㅠ
참고로...
모듈로 컴파일하려고 하는 파일은 다음과 같습니다.
1 /*
2 * test_module.c
3 *
4 * Created on: 2012. 11. 8.
5 * Author: moon
6 */
7
8
9 #include <linux/kernel.h>
10
11 #include <linux/module.h>
12
13 #include <linux/init.h>
14
15
16
17
18 int __intit test_init()
19
20 {
21
22 printk("module init \n");
23
24 return 0;
25
26 }
27
28 void __exit test_exit()
29
30 {
31
32 printk("module exit \n");
33 }
34
35
36
37
38 module_init( test_init );
39
40 module_exit( test_exit );
41
42 MODULE_LICENSE("GPL");
라인 오타가 있었군요 ㅠ 아 죄송하고 감사합니다..
라인을 고치고 나서
test_module.c 에 관한 에러는 수정되었습니다.
그런데 그윗단의 많은 에러들은 그대로인데요.. 인클루드를 잘못하고있는건가요?
arch를 ARM이 아닌 x86으로 찾고 있는 문제 입니다.
위에 스크린샷 찍힌 Makefile에서 크로스 컴파일러를 보니
cc := arm-generic-linux-gnueabi-gcc=4.3.2
로 되어 있네요. 컴파일러를 못찾아서 우분투에 기본적으로 설치 되어 있는 x86용 컴파일러로 컴파일 한것 같습니다.
cc := arm-generic-linux-gnueabi-gcc-4.3.2
로 변경 하시면 정상적으로 되실거라 봅니다~
변경 하시고 꼭 clean 한번 하신다음에 다시 make 하세요!
Makefile 에서
make -C $(KDIR) SUBDIRS=$(PWD) modules
==>> ARCH=arm make -C $(KDIR) SUBDIRS=$(PWD) modules
make_s5pv210.sh 에는 ARCH=arm 이 선언되어 있죠.
해당 쉘을 한번 보셨으면 되었을텐데...
답변 감사합니다.!
그런데 다른에러가 나서 혹시 크로스컴파일 설정을 해줘야 하는지.. 궁금합니다..
메이크 파일은 다음과 같구요
1 cc := arm-generic-linux-gnueabi-gcc-4.3.2
2
3 obj-m := test_module.o
4
5
6
7
8 KDIR := /home/s5pv210/build_s5pv210
9
10
11 all:
12 ARCH=arm make -C $(KDIR) SUBDIRS=$(PWD) modules
13
14 clean:
15 rm -rf *.0
16 rm -rf *.ko
17 rm -rf *.mod.*
18 rm -rf .*.cmd
컴파일 했을때
case 1 :
root@spao-VirtualBox:/home/s5pv210/test# make
ARCH=arm make -C /home/s5pv210/build_s5pv210 SUBDIRS=/home/s5pv210/test modules
make[1]: Entering directory `/home/s5pv210/build_s5pv210'
make -C /home/s5pv210/linux-2.6.35-s5pv210 O=/home/s5pv210/build_s5pv210/. modules
WARNING: Symbol version dump /home/s5pv210/build_s5pv210/Module.symvers
is missing; modules will have no dependencies and modversions.
CC [M] /home/s5pv210/test/test_module.o
gcc: error trying to exec 'cc1': execvp: No such file or directory
make[4]: *** [/home/s5pv210/test/test_module.o] Error 1
make[3]: *** [_module_/home/s5pv210/test] Error 2
make[2]: *** [sub-make] Error 2
make[1]: *** [all] Error 2
make[1]: Leaving directory `/home/s5pv210/build_s5pv210'
make: *** [all] Error 2
ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ
case 2 :
root@spao-VirtualBox:/home/s5pv210/test# sudo make
ARCH=arm make -C /home/s5pv210/build_s5pv210 SUBDIRS= modules
make[1]: Entering directory `/home/s5pv210/build_s5pv210'
make -C /home/s5pv210/linux-2.6.35-s5pv210 O=/home/s5pv210/build_s5pv210/. modules
Using /home/s5pv210/linux-2.6.35-s5pv210 as source for kernel
GEN /home/s5pv210/build_s5pv210/Makefile
CHK include/linux/version.h
CHK include/generated/utsrelease.h
make[4]: `include/generated/mach-types.h' is up to date.
CC kernel/bounds.s
cc1: error: unrecognized command line option ‘-mlittle-endian’
cc1: error: unrecognized command line option ‘-mno-thumb-interwork’
/home/s5pv210/linux-2.6.35-s5pv210/kernel/bounds.c:1:0: error: unknown ABI (aapcs-linux) for -mabi= switch
/home/s5pv210/linux-2.6.35-s5pv210/kernel/bounds.c:1:0: error: bad value (armv5t) for -march= switch
make[4]: *** [kernel/bounds.s] Error 1
make[3]: *** [prepare0] Error 2
make[2]: *** [sub-make] Error 2
make[1]: *** [all] Error 2
make[1]: Leaving directory `/home/s5pv210/build_s5pv210'
make: *** [all] Error 2
라는 에러 가 나는데..
크로스 컴파일은 루트에서 gcc 파일을 4.3.2 버젼을 / (루트에서 ) 압축 풀기만 하는게 아닌가요?
커널은 컴파일하신것 맞으시겠죠?
빌드쉘에 보시면
CROSS_COMPILE=xxxxxx 되어 있을 겁니다.
그걸 빠트리신듯.
ARCH=arm make CROSS_COMPILE=arm-generic-linux-gnueabi- -C $(KDIR) SUBDIRS=$(PWD) modules
커널에 있는 컴파일 쉘에 있는 명령어에서 사용하는 옵션을 그대로 사용하시면 될겁니다.
오류가 날때는 컴파일러가 친철하게 다 알려 주고 있습니다~
/home/work/test/test_module.c:18:13: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘test_init’
일단 18번라인 에서 에러가 났다고 표시해 주고 있습니다.
그럼 18번째 라인이 에러의 원인이겠죠?
/home/work/test/test_module.c:38:1: error: ‘test_init’ undeclared (first use in this function)
test_init 이 없다고 표시해 주고 있네요.
/home/work/test/test_module.c:38:1: error: ‘init_module’ aliased to undefined symbol ‘test_init’
여기서도 module_init에 등록된 test_init이 없다고 나옵니다.
그래서 18번 라인을 보시면
18 int __intit test_init()
아~ 오타가 있으십니다. __init 이 아니라 __intit라고 되어 있네요-_-;
int __init test_init()
으로 고치시면 잘 되실겁니다!
열공하세요!!!