linux-2.6.30.4移植至2440開發板經驗談

轉自http://blog.csdn.net/sanlinux/archive/2009/11/22/4852575.aspx

一、下載linux-2.6.30.4源碼,並解壓

ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.30.4.tar.gz

tar zxvf linux-2.6.30.4.tar.gz

並且下載支持ARM的補丁文件,給標準內核打上ARM補丁。

ftp://ftp.arm.linux.org.uk/pub/linux/arm/kernel/v2.6/patch-2.6.0-rmk2.bz2

二、在系統中添加對ARM的支持

$vim Makefile

193#ARCH           ?= $(SUBARCH)
194 #CROSS_COMPILE  ?=
195 ARCH=arm
196 CROSS_COMPILE=arm-linux-

三、修改系統時鐘

$vim arch/arm/mach-s3c2440/mach-smdk2440.c

系統的外部時鐘爲12MHz

160 static void __init smdk2440_map_io(void)
161 {
162         s3c24xx_init_io(smdk2440_iodesc, ARRAY_SIZE(smdk2440_iodesc));
163         //s3c24xx_init_clocks(16934400);
164         //edit by San

165         s3c24xx_init_clocks(12000000);
166         s3c24xx_init_uarts(smdk2440_uartcfgs, ARRAY_SIZE(smdk2440_uartcfgs));
167 }

四、製作或者獲取內核配置單.config

$make menuconfig

五、修改機器碼

【linux內核源碼中查看機器碼相關文件:】

$vim arch/arm/mach-s3c2440/mach-smdk2440.c

178 MACHINE_START(S3C2440 , "SMDK2440")
179         /* Maintainer: Ben Dooks <[email protected]> */
180         .phys_io        = S3C2410_PA_UART,
181         .io_pg_offst    = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
182         .boot_params    = S3C2410_SDRAM_PA + 0x100,
183
184         .init_irq       = s3c24xx_init_irq,
185         .map_io         = smdk2440_map_io,
186         .init_machine   = smdk2440_machine_init,
187         .timer          = &s3c24xx_timer,
188 MACHINE_END

修改機器碼,使之與bootloader的機器碼相同,這裏使用的是u-boot,機器碼爲168

$vim arch/arm/tools/mach-types

 379 s3c2440                  ARCH_S3C2440            S3C2440                 168

$vim arch/arm/tools/Makefile

 7 include/asm-arm/mach-types.h : $(src)/gen-mach-types $(src)/mach-types
 8         @echo '  Generating $@'
 9         @mkdir -p $(dir $@)
10         $(Q)$(AWK) -f $^ > $@ || { rm -f $@; /bin/false; }

$vim include/asm/mach-types.h

375 #define MACH_TYPE_S3C2440              168


【U-boot中的相關配置文件】

$vim include/asm-arm/mach-types.h

377 #define MACH_TYPE_S3C2440              168

