免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2198 | 回复: 0
打印 上一主题 下一主题

移植linux-2.6.38.8 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-12-22 08:51 |只看该作者 |倒序浏览
linux最新稳定版的内核是2.6.39.2,由于yaffs补丁对它还没有支持,故选用linux-2.6.38.8。
 
平台:Vmware-7.1.4 ,Ubuntu 10.04
硬件:mini2440
交叉编译器:arm-linux-gcc 4.1.2(openmoko制作)
 
移植目标:
移植基本内核,支持yaffs文件系统。
 
移植步骤:
1.下载解压linux-2.6.38.8.tar.bz2,修改Makefile使其支持arm。
#vi Makefile
  1. ARCH ?= arm
  2. CROSS_COMPILE ?= arm-linux-
 
2.修改机器码,以匹配bootloader的机器码
#vi arch/arm/tools/mach-types
  1. mini2440 MACH_MINI2440 MINI2440 1999
由于现在使用的mini2440开发板,在此可以选择默认的MACHINE_TYPE
 
3.修改kernel的MACH_TYPE代码引用部分 ,确定kernel的MACH_TYPE,并修改时钟。
#vi arch/arm/mach-s3c2440/mach-smdk2440.c
  1. //MACHINE_START(S3C2440, "SMDK2440")
改为:
  1. MACHINE_START(MINI2440, "MXH2440")
显示换成自己的logo,O(∩_∩)O~
 
修改时钟:
  1. static void __init smdk2440_map_io(void)
  2. {
  3.     s3c24xx_init_io(smdk2440_iodesc, ARRAY_SIZE(smdk2440_iodesc));
  4.     s3c24xx_init_clocks(12000000);
  5.     s3c24xx_init_uarts(smdk2440_uartcfgs, ARRAY_SIZE(smdk2440_uartcfgs));
  6. }
 
4.修改Nand Flash分区。这里只创建三个分区,其他多余的分区屏蔽掉
#vi arch/arm/plat-s3c24xx/common-smdk.c
  1. /* NAND parititon from 2.4.18-swl5 */

  2. static struct mtd_partition smdk_default_nand_part[] = {
  3.     [0] = {
  4.         .name = "mxh_uboot",
  5.         .size = 0x60000,//大小对应与u-boot里的分区大小384k
  6.         .offset = 0,
  7.     },
  8.     [1] = {
  9.         .name = "mxh_kernel",
  10.         .offset = 0x100000,
  11.         .size = 0x500000,//内核区间的大小给5M,起始地址为0x100000,结束地址为0x600000,那么0x60000-->0x100000这段哪里去了?在u-boot里60000-->80000是给param参数区了,我将80000-->100000这段空闲起来了
  12.     },
  13.     [2] = {
  14.         .name = "mxh_yaffs2",
  15.         .offset = 0x600000,
  16.         .size = 0xfa00000,// nandflash的剩余大小为250M
  17.     }
  18. };
 
5.接下来做yaffs支持注意老版本的yaffs已经不支持linux-2.6.36以上内核了,需要最新版本yaffs
首先下载git,然后用git下载,为内核打上补丁。
#apt-get install git-core
#git clone git://www.aleph1.co.uk/yaffs2
#cd yaffs2
#patch-ker.sh c m [linux-kernel]
 
6.复制s3c2410的配置文件到当前目录下
#cp arch/arm/configs/s3c2410_defconfig ./mxh_config
 
7.配置内核选项,加载mxh_config
#make menuconfig
新版yaffs2补丁有点问题,如果我们先选中General setup选项中的
配置时,则文件系统中将不会见到yaffs的配置。反之,如果我们先选择文件系统yaffs2配置时就不会出现这个问题:
所以我选择第二种方法,先配置文件系统,保存配置文件mxh_config.这是我经过一次无意的实验得出的结论,应该这是yaffs的Kconfig和Makefile的问题了,但是我没有深入研究,先移植了再说。
啰嗦了半天,其实我想说的是:
#make menuconfig
-->load mxh_config-->File systems-->Miscellaneous filesystems-->yaffs2 support-->save mxh_config-->Exit
#make menuconfig
-->load mxh_config-->General setup-->Configure standard kernel features (expert users)
 
8.配置System Type:
 
