Guide Compiling kernel modules for Raspbian - Raspberry Pi Forums


i sorry poor english , come china, english not good,hope can understand me.

tried many days compiler kernel module, failed .i can make module successful ,but when try insert module kernel ,errors occurs. kernel says module invalid format ,but don't know how resolve problem . few days ago, search resolution google ,and find topic in raspberry pi form ,they tool can use --- rpi-source .also,it's tool use, useful ,easily, powerful . news of rpi-source, make own "hello world" module successful , insert module successful , it's news me .
don't want use rpi-source ,although it's easy , useful .i download source code github ,config kernel , compiler step step. read rpi-source source code here :https://raw.githubusercontent.com/notro ... rpi-source seems written python, pure c liker, , don't know python . think can understand python code .so try download source code , config step step .lucky,i did successful ,want share you.

must know:
1.the kernel version (using uname -r in shell). 3.18.13-v7+ .
2.the gcc version (using gcc --version ).
3.the gcc compiler pi's version (using cat /proc/version ). note: gcc version must higher gcc version saved in /proc/version ,if not,although can make module successful ,but when try insert module, kernel says invaild format. update gcc first .


next :
1. update pi linux kernel using rpi-update .
2. install higher version gcc using apt-get .my version gcc-4.9
3. change gcc-4.9 default gcc ,using (gcc-4.6 old gcc )
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 20
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 50
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.6 20
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.9 50
4. download pi source code https://github.com/raspberrypi/linux .note page's makefile's version ,must same yours. saving zip file /usr/src .
5. unzip rpi-linux-xxx.zip .note: not use "unzip" tool unzip,because file name long. should use "jar" tool.
6. after unzip ,make link between /lib/modules/$(uname -r)/build , /usr/src/rpi-linux-xxx using "ln" tools.
7. change super user "su" command , path /lib/modules/$(uname -r)/build using "cd" command.
8. run "make mrproper"
9. run "gzip -dc /proc/config.gz > .config"
10. run "make modules_prepare"

,almost step done, , left important step:
1.check cpu ,armv6 or armv71
2.go page:https://github.com/raspberrypi/firmware ... ster/extra .
3.if cpu armv6, download module.symvers, if armv71 ,download module7.symvers. saving module.symvers or module7.symvers /lib/module/$(uname -r)/build . if cpu armv71,rename module7.symvers module.symvers.

that's all. compiler module ,have fun!
luck!
thanks.



raspberrypi



Comments

Popular posts from this blog

opencv3, tbb and rasp pi 2 - Raspberry Pi Forums

small ethernet problem - Raspberry Pi Forums

Multithumb configuration params not working? - Joomla! Forum - community, help and support