kernel2.6.21에 busybox-1.12.1로 filesystem을 만들었다.
module 프로그램 좀 해보려니까 busybos의 insmod, depmod, modprobe가 안먹힌다..-_ -
$ insmod test.ko
insmod: module 'test.ko' not found
$ depmod test.ko
depmod: chdir(test.ko): Not a directory
$ modprobe test.ko
modprobe: module 'test.ko' not found
오만 삽질을 다하다가 아무래도 busybox가 의심스러워
modutil을 직접 컴파일하기로 했다.
1. 최신버전의 module-init-tools를 다운로드 받는다.
(현재 최신버전은 module-init-tools-3.4.tar.bz2)
2. 압축해제
$ tar -xvf module-init-tools-3.4.tar.bz2
$ cd module-init-tools-3.4
3. configuration
- cross_compile(arm-none-linux-gnueabi-gcc)와 host(arm-linux)를 지정해주고 파일이 생성될 디렉토리(/temp)를 지정해준다.
# ./configure --host=arm-linux CC=arm-none-linux-gnueabi-gcc --prefix=/temp
configure: WARNING: If you wanted to set the --build type, don't use --host.
If a cross compiler is detected then cross compile mode will be used.
checking build system type... i686-pc-linux-gnu
checking host system type... arm-unknown-linux-gnu
checking target system type... arm-unknown-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for arm-linux-strip... arm-linux-strip
checking for arm-linux-gcc... arm-none-linux-gnueabi-gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... yes
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether arm-none-linux-gnueabi-gcc accepts -g... yes
checking for arm-none-linux-gnueabi-gcc option to accept ANSI C... none needed
checking for style of include used by make... GNU
checking dependency style of arm-none-linux-gnueabi-gcc... gcc3
configure: Adding gcc options: -g -O2 -Wunused -Wall
configure: creating ./config.status
config.status: creating Makefile
config.status: executing depfiles commands
# - 이대로 컴파일을 하면 모두 dynamic link가 되어버린다. static link로 바꿔주기 위해 Makefile의 CFLAGS에 -static옵션을 붙인다.
$ vi Makefile
141 CFLAGS = -g -O2 -Wunused -Wall -static
4. Compile 및 install
- configuration이 끝났으면 컴파일을 한다.
$ make - 컴파일이 끝나면 configure에서 정의해 준 디렉토리에 파일을 생성 시킨다.
$ make install
5. 확인
- 생성된 파일의 속성을 확인해 보자.
$ file lsmod
lsmod: ELF 32-bit LSB executable, ARM, version 1 (SYSV), for GNU/Linux 2.6.14, statically linked, for GNU/Linux 2.6.14, not stripped
이렇게 module-util의 컴파일이 끝났다.
다시 test.ko에 대한 insmod, lsmod, rmmod시에 모두 정상동작 하였다.
끝~