linux-2.6.34.1移植到TQ2440
1. 解壓linux-2.6.34.tar.gz源碼包:
? ??源碼下載地址:https://www.kernel.org/pub/linux/kernel/v2.6/
? ?也可以在linux下,輸入命令# wget??https://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.34.1.tar.gz
??? tar zxvf linux-2.6.34.1.tar.gz
? ??編譯內(nèi)核要用uImage命令,如果不支持uImage需要先安裝uImage制作工具:apt-get install uboot-mkimage
2. 進入linux根目錄,修改Makefile文件:
??? $cd linux
??? $vim Makefile
??? 將第191和第192行改為如下配置
??? 191 ARCH??????????? ?= arm
?? ?192 CROSS_COMPILE?? ?=arm-linux-
3. 修改時鐘設(shè)置:
??? $vim arch/arm/mach-s3c2440/mach-smdk2440.c
???? 將第163行改為:
???? 163???????? s3c24xx_init_clocks(12000000);
4.? 修改內(nèi)核的機器碼,該機器碼要與u-boot中的機器碼一致,否則開發(fā)板內(nèi)核無法啟動,u-boot的機器碼存放在u-boot/arch/arm/include/asm/mach-types.h
??????內(nèi)核的機器碼存放在arch/armtool/mach-types文件中。
????? $vim arch/arm/tools/mach-types
5.? 修改nand flash分區(qū)表:
???? $ vim arch/arm/plat-s3c24xx/common-smdk.c
????109 /* NAND parititon from 2.4.18-swl5 */
????110?
??? 111 static struct mtd_partition smdk_default_nand_part[] = {
??? 112???????? [0] = {
??? 113???????????????? .name?? = "u-boot",
??? 114???????????????? .size?? = 0x00040000,
??? 115???????????????? .offset = 0,
??? 116???????? },
??? 117???????? [1] = {
??? 118???????????????? .name?? = "param",
??? 119???????????????? .offset = 0x00040000,
??? 120???????????????? .size?? = 0x00020000,
??? 121???????? },
??? 122???????? [2] = {
??? 123???????????????? .name?? = "kernel",
??? 124???????????????? .offset = 0x00060000,
??? 125???????????????? .size?? = 0x00300000,
??? 126???????? },
??? 127???????? [3] = {
??? 128???????????????? .name?? = "rootfs",
??? 129???????????????? .offset = 0x00360000,
??? 130???????????????? .size?? = 0x0FCA0000,
??? 131???????? },
??? 132 };??
?????修改nand flash 讀寫時序配置。???
????143 /* choose a set of timings which should suit most 512Mbit
????144? * chips and beyond.
????145 */
????146?
??? 147 static struct s3c2410_platform_nand smdk_nand_info = {
??? 148???????? .tacls????????? = 10,
??? 149???????? .twrph0???????? = 25,
??? 150???????? .twrph1???????? = 10,
??? 151???????? .nr_sets??????? = ARRAY_SIZE(smdk_nand_sets),
??? 152???????? .sets?????????? = smdk_nand_sets,
??? 153 }
6. 去掉硬件ECC校驗配置。
???? $ vim drivers/mtd/nand/s3c2410.c
?????822???????????????? chip->ecc.mode????? = NAND_ECC_NONE;
7. 執(zhí)行make s3c2410_defconfig 加載s3c2410的默認配置參數(shù)。
??? $ make s3c2410_defconfig
??? 配置內(nèi)核
??? $make menuconfig
8.?修改Kernel Feature選項,添加對新的編譯工具的支持:
???? Kernel Features? --->
???? [*] Use the ARM EABI to compile the kernel
?????[*]?? Allow old ABI binaries to run with this kernel (EXPERIMENTAL)?
9.添加NAND Flash驅(qū)動:
???? Device Drivers? --->
?????????? <*> Memory Technology Device (MTD) support? --->
?????????????????? <*>?? NAND Device Support? --->
?????????????????????????? <*>?? NAND Flash support for Samsung S3C SoCs
???????????????????????????[ ]???? Samsung S3C NAND driver debug
???????????????????????????[ ]???? Samsung S3C NAND Hardware ECC
10. 編譯內(nèi)核:這里我們把內(nèi)核編譯成uImage的格式,如果系統(tǒng)當(dāng)前工具鏈不支持uImage編譯的話先要安裝uImage編譯工具。
???$sudo apt-get install uboot-mkimage
???$make uImage
?
我的筆記本編譯很慢?,20分鐘左右?
終于編譯完成?
?
uImage就是linux的內(nèi)核,可以直接燒錄到nand flash鏡像文件,路徑在arch/arm/boot?,如下圖
?
? ?此時編譯出的內(nèi)核還并不能啟動文件系統(tǒng),如下:
? ??
?11.? 下載yaffs2源代碼:
????如果系統(tǒng)已經(jīng)安裝git工具,就直接執(zhí)行:
? $ git clone git://www.aleph1.co.uk/yaffs2
12.進入源碼目錄,為內(nèi)核打支持yaffs2的補丁:
????$cd yaffs2
????$???./patch-ker.sh c m ../linux-2.6.35(此處我輸入命令顯示錯誤?)在網(wǎng)上查找好多無解
? 應(yīng)為:
? ?# ?./patch-ker.sh c m /home/book/mylinux/linux-2.6.34.1
應(yīng)在yaffs2目錄內(nèi)?,如圖:
?
?13. 重新配置內(nèi)核,添加yaffs文件系統(tǒng)的支持:
? ? "# cd .."進入linux-2.6.43.1?
???? $make menuconfig
???? File System--->
?????????? [*] Miscellaneous filesystems--->
? ? ? ? ? ? ? ? ??<*>?yaffs2?file?system?support (此處有yaffs2 file system support出現(xiàn)?)?
?
執(zhí)行命令:# make ulmage ?(此處的u"I"mage,"I"不是小寫的L,是大寫的i,第一次我也搞錯了?)
出現(xiàn)如下信息
?
經(jīng)過漫長等待:如下
?
? ? ? 此時可以大功告成了?
linux-2.6.34.1打yaffs2補丁時出錯:bash: ./patch-ker.sh: Permission denied
解決辦法是:在yaffs目錄下進行 chmod? ?777 patch-ker.sh 命令就可以了。
?
?? ? ?重新編譯文件系統(tǒng)后可以正常啟動:
? ? ??
14.添加DM9000網(wǎng)卡的支持:
? ??修改arch/arm/mach-s3c2440/mach-smdk2440.c,構(gòu)建DM9000平臺設(shè)備
#include <linux/dm9000.h>?
#define MACH_TQ2440_DM9K_BASE (S3C2410_CS4 + 0x300)?
/* support DM9000 */?
static struct resource TQ2440_dm9k_resource[] = {?
[0] = {?
.start = MACH_TQ2440_DM9K_BASE,?
.end?= MACH_TQ2440_DM9K_BASE + 3,?
.flags = IORESOURCE_MEM
},?
[1] = {?
.start = MACH_TQ2440_DM9K_BASE + 4,?
.end?= MACH_TQ2440_DM9K_BASE + 7,?
.flags = IORESOURCE_MEM?
},?
[2] = {
.start = IRQ_EINT7,
.end?= IRQ_EINT7,
.flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE
}
};?
/*
* The DM9000 has no eeprom, and set it's MAC address
*/?
static struct dm9000_plat_data TQ2440_dm9k_pdata = {
.flags?= (DM9000_PLATF_16BITONLY | DM9000_PLATF_NO_EEPROM),
.dev_addr?= "\x00\x11\x22\x33\x44\x66",
};?
static struct platform_device TQ2440_device_eth = {
.name?= "dm9000",
.id?= -1,
.num_resources?= ARRAY_SIZE(TQ2440_dm9k_resource),
.resource?= TQ2440_dm9k_resource,?
.dev?= {?
.platform_data?= &TQ2440_dm9k_pdata,
},
};?
smdk2440_devices[]?結(jié)構(gòu)體數(shù)組添加如下代碼
&TQ2440_device_eth
15.修改drivers/net/ethernet/davicom/dm9000.c第44行加入如下代碼
#include "dm9000.h"
#if defined(CONFIG_ARCH_S3C2440)
#include <mach/regs-mem.h>
#endif
第1375行加入如下代碼
u32 id_val;
#if defined(CONFIG_ARCH_S3C2440)
unsigned int oldval_bwscon = *(volatile unsigned int *)S3C2410_BWSCON;
unsigned int oldval_bankcon4? =? *(volatile? unsigned? int *)S3C2410_BANKCON4;
#endif
/* Init network device */
第1387行加入如下代碼
dev_dbg(&pdev->dev, "dm9000_probe()\n");
#if defined(CONFIG_ARCH_S3C2440)
/*?設(shè)置Bank4:總線寬度為16,使能nWAIT */
*((volatile unsigned int *)S3C2410_BWSCON) = (oldval_bwscon & ~(3<<16)) |
S3C2410_BWSCON_DW4_16 | S3C2410_BWSCON_WS4 | S3C2410_BWSCON_ST4;
/*?設(shè)置Bandk4的時間參數(shù)?*/
*((volatile unsigned int *)S3C2410_BANKCON4) = 0x1f7c;
#endif
/* setup board info structure */
第1615行
out:
/*?恢復(fù)寄存器原來的值?*/
#if defined(CONFIG_ARCH_S3C2440)
*(volatile unsigned int *)S3C2410_BWSCON = oldval_bwscon;
*(volatile unsigned int *)S3C2410_BANKCON4 = oldval_bankcon4;
#endif
16.配置內(nèi)核支持DM9000
# make menuconfig
[*] Networking support? --->
Networking options? --->
<*> Packet socket
<*> Unix domain socket
[*] TCP/IP networking
[*]?? IP: multicasting
[*]?? IP: kernel level autoconfiguration
[*]???? IP: BOOTP support
Device Drivers? --->
[*] Network device support? --->
[*]?? Ethernet (10 or 100Mbit)? --->
<*>?? DM9000 support
File systems? --->
[*] Network File Systems (NEW)? --->
<*>?? NFS client support
[*]???? NFS client support for NFS version 3 (NEW)
[*]?????? NFS client support for the NFSv3 ACL protocol extension
[*]?? Root file system on NFS
TQ2440 # save
20130616晚22:51睡覺 ? ? ?,未完待續(xù).................................
總結(jié)
以上是生活随笔為你收集整理的linux-2.6.34.1移植到TQ2440的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: logic pro X 扫不出Waves
- 下一篇: 从王者荣耀看设计模式(虚拟代理模式)