다시 반복하지만 가급적이면 이 책에서 사용하는 4.19 버전에 맞춰 라즈비안 리눅스 커널 소스코드를 다운로드하길 바랍니다. 2021년이 되면 라즈비안 기본 브랜치가 아마 새로운 버전으로 설정될 수 있습니다. 즉, git clone 명령어로 브랜치 이름을 지정하지 않으면 최신 브랜치 소스코드를 다운로드하게 됩니다.
ERROR: Kernel configuration is invalid. include/generated/autoconf.h or include/config/auto.conf are missing. Run 'make oldconfig && make prepare' on kernel src to fix it.
/home/serum/linux/Makefile:590: include/config/auto.conf: No such file or directory make[1]: *** [/home/serum/linux/Makefile:641: include/config/auto.conf] Error 1 make[1]: Leaving directory '/out' make: *** [Makefile:146: sub-make] Error 2 cp: cannot stat '/out/arch/arm/boot/dts/*.dtb': No such file or directory cp: cannot stat '/out/arch/arm/boot/dts/overlays/*.dtb': No such file or directory cp: cannot stat '/out/arch/arm/boot/dts/overlays/README': No such file or directory cp: cannot stat '/out/arch/arm/boot/zImage': No such file or directory
라즈베리파이에 device driver를 만들어서 insmod로 추가하려고 하니, Invalid module format이라는 에러가 발생하였습니다. 여기저기 찾아보니, 버전이 안맞아서 그렇다고 하여, 현재 라즈베리파이는 버전이 5.10.17-v7+라고 나오는데, 최신 커널 을 다운받으니 5.10.42라고 표시가 됩니다. 보드와 동일한 소스코드를 받으려고, $ git clone --depth=1 --branch rpi-5.10.17 https://github.com/raspberrypi/linux 을 입력하니, branch를 찾을 수 없다고 나오는데요. 어떤 방법으로 해당 버전을 받을 수 있는지요? 아니면, insmod했을 때 에러가 발생한 내용이 버전이 맞지 않는 문제 말고 다른 문제가 있는 것인지 궁금합니다.
제가 리눅스 시작한지 얼마 안되서, 저자님께서 말씀하신 커널 로그에 대해 어떤 것인지 잘 모르겠습니다. 우선 제가 진행했던 것은 sudo insmod simple_dev.ko를 했더니 insmod: ERROR: could not insert module simple_dev.ko: Invalid module format 이라고 나옵니다.
simple_dev.c 의 내용은 #include <linux/kernel.h> #include <linux.module.h> #include <linux/init.h> MODULE_LICENSE("GPL"); MODULE_AUTHOR("DE"); static int module_begin(void) { printk(KERN_ALERT, "hello, doulen"); return 0; } static void module_end(void) { printk(KERN_ALERT, "goodbyen"); } module_init(module_begin); module_exit(module_end);
Makefile obj-m += simple_dev.o all: make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules clean: make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
http://rousalome.egloos.com/10016289 여기 보니, 동일하게 설명이 되어 있네요. 그래서 커널로그라고 말씀하신 것을 확인해 봤습니다. sudo insmod simple_dev.ko insmod: ERROR: could not insert module simple_dev.ko: Invalid module format tail -20 /val/log/kern.log Module has invalid ELF header 라고 표시가 되네요.
http://rousalome.egloos.com/10016289 이 부분을 다시 보고 있는데요, 저자님께서는 make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules 이 부분에서, build 폴더가 있는데, 저는 없습니다.
/home/pi/work/module_work/hello_module.c:3:10: fatal error: linux.module.h: No such file or directory #include <linux.module.h> ^~~~~~~~~~~~~~~~
이어서 빌드를 해보니 printk에 전달되는 로그 레벨 인자로 Warning 에러가 발생하네요.
/home/pi/work/module_work/hello_module.c: In function ‘module_begin’: /home/pi/rpi_kernel_src/linux/include/linux/kern_levels.h:5:18: warning: too many arguments for format [-Wformat-extra-args] #define KERN_SOH "" /* ASCII Start Of Header */ ^~~~~~ /home/pi/rpi_kernel_src/linux/include/linux/kern_levels.h:9:20: note: in expansion of macro ‘KERN_SOH’ #define KERN_ALERT KERN_SOH "1" /* action must be taken immediately */ ^~~~~~~~
제가 복사해서 붙여넣는 기능을 몰라서, 라즈베리파이에 있는 화면을 전부 타이핑을 하다 보니, 오타가 있었던 것 같습니다. 정리하면, 저자님 환경에서는 문제가 없는 것 같습니다. 질문 올리고, 책을 다시 여러번 읽었고, 빌드하니라 시간이 오래 걸렸는데, 다시 올려주신 내용 확인해 보고, 질문 있으면 다시 글 올리겠습니다. 이렇게 확인까지 해주셔서 감사합니다.
There is 2019-07-10-raspbian-buster-full.zip in this link.
When I downloaded 2019-07-10-raspbian-buster.zip(instead full), (Because 'raspberrypi.org' is changed) Error was not disappeared...
I found and downloaded 2019-07-10-raspbian-buster-ful.zip 's link. Then, Build Success.
Gook luck. Thank you for your book.
(I wrote this comment in rasbian. So, I used english... Sorry for my bad english.)
+ When I downloaded 'not full' version, I can't also execute 'apt-get install git bc flex libssl-dev'.(exactly, libssl-dev) If you download 'full' version, It will be ok.
최근 덧글