<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > linux-2.6.30.4移植至2440開發(fā)板

          linux-2.6.30.4移植至2440開發(fā)板

          作者: 時(shí)間:2016-11-22 來源:網(wǎng)絡(luò) 收藏

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

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

          本文引用地址:http://www.ex-cimer.com/article/201611/319974.htm

          tar zxvf linux-2.6.30.4.tar.gz

          二、在系統(tǒng)中添加對(duì)ARM的支持

          $vim Makefile

          193#ARCH ?= $(SUBARCH)

          194#CROSS_COMPILE ?=

          195 ARCH=arm

          196 CROSS_COMPILE=arm-linux-

          三、修改系統(tǒng)時(shí)鐘

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

          系統(tǒng)的外部時(shí)鐘為12MHz

          160static void __init smdk2440_map_io(void)

          161{

          162s3c24xx_init_io(smdk2440_iodesc,ARRAY_SIZE(smdk2440_iodesc));

          163//s3c24xx_init_clocks(16934400);

          164//edit by

          165 s3c24xx_init_clocks(12000000);

          166s3c24xx_init_uarts(smdk2440_uartcfgs,ARRAY_SIZE(smdk2440_uartcfgs));

          167}

          說明:如果系統(tǒng)時(shí)鐘不匹配,則出現(xiàn)亂碼。

          四、制作或者獲取內(nèi)核配置單.config

          $make menuconfig

          說明:一個(gè)比較好的做法是先調(diào)用自帶的配置清單,該配置清單在arch/arm/configs目錄,文件名為:s3c2410_defconfig,該配置文件幾乎S3C24XX系列CPU的配置項(xiàng),可以在此基礎(chǔ)上修改配置項(xiàng)。x86的配置項(xiàng)在arch/x86/configs目錄下,文件名為:i386_defconfig(32為cpu)。

          cp arch/arm/configs/s3c2410_defconfig .config

          五、修改機(jī)器碼

          【linux內(nèi)核源碼中查看機(jī)器碼相關(guān)文件:】

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

          178 MACHINE_START(S3C2440 , "SMDK2440")

          179/* Maintainer: Ben Dooks */

          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,

          188MACHINE_END

          修改機(jī)器碼,使之與bootloader的機(jī)器碼相同,這里使用的是u-boot,機(jī)器碼為168

          $vim arch/arm/tools/mach-types

          379 s3c2440 ARCH_S3C2440 S3C2440168

          $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_S3C2440168 //這個(gè)沒有找見

          【U-boot中的相關(guān)配置文件】

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

          377 #define MACH_TYPE_S3C2440 168

          總結(jié):首先從linux內(nèi)核源碼中找出機(jī)器類型(如S3C2440 ),其次,根據(jù)u-boot中給出的對(duì)應(yīng)機(jī)器類型的機(jī)器碼(如377 #define MACH_TYPE_S3C2440 168 )修改內(nèi)核機(jī)器碼。流程如下:

          內(nèi)核:

          $vimarch/arm/mach-s3c2440/mach-smdk2440.c

          U-boot:

          $viminclude/asm-arm/mach-types.h

          內(nèi)核:

          $vimarch/arm/tools/mach-types

          說明:如果機(jī)器碼錯(cuò)誤,則系統(tǒng)提示選取平臺(tái),死機(jī)。

          六、編譯鏡像

          $make zImage

          七、板子燒寫

          使用DNW工具將內(nèi)核鏡像燒寫至開發(fā)板中

          八、遇到的問題

          問題:

          Kernel panic - not syncing: Attempted to kill init!

          解決辦法:

          $make menuconfig

          選擇以下兩項(xiàng):

          Kernel Features --->

          [*] Use the ARM EABI to compile the kernel

          [*] Allow old ABI binaries to run with this kernel (EXPERIMENTAL)

          九、NandFlash驅(qū)動(dòng)移植

          linux里面已經(jīng)包含NandFlash驅(qū)動(dòng),只需對(duì)源碼進(jìn)行修改即可。

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

          107 /* NAND parititon from 2.4.18-swl5*/

          108

          109 static struct mtd_partitionsmdk_default_nand_part[] = {

          110#if defined(CONFIG_64MB_NAND )

          111 [0] = {

          112.name = "Board_uboot",

          113.size = 0x00040000,

          114.offset = 0x00000000,

          115},

          116[1] = {

          117.name = "Board_kernel",

          118.size = 0x00200000,

          119.offset= 0x00200000,

          120},

          121[2] = {

          122.name = "Board_yaffs2",

          123.size = 0x03BF8000,

          124.offset = 0x00400000,

          125}

          126#elif defined(CONFIG_128MB_NAND)

          127 [0]={

          128.name ="Board_uboot",

          129.offset =0x00000000,

          130.size =0x00040000,

          131},

          132[1]={

          133.name ="Board_kernel",

          134.offset =0x00200000,

          135.size =0x00200000,

          136},

          137[2]={

          138.name ="Board_yaffs2"

          139.offset =0x00400000,

          140.size =0x07BA0000,

          141}

          142 #elif defined(CONFIG_more_than_256MB_NAND)

          143 [0]={

          144.name ="Board_uboot",

          145.offset =0x00000000,

          146.size =0x00040000,

          147},

          148[1]={

          149.name ="Board_kernel",

          150.offset =0x00200000,

          151.size =0x00200000,

          152},

          153[2]={

          154.name ="Board_yaffs2",

          155.offset =0x00400000,

          156.size =0x0FB80000,

          157}

          158#endif

          159};

          2、$vimdrivers/mtd/nand/Kconfig

          166 choice

          167prompt "Nand Flash Capacity select"

          168depends on MTD

          169help

          170Board Nand Flash Capacity select

          171

          172 config 64MB_NAND

          173 boolean "64MB Nand for Board"

          174depends on MTD

          175help

          176Set 64MB Nand parts

          177

          178 config 128MB_NAND

          179boolean "128MB Nand for Board"

          180depends on MTD

          181help

          182Set 128MB Nand parts

          183

          184 config more_than_256MB_NAND

          185boolean "256MB~1GB Nand for Board"

          186depends on MTD

          187help

          188Set 256MB~1GB Nand parts

          189

          190 endchoice

          注:如果在make menuconfig中選中64MB_NAND,則在.config表現(xiàn)形式如下:

          CONFIG _64MB_NAND=y

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

          這個(gè)過程就是實(shí)現(xiàn)了內(nèi)核的定制,比如新增Nand驅(qū)動(dòng)、或者去除wireless驅(qū)動(dòng)。。。

          十、移植yaffs2文件系統(tǒng)

          1、獲取yaffs2源碼

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

          www.aleph1.co.uk/home/aleph1/git/yaffs2

          2、在內(nèi)核中添加對(duì)yaffs2的支持

          在剛下載的yaffs2源碼中,執(zhí)行:

          ./patch-ker.sh c ../linux-2.6.30.4(兩個(gè)文件夾放一起)

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

          3、在配置單中添加對(duì)yaffs2的支持

          $make menuconfig

          File systems --->

          [*]Miscellaneous filesystems --->

          <*> YAFFS2 file system support

          注意:假如在內(nèi)核中沒有添加對(duì)yaffs2的支持,則出現(xiàn)找不到或者掛載文件系統(tǒng)是失敗的提示:

          Listof all partitions:

          01004096 ram0 (driver?)

          01014096 ram1 (driver?)

          01024096 ram2 (driver?)

          01034096 ram3 (driver?)

          01044096 ram4 (driver?)

          01054096 ram5 (driver?)

          01064096 ram6 (driver?)

          01074096 ram7 (driver?)

          01084096 ram8 (driver?)

          01094096 ram9 (driver?)

          010a 4096 ram10 (driver?)

          010b4096 ram11 (driver?)

          010c 4096 ram12 (driver?)

          010d4096 ram13 (driver?)

          010e4096 ram14 (driver?)

          010f 4096 ram15 (driver?)

          1f00 256 mtdblock0 (driver?)

          1f01 2048 mtdblock1 (driver?)

          1f02 63168 mtdblock2 (driver?)

          Nofilesystem could mount root, tried: ext3 ext2 cramfs msdos vfat romfs

          Kernel panic - not syncing: VFS: Unable tomount root fs on unknown-block(31,2)

          4、yaffs2移植完成,重新編譯內(nèi)核

          十一、在內(nèi)核中添加tmpfs支持

          如果不添加tmpfs支持,那么將會(huì)出現(xiàn)那/tmp掛載失敗的提示。關(guān)于tmpfs的作用待研究。

          mount: mounting tmpfs on /tmp failed: Invalidargume

          文件系統(tǒng)配置:

          [root@ /]#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

          十二遇到的問題及解決方案

          drivers/rtc/hctosys.c:unable to open rtc device (rtc0)

          1. 內(nèi)核配置選項(xiàng)


          --- Real TimeClock
          [*] Set system time from RTC on startup andresume
          (rtc0) RTC used to set the systemtime
          [ ] RTC debugsupport
          *** RTC interfaces***
          [*] /sys/class/rtc/rtcN(sysfs)
          [*] /dev/rtcN (characterdevices)
          [ ] RTC UIE emulation on devinterface
          *** on-CPU RTC drivers***
          <*> Samsung S3Cseries SoC RTC

          2. linux kernel 中 已經(jīng)支持S3C2410的RTC,但是并沒有添加到平臺(tái)設(shè)備初始化數(shù)組中,所以系統(tǒng)啟動(dòng)時(shí)并不會(huì)初始化這一部分,需要修改文件mach-smdk.c

          static struct platform_device*smdk2410_devices[] __initdata = {
          &s3c_device_ohci,
          &s3c_device_lcd,
          &s3c_device_wdt,
          &s3c_device_i2c0,
          &s3c_device_iis,
          &s3c_device_rtc, //新增代碼
          };

          3. 創(chuàng)建設(shè)備節(jié)點(diǎn),在文件系統(tǒng)/dev目錄下執(zhí)行:

          sudo mknod rtc c 10 135

          4. 重新編譯內(nèi)核,查看啟動(dòng)信息

          s3c2410-rtcs3c2410-rtc: rtc disabled,re-enabling

          s3c2410-rtcs3c2410-rtc: rtc core:registered s3c asrtc0

          這里說明rtc驅(qū)動(dòng)起來可以正常工作了

          uncorrectable error :<3>end_request: I/O error, dev mtdblock2, sector 2

          EXT3-fs: unable to readsuperblock

          uncorrectable error :<3>end_request: I/O error, dev mtdblock2, sector 2

          EXT2-fs: unable to readsuperblock

          uncorrectable error :<3>end_request: I/O error, dev mtdblock2, sector 0

          Buffer I/O error ondevice mtdblock2, logical block 0

          uncorrectable error :<3>end_request: I/O error, dev mtdblock2, sector 0

          Buffer I/O error ondevice mtdblock2, logical block 0

          uncorrectable error :<3>end_request: I/O error, dev mtdblock2, sector 8

          Buffer I/O error ondevice mtdblock2, logical block 1

          uncorrectable error :<3>end_request: I/O error, dev mtdblock2, sector 8

          Buffer I/O error ondevice mtdblock2, logical block 1

          uncorrectable error :<3>end_request: I/O error, dev mtdblock2, sector 16

          Buffer I/O error ondevice mtdblock2, logical block 2

          uncorrectable error :<3>end_request: I/O error, dev mtdblock2, sector 16

          Buffer I/O error ondevice mtdblock2, logical block 2

          uncorrectable error :<3>end_request: I/O error, dev mtdblock2, sector 24

          Buffer I/O error ondevice mtdblock2, logical block 3

          uncorrectable error :<3>end_request: I/O error, dev mtdblock2, sector 24

          Buffer I/O error ondevice mtdblock2, logical block 3

          uncorrectable error :<3>end_request: I/O error, dev mtdblock2, sector 0

          FAT: unable to read bootsector

          VFS: Cannot open rootdevice "mtdblock2" or unknown-block(31,2)

          Please append a correct"root=" boot option; here are the available partitions:

          1f00 256 mtdblock0 (driver?)

          1f01 2048 mtdblock1 (driver?)

          1f02 257536 mtdblock2 (driver?)

          Kernel panic - notsyncing: VFS: Unable to mount root fs on unknown-block(31,2)

          MTD分區(qū)與bootloader不匹配

          #elif defined(CONFIG_more_than_256MB_NAND)

          [0]= {

          .name = "Board_uboot",

          .offset = 0x00000000,

          .size = 0x00080000,

          },

          [1]= {

          .name = "Board_kernel",

          .offset= 0x00240000,

          .size = 0x00200000,

          },

          [2]= {

          .name = "Board_yaffs2",

          .offset= 0x00440000,

          .size = 0x0FB40000,

          }

          **************************************************************************************************************************************************************

          [0]和[1]分區(qū)不連貫的表面原因 中間的部分存放uboot的參數(shù)以及開機(jī)畫面???環(huán)境變量

          uboot分區(qū)信息:

          0x0 到0x40000為uboot的分區(qū),256K,
          0x40000到0x4c000 為parameters分區(qū),48K,
          0x50000到0x70000 為eboot分區(qū),128K,
          0x70000到0x1F0000為logo分區(qū),1536K,
          0x1F0000 到0x3F0000為kernel分區(qū),2M,
          0x3F0000 到0x3FF8000 為root分區(qū),60.03125M


          nand分區(qū)信息:

          static struct mtd_partition smdk_default_nand_part[] = {
          [0] = {
          .name = "TQ2440_uboot",
          .size = 0x00040000,
          .offset = 0x00000000,
          },
          [1] = {
          .name = "TQ2440_kernel",
          .offset = 0x0004C000,
          .size = 0x00200000,
          },
          [2] = {
          .name = "TQ2440_yaffs2",
          .offset = 0x0024C000,
          .size = 0x03DB0000,
          }
          };

          uboot的分區(qū)和文件系統(tǒng)的分區(qū),沒有聯(lián)系的。唯一的聯(lián)系就是uboot引導(dǎo)啟動(dòng)的時(shí)候,命令要根據(jù)文件系統(tǒng)的分區(qū)信息來引導(dǎo)。比如要從mtdblock2啟動(dòng),那么bootcmd中的命令bootm0xXXXXXXX就要和mtdblock2的首地址一樣。。。。



          評(píng)論


          相關(guān)推薦

          技術(shù)專區(qū)

          關(guān)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();