1.1.1 Device resource initialization
Linux-2..6.32.2 already comes with a complete DM9000 network card driver (source code location: linux-2.6.32.2/drivers/net/dm9000.c). It is also a platform device, so the code is initialized on the target platform. , just fill in the corresponding structure table (in mach-mini2440.c), the specific steps are as follows:
First add the header file dm9000.h required by the driver:
#include Then define the physical base address of the DM9000 network card device for later use: /* DM9000AEP 10/100 ethernet controller */ #define MACH_MINI2440_DM9K_BASE (S3C2410_CS4 + 0x300) Then fill in the resource settings of the platform device to match it with the DM9000 network card driver interface, as follows static struct resource mini2440_dm9k_resource[] = { [0] = { .start = MACH_MINI2440_DM9K_BASE, .end = MACH_MINI2440_DM9K_BASE + 3, .flags = IORESOURCE_MEM }, [1] = { .start = MACH_MINI2440_DM9K_BASE + 4, .end = MACH_MINI2440_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 it's MAC address is set by * * * the bootloader before starting the kernel. * * */ static struct dm9000_plat_data mini2440_dm9k_pdata = { .flags = (DM9000_PLATF_16BITONLY | DM9000_PLATF_NO_EEPROM), }; static struct platform_device mini2440_device_eth = { .name = "dm9000", .id = -1, .num_resources = ARRAY_SIZE(mini2440_dm9k_resource), .resource = mini2440_dm9k_resource, .dev = { .platform_data = &mini2440_dm9k_pdata, }, }; //At the same time, add the network card platform equipment prepared above in the mini2440 device set, as shown in the red part below static struct platform_device *mini2440_devices[] __initdata = { &s3c_device_usb, &s3c_device_lcd, &s3c_device_wdt, &s3c_device_i2c0, &s3c_device_iis, &mini2440_device_eth, &s3c_device_nand, }; In this way, the interface of the DM9000 platform device is completed. 1.1.2 Adjust the bit width register used by DM9000 Because the DM9000 network card driver of Linux-2.6.32.2 is not specially prepared for mini2440, some porting work needs to be done in its source code, as follows. Open linux-2.6.32.2/ drivers/net/dm9000.c, and add 2410 related configuration definitions to the header file, as follows #include #include #include #if defined(CONFIG_ARCH_S3C2410) #include #endif #include "dm9000.h" Add the following red part to the initialization function of the dm9000 device. Here is the timing for configuring the chip select bus used by DM9000. Because mini2440 currently only has one device that can be expanded through the bus, it will be easier to understand if you directly modify the relevant register configuration in this device driver. Some, of course, this part can also be placed in mach-mini2440.c (note that if you put this part in mach-mini2440.c, there will be several constants that you need to find and define yourself). You can experiment by yourself, and I won’t go into details here. . static int __init dm9000_init(void) { #if defined(CONFIG_ARCH_S3C2410) unsigned int oldval_bwscon = *(volatile unsigned int *)S3C2410_BWSCON; unsigned int oldval_bankcon4 = *(volatile unsigned int *)S3C2410_BANKCON4; *((volatile unsigned int *)S3C2410_BWSCON) = (oldval_bwscon & ~(3<<16)) | S3C2410_BWSCON_DW4_16 | S3C2410_BWSCON_WS4 | S3C2410_BWSCON_ST4; *((volatile unsigned int *)S3C2410_BANKCON4) = 0x1f7c; #endif printk(KERN_INFO "%s Ethernet Driver, V%sn", CARDNAME, DRV_VERSION); return platform_driver_register(&dm9000_driver); } 1.1.3 About MAC address It should be noted that the DM9000 network card used in this development board does not have an external EEPROM to store the MAC address, so the MAC address in the system is a "soft" address, which means it can be modified through software and can be changed to other values at will. It can be seen in the static int __devinit dm9000_probe(struct platform_device *pdev) function: /* try reading the node address from the attached EEPROM */ //Try to read MAC address from EEPROM for (i = 0; i < 6; i += 2) dm9000_read_eeprom(db, i / 2, ndev->dev_addr+i); if (!is_valid_ether_addr(ndev->dev_addr) && pdata != NULL) { mac_src = "platform data"; memcpy(ndev->dev_addr, pdata->dev_addr, 6); } 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); } //Use "soft" MAC address: 08:90:90:90:90:90 memcpy(ndev->dev_addr, "x08x90x90x90x90x90", 6); if (!is_valid_ether_addr(ndev->dev_addr)) dev_warn(db->dev, "%s: Invalid ethernet MAC address. Please " "set using ifconfign", ndev->name); In fact, DM9000 has been transplanted so far. 1.1.4 Configure the kernel to add DM9000, compile and run the test At this time, the kernel source code directory will be brought, execute: #make menuconfig Start configuring the network card driver in the kernel and select the following menu items in sequence Device Drivers --->Network device support ---> Ethernet (10 or 100Mbit) ---> You can find the configuration items of DM9000, and you can see that DM9000 has been selected. This is because the default kernel configuration of Linux-2.6.32.2 has added support for DM9000. Then execute: #make zImage Finally, generate the arch/arm/boot/zImage file, use the "k" command to burn it to the development board, and start it using the default file system. Run the ifconfig command in the command line terminal to see the following. [root@FriendlyARM /]# ifconfig eth0 Link encap:Ethernet HWaddr 08:90:90:90:90:90 inet addr:192.168.1.230 Bcast:192.168.1.255 Mask:255.255.255.0 UP BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) Interrupt:51 Base address:0x300 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:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) Test network: ping 127.0.0.1. If there is a number after the equal sign, it means that the network card is pinging the gateway address normally. If there is a number after the equal sign, it is connecting to the gateway and pinging the IP of other hosts normally. If there is a number after the equal sign, it is pinging the IP of other hosts. The connection is OK.
Previous article:linux2.6.32.2 mini2440 platform transplantation--activate RTC driver
Next article:Linux 2.6.32.2 mini2440 platform transplantation-kernel transplantation, yaffs2 file system transplantation
Recommended ReadingLatest update time:2024-11-16 13:49
- Popular Resources
- Popular amplifiers
- Network Operating System (Edited by Li Zhixi)
- Microgrid Stability Analysis and Control Microgrid Modeling Stability Analysis and Control to Improve Power Distribution and Power Flow Control (
- MATLAB and FPGA implementation of wireless communication
- Introduction to Internet of Things Engineering 2nd Edition (Gongyi Wu)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- After CC2500 continues to send and receive data for a period of time, it can no longer receive data. CC2500 needs to be reset before it can continue to send and receive data.
- Download and answer questions to win prizes: Efficient PCB design with Mentor's Xpedition Layout
- National College Student Electronic Design Competition Protues Series
- Can you understand these basic module circuits?
- 2020-5-21-Bone vibration test completed
- Oscilloscope Differential Probe Delay Measurement
- [SAMR21 New Gameplay] 24. Usage of I2C
- AD17 There is a problem with copper laying on a four-layer board
- Static Timing Analysis Basics and Applications
- Cost-effective 0-10V analog signal isolation technology: based on Y capacitor isolation