9.配置Kernel Features:
选中Use the ARM EABI to compile the kerne
10.其它的选择默认的即可。可参考:http://blog.chinaunix.net/space.php?uid=20788517&do=blog&id=34710
 
11.save mxh_config
#cp mxh_config .config
 
12.编译内核
#make zImage
如果没有任何错误,编译出来的内核在arch/arm/boot/目录下,文件zImage即是。
 
13.u-boot支持uImage,不直接支持zImage,因此还要将zImage转换成uImage格式
经过编译后的u-boot在根目录下的tools目录中,会有个叫做mkimage的工具,他可以给zImage添加一个header,也就是说使得通常我们编译的内核zImage添加一个数据头信息部分,我们把添加头后的image通常叫uImage,uImage是可以被u-boot直接引导的内核镜像。
mkimage工具的使用介绍如下:
使用: 中括号括起来的是可选的
mkimage [-x] -A arch -O os -T type -C comp -a addr -e ep -n name -d data_file[:data_file...] image
选项:
-A:set architecture to 'arch'       //用于指定CPU类型,比如ARM
-O:set operating system to 'os'     //用于指定操作系统,比如Linux
-T:set image type to 'type'         //用于指定image类型,比如Kernel
-C:set compression type 'comp'      //指定压缩类型
-a:set load address to 'addr' (hex) //指定image的载入地址
-e:set entry point to 'ep' (hex)    //内核的入口地址,一般为image的载入地址+0x40(信息头的大小)
-n:set image name to 'name'         //image在头结构中的命名
-d:use image data from 'datafile'   //无头信息的image文件名
-x:set XIP (execute in place)       //设置执行位置
 
先将u-boot下的tools中的mkimage复制到主机的/usr/local/bin目录下,这样就可以在主机的任何目录下使用该工具了。现在我们进入kernel生成目录(一般是arch/arm/boot目录),然后执行如下命令,就会在该目录下生成一个uImage.img的镜像文件,把他复制到tftp目录下,这就是我们所说的uImage。
mkimage -n 'linux-2.6.38' -A arm -O linux -T kernel -C none -a 0x30008000 -e 0x30008040 -d zImage uImage
 
为了方便我们可以把上面这句写成一个脚本叫做mkkernel.sh,并给它加上可执行权限
#vi mkkernel.sh
 
  1. mkimage -n 'linux-2.6.38' -A arm -O linux -T kernel -C none -a 0x30008000 -e 0x30008040 -d zImage uImage
#chmod +x mkkernel.sh
 
14.下载uImage运行
 
  1. #################################################
  2. ##            boot from NAND flash             ##
  3. ##                                             ##
  4. ##   U-Boot 2010.06 (Jul 01 2011 - 22:10:39)   ##
  5. ##                                             ##
  6. ##   My Blog : http://xurafreedom.cublog.cn    ##
  7. ##                                             ##
  8. #################################################
  9. DRAM: 64 MiB
  10. Flash: 2 MiB
  11. NAND: 256 MiB

  12. NAND read: mtdparts variable not set, see 'help mtdparts'
  13. incorrect device type in logo
  14. 'logo' is not a number
  15. Video: 320x240x16 15kHz 52Hz
  16. In: serial
  17. Out: serial
  18. Err: serial
  19. USB slave is enable!
  20. Net: dm9000
  21. nand read 0x30008000 0x100000 0x500000; bootm 0x30008000
  22. Hit any key to stop autoboot: 0

  23. NAND read: device 0 offset 0x100000, size 0x500000
  24. 5242880 bytes read: OK
  25. ## Booting kernel from Legacy Image at 30008000 ...
  26. Image Name: linux-2.6.38
  27. Created: 2011-07-03 2:47:37 UTC
  28. Image Type: ARM Linux Kernel Image (uncompressed)
  29. Data Size: 2149028 Bytes = 2 MiB
  30. Load Address: 30008000
  31. Entry Point: 30008040
  32. Verifying Checksum ... OK
  33. XIP Kernel Image ... OK
  34. OK
  35. Starting kernel ...
  36. Uncompressing Linux... done, booting the kernel.
  37. Linux version 2.6.38.8 (xura@ubuntu) (gcc version 4.1.2) #1 Sat Jul 2 01:19:36 PDT 2011
  38. CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177
  39. CPU: VIVT data cache, VIVT instruction cache
  40. Machine: MXH2440
  41. Memory policy: ECC disabled, Data cache writeback
  42. CPU S3C2440A (id 0x32440001)
  43. S3C24XX Clocks, Copyright 2004 Simtec Electronics
  44. S3C244X: core 400.000 MHz, memory 100.000 MHz, peripheral 50.000 MHz
  45. CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on
  46. Built 1 zonelists in Zone order, mobility grouping on. Total pages: 16256
  47. Kernel command line: noinitrd root=/dev/mtdblock2 init=/linuxrc console=ttySAC0
  48. PID hash table entries: 256 (order: -2, 1024 bytes)
  49. Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
  50. Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
  51. Memory: 64MB = 64MB total
  52. Memory: 60472k/60472k available, 5064k reserved, 0K highmem
  53. Virtual kernel memory layout:
  54. vector : 0xffff0000 - 0xffff1000 ( 4 kB)
  55. fixmap : 0xfff00000 - 0xfffe0000 ( 896 kB)
  56. DMA : 0xffc00000 - 0xffe00000 ( 2 MB)
  57. vmalloc : 0xc4800000 - 0xf6000000 ( 792 MB)
  58. lowmem : 0xc0000000 - 0xc4000000 ( 64 MB)
  59. modules : 0xbf000000 - 0xc0000000 ( 16 MB)
  60. .init : 0xc0008000 - 0xc0029000 ( 132 kB)
  61. .text : 0xc0029000 - 0xc0402404 (3942 kB)
  62. .data : 0xc0404000 - 0xc0429fc0 ( 152 kB)
  63. NR_IRQS:85
  64. irq: clearing subpending status 00000002
  65. Console: colour dummy device 80x30
  66. console [ttySAC0] enabled
  67. Calibrating delay loop... 199.47 BogoMIPS (lpj=498688)
  68. pid_max: default: 32768 minimum: 301
  69. Mount-cache hash table entries: 512
  70. CPU: Testing write buffer coherency: ok
  71. gpiochip_add: gpios 288..303 (GPIOK) failed to register
  72. gpiochip_add: gpios 320..334 (GPIOL) failed to register
  73. gpiochip_add: gpios 352..353 (GPIOM) failed to register
  74. NET: Registered protocol family 16
  75. S3C Power Management, Copyright 2004 Simtec Electronics
  76. S3C2440: Initialising architecture
  77. S3C2440: IRQ Support
  78. S3C244X: Clock Support, DVS off
  79. bio: create slab <bio-0> at 0
  80. i2c-core: driver [pcf50633] using legacy suspend method
  81. i2c-core: driver [pcf50633] using legacy resume method
  82. SCSI subsystem initialized
  83. usbcore: registered new interface driver usbfs
  84. usbcore: registered new interface driver hub
  85. usbcore: registered new device driver usb
  86. s3c-i2c s3c2440-i2c: slave address 0x10
  87. s3c-i2c s3c2440-i2c: bus frequency set to 97 KHz
  88. s3c-i2c s3c2440-i2c: i2c-0: S3C I2C adapter
  89. Advanced Linux Sound Architecture Driver Version 1.0.23.
  90. NET: Registered protocol family 2
  91. IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
  92. TCP established hash table entries: 2048 (order: 2, 16384 bytes)
  93. TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
  94. TCP: Hash tables configured (established 2048 bind 2048)
  95. TCP reno registered
  96. UDP hash table entries: 256 (order: 0, 4096 bytes)
  97. UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
  98. NET: Registered protocol family 1
  99. RPC: Registered udp transport module.
  100. RPC: Registered tcp transport module.
  101. RPC: Registered tcp NFSv4.1 backchannel transport module.
  102. NetWinder Floating Point Emulator V0.97 (extended precision)
  103. JFFS2 version 2.2. (NAND) (SUMMARY) ?? 2001-2006 Red Hat, Inc.
  104. ROMFS MTD (C) 2007 Red Hat, Inc.
  105. msgmni has been set to 118
  106. io scheduler noop registered
  107. io scheduler deadline registered
  108. io scheduler cfq registered (default)
  109. Console: switching to colour frame buffer device 30x40
  110. fb0: s3c2410fb frame buffer device
  111. Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled
  112. s3c2440-uart.0: ttySAC0 at MMIO 0x50000000 (irq = 70) is a S3C2440
  113. s3c2440-uart.1: ttySAC1 at MMIO 0x50004000 (irq = 73) is a S3C2440
  114. s3c2440-uart.2: ttySAC2 at MMIO 0x50008000 (irq = 76) is a S3C2440
  115. lp: driver loaded but no devices found
  116. ppdev: user-space parallel port driver
  117. brd: module loaded
  118. loop: module loaded
  119. Uniform Multi-Platform E-IDE driver
  120. ide-gd driver 1.18
  121. ide-cd driver 5.00
  122. S3C24XX NAND Driver, (c) 2004 Simtec Electronics
  123. s3c24xx-nand s3c2440-nand: Tacls=2, 20ns Twrph0=6 60ns, Twrph1=2 20ns
  124. s3c24xx-nand s3c2440-nand: NAND soft ECC
  125. NAND device: Manufacturer ID: 0xec, Chip ID: 0xda (Samsung NAND 256MiB 3,3V 8-bit)
  126. Scanning device for bad blocks
  127. Bad eraseblock 1461 at 0x00000b6a0000
  128. Creating 3 MTD partitions on "NAND":
  129. 0x000000000000-0x000000060000 : "mxh_uboot"
  130. 0x000000100000-0x000000600000 : "mxh_kernel"
  131. 0x000000600000-0x000010000000 : "mxh_yaffs2"
  132. dm9000 Ethernet Driver, V1.31
  133. usbmon: debugfs is not available
  134. ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
  135. s3c2410-ohci s3c2410-ohci: S3C24XX OHCI
  136. s3c2410-ohci s3c2410-ohci: new USB bus registered, assigned bus number 1
  137. s3c2410-ohci s3c2410-ohci: irq 42, io mem 0x49000000
  138. hub 1-0:1.0: USB hub found
  139. hub 1-0:1.0: 2 ports detected
  140. usbcore: registered new interface driver libusual
  141. usbcore: registered new interface driver usbserial
  142. USB Serial support registered for generic
  143. usbcore: registered new interface driver usbserial_generic
  144. usbserial: USB Serial Driver core
  145. USB Serial support registered for FTDI USB Serial Device
  146. usbcore: registered new interface driver ftdi_sio
  147. ftdi_sio: v1.6.0:USB FTDI Serial Converters Driver
  148. USB Serial support registered for pl2303
  149. usbcore: registered new interface driver pl2303
  150. pl2303: Prolific PL2303 USB to serial adaptor driver
  151. mousedev: PS/2 mouse device common for all mice
  152. S3C24XX RTC, (c) 2004,2006 Simtec Electronics
  153. S3C2410 Watchdog Timer, (c) 2004 Simtec Electronics
  154. s3c2410-wdt s3c2410-wdt: watchdog inactive, reset disabled, irq enabled
  155. ALSA device list:
  156. No soundcards found.
  157. TCP cubic registered
  158. NET: Registered protocol family 17
  159. drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
  160. yaffs: dev is 32505858 name is "mtdblock2" rw
  161. yaffs: passed flags ""
  162. VFS: Mounted root (yaffs filesystem) on device 31:2.
  163. Freeing init memory: 132K
  164. Failed to execute /linuxrc. Attempting defaults...
  165. Kernel panic - not syncing: No init found. Try passing init= option to kernel. See Linux Documentation/init.txt for guidance.
  166. [<c003a410>] (unwind_backtrace+0x0/0xe4) from [<c0048804>] (panic+0x54/0x18c)
  167. [<c0048804>] (panic+0x54/0x18c) from [<c002958c>] (init_post+0x9c/0xc4)
  168. [<c002958c>] (init_post+0x9c/0xc4) from [<c000888c>] (kernel_init+0xfc/0x138)
  169. [<c000888c>] (kernel_init+0xfc/0x138) from [<c0035c78>] (kernel_thread_exit+0x0/0x8)

还没有文件系统,故下面出现错误,移植yaffs2文件系统,http://blog.chinaunix.net/space.php?uid=20788517&do=blog&id=34708

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP