當(dāng)前位置:首頁(yè) > 單片機(jī) > 單片機(jī)
[導(dǎo)讀]硬件設(shè)備:網(wǎng)卡:dm9000NandFlash:K9F1208U0C 64M1, 下載并解壓縮內(nèi)核,修改頂層Makefile的編譯器選項(xiàng):ARCH ?=armCROSS_COMPILE ?=arm-softfloat-linux-gnu-2, 修改linux-2.6.12/arch/arm/mach-s3c2410/devs.c, 使其支持

硬件設(shè)備:網(wǎng)卡:dm9000NandFlash:K9F1208U0C 64M

1, 下載并解壓縮內(nèi)核,修改頂層Makefile的編譯器選項(xiàng):
ARCH ?=arm
CROSS_COMPILE ?=arm-softfloat-linux-gnu-

2, 修改linux-2.6.12/arch/arm/mach-s3c2410/devs.c, 使其支持NandFlash和DM9000網(wǎng)卡:
添加頭文件:
#include //該頭文件將從linux-2.6.14的內(nèi)核中copy到include/linux中去
#include
#include
#include

添加dm9000網(wǎng)卡設(shè)備的支持
EXPORT_SYMBOL(s3c_device_usb);

/* NIC DM9000A64 driver,copy from linux-2.6.14. add by guowenxue 2008.08.15 */
/* My board: nETH_CS接NGCS3, 中斷線(xiàn)IRQ_LAN接EINT9, CMD接A2 */

#ifndef S3C2410_CS3
#define S3C2410_CS3 (0x18000000)
#endif

