新聞中心

        EEPW首頁 > 嵌入式系統 > 設計應用 > linux-2.6.14移植到S3C2440

        linux-2.6.14移植到S3C2440

        作者: 時間:2016-11-22 來源:網絡 收藏
        現在應該很少使用2.6.14的內核了,但由于項目需要,最近移植了2.6.版本的內核到S3C2440上,并移植了CS8900網卡驅動(網卡驅動移植參考http://blog.csdn.net/ce123/article/details/8424399)。之所以移植網卡驅動,是因為yaffs2格式的文件系統一直掛載不成功,啟動后的錯誤信息如下:
        Mounted devfs on /dev
        Freeing init memory: 92K
        Failed to execute /linuxrc. Attempting defaults...
        Kernel panic - not syncing: No init found. Try passing init= option to kernel.
        這個問題只能先放一下,最后成功掛載nfs。yaffs2格式文件系統的問題以后再深入研究。整理一下最近做過的東西,怕遺忘了。

        1.頂層Makefile的修改

        [plain]view plaincopy
        print?
        1. ARCH?=arm
        2. CROSS_COMPILE?=arm-linux-
        交叉編譯器的使用請參考http://blog.csdn.net/ce123/article/details/8333421

        2.修改時鐘頻率

        linux/arch/arm/mach-s3c2410/mach-smdk2440.c
        [plain]view plaincopy
        print?
        1. staticvoid__initsmdk2440_map_io(void)
        2. {
        3. s3c24xx_init_io(smdk2440_iodesc,ARRAY_SIZE(smdk2440_iodesc));
        4. s3c24xx_init_clocks(12000000);//12M
        5. s3c24xx_init_uarts(smdk2440_uartcfgs,ARRAY_SIZE(smdk2440_uartcfgs));
        6. s3c24xx_set_board(&smdk2440_board);
        7. }

        3.修改機器ID

        linux/arch/arm/tools/mach-types
        s3c2440 ARCH_S3C2440 S3C2440 168
        這個值要和uboot中的值對應起來,在uboot的arch/arm/tools/mach-types中有如下定義:
        #define MACH_TYPE_S3C2440 168
        這兩個值一樣即可。

        4.設置Nand Flash分區

        4.1建立Nand Flash分區表

        在linux/arch/arm/mach-s3c2410/devs.c中增加
        [plain]view plaincopy
        print?
        1. #include
        2. #include
        3. #include
        4. /*NANDparititon*/
        5. staticstructmtd_partitionsmdk_default_nand_part[]={
        6. [0]={
        7. .name="Board_uboot",
        8. .offset=0x00000000,
        9. .size=0x00080000,
        10. },
        11. [1]={
        12. .name="Board_kernel",
        13. .offset=0x00240000,
        14. .size=0x00200000,
        15. },
        16. [2]={
        17. .name="Board_yaffs2",
        18. .offset=0x00440000,
        19. .size=0x0FB40000,
        20. }
        21. };
        name:代表分區名字
        size:代表flash分區大小(單位:字節)
        offset:代表flash分區的起始地址(相對于0x0的偏移)
        劃分3個區,分別存放uboot, kernel和文件系統。

        4.2.加入Nand Flash分區

        [plain]view plaincopy
        print?
        1. staticstructs3c2410_nand_setsmdk_nand_sets[]={
        2. [0]={
        3. .name="NAND",
        4. .nr_chips=1,
        5. .nr_partitions=ARRAY_SIZE(smdk_default_nand_part),
        6. .partitions=smdk_default_nand_part,
        7. },
        8. };
        nr_partitions: 指明partition_info中定義的分區數目
        partitions:分區信息表

        4.3.建立Nand Flash芯片支持

        [plain]view plaincopy
        print?
        1. staticstructs3c2410_platform_nandsmdk_nand_info={
        2. .tacls=20,
        3. .twrph0=60,
        4. .twrph1=20,
        5. .nr_sets=ARRAY_SIZE(smdk_nand_sets),
        6. .sets=smdk_nand_sets,
        7. };
        tacls,twrph0,twrph1的意思見S3C2440的數據手冊,這3個值最后會被設置到NFCONF中。
        sets:支持的分區集
        nr_set:分區集的個數

        4.4.加入Nand Flash芯片支持到Nand Flash驅動

        [plain]view plaincopy
        print?
        1. structplatform_devices3c_device_nand={
        2. .name="s3c2410-nand",
        3. .id=-1,
        4. .num_resources=ARRAY_SIZE(s3c_nand_resource),
        5. .resource=s3c_nand_resource,
        6. .dev={
        7. .platform_data=&smdk_nand_info
        8. }
        9. };
        name:設備名稱
        id:有效設備編號,如果只有唯一的一個設備為-1,有多個設備從0開始計數.
        num_resource:有幾個寄存器區
        resource:寄存器區數組首地址
        dev:支持的Nand Flash設備

        4.5指定啟動時初始化

        linux/arch/arm/mach-s3c2410/mach-smdk2440.c
        [plain]view plaincopy
        print?
        1. staticstructplatform_device*smdk2440_devices[]__initdata={
        2. &s3c_device_usb,
        3. &s3c_device_lcd,
        4. &s3c_device_wdt,
        5. &s3c_device_i2c,
        6. &s3c_device_iis,
        7. &s3c_device_nand,//增加
        8. };

        5.禁止Flash ECC校驗

        修改drivers/mtd/nand/s3c2410.c 文件s3c2410_nand_init_chip()函數,在該函數體最后加上一條語句:
        [plain]view plaincopy
        print?
        1. chip->eccmode=NAND_ECC_NONE;

        6.支持devfs

        在2.6.14中已經不支持devfs了,內核配置文件中已經沒有了相關的配置選擇,但其代碼還保留了。修改fs/Kconfig文件找到menu "Pseudo filesystems"添加如下語句:
        [plain]view plaincopy
        print?
        1. configDEVFS_FS
        2. bool"/devfilesystemsupport(OBSOLETE)"
        3. dependsonEXPERIMENTAL
        4. help
        5. Thisissupportfordevfs,avirtualfilesystem(like/proc)which
        6. providesthefilesysteminterfacetodevicedrivers,normallyfound
        7. in/dev.Devfsdoesnotdependonmajorandminornumber
        8. allocations.Devicedriversregisterentriesin/devwhichthen
        9. appearautomatically,whichmeansthatthesystemadministratordoes
        10. nothavetocreatecharacterandblockspecialdevicefilesinthe
        11. /devdirectoryusingthemknodcommand(orMAKEDEVscript)anymore.
        12. Thisisworkinprogress.Ifyouwanttousethis,you*must*read
        13. thematerialin,especially
        14. thefileREADMEthere.
        15. Notethatdevfsnolongermanages/dev/pts!IfyouareusingUNIX98
        16. ptys,youwillalsoneedtomountthe/dev/ptsfilesystem(devpts).
        17. Notethatdevfshasbeenobsoletedbyudev,
        18. .
        19. Ithasbeenstrippeddowntoabareminimumandisonlyprovidedfor
        20. legacyinstallationsthatuseitsnamingschemewhichis
        21. unfortunatelydifferentfromthenamesnormalLinuxinstallations
        22. use.
        23. Ifunsure,sayN.
        24. configDEVFS_MOUNT
        25. bool"Automaticallymountatboot"
        26. dependsonDEVFS_FS
        27. help
        28. ThisoptionappearsifyouhaveCONFIG_DEVFS_FSenabled.Setting
        29. thistoYwillmakethekernelautomaticallymountdevfsonto/dev
        30. whenthesystemisbooted,beforetheinitthreadisstarted.
        31. Youcanoverridethiswiththe"devfs=nomount"bootoption.
        32. Ifunsure,sayN.
        33. configDEVFS_DEBUG
        34. bool"Debugdevfs"
        35. dependsonDEVFS_FS
        36. help
        37. IfyousayYhere,thenthe/devfilesystemcodewillgenerate
        38. debuggingmessages.Seethefile
        39. formore
        40. details.
        41. Ifunsure,sayN.
        42. configDEVPTS_FS_XATTR
        43. bool"/dev/ptsExtendedAttributes"
        44. dependsonUNIX98_PTYS
        45. help
        46. Extendedattributesarename:valuepairsassociatedwithinodesby
        47. thekernelorbyusers(seetheattr(5)manualpage,orvisit
        48. fordetails).
        49. Ifunsure,sayN.
        50. configDEVPTS_FS_SECURITY
        51. bool"/dev/ptsSecurityLabels"
        52. dependsonDEVPTS_FS_XATTR
        53. help
        54. Securitylabelssupportalternativeaccesscontrolmodels
        55. implementedbysecuritymoduleslikeSELinux.Thisoption
        56. enablesanextendedattributehandlerforfilesecurity
        57. labelsinthe/dev/ptsfilesystem.
        58. Ifyouarenotusingasecuritymodulethatrequiresusing
        59. extendedattributesforfilesecuritylabels,sayN.
        60. configTMPFS
        61. bool"Virtualmemoryfilesystemsupport(formershmfs)"
        62. help
        63. Tmpfsisafilesystemwhichkeepsallfilesinvirtualmemory.
        64. Everythingintmpfsistemporaryinthesensethatnofileswillbe
        65. createdonyourharddrive.Thefilesliveinmemoryandswap
        66. space.Ifyouunmountatmpfsinstance,everythingstoredthereinis
        67. lost.
        68. Seefordetails.

        7.內核裁剪

        7.1內核配置文件

        將arch/arm/configs/s3c2410_defconfig .config拷到內核目錄樹根下:
        cp arch/arm/configs/s3c2410_defconfig .config
        make menuconfig 將s3c2410_defconfig 導入,在s3c2410_defconfig基礎上,裁剪內核。

        7.2內核選項

        Loadable module support >
        [*] Enable loadable module support
        [*] Automatic kernel module loading

        System Type >
        [*] S3C2410 DMA support

        Floating point emulation >
        [*] NWFPE math emulation

        接下來要做的是對內核MTD子系統的設置

        Device Drivers >
        Memory Technology Devices (MTD) >
        [*] MTD partitioning support /*支持MTD分區,這樣我們在前面設置的分區才有意義*/
        [*] Command line partition table parsing /*支持從命令行設置flash分區信息,靈活*/
        RAM/ROM/Flash chip drivers >
        <*> Detect flash chips by Common Flash Interface (CFI) probe
        <*> Detect nonCFI AMD/JEDECcompatible flash chips
        <*> Support for Intel/Sharp flash chips
        <*> Support for AMD/Fujitsu flash chips
        <*> Support for ROM chips in bus mapping
        NAND Flash Device Drivers >
        <*> NAND Device Support
        <*> NAND Flash support for S3C2410/S3C2440 SoC
        Character devices >
        [*] Nonstandard serial port support
        [*] S3C2410 RTC Driver

        接下來做的是針對文件系統的設置

        File systems >
        <> Second extended fs support #去除對ext2的支持
        Pseudo filesystems >
        [*] /proc file system support
        [*] Virtual memory file system support (former shm fs)
        [*] /dev file system support (OBSOLETE)
        [*] Automatically mount at boot (NEW)
        這里會看到我們前先修改fs/Kconfig的成果,devfs已經被支持上了
        Miscellaneous filesystems >
        Network File Systems >
        <*> NFS file system support

        7.3編譯

        make即可。

        8.總結

        以前將linux-2.6.30.4移植S3C2440(http://blog.csdn.net/ce123/article/details/6581248),基本過程很相似。照著這個過程一般都能移植好一個內核,但明白這個過程背后的東西才是王道。


        評論


        相關推薦

        技術專區

        關閉
        主站蜘蛛池模板: 巴塘县| 乐陵市| 乡宁县| 普安县| 武鸣县| 长武县| 临武县| 河津市| 云梦县| 区。| 盐山县| 正镶白旗| 沛县| 宁德市| 寻乌县| 普兰县| 奇台县| 兴安盟| 晋城| 安国市| 治多县| 西贡区| 彩票| 泸州市| 宜阳县| 永济市| 昆明市| 绩溪县| 清水河县| 屯昌县| 元氏县| 巫山县| 密云县| 莱阳市| 镇康县| 彰化市| 义乌市| 南安市| 十堰市| 博客| 吴桥县|