Transplantation of network card dm9000e Based on S3C2440 embedded Linux

Source: Internet
Author: User
The steps for porting A dm9000e Nic to mini2440 are as follows:

I. view the circuit diagram

On the basis of porting the Linux-2.6.29.1 kernel and root file system on the mini2440 Development Board, transplantation of network card dm9000e, because there is a book written by Wei Dongshan in the hand "embedded Linux application development full manual, find the dm9000 Nic porting part in the book, and compare the schematic diagram in the book with the friendly CD. before transplantation, start by looking at the schematic. After reading the circuit diagrams of dm9000e and S3C2440, we found that:

1. The dm9000e is mounted to the S3C2440 bus.

S3C2440 accesses dm9000e through the bus. The base address of the physical address used by mini2440 to access dm9000e is bank4. An address line addr2 is used, which corresponds to the CMD pin of dm9000e. Because dm9000e's address signal and data signal are reused, the cmd pin determines whether the address signal is transmitted or the data signal. Therefore, the status of the addr2 pin on the address line determines whether the dm9000e and S3C2440 transmit the address signal or the data signal.

2. The bus bit width is 16 and nwait signal is used.

3. The dm9000e receives the complete data packet and notifies the S3C2440 through the interrupt pin to receive the data packet. The interrupt Pin connected to the S3C2440 is eint7.

2. NIC Driver Modification

When you modify the NIC Driver in the kernel, you must first check whether the current kernel supports the NIC. If not, you need to find the driver that supports the NIC to modify it. I am using the Linux-2.6.29.1 kernel, this kernel has a good support for dm9000e, which in the kernel documentation/networking/dm9000.txt has a detailed description of the dm9000 driver in the kernel, the following describes the friendly support of the Linux-2.6.29.1 kernel for the dm9000e Nic.

The driver supports three dm9000 variants, the dm9000e which is the first chip supported as well as the newer dm9000a and dm9000b devices. it is currently maintained and tested by Ben dooks, who shoshould be CC: To any patches for this driver.

Some earlier versions of the kernel (such as linux-2.6.13, etc.) do not support dm9000e, you can use another kernel version of The dm9000.c driver to add to the kernel, modify and configure. Because the Kernel used here has good support for the dm9000e Nic, you only need to configure and modify it.

1. Modify the dm9000 platform device

Modify/ARCH/ARM/plat-s3c24xx/common-smdk.c files

(1) Add the header file to be included

# If defined (config_dm9000) | defined (config_dm9000_module)

# Include

# Endif

(2) Add the dm9000 platform device structure

# If defined (config_dm9000) | defined (config_dm9000_module)

/* Dm9000 */

Static struct resource initi_dm9k_resource [] = {

[0] = {

. Start = s3c2410_cs4, // addr2 = 0

. End = s3c2410_cs4 + 3,

. Flags = ioresource_mem,

},

[1] = {

. Start = s3c2410_cs4 + 4, // addr2 = 1

. End = s3c2410_cs4 + 4 + 3,

. Flags = ioresource_mem,

},

[2] = {

. Start = irq_eint7,

. End = irq_eint7,

. Flags = ioresource_irq,

}

};

Static struct dm9000_plat_data initi_dm9k_platdata = {

. Flags = dm9000_platf_16bitonly,

};

Static struct platform_device initi_device_dm9k = {

. Name = "dm9000 ",

. ID = 0,

. Num_resources = array_size (initi_dm9k_resource ),

. Resource = maid,

. Dev = {

. Platform_data = & cloud_dm9k_platdata,

}

};

# Endif

(3) Add the dm9000 platform device to the kernel device list

/* Devices we initialise */

Static struct platform_device _ initdata * smdk_devs [] = {

& Amp; cloud_device_nand,

& Smdk_led4,

& Smdk_led5,

& Smdk_led6,

& Smdk_led7,

# If defined (config_dm9000) | defined (config_dm9000_module)

& Amp; cloud_device_dm9k,

# Endif

};

2. Modify Drivers/NET/dm9000.c

Dm9000.c contains the dm9000_probe function, which completes the enumeration of dm9000 devices. The introduction of the dm9000_probe function is described in detail in the "embedded Linux application development complete manual.

(1) Add necessary header files

# If defined (config_arch_s3c2410)

# Include

# Endif

# Include Yes # include, which makes it easier for me to compile and modify it to # include After compilation is successful, this is caused by the difference in the file where the program of different versions of kernel files is located.

(2) set the memory in dm9000_probe to make bank4 available and set the default MAC address (you can also set the startup script in the root file system). The added code is as follows:

/*

* Search dm9000 board, allocate space and register it

*/

Static int _ devinit

Dm9000_probe (struct platform_device * pdev)

{

...

# If defined (config_arch_s3c2410)

Unsigned int oldval_bwscon; // used to save the value of the bwscon register

Unsigned int oldval_bankcon4; // used to save the value of the s3c2410_bankcon4 register.

# Endif

...

# If defined (config_arch_s3c2410)

// Set bank4: The bus width is 16 to enable nwait

Oldval_bwscon = * (volatile unsigned int *) s3c2410_bwscon );

* (Volatile unsigned int *) s3c2410_bwscon) = (oldval_bwscon &~ (3dev_addr ))

Dev_warn (db-> Dev, "% s: Invalid Ethernet MAC address. Please"

"Set using ifconfig/N", ndev-> name );

# If defined (config_arch_s3c2410)

Printk ("now use the default MAC address: 08: 90: 90: 90: 90: 90/N ");

Ndev-> dev_addr [0] = 0x08;

Ndev-> dev_addr [1] = 0x90;

Ndev-> dev_addr [2] = 0x90;

Ndev-> dev_addr [3] = 0x90;

Ndev-> dev_addr [4] = 0x90;

Ndev-> dev_addr [5] = 0x90;

# Endif

...

Out:

Printk ("% s: Not found (% d)./N", cardname, RET );

# If defined (config_arch_s3c2410)

* (Volatile unsigned int *) s3c2410_bwscon) = oldval_bwscon;

* (Volatile unsigned int *) s3c2410_bankcon4) = oldval_bankcon4;

# Endif

(3) Specify the trigger method when the registration is interrupted

Dm9000_open (struct net_device * Dev)

{

...

Irqflags | = ir1__shared;

# If defined (config_arch_s3c2410)

If (request_irq (Dev-> IRQ, & dm9000_interrupt, ir1__shared | ir1__trigger_rising, Dev-> name, Dev ))

# Else

If (request_irq (Dev-> IRQ, & dm9000_interrupt, ir1__shared, Dev-> name, Dev ))

# Endif

// If (request_irq (Dev-> IRQ, & dm9000_interrupt, irqflags, Dev-> name, Dev ))

Return-eagain;

...

}

3. Add the NIC dm9000 configuration in the kernel

Run the "make menuconfig" command in the kernel directory to perform the following Configuration:

Device Drivers --->

[*] Network device support --->

[*] Ethernet (10 or 100 Mbit) --->

Dm9000 support

[*] Networking support --->

Networking options --->

TCP/IP networking

IP: Kernel leel autoconfiguration

// Add NFS support

File systems --->

[*] Networking file systems --->

NFS client support

[*] NFS client support for NFS Version 3

[*] NFS client support for the nfsv3 ACL protocol Extension

[*] Boot file system on NFS

[*] NFS server support

4. Modify the root file system startup script RFM

Add the following to the root file etc/init. d/RCS:

Echo "Network Interface"

/Sbin/ifconfig lo 127.0.0.1

/Sbin/ifconfig eth0 192.168.1.230 up

Route add default GW 192.168.1.1

V. Testing and Modification

Download the modified kernel and root file system to the mini2440 Development Board. The following message is displayed at startup:

---------- Munt all ----------------

Network Interface

Dm9000 dm9000.0: Warning: No IRQ resource flags set.

Eth0: link up, 10 Mbps, half-duplex, LPA 0x0021

**************************************** *******

* ************** Studying arm *********************

Kernel version: linux-2.6.29.1

Student: Feng Dong Rui

Date: 2009.07.15

**************************************** *******

Please press enter to activate this console.

[Mrfeng] #

1. Test

Please press enter to activate this console.

[Mrfeng] # ifconfig-

Eth0 link encap: Ethernet hwaddr 10: 23: 45: 67: 89: AB

Inet ADDR: 192.168.1.230 bcast: 192.168.1.255 mask: 255.255.255.0

Up broadcast running Multicast MTU: 1500 Metric: 1

RX packets: 1506 errors: 0 dropped: 0 overruns: 0 frame: 0

TX packets: 0 errors: 0 dropped: 0 overruns: 0 carrier: 0

Collisions: 0 FIG: 1000

RX Bytes: 101460 (99.0 kib) TX Bytes: 0 (0.0 B)

Interrupt: 51 base address: 0x8000

Lo link encap: local loopback

Inet ADDR: 127.0.0.1 mask: 255.0.0.0

Up loopback running MTU: 16436 Metric: 1

RX packets: 6 errors: 0 dropped: 0 overruns: 0 frame: 0

TX packets: 6 errors: 0 dropped: 0 overruns: 0 carrier: 0

Collisions: 0 txqueuelen: 0

RX Bytes: 504 (504.0 B) TX Bytes: 504 (504.0 B)

[Mrfeng] # Ping 127.0.0.1

Ping 127.0.0.1 (127.0.0.1): 56 data bytes

64 bytes from 127.0.0.1: seq = "0" TTL = "64" time = "1". 004 MS

64 bytes from 127.0.0.1: seq = "1" TTL = "64" time = "0". 518 MS

64 bytes from 127.0.0.1: seq = "2" TTL = "64" time = "0". 436 MS

^ C

--- 127.0.0.1 Ping statistics ---

3 packets transmitted, 3 packets received, 0% packet loss

Round-trip min/AVG/max = 0.436/0.652/1.004 MS

[Mrfeng] # Ping 192.168.1.103

Ping 192.168.1.103 (192.168.1.103): 56 data bytes

64 bytes from 192.168.1.103: seq = "0" TTL = "64" time = "2". 098 MS

64 bytes from 192.168.1.103: seq = "1" TTL = "64" time = "1". 342 MS

64 bytes from 192.168.1.103: seq = "2" TTL = "64" time = "0". 823 MS

^ C

--- 192.168.1.103 Ping statistics ---

3 packets transmitted, 3 packets received, 0% packet loss

Round-trip min/AVG/max = 0.823/1.421/2.098 MS

// Mount the Network File System

[Mrfeng] # Mount-T nfs-O nolock 192.168.1.103:/opt/nfs/mnt

[Mrfeng] # ls/mnt

Pic.jpg

[Mrfeng] # umount/mnt

[Mrfeng] # ls/mnt

[Mrfeng] #

Note: to mount a Network File System, you must set a shared directory in Linux to mount the directory from the Development Board, the shared directory NFS has been set in/opt in the redhat9.0 system under the virtual machine. The IP address of the virtual machine is 192.168.1.103. Therefore, Mount-T nfs-O nolock 192.168.1.103: mount the/opt/nfs/mnt command.

2. Previous problems

(1) Ping other hosts in different LAN, and Ping yourself may also encounter the following problems:

[ ] (Initi_irq_demux_extint4t7 + 0x0/0xa8) from [ ] (Asm_do_irq + 0x

44/0 x5c)

R4: c03c2350

[ ] (Asm_do_irq + 0x0/0x5c) from [ ] (_ Irq_svc + 0x24/0 xa0)

Exception stack (0xc2e2bd98 to 0xc2e2bde0)

Bd80: 00000000 fb000000

Bda0: 00000001 00000000 c03c2a18 00000033 40000013 00000080 00000033

Bdc0: c39bfc80 c2e2be10 c2e2bdbc c2e2bde0 c007320c c0072748 60000013 ffffffff

R7: 00000080 R6: 00000010 R5: f4000000 R4: ffffffff

[ ] (Setup_irq + 0x0/0x248) from [ ] (Request_irq + 0xb0/0xcc)

[ ] (Request_irq + 0x0/0xcc) from [ ] (Dm9000_open + 0x16c/0x23c)

[ ] (Dm9000_open + 0x0/0x23c) from [ ] (Dev_open + 0xa8/0x10c)

[ ] (Dev_open + 0x0/0x10c) from [ ] (Dev_change_flags + 0x98/0x164

)

R5: 00000000 R4: c382b800

[ ] (Dev_change_flags + 0x0/0x164) from [ ] (Devinet_ioctl + 0x2f0

/0x708)

R7: bed9ba88 R6: c39fdf00 R5: 00000000 R4: ffffff9d

[ ] (Devinet_ioctl + 0x0/0x708) from [ ] (Inet_ioctl + 0xc0/0xf4)

[ ] (Inet_ioctl + 0x0/0xf4) from [ ] (Sock_ioctl + 0x1e4/0x244)

[ ] (Sock_ioctl + 0x0/0x244) from [ ] (Vfs_ioctl + 0x3c/0x84)

R7: 00000003 R6: 00008914 R5: ffffffe7 R4: c2d1a420

[ ] (Vfs_ioctl + 0x0/0x84) from [ ] (Do_vfs_ioctl + 0x284/0 x2a4)

R5: 00000000 R5: bed9ba88 R4: c2d1a420

[ ] (Do_vfs_ioctl + 0x0/0x2a4) from [ ] (Sys_ioctl + 0x40/0 x5c)

R7: 00000036 R6: 00008914 R5: fffffff7 R4: c2d1a420

[ ] (Sys_ioctl + 0x0/0x5c) from [ ] (Ret_fast_syscall + 0x0/0x2c)

R6: 00000000 R5: 00159dec R4: 00159d5c

The cause of this problem is that I did not set the trigger method of the interrupt to the default one and did not change it to the one modified above.

(2) The Network File System cannot be mounted.

Possible cause: Check whether NFS support is selected in the Kernel configuration, whether the Linux host can connect to the LAN and set a shared directory, and whether the hardware connection is good. Whether the firewall of the Linux host is disabled or whether the NFS service is enabled.

Vi. References

In the course of study, I referred to the book "embedded Linux application development full manual" written by Wei Dongshan. Although I did not elaborate on many things, the Book of Embedded Linux cannot be detailed in a book, but I read it unconsciously every time I want to do anything, which is of great reference value to me. In addition, the blog and post content of some enthusiastic netizens on the Internet gave me a lot of reference. In combination with the "Hundred Masters" to solve the problem, there are a lot of online materials, not to mention them one by one.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.