/* change 0x08000000 to S3C2410_CS3 */
static struct resource s3c_dm9000_resource[] =
{
[0] = {
.start = S3C2410_CS3 + 0x300,
.end = S3C2410_CS3 + 0x300 + 0x03,
.flags = IORESOURCE_MEM
},

[1] = {
.start = S3C2410_CS3 + 0x300 + 0x04,
.end = S3C2410_CS3 + 0x300 + 0x04 + 0x3f, // It's 0x3f, not 0x3
.flags = IORESOURCE_MEM
},

[2] = {
.start = IRQ_EINT9, // My board use EINT9
.end = IRQ_EINT9,
.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= -1,
.num_resources= ARRAY_SIZE(s3c_dm9000_resource),
.resource= s3c_dm9000_resource,
.dev= {
.platform_data = &s3c_device_dm9000_platdata,
}
};

EXPORT_SYMBOL(s3c_device_dm9000);

/**** Add end *****/
/* LCD Controller */


添加NandFlash的支持:
/* NAND Controller */

static struct resource s3c_nand_resource[] = {
[0] = {
.start = S3C2410_PA_NAND,
.end = S3C2410_PA_NAND + S3C24XX_SZ_NAND,
.flags = IORESOURCE_MEM,
}
};


/******* add by guowenxue 2008.10.28 *********/

static struct mtd_partition partition_info[] =
{
{
name: "mtdblock0 uboot 1M", //mtdblock0 1*1M = 1M
size: 0x00100000,
offset: 0,
}, {
name: "mtdblock1 kernel 3M", //mtdblock1 3.1M = 3M
size: 0x00300000,
offset: 0x00100000,
}, {
name: "mtdblock2 rootfs 6M", //mtdblock2 6*1M = 6M
size: 0x00600000,
offset: 0x00400000,
}, {
name: "mtdblock3 apps 27M", //mtdblock3 27*1M = 27M
size: 0x01B00000,
offset: 0x00A00000,
}, {
name: "mtdblock4 user 27M", //mtdblock4 27*1M = 27M
size: 0x01B00000,
offset: 0x02500000,
}
};
struct s3c2410_nand_set nandset =
{
nr_partitions: 5, /* the number of partitions */
partitions: partition_info, /* partition table */
};

struct s3c2410_platform_nand superlpplatform=
{
tacls:0,
twrph0:30,
twrph1:0,
sets: &nandset,
nr_sets: 1,
};

struct platform_device s3c_device_nand =
{
.name = "s3c2410-nand", /* Device name */
.id = -1, /* Device ID */
.num_resources = ARRAY_SIZE(s3c_nand_resource),
.resource = s3c_nand_resource, /* Nand Flash Controller Registers */

/* Add the Nand Flash device */
.dev = {
.platform_data = &superlpplatform
}
};

/****** add end ********/


3, 修改文件linux-2.6.12/arch/arm/mach-s3c2410/devs.h,導(dǎo)出dm9000設(shè)備:
extern struct platform_device s3c_device_sdi;
extern struct platform_device s3c_device_dm9000; //add by guowenxue,2008.11.15

4, 修改文件linux-2.6.12/arch/arm/mach-s3c2410/mach-smdk2410.c, 添加dm9000和nandflash
static struct platform_device *smdk2410_devices[] __initdata = {
&s3c_device_usb,
&s3c_device_lcd,
&s3c_device_wdt,
&s3c_device_i2c,
&s3c_device_iis,
&s3c_device_nand, // this member add by guowenxue 2003.10.28
&s3c_device_dm9000, // this member add by guowenxue 2003.11.15
};

5, 從linux-2.6.14的內(nèi)核中拷貝driver/net/dm9000.c和dm9000.h到相應(yīng)目錄,同時(shí)拷貝
linux-2.6.14/include/linux/dm9000.h到linux-2.6.12的相應(yīng)目錄.修改driver/net/dm9000.c如下:
在文件開(kāi)始處添加:
#define INTMOD (0x4A000004) //These two line add by guowenxue 2008.11.15
static void *intmod;

在static int dm9000_probe(struct device *dev)函數(shù)申明完變量后添加:
intmod=ioremap_nocache(INTMOD,0x0000004);
writel(0x0,intmod);

同樣在該函數(shù)中,注釋掉從ROM中讀MAC地址,改為我們自己設(shè)置的MAC地址:
#if 0 /* Read SROM content */
for (i = 0; i < 64; i++)
((u16 *) db->srom)[i] = read_srom_word(db, i);

/* Set Node Address, the first 6 bytes is the MAC address */
for (i = 0; i < 6; i++)
ndev->dev_addr[i] = db->srom[i];
#endif
添加:
#if 1 // add by guowenxue, set MAC address by myself 2008.11.17
unsigned char def_eth_mac_addr[]={0x22,0x44,0x66,0x88,0x44,0x66};
for(i=0; i<6; i++)
ndev->dev_addr[i] = def_eth_mac_addr[i];
#endif

在函數(shù)static int dm9000_open(struct net_device *dev)中添加set_irq_tye():
set_irq_type(dev->irq, IRQT_RISING); // 申請(qǐng)類(lèi)型為上升沿中斷,否則PC ping不通開(kāi)發(fā)板.
if (request_irq(dev->irq, &dm9000_interrupt, SA_SHIRQ, dev->name, dev))
return -EAGAIN;


6, 修改linux-2.6.12/drivers/serial/s3c2410.c
修改#define S3C24XX_SERIAL_DEVFS “tts/”
為:#define S3C24XX_SERIAL_DEVFS "ttyS"

修改結(jié)構(gòu)體static struct uart_driver s3c24xx_uart_drv的成員.dev_name為:
// .dev_name = "s3c2410_serial",
.dev_name = "ttyS",
之前編譯的內(nèi)核,怎么都不能初始化console,進(jìn)入busybox,原來(lái)s3c2410默認(rèn)的串口名并不是
ttyS0或tySAC0. 另外S3C2410的串口主設(shè)備號(hào)注冊(cè)為204,次設(shè)備號(hào)為64.這樣我們?cè)诟募?br/>系統(tǒng)里就要注意了:#mknod –mode=755 ttyS0 c 204 64

7, 修改文件drivers/net/arm/Kconfig,添加dm9000驅(qū)動(dòng)選項(xiàng):
config DM9000
tristate "DM9000 support"
depends on ARM && NET_ETHERNET
select CRC32
select MII
---help---
Support for DM9000 chipset.

To compile this driver as a module, choose M here and read
. The module will be
called dm9000.

#config MACE
#tristate "MACE (Power Mac ethernet) support"
#depends on NET_ETHERNET && PPC_PMAC && PPC32

8, 修改文件linux-2.6.12/drivers/net/Makefile, 添加DM9000的編譯選項(xiàng).
obj-$(CONFIG_SMC91X) += smc91x.o
obj-$(CONFIG_DM9000) += dm9000.o

9, make menuconfig生成配置文件:
System Type --->
ARM system type (Samsung S3C2410) --->
S3C24XX Implementations --->
[*] SMDK2410/A9M2410
[*] S3C2410 DMA support
[*] Support Thumb user binaries

Boot options --->
(noinitrdroot=/dev/mtdblock2 init=/linuxrcconsole=ttySAC0,115200) Default kernel command

Floating point emulation --->
[*] NWFPE math emulation

Device Drivers --->
Memory Technology Devices (MTD) --->
<*> Memory Technology Device (MTD) support
<*> MTD concatenating support
[*] MTD partitioning support
[*] Command line partition table parsing
<*> Direct char device access to MTD devices
<*> Caching block device access to MTD devices
RAM/ROM/Flash chip drivers --->
<*> Detect flash chips by Common Flash Interface (CFI) probe
<*> Detect non-CFI AMD/JEDEC-compatible flash chips
<*> Support for Intel/Sharp flash chips
<*> Support for AMD/Fujitsu flash chips
<*> Support for RAM chips in bus mapping
NAND Flash Device Drivers --->
<*> NAND Device Support
<*> NAND Flash support for S3C2410 SoC

Networking support --->
[*] Networking support
[*] Network device support
Ethernet (10 or 100Mbit) --->
[*] Ethernet (10 or 100Mbit)
<*> DM9000 support

Character devices --->
Serial drivers --->
<*> Samsung S3C2410 Serial port support
[*] Support for console on S3C2410 serial port

File systems --->
Pseudo filesystems --->
[*] /proc file system support
可選/dev file system support
[*] /dev/pts Extended Attributes
[*] /dev/pts Security Labels
[*] tmpfs Extended Attributes
[*] tmpfs Security Labels

Miscellaneous filesystems --->
<*> Journalling Flash File System v2 (JFFS2) support
(0) JFFS2 debugging verbosity (0 = quiet, 2 = noisy)
[*] JFFS2 support for NAND flash
[*] Advanced compression options for JFFS2
[*] JFFS2 ZLIB compression support
[*] JFFS2 RTIME compression support
<*> Compressed ROM file system support (cramfs)
<*> FreeVxFS file system support (VERITAS VxFS(TM) compatible)

Network File Systems --->
<*> NFS file system support
[*] Provide NFSv3 client support
[*] Provide NFSv4 client support (EXPERIMENTAL)

移植過(guò)程中碰到的主要問(wèn)題及解決方法

1, NAND_ECC_NONE selected by board driver. This is not recommended !!
和Reading data from NAND FLASH without ECC is not recommended
這是因?yàn)殛P(guān)閉了mtd/nand/s3c2410.c中的ECC檢測(cè):
不要在函數(shù)s3c2410_nand_init_chip()的最后添加下面這行代碼:
Chip->eccmode = NAND_ECC_NONE;
不關(guān)閉硬件ECC, 使用cramfs和jffs2文件系統(tǒng)很正常,對(duì)于yaffs2還沒(méi)試過(guò).
2, ftl_cs: FTL header not found.
Make menuconfig時(shí):
Device Drivers -?
Memory Technology Devices (MTD) -?不要選擇下面這三個(gè)選項(xiàng)
<>FTL (Flash Translation Layer) support
<> NFTL (NAND Flash Translation Layer) support
<>INFTL (Inverse NAND Flash Translation Layer) support
3, linux啟動(dòng)busybox時(shí)提示: Can't open /dev/ttyS0: No such file or directory
這是因?yàn)閮?nèi)核里s3c2410的串口驅(qū)動(dòng),注冊(cè)的串口設(shè)備名并不是ttyS0,并且串口設(shè)備的
主,次設(shè)備號(hào)也不是根文件系統(tǒng)/dev目錄下的設(shè)備. 按照上面移植內(nèi)核的方法,修改s3c2410
的串口驅(qū)動(dòng)程序(linux-2.6.12/drivers/serial/s3c2410.c)就OK了.

4, 關(guān)于dm9000網(wǎng)卡驅(qū)動(dòng)的幾個(gè)問(wèn)題:
dm9000 Ethernet Driver
dm9000: read wrong id 0x2b2a2928
dm9000: read wrong id 0x2b2a2928
dm9000: wrong id: 0x2b2a2928
dm9000: not found (0).
主要是最開(kāi)始按照網(wǎng)上移植dm9000的驅(qū)動(dòng)方法,在文件linux-2.6.12/arch/arm/mach-s3c2410/devs.c
中沒(méi)有設(shè)置正確的片選線(xiàn)(NGCS3),中斷線(xiàn)(INT9)以及那個(gè)CMD連接A2上.

dm9000 Ethernet Driver
eth%d: Invalid ethernet MAC address. Please set using ifconfig
eth0: dm9000 at c4862300,c4864304 IRQ 53 MAC: 00:00:00:00:00:00
在dm9000驅(qū)動(dòng)的源代碼(driver/net/dm9000.c)中,默認(rèn)是從ROM中讀取MAC地址,而我的開(kāi)發(fā)板
上沒(méi)有ROM,所以在上面的驅(qū)動(dòng)中我自己設(shè)置MAC地址就OK了.

在busybox里使用tftp下載文件時(shí),總是提示timeout.后來(lái)又發(fā)現(xiàn):開(kāi)發(fā)板能ping通PC,而PC確不
能ping通開(kāi)發(fā)板,若開(kāi)發(fā)板ping PC的時(shí)候, PC確可以ping通開(kāi)發(fā)板.
在驅(qū)動(dòng)文件(driver/net/dm9000.c)的函數(shù)static int dm9000_open(struct net_device *dev)中,在申請(qǐng)
中斷之前,指定申請(qǐng)的中斷類(lèi)型為上升沿中斷.詳細(xì)方法參考上面的代碼.

關(guān)于jffs2文件系統(tǒng)的問(wèn)題:
在使用下面這個(gè)命令創(chuàng)建的jffs2.img時(shí)會(huì)報(bào)錯(cuò):
PC上: #mkfs.jffs2 -r jfss2 -o jffs2.img
開(kāi)發(fā)板上:
>:echo jffs2.img > /dev/mtdb3
nand_write_ecc: Attempt to write not page aligned data
>: mount -t jffs2 /dev/mtdblock3 /apps/
mtd->read(0x400 bytes from 0x0) returned ECC error
CLEANMARKER node found at 0x00000000 has totlen 0xc != normal 0x0
mtd->read(0x2c bytes from 0xc) returned ECC error

使用下面這個(gè)命令創(chuàng)建的jffs2.img燒入很正常:
mkfs.jffs2 -r jffs2 -o jffs2.img -e 0x4000 --pad=0x1B00000 -s 0x200 –n

mkfs.jffs2的幾個(gè)選項(xiàng)說(shuō)明:
(1)-r : 指定要做成image的源資料夾.
(2)-o : 指定輸出image檔案的文件名.
(3)-e : 每一塊要抹除的block size,預(yù)設(shè)是64KB.要注意,不同的flash, 其block size會(huì)不一樣.我的是三星的K9F1208U0B.
(4)--pad (-p): 用16進(jìn)制來(lái)表示所要輸出檔案的大小,也就是jffs2.img的size。很重要的是, 為了不浪費(fèi)flash空間, 這個(gè)值最好符合flash driver所規(guī)劃的區(qū)塊大小.以我的板子來(lái)說(shuō),就是27MB(0x1B00000).
(5)如果掛載后會(huì)出現(xiàn)類(lèi)似:CLEANMARKER node found at 0x0042c000 has totlen 0xc != normal 0x0 的警告,則加上 -n 就會(huì)消失。

本站聲明: 本文章由作者或相關(guān)機(jī)構(gòu)授權(quán)發(fā)布,目的在于傳遞更多信息,并不代表本站贊同其觀點(diǎn),本站亦不保證或承諾內(nèi)容真實(shí)性等。需要轉(zhuǎn)載請(qǐng)聯(lián)系該專(zhuān)欄作者,如若文章內(nèi)容侵犯您的權(quán)益,請(qǐng)及時(shí)聯(lián)系本站刪除。
換一批
延伸閱讀

9月2日消息,不造車(chē)的華為或?qū)⒋呱龈蟮莫?dú)角獸公司,隨著阿維塔和賽力斯的入局,華為引望愈發(fā)顯得引人矚目。

關(guān)鍵字: 阿維塔 塞力斯 華為

倫敦2024年8月29日 /美通社/ -- 英國(guó)汽車(chē)技術(shù)公司SODA.Auto推出其旗艦產(chǎn)品SODA V,這是全球首款涵蓋汽車(chē)工程師從創(chuàng)意到認(rèn)證的所有需求的工具,可用于創(chuàng)建軟件定義汽車(chē)。 SODA V工具的開(kāi)發(fā)耗時(shí)1.5...

關(guān)鍵字: 汽車(chē) 人工智能 智能驅(qū)動(dòng) BSP

北京2024年8月28日 /美通社/ -- 越來(lái)越多用戶(hù)希望企業(yè)業(yè)務(wù)能7×24不間斷運(yùn)行,同時(shí)企業(yè)卻面臨越來(lái)越多業(yè)務(wù)中斷的風(fēng)險(xiǎn),如企業(yè)系統(tǒng)復(fù)雜性的增加,頻繁的功能更新和發(fā)布等。如何確保業(yè)務(wù)連續(xù)性,提升韌性,成...

關(guān)鍵字: 亞馬遜 解密 控制平面 BSP

8月30日消息,據(jù)媒體報(bào)道,騰訊和網(wǎng)易近期正在縮減他們對(duì)日本游戲市場(chǎng)的投資。

關(guān)鍵字: 騰訊 編碼器 CPU

8月28日消息,今天上午,2024中國(guó)國(guó)際大數(shù)據(jù)產(chǎn)業(yè)博覽會(huì)開(kāi)幕式在貴陽(yáng)舉行,華為董事、質(zhì)量流程IT總裁陶景文發(fā)表了演講。

關(guān)鍵字: 華為 12nm EDA 半導(dǎo)體

8月28日消息,在2024中國(guó)國(guó)際大數(shù)據(jù)產(chǎn)業(yè)博覽會(huì)上,華為常務(wù)董事、華為云CEO張平安發(fā)表演講稱(chēng),數(shù)字世界的話(huà)語(yǔ)權(quán)最終是由生態(tài)的繁榮決定的。

關(guān)鍵字: 華為 12nm 手機(jī) 衛(wèi)星通信

要點(diǎn): 有效應(yīng)對(duì)環(huán)境變化,經(jīng)營(yíng)業(yè)績(jī)穩(wěn)中有升 落實(shí)提質(zhì)增效舉措,毛利潤(rùn)率延續(xù)升勢(shì) 戰(zhàn)略布局成效顯著,戰(zhàn)新業(yè)務(wù)引領(lǐng)增長(zhǎng) 以科技創(chuàng)新為引領(lǐng),提升企業(yè)核心競(jìng)爭(zhēng)力 堅(jiān)持高質(zhì)量發(fā)展策略,塑強(qiáng)核心競(jìng)爭(zhēng)優(yōu)勢(shì)...

關(guān)鍵字: 通信 BSP 電信運(yùn)營(yíng)商 數(shù)字經(jīng)濟(jì)

北京2024年8月27日 /美通社/ -- 8月21日,由中央廣播電視總臺(tái)與中國(guó)電影電視技術(shù)學(xué)會(huì)聯(lián)合牽頭組建的NVI技術(shù)創(chuàng)新聯(lián)盟在BIRTV2024超高清全產(chǎn)業(yè)鏈發(fā)展研討會(huì)上宣布正式成立。 活動(dòng)現(xiàn)場(chǎng) NVI技術(shù)創(chuàng)新聯(lián)...

關(guān)鍵字: VI 傳輸協(xié)議 音頻 BSP

北京2024年8月27日 /美通社/ -- 在8月23日舉辦的2024年長(zhǎng)三角生態(tài)綠色一體化發(fā)展示范區(qū)聯(lián)合招商會(huì)上,軟通動(dòng)力信息技術(shù)(集團(tuán))股份有限公司(以下簡(jiǎn)稱(chēng)"軟通動(dòng)力")與長(zhǎng)三角投資(上海)有限...

關(guān)鍵字: BSP 信息技術(shù)
關(guān)閉
關(guān)閉