總結:首先從linux內核源碼中找出機器類型(如S3C2440 ),其次,根據u-boot中給出的對應機器類型的機器碼(如377 #define MACH_TYPE_S3C2440 168 )修改內核機器碼。流程如下:

內核:

$vim arch/arm/mach-s3c2440/mach-smdk2440.c

U-boot:

$vim include/asm-arm/mach-types.h

內核:

$vim arch/arm/tools/mach-types

六、編譯鏡像

$make zImage

 

七、板子燒寫

使用DNW工具將內核鏡像燒寫至開發板中

 八、遇到的問題

問題:

  Kernel panic - not syncing: Attempted to kill init!

解決辦法:

  $make menuconfig

選擇以下兩項:

 Kernel Features  --->

 [*] Use the ARM EABI to compile the kernel                               
 [*]   Allow old ABI binaries to run with this kernel (EXPERIMENTAL)

九、NandFlash驅動移植

linux裏面已經包含NandFlash驅動,只需對源碼進行修改即可。

1、$vim arch/arm/plat-s3c24xx/common-smdk.c

107 /* NAND parititon from 2.4.18-swl5 */
108
109 static struct mtd_partition smdk_default_nand_part[] = {
110 #if defined(CONFIG_San_64MB_NAND )
111         [0] = {
112                 .name   = "San_Board_uboot",
113                 .size   = 0x00040000,
114                 .offset = 0x00000000,
115         },
116         [1] = {
117                 .name   = "San_Board_kernel",
118                 .offset = 0x00200000,
119                 .size   = 0x00200000,
120         },
121         [2] = {
122                 .name   = "San_Board_yaffs2",
123                 .offset = 0x00400000,
124                 .size   = 0x03BF8000,
125         }
126 #elif defined(CONFIG_San_128MB_NAND)
127         [0]={
128                 .name   ="San_Board_uboot",
129                 .offset =0x00000000,
130                 .size   =0x00040000,
131         },
132         [1]={
133                 .name   ="San_Board_kernel",
134                 .offset =0x00200000,
135                 .size   =0x00200000,
136         },
137         [2]={
138                 .name   ="San_Board_yaffs2"
139                 .offset =0x00400000,
140                 .size   =0x07BA0000,
141         }
142 #elif defined(CONFIG_ San_more_than_256MB_NAND)

143         [0]={
144                 .name   ="San_Board_uboot",
145                 .offset =0x00000000,
146                 .size   =0x00040000,
147          },
148          [1]={
149                  .name   ="San_Board_kernel",
150                  .offset =0x00200000,
151                  .size   =0x00200000,
152          },
153          [2]={
154                  .name   ="San_Board_yaffs2",
155                  .offset =0x00400000,
156                  .size   =0x0FB80000,
157          }
158 #endif
159 };

2、$vimdrivers/mtd/nand/Kconfig

166 choice
167         prompt "Nand Flash Capacity select"
168         depends on MTD
169         help
170           SanBoard Nand Flash Capacity select
171
172 config San_64MB_NAND
173         boolean "64MB Nand for SanBoard"
174         depends on MTD
175         help
176           Set 64MB Nand parts
177
178 config San_128MB_NAND
179         boolean "128MB Nand for SanBoard"
180         depends on MTD
181         help
182           Set 128MB Nand parts
183
184 config San_more_than_256MB_NAND
185         boolean "256MB~1GB Nand for SanBoard"
186         depends on MTD
187         help
188           Set 256MB~1GB Nand parts
189
190 endchoice

注:如果在make menuconfig中選中San_64MB_NAND,則在.config表現形式如下:

CONFIG_San_64MB_NAND=y

這實際是給C源文件提供預編譯變量,如#if defined(CONFIG_San_64MB_NAND).......

這個過程就是實現了內核的定製,比如新增Nand驅動、或者去除wireless驅動。。。

十、移植yaffs2文件系統

1、獲取yaffs2源碼

http://www.aleph1.co.uk/cgi-bin/viewcvs.cgi/

2、在內核中添加對yaffs2的支持

在剛下載的yaffs2源碼中,執行:

./patch-ker.sh c ../linux-2.6.30.4

此時在內核fs目錄下,新增“yaffs2”目錄,同時fs/目錄下面的Makefile文件和Kconfig文件也添加了yaffs2的配置和編譯條件。

3、在配置單中添加對yaffs2的支持


$make menuconfig

File systems  --->

                [*] Miscellaneous filesystems  --->

                                     <*>   YAFFS2 file system support

注意:假如在內核中沒有添加對yaffs2的支持,則出現找不到或者掛載文件系統是失敗的提示:

List of all partitions:
0100       4096 ram0 (driver?)
0101       4096 ram1 (driver?)
0102       4096 ram2 (driver?)
0103       4096 ram3 (driver?)
0104       4096 ram4 (driver?)
0105       4096 ram5 (driver?)
0106       4096 ram6 (driver?)
0107       4096 ram7 (driver?)
0108       4096 ram8 (driver?)
0109       4096 ram9 (driver?)
010a       4096 ram10 (driver?)
010b       4096 ram11 (driver?)
010c       4096 ram12 (driver?)
010d       4096 ram13 (driver?)
010e       4096 ram14 (driver?)
010f       4096 ram15 (driver?)
1f00        256 mtdblock0 (driver?)
1f01       2048 mtdblock1 (driver?)
1f02      63168 mtdblock2 (driver?)
No filesystem could mount root, tried:  ext3 ext2 cramfs msdos vfat romfs
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(31,2)

4、yaffs2移植完成,重新編譯內核

十一、在內核中添加tmpfs支持

如果不添加tmpfs支持,那麼將會出現那/tmp掛載失敗的提示。關於tmpfs的作用待研究。

mount: mounting tmpfs on /tmp failed: Invalid argume

文件系統配置:

[root@san /]#cat /etc/fstab
proc /proc proc defaults 0 0
tmpfs /tmp tmpfs defaults 0 0
sysfs /sys sysfs defaults 0 0
tmpfs /dev tmpfs defaults 0 0
var /dev tmpfs defaults 0 0

File systems  --->

                      Pseudo filesystems  --->

                                      [*] Virtual memory file system support (former shm fs)

                                      [*]   Tmpfs POSIX Access Control Lists

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章