arm-linux-gcc4.4.3編譯s3c2410平台linux內核


寫在前面:2.6.14版本的內核用arm-linux-gcc4.4.3沒有編譯成功,下載2.6.37版本的內核用arm-linux-gcc4.4.3編譯通過。

 

一、首先下載linux內核:

linux-2.6.14.tar.bz2 下載地址:http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.14.tar.bz2

二、解壓linux-2.6.14.tar.bz2:

tar -jxvf linux-2.6.14.tar.bz2

三、配置Makefile文件:

1、打開源碼根目錄下的Makefile文件:

gedit Makefile

修改Makefile文件:

ARCH            ?= arm
CROSS_COMPILE   ?= arm-linux-

2、查看目錄結構:

ls -l linux-2.6.14/arch/arm/

drwxrwxr-x 4 mlx mlx  4096 Oct 28  2005 boot
drwxrwxr-x 2 mlx mlx  4096 Oct 28  2005 common
drwxrwxr-x 2 mlx mlx  4096 Oct 28  2005 configs
-rw-rw-r-- 1 mlx mlx 21221 Oct 28  2005 Kconfig
-rw-rw-r-- 1 mlx mlx  3845 Oct 28  2005 Kconfig.debug
drwxrwxr-x 2 mlx mlx  4096 Oct 28  2005 kernel
drwxrwxr-x 2 mlx mlx  4096 Oct 28  2005 lib
... ...
drwxrwxr-x 2 mlx mlx  4096 Oct 28  2005 mach-s3c2410
... ...

可以看到該內核支持s3c2410芯片。

3、查看芯片的默認配置文件:

ls -l linux-2.6.14/arch/arm/configs/

-rw-rw-r-- 1 mlx mlx 18719 Oct 28  2005 rpc_defconfig
-rw-rw-r-- 1 mlx mlx 20543 Oct 28  2005 s3c2410_defconfig
-rw-rw-r-- 1 mlx mlx 16901 Oct 28  2005 shannon_defconfig
-rw-rw-r-- 1 mlx mlx 21104 Oct 28  2005 shark_defconfig
-rw-rw-r-- 1 mlx mlx 18173 Oct 28  2005 simpad_defconfig
-rw-rw-r-- 1 mlx mlx 13382 Oct 28  2005 smdk2410_defconfig
-rw-rw-r-- 1 mlx mlx 28956 Oct 28  2005 spitz_defconfig
-rw-rw-r-- 1 mlx mlx 17936 Oct 28  2005 versatile_defconfig

四、編譯內核:

1、拷貝配置文件:

cd linux-2.6.14

cp -f arch/arm/configs/s3c2410_defconfig .config

2、make menuconfig

make menuconfig出錯

(1)、Makefile:450: *** mixed implicit and normal rules: deprecated syntax
(2)、make: *** No rule to make target 'menuconfig'.  Stop.

針對(1),是由於我的系統的make工具太新,make的舊版規則已經無法兼容新版。按照以下方式,問題得到解決:

 

在makefile中修改:

config %config: scripts_basic outputmakefile FORCE

改為:

%config: scripts_basic outputmakefile FORCE

 

修改/ %/: prepare scripts FORCE(錯)

為:%/: prepare scripts FORCE(對)

如果正確不做修改

修改后繼續make menuconfig,又出現錯誤:

You must install ncurses-devel in order
>> to use 'make menuconfig'

安裝:

sudo apt-get install libncurses5-dev

安裝完畢后再次執行make menuconfig即可運行

選擇 Load an Alternate Configation File 回車
               選擇.config

選擇 save an Alternate Configation File 回車

        此處顯示的是我們剛選擇的defconfig文件路徑,刪除掉,改為linux 2.6.26 解壓路徑下的.config(XXXXXX/.config)

 

3、出現錯誤:arch/arm: Is a directory. Stop.

原因:ARCH            ?= arm這句話的arm后出現了空格

make zImage 開始編譯,編譯成功會生成zImage文件

 出錯

arch/arm/mm/alignment.c: In function 'proc_alignment_write':
arch/arm/mm/alignment.c:119: error: read-only variable '__r2' used as 'asm' output
arch/arm/mm/alignment.c:119: error: read-only variable '__r2' used as 'asm' output
arch/arm/mm/alignment.c:119: error: read-only variable '__r2' used as 'asm' output
arch/arm/mm/alignment.c:119: error: read-only variable '__r2' used as 'asm' output
scripts/Makefile.build:193: recipe for target 'arch/arm/mm/alignment.o' failed
make[1]: *** [arch/arm/mm/alignment.o] Error 1
Makefile:784: recipe for target 'arch/arm/mm' failed
make: *** [arch/arm/mm] Error 2

網上說是因為arm-linux-gcc版本過高導致的,用3.4.1版本。

 

五、下載2.6.37內核,按照上面的方式重新make:

報錯

Can't use 'defined(@array)' (Maybe you should just omit the defined()?) at kernel/timeconst.pl line 373.
/home/mlx/ArmLinux/linux-2.6.37/kernel/Makefile:139: recipe for target 'kernel/timeconst.h' failed
make[1]: *** [kernel/timeconst.h] Error 255
Makefile:914: recipe for target 'kernel' failed
make: *** [kernel] Error 2

解決:將kernel/timeconst.pl中第373行的defined()去掉只留下@val就可以了

繼續make,報錯:

drivers/leds/leds-h1940.c: In function 'h1940_greenled_set':
drivers/leds/leds-h1940.c:33: error: implicit declaration of function 'h1940_latch_control'
scripts/Makefile.build:250: recipe for target 'drivers/leds/leds-h1940.o' failed
make[2]: *** [drivers/leds/leds-h1940.o] Error 1
scripts/Makefile.build:380: recipe for target 'drivers/leds' failed
make[1]: *** [drivers/leds] Error 2
Makefile:914: recipe for target 'drivers' failed
make: *** [drivers] Error 2

直接把h1940_latch_control()函數注銷掉,具體修解決方法還不知道。

繼續make,完成后生成了vmlinux。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM