硬件平臺:FL2440
主機平臺:Ubuntu 11.04
交叉編譯器:arm-linux-gcc 4.3.2
原創(chuàng)作品,轉(zhuǎn)載請標明出處 http://blog.csdn.net/yming0221/article/details/6604616
本來是想移植最新的內(nèi)核2.6.39但是總是在編譯快完成的時候報錯,有人說是新的內(nèi)核對arm平臺的支持不好,所以就降低了一下版本,這里移植2.6.35.4內(nèi)核
一、準備工作
下載arm-linux-gcc 4.3.2,然后安裝并配置環(huán)境變量
最后執(zhí)行arm-linux-gcc -v查看
二、移植
3 、增加 devfs 文件管理器的支持
我們所用的文件系統(tǒng)使用的是 devfs 文件管理器。修改 fs/Kconfig ,
找到
menu "Pseudo filesystems"
添加如下語句:
config DEVFS_FS
bool "/dev file system support (OBSOLETE)"
default y
config DEVFS_MOUNT
bool "Automatically mount at boot"
default y
depends on DEVFS_FS
幫助理解:Kconfig就是對應(yīng)著內(nèi)核的配置菜單。假如要想添加新的驅(qū)動到內(nèi)核的源碼中,能夠修改Kconfig,
這樣就能夠選擇這個驅(qū)動,假如想使這個驅(qū)動被編譯,要修改Makefile。
4 、修改晶振頻率 ( 可解決打印信息亂碼問題 )
文件: arch/arm/mach-s3c2440/mach-smdk2440.c
/*s3c24xx_init_clocks(16934400);*/s3c24xx_init_clocks(12000000);
5 、修改 MTD 分區(qū)
static struct mtd_partition smdk_default_nand_part[] = { [0] = { .name = "Boot", .size = 0x00100000, .offset = 0 }, [1] = { .name = "MyApp", .size = 0x003c0000, .offset = 0x00140000, }, [2] = { .name = "Kernel", .size = 0x00300000, .offset = 0x00500000, }, [3] = { .name = "fs_yaffs", .size = 0x0f000000, //240M .offset = 0x00800000, }, /*[4] = { .name = "WINCE", .size = 0x03c00000, .offset = 0x04400000, } */ };
具體參考 http://blog.csdn.net/yming0221/article/details/6566551
6 、關(guān)閉 ECC 校驗
文件:
drivers/mtd/nand/s3c2410.c
函數(shù):
s3c2410_nand_init_chip
/*chip->ecc.mode = NAND_ECC_SOFT; */chip->ecc.mode = NAND_ECC_NONE;
問題:關(guān)于ECC:ECC是“Error Correcting Code”的簡寫,中文名稱是“錯誤檢查和糾正”。ECC是一種能夠?qū)崿F(xiàn)
“錯誤檢查和糾正”的技術(shù),ECC內(nèi)存就是應(yīng)用了這種技術(shù)的內(nèi)存,一般多應(yīng)用在服務(wù)器及圖形工作站上,這將使整個
電腦系統(tǒng)在工作時更趨于安全穩(wěn)定。此處為避免容易出錯,將ECC關(guān)閉。
7 、修改 nandflash 驅(qū)動,支持 K9F1G08 的 nandflash
修改drivers/mtd/nand 下面的 nand_bbt.c 文件:
static struct nand_bbt_descr largepage_memorybased = { .options = 0, .offs = 0, .len = 1, // 原數(shù)值為2,支持2K每頁的flash修改為1。K9F1G08,K9F2G08是2k每頁的flash .pattern = scan_ff_pattern }; static struct nand_bbt_descr largepage_flashbased = { .options = NAND_BBT_SCAN2NDPAGE, .offs = 0, .len = 1, //原數(shù)值為2,支持2K每頁的flash修改為1。K9F1G08,K9F2G08是2k每頁的flash .pattern = scan_ff_pattern };
8 、下面,開始配置內(nèi)核。
進入 linux-2.6.35 目錄,把 s3c2410 的默認配置寫入 config 文件。
make s3c2410_defconfig
make menuconfig
配置內(nèi)核特點使用ARM EABI編譯
配置文件系統(tǒng)選項
配置
yaffs2
文件系統(tǒng)
修改配置如下:
File systems --->
[*] Miscellaneous filesystems --->
<*> YAFFS2 file system support
-*- 512 byte / page devices
-*- 2048 byte (or larger) / page devices
[*] Autoselect yaffs2 format
[*] Cache short names in RAM
配置
cpu
相關(guān)選項
修改配置如下:
System Type --->
S3C2440 Machines --->
[*] SMDK2440
[*] SMDK2440 with S3C2440 CPU module
去掉 S3C2400 Machines 、 S3C2410 Machines 、 S3C2412 Machines 、 S3C2442 Machines 的所有選項 ,
否則會報錯。如果現(xiàn)在編譯內(nèi)核,下載到開發(fā)板中,內(nèi)核就可以正常啟動了 . 有了雛形,繼續(xù)移植設(shè)備驅(qū)動。
這里,內(nèi)核選項 * 代表編譯至內(nèi)核, M 代表編譯為模塊 。
9 、移植 USB host 驅(qū)動
在這個版本的 linux 內(nèi)核,已經(jīng)對 USB 驅(qū)動進行來很好的支持,僅僅需要修改配置。
Device Drivers --->
[*] USB support --->
{*} Support for Host-side USB
[*] USB device filesystem (DEPRECATED)
[*] USB device class-devices (DEPRECATED)
<*> OHCI HCD support
<*> USB Mass Storage support
[*] HID Devices --->
{*} Generic HID support
[*] /dev/hidraw raw HID device support
SCSI device support --->
<*> SCSI device support
[*] legacy /proc/scsi/ support
<*> SCSI disk support
<*> SCSI tape support
10 、移植 RTC 驅(qū)動
在這個版本的 linux 內(nèi)核,已經(jīng)對 RTC 驅(qū)動進行來很好的支持,不需要修改配置。相應(yīng)配置如下
Device Drivers --->
<*> Real Time Clock --->
[*] Set system time from RTC on startup and resume
(rtc0) RTC used to set the system time
[ ] RTC debug support
*** RTC interfaces ***
[*] /sys/class/rtc/rtcN (sysfs)
[*] /proc/driver/rtc (procfs for rtc0)
[*] /dev/rtcN (character devices)
<*> Samsung S3C series SoC RTC
然后添加對設(shè)備的支持
打開
arch/arm/mach-s3c2440/mach-smdk2440.c
,添加設(shè)備,代碼如下:
static struct platform_device *smdk2440_devices[] __initdata = { &s3c_device_ohci, &s3c_device_lcd, &s3c_device_wdt, &s3c_device_i2c0, &s3c_device_iis, &s3c_device_rtc, };
11 、移植 UDA1341 驅(qū)動
在平臺上添加和配置 UDA1341:
修改 arch/arm/mach-s3c2440/mach-smdk2440.c ,在開始添加頭文件
#include <sound/s3c24xx_uda134x.h>
#include <mach/gpio-fns.h>
static struct s3c24xx_uda134x_platform_data s3c24xx_uda134x_data = { .l3_clk = S3C2410_GPB(4), .l3_data = S3C2410_GPB(3), .l3_mode = S3C2410_GPB(2), .model = UDA134X_UDA1341, }; static struct platform_device s3c24xx_uda134x = { .name = "s3c24xx_uda134x", .dev = { .platform_data = &s3c24xx_uda134x_data, } };
把設(shè)備添加到平臺當中
static struct platform_device *smdk2440_devices[] __initdata = { &s3c_device_ohci, &s3c_device_lcd, &s3c_device_wdt, &s3c_device_i2c0, &s3c_device_iis, &s3c_device_rtc, &s3c24xx_uda134x, };
內(nèi)核配置如下
Device Drivers --->
<*> Sound card support --->
<*> Advanced Linux Sound Architecture --->
<*> OSS Mixer API
<*> OSS PCM (digital audio) API
[*] OSS PCM (digital audio) API - Include plugin system
[*] Support old ALSA API
[*] Verbose procfs contents
[*] Verbose printk
[*] Generic sound devices --->
<*> ALSA for SoC audio support --->
<*> SoC Audio for the Samsung S3C24XX chips
<*> SoC I2S Audio support UDA134X wired to a S3C24XX
12 、移植 DM9000 驅(qū)動
a
、修改
drivers/net/dm9000.c
文件:
頭文件增加:
#include <mach/regs-gpio.h>
#include <mach/irqs.h>
#include <mach/hardware.h>
在 dm9000_probe 函數(shù) 開始增加:
unsigned char ne_def_eth_mac_addr[]={0x00,0x12,0x34,0x56,0x80,0x49}; static void *bwscon; static void *gpfcon; static void *extint0; static void *intmsk; #define BWSCON (0x48000000) #define GPFCON (0x56000050) #define EXTINT0 (0x56000088) #define INTMSK (0x4A000008) bwscon=ioremap_nocache(BWSCON,0x0000004); gpfcon=ioremap_nocache(GPFCON,0x0000004); extint0=ioremap_nocache(EXTINT0,0x0000004); intmsk=ioremap_nocache(INTMSK,0x0000004); writel(readl(bwscon)|0xc0000,bwscon); writel( (readl(gpfcon) & ~(0x3 << 14)) | (0x2 << 14), gpfcon); writel( readl(gpfcon) | (0x1 << 7), gpfcon); // Disable pull-up writel( (readl(extint0) & ~(0xf << 28)) | (0x4 << 28), extint0); //rising edge writel( (readl(intmsk)) & ~0x80, intmsk);
在這個函數(shù)的最后需要修改:
if (!is_valid_ether_addr(ndev->dev_addr)) { /* try reading from mac */ mac_src = "chip"; for (i = 0; i < 6; i++) //ndev->dev_addr[i] = ior(db, i+DM9000_PAR); ndev->dev_addr[i] = ne_def_eth_mac_addr[i]; }
b 、修改 arch/arm/mach-s3c2440/mach-smdk2440.c ,添加設(shè)備
static struct platform_device *smdk2440_devices[] __initdata = { &s3c_device_ohci, &s3c_device_lcd, &s3c_device_wdt, &s3c_device_i2c0, &s3c_device_iis, &s3c_device_rtc, &s3c24xx_uda134x, &s3c_device_dm9000, };
c
、修改
arch/arm/plat-s3c24xx/devs.c
添加頭文件
#include <linux/dm9000.h>
添加以下代碼
static struct resource s3c_dm9000_resource[] = { [0] = { .start = S3C24XX_PA_DM9000, .end = S3C24XX_PA_DM9000+ 0x3, .flags = IORESOURCE_MEM }, [1]={ .start = S3C24XX_PA_DM9000 + 0x4, //CMD pin is A2 .end = S3C24XX_PA_DM9000 + 0x4 + 0x7c, .flags = IORESOURCE_MEM }, [2] = { .start = IRQ_EINT7, .end = IRQ_EINT7, .flags = IORESOURCE_IRQ }, }; static struct dm9000_plat_data s3c_device_dm9000_platdata = { .flags= DM9000_PLATF_16BITONLY, }; struct platform_device s3c_device_dm9000 = { .name= "dm9000", .id= 0, .num_resources= ARRAY_SIZE(s3c_dm9000_resource), .resource= s3c_dm9000_resource, .dev= { .platform_data = &s3c_device_dm9000_platdata, } }; EXPORT_SYMBOL(s3c_device_dm9000);
d 、修改 arch/arm/plat-samsung/include/plat/devs.h 45 行附近 , 添加
extern struct platform_device s3c_device_dm9000;
e 、修改 arch/arm/mach-s3c2410/include/mach/map.h 文件
/* DM9000 */
#define S3C24XX_PA_DM9000 0x20000300
#define S3C24XX_VA_DM9000 0xE0000000
13 、啟動畫面顯示小企鵝的方法
配置內(nèi)核 ,下面是必選項
Device Drivers--->
Graphics support --->
<*> Support for frame buffer devices
<*> S3C2410 LCD framebuffer support ,multi support!
Console display driver support --->
<*> Framebuffer Console support
Logo configuration --->
[*] Bootup logo
[*] Standard 224-color Linux logo
14 、 3.5 寸 LCD 顯示的移植
2.6.34 內(nèi)核中已經(jīng)支持
15 、修改 uart2 為普通串口以及測試程序
修改 arch/arm/mach-s3c2440/mach-smdk2440.c 中的 uart2 的配置,修改后如下:
static struct s3c2410_uartcfg smdk2440_uartcfgs[] __initdata = { [0] = { .hwport = 0, .flags = 0, .ucon = 0x3c5, .ulcon = 0x03, .ufcon = 0x51, }, [1] = { .hwport = 1, .flags = 0, .ucon = 0x3c5, .ulcon = 0x03, .ufcon = 0x51, }, /* IR port */ [2] = { .hwport = 2, .flags = 0, .ucon = 0x3c5, .ulcon = 0x03,/*fatfish 0x43*/ .ufcon = 0x51, } };
在 drivers/serial/samsung.c 中添加對 uart2 控制器的配置,配置為普通串口。
添加頭文件:
#include <linux/gpio.h>
#include <mach/regs-gpio.h>
在 static int s3c24xx_serial_startup(struct uart_port *port) 函數(shù)中,添加
if (port->line == 2) { s3c2410_gpio_cfgpin(S3C2410_GPH(6), S3C2410_GPH6_TXD2); s3c2410_gpio_pullup(S3C2410_GPH(6), 1); s3c2410_gpio_cfgpin(S3C2410_GPH(7), S3C2410_GPH7_RXD2); s3c2410_gpio_pullup(S3C2410_GPH(7), 1); }
16 、移植看門狗
修改配置
Device Drivers --->
[*] Watchdog Timer Support --->
<*> S3C2410 Watchdog
最后:make zImage
最后編譯出來的zImage就2.1M左右。
不過,此時,顯示屏顯示還有點問題,出現(xiàn)上下兩欄。解決方法如下:
修改mach-smdk2440.c中
static struct s3c2410fb_display smdk2440_lcd_cfg __initdata = { /* Config for 320x240 LCD */ .lcdcon5 = S3C2410_LCDCON5_FRM565 | S3C2410_LCDCON5_INVVLINE | S3C2410_LCDCON5_INVVFRAME | S3C2410_LCDCON5_PWREN | S3C2410_LCDCON5_HWSWP, .type = S3C2410_LCDCON1_TFT, .width = 320, .height = 240, .pixclock = 270000, .xres = 320, .yres = 240, .bpp = 16, .left_margin =8, .right_margin = 5, .hsync_len = 63, .upper_margin = 15, .lower_margin = 3, .vsync_len = 5, };
并且將.lpcsel = ((0xCE6) & ~7) | 1<<4,注釋掉
static struct s3c2410fb_mach_info smdk2440_fb_info __initdata = { .displays = &smdk2440_lcd_cfg, .num_displays = 1, .default_display = 0, #if 0 /* currently setup by downloader */ .gpccon = 0xaa940659, .gpccon_mask = 0xffffffff, .gpcup = 0x0000ffff, .gpcup_mask = 0xffffffff, .gpdcon = 0xaa84aaa0, .gpdcon_mask = 0xffffffff, .gpdup = 0x0000faff, .gpdup_mask = 0xffffffff, #endif //.lpcsel = ((0xCE6) & ~7) | 1<<4, };重新編譯即可。
至此,2.6.35.4內(nèi)核移植成功。
更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號聯(lián)系: 360901061
您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對您有幫助就好】元
