2009年5月26日 星期二

insmod module on MIPS target board 常見的錯誤

1._gp_disp symbol being undefined
_gp_disp is a magic symbol used with PIC code on MIPS. Be happy, this error message saved you from crashing your system. You should use the same compiler options to compile a kernel module as the kernel makefiles do. In particular the options -fno-pic -mno-abicalls are important.
2.xxx.o:Relocation overflow of type 4 for....

This error is caused by the limited range of relocation type 4 (R_MIPS26) which due to it's 26-bit offset only has a 28-bit reach. Modules and kernels happen to be located very far from each other and as the result this 28-bit range is insufficient. Insmod, not being stupid notices the problem and issues this error message.

The solution is the same as in the previous section. When compiling a kernel you must use the same compiler flags for modules as your actual kernel source is using in this particular kernel configuration. These are different from the flags that are used during the build of the kernel itself. In this particular case the module was built without -mlong-calls which is causing this kind of error.

2009年5月10日 星期日

Build toolchain 工具

1. buildroot (http://buildroot.uclibc.org/)
利用make menuconfig 來選擇你要的選項,例如:CPU type, gcc, glib....
並不是每個組合都是OK,有些搭配是有問題的,請先參考這篇文章(http://www.kegel.com/crosstool/crosstool-0.43/buildlogs/),小弟之前一直再蠻幹,後來才發現某些組合根本就是fail。

以上兩種build toolchain 的tool在compiler的時候,會出現gcc compiler error,尤其以新版gcc來cimpiler 舊版本gcc,時常會發現gcc語法上的錯誤,主要是因為舊版本gcc語法上較新版gcc不那麼嚴謹,所以會有錯誤發生,依照錯誤訊息,改寫一下souce code就OK,如果是錯在assembly code,你必須要有一些assembly的基礎,先試著了解code在做啥,才有辦法改寫,如果還是不行就問問google大神,祖國有很多文章可以參考,但總是不了了之,但是可以大概了結問題所在,所以也是有一點幫助。

Swap space via NFS

1. 產生swap file (32MB) 
dd if=/dev/zero of=/nfs/swap32 bs=1024k count=32
2.設定 /nfs/swap32為swap分割區
mkswap /nfs/swap32

3.將/dev/loop0與/nfs/swap32連結
losetup /dev/loop0 /nfs/swap32

4.設定 /dev/lopp0為swap分割區
mkswap /dev/loop0

5. 將/dev/loop0掛上swap
 swapon /dev/loop0