#嵌入式Linux最小系統移植# mini2440內核4.0.8移植記錄



/*移植內核Linux4.0.8*/

1.機器碼匹配(linux/arch/arm/tools/mach-types)
# machine_is_xxx    CONFIG_xxxx         MACH_TYPE_xxx           number
        mini2440            MACH_MINI2440           MINI2440                 1999
        oluan2440           MACH_OLUAN2440      OLUAN2440                1999

    MACH_TYPE_xxx 與MACHINE_START中匹配 
    CONFIG_xxxx     與linux/arch/arm/mach-s3c2440中的Kconfig、Makefile匹配

2.修改:MACHINE_START(S3C2440, "SMDK2440")
    爲:  MACHINE_START(OLUAN, "Hello Hulin oluan!")

3.修改晶振頻率:
s3c2440_init_clocks(12000000); //友善之臂開發板晶振頻率爲12MHz

4.修改Makefile和Kconfig
修改Kconfig,添加
config MACH_OLUAN2440
    bool "OLUAN2440 Test Hello xiaozeng"
    select EEPROM_AT24 if I2C
    select LEDS_CLASS
    select LEDS_TRIGGERS
    select LEDS_TRIGGER_BACKLIGHT
    select NEW_LEDS
    select S3C_DEV_NAND
    select S3C_DEV_USB_HOST
    select S3C_SETUP_CAMIF
    help
      Say Y here to select support for the MINI2440. Is a 10cm x 10cm board
      available via various sources. It can come with a 3.5" or 7" touch LCD.


5.make mini2440_defconfig

6.make menuconfig
配置system type

7.make zImage
移植出錯:“MACH_TYPE_OLUAN”  undeclared here (not in a function) 
解決:     MACHINE_START(OLUAN, "Hello Hulin oluan!")寫錯
                    該寫爲          (OLUAN2440, "Hello Hulin oluan!") 

再次make zImage

(等待較長時間...)

Kernel: arch/arm/boot/zImage is ready  大小:2.8 MB 

8.將zImage燒入開發板,錯誤:no os found
    將fs_mini一併燒入開發板,錯誤:串口信息停止在Load Kernel...

9.在移植內核中修改Nand Flash分區表

/*下面開始分析smdk2440_machine_init(void)*/

1.添加

2.make menuconfig

3.make zImage
編譯錯誤:undefined reference to 'smdk_machine_init'
解決:     註釋:
                    //smdk_machine_init()
                    自己添加相關函數:
                    s3c_nand_set_platdata(&oluan2440_nand_info);
                    platform_add_devices(oluan_devices, ARRAY_SIZE(oluan_devices));

編譯錯誤:arch/arm/mach-s3c24xx/mach-oluan2440.c:214: error: array type has incomplete element type
                    arch/arm/mach-s3c24xx/mach-oluan2440.c:215: error: array index in non-array initializer
解決:     添加頭文件:      
                    #include <linux/mtd/partitions.h>
                    #include <linux/platform_data/mtd-nand-s3c2410.h>               

4.Kernel: arch/arm/boot/zImage is ready  大小:2.8 MB 

5.將fs_mini一併燒入開發板,錯誤仍然爲:串口信息停止在Load Kernel...


/*換了開源的uboot
E:\嵌入式Linux\【申嵌培訓】u-boot移植與開發班
\【申嵌培訓】u-boot實戰移植篇\src\u-boot-2010.03-embedclub-menu\u-boot-2010.03
*/
1.make uImage
編譯錯誤:"mkimage" command not found - U-Boot images will not be built
解決:     mkimage
                    bash: mkimage: 未找到命令...
                    安裝軟件包“uboot-tools”以提供命令“mkimage”? [N/y] y

2.make uImage
Image Name:   Linux-4.0.8
Created:      Mon Dec  5 02:38:32 2016
Image Type:   ARM Linux Kernel Image (uncompressed)
Data Size:    2772696 Bytes = 2707.71 kB = 2.64 MB
Load Address: 30008000
Entry Point:  30008000
Image arch/arm/boot/uImage is ready

3.把uImage(linux4.0.8)燒入開發板

[u-boot@SMDK2440A]# bootm
## Booting kernel from Legacy Image at 30008000 ...
   Image Name:   Linux-4.0.8
   Created:      2016-12-04  18:38:32 UTC
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    2772696 Bytes =  2.6 MB
   Load Address: 30008000
   Entry Point:  30008000
   Verifying Checksum ... OK
   XIP Kernel Image ... OK
OK

Starting kernel ...

data abort
pc : [<30008008>]          lr : [<33fa6cac>]
sp : 33f3d64c  ip : 00000000     fp : 30008000
r10: 33fc4008  r9 : 000007cf     r8 : 33f3ffe0
r7 : 33f3ffc4  r6 : 33f412ad     r5 : 30000100  r4 : 00000000
r3 : 00000000  r2 : 30000100     r1 : 000007cf  r0 : 00000000
Flags: nzCv  IRQs off  FIQs off  Mode SVC_32
Resetting CPU ...

resetting ...

解決:手動法:http://blog.csdn.net/zgrjkflmkyc/article/details/8975750
            自動法:http://blog.chinaunix.net/uid-28382924-id-3421282.html


4.內核正常啓動信息:
## Booting kernel from Legacy Image at 30008000 ...
   Image Name:   Linux kernel www.embedclub.com
   Created:      2011-08-17   6:24:43 UTC
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    2266616 Bytes =  2.2 MB
   Load Address: 30008000
   Entry Point:  30008040
   Verifying Checksum ... OK
   XIP Kernel Image ... OK
OK

Starting kernel ...

Uncompressing Linux.....................................................
.............................................. done, booting the kernel.


5.出錯: Starting kernel ...   之後串口輸出全是亂碼
    解決: 修改串口波特率
                 set bootargs noinitrd root=/dev/mtdblock3 rootfstype=yaffs2 init=/linuxrc console=ttySAC0,115200
                 save

    出錯: ftl_cs: FTL header not found的解決辦法
    解決: http://blog.chinaunix.net/uid-20665047-id-3451562.html

    出錯: 企鵝圖標沒有

6.

掛載root時候出錯:
end_request: I/O error, dev mtdblock3, sector 0
Buffer I/O error on device mtdblock3, logical block 0
end_request: I/O error, dev mtdblock3, sector 0
Buffer I/O error on device mtdblock3, logical block 0
end_request: I/O error, dev mtdblock3, sector 8

解決:Kernel command line: 出錯
 bootargs noinitrd  root=/dev/mtdblock4 rootfstype=yaffs2 init=/linuxrc console=ttySAC0,115200
少了rootfstype 
在uboot下
     set bootargs noinitrd root=/dev/mtdblock3 rootfstype=yaffs2 init=/linuxrc console=ttySAC0,115200;save


7.  燒寫內核: nand erase 0x60000 0x500000; nand write 0x30008000 0x60000 0x500000
        燒寫root: nand erase 0x560000 $filesize; nand write.yaffs 0x30008000 0x560000 $filesize   

出錯:VFS: Cannot open root device "mtdblock3" or unknown-block(31,3): error -19
            Please append a correct "root=" boot option; here are the available partitions: 
解決:給內核打上yaffs2補丁

8.打yaffs2補丁

# git clone git://www.aleph1.co.uk/yaffs2           
# cd yaffs2/
# ./patch-ker.sh c /home/invoker/akernel4.0/linux-4.0.8
# make menuconfig 將添加yaffs2至內核
# make uImage

出錯:In function 'yaffs_readpage_nolock':   //http://www.2cto.com/kf/201608/533812.html
            struct file has no member named 'f_dentry'
解決:在yaffs_vfs.c中添加:
            #define f_dentry f_path.dentry
            #define f_vfsmnt f_path.mnt

出錯:fs/yaffs2/yaffs_endian.h:31: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'swap_loff_t'
解決:在yaffs_endian.h中添加:
            #ifndef Y_LOFF_T
            #define Y_LOFF_T loff_t               
            #endif

出錯:conflicting types for 'nval_del'
解決:error: conflicting types for ‘nval_del’,查看nval_del幾個函數,這裏我看不出有什麼類型衝突錯誤,
            網上搜了下主要是第一個WARNING那裏引起的. 
            在yaffs_nameval.h中,結構體struct yaffs_dev的定義出現在參數列表中,
            而在此之前沒有定義,這樣會導致函數不識別這個結構體引發上面的錯誤,
            查詢了下struct yaffs_dev在”yaffs_guts.h”中被定義,
            因此在yaffs_nameval.h文件中include下”yaffs_guts.h”就OK了

出錯:yaffs_guts.c:line: undefined reference to function           
解決:在Makefile下面添加:yaffs-y += yaffs_endian.o 

9.  make uImage
        燒寫內核: nand erase 0x60000 0x500000; nand write 0x30008000 0x60000 0x500000
        燒寫root: usbslave 1 0x30008000;nand erase 0x560000 $filesize; nand write.yaffs 0x30008000 0x560000 $filesize

10. 成功加載yaffs2根文件系統
        Please press Enter to activate this console. 
        starting pid 768, tty '/dev/ttySAC0': '/bin/sh'

11. 燒寫自己製作的first_fs.yaffs2後
出錯:Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000004
解決:kernel 編譯的時候,沒有選中 EABI 選項    

12.make menuconfig 
     選中EABI
     make uImage
     燒入開發板後,啓動...    
        Please press Enter to activate this console


出錯:編譯linux4.0.8 mach-mini2440時遇到no machine record defined錯誤的解決方法 
解決:http://blog.chinaunix.net/uid-21868349-id-1813595.html


static void __init smdk2440_machine_init(void)
{
    s3c24xx_fb_set_platdata(&smdk2440_fb_info);
    s3c_i2c0_set_platdata(NULL);

    platform_add_devices(smdk2440_devices, ARRAY_SIZE(smdk2440_devices));
    smdk_machine_init();
}

smdk_machine_init(linux/arch/arm/mach-s3c244xx/common-smdk.c)

void __init smdk_machine_init(void)
{
    /* Configure the LEDs (even if we have no LED support)*/

    int ret = gpio_request_array(smdk_led_gpios,
                     ARRAY_SIZE(smdk_led_gpios));
    if (!WARN_ON(ret < 0))
        gpio_free_array(smdk_led_gpios, ARRAY_SIZE(smdk_led_gpios));

    if (machine_is_smdk2443())
        smdk_nand_info.twrph0 = 50;

    s3c_nand_set_platdata(&smdk_nand_info);

    platform_add_devices(smdk_devs, ARRAY_SIZE(smdk_devs));

    s3c_pm_init();
}



static struct platform_device *smdk2440_devices[] __initdata = {
    &s3c_device_ohci,
    &s3c_device_lcd,
    &s3c_device_wdt,
    &s3c_device_i2c0,
    &s3c_device_iis,
};





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