Abstract: This article introduced how to carry on the embedded software debugging in the embedded debugger through the ethernet mouth, has realized between the main engine and the development board net mouth correspondence. Has conducted the research in view of concrete embedded development board S3C4510B to the net mouth actuation and the network protocol, reduced the net mouth actuation and the network protocol redundant part, both had guaranteed the debugger may carry on the remote debugging through the ethernet, and can satisfy the embedded system the request which takes to the resources.
Key word: Embedded development board; Network protocol; Embedded debugger
0. introduction
Along with embedded system’s widespread application, the embedded software development becomes day by day important. The embedded software development is different with the tabletop software development, its outstanding feature is the software development debugging process uses the host machine/target machine’s pattern to carry on, its overlapping debugger divides into the host machine and the target machine two parts, therefore needs to carry on between the main engine and target machine’s correspondence in the software debugging process.
At present between the host machine and target machine’s mailing address mainly has the serial port way, the ethernet connection way and the USB connection way three kinds, the serial port correspondence realizes simply, stable reliable, is the present widespread use mailing address, but the serial port correspondence has the speed to be slow, the signal distance is limited and so on malpractices, but the ethernet connection way may overcome the serial port way the insufficiency, not only may provide the stable reliable data transmission, moreover, regardless of being the transmission speed or the transmitting range by far surpasses the serial port way, is one fast highly effective mailing address. At present the network service agreement’s development was quite already mature, Internet project committee IETF and subordinate’s management group IESG in RFC Wen Dang the define clearly Internet agreement race’s standard, this standard already had already become one kind of standard in Internet the widespread application. How this article according to this standard to discuss has realized the ethernet connection correspondence in the embedded debugger, has given one kind based on the embedded debugger’s network service method.
1. hardware architecture
S3C4510B was a section of 16/32 RISC embedded processor which Tristar Corporation developed, the chip interior integrated a 10Mbps/100Mvps ethernet controller, what the network card chip used was RTL8201. The ethernet controller mainly divides into the BDMA controller and the MAC sublayer two parts, this controller work in the MAC level, the compatible IEEE802.3 protocol standard, supports the half-duplex or the full-duplex pattern, uses the medium independent connection (MII) and the network card chip correspondence.
2. communication protocol
In the embedded debugger’s correspondence, the main engine to the target machine routing directive, the target machine receive, the executive command and the result returns main engine, the net mouth correspondence is mainly faces the data and the string of character transmission, therefore mainly uses the IP agreement, the ARP agreement and the UDP agreement in the correspondence. Must through the network debugging target machine, then the target machine IP address’s establishment is essential, therefore the target machine also needs to realize the BOOTP agreement, through the BOOTP agreement to the main engine application this aircraft IP address, completes the IP address the disposition.
The BOOTP agreement is the vectoring procedure agreement, is one kind based on the UDP/IP agreement, mainly uses in the client obtaining this aircraft IP address, the server IP address and other disposition information from the server, like local subnet mask and so on. The UDP agreement is the User Datagram Protocol, is one simple face the data newspaper transport protocols, is different with TCP, UDP does not provide to the IP agreement reliable mechanism, the class control as well as the error recovery function, therefore realizes is quite simple, and does not affect the transmission speed, is suitable in the embedded system. The IP agreement is the internet protocol, is in the network realizes the data transmission foundation, all TCP, the UDP data by the IP data newspaper form transmission, this agreement has provided one highly effective unreliable connectionless transmission mode. The ARP agreement is the Address Resolution Protocol, is the IP address and the corresponding physical address provides the mapping.
3. The network service procedure realizes
The concrete procedure realizes mainly includes the net mouth actuation and the communication protocol two parts, the net mouth actuation is the initialization S3C4510B hardware, is mainly the ethernet controller and the receiving and dispatching cushion establishment; The network protocol realizes is mainly completes the data receiving and dispatching, the guarantee goal board turning on ethernet. The procedure realizes flow as shown in Figure 1.

Figure 1 the procedure realizes the flow chart
3.1 net mouth actuation realizes
The net mouth actuation realizes mainly aims at the hardware initialization which the concrete development board does, disposes the hardware working conditions.
3.1.1 management network card chip
Reads and establishes network card’s active status in 4510 development boards by the MAC level’s status manager cybertron through the MII connection, the physical equipment address and the internal register address deposits in the station supervisory control and in address register STACON, but must establish or the read data places in station managerial data register STADATA.
In the practical application, network card’s MAC address may read from ICC EEPROM, may also establish voluntarily, so long as guarantees in the identical local area network this address uniqueness then.
3.1.2 initialization ethernet controller
①Closes MAC, the BDMA receiving and dispatching interrupt, guarantees the initialization routine smooth advance.
②Establishes MAC, the BDMA interrupt to the meter. In S3C4510B altogether has 21 interrupt sources, MAC and the BDMA transmission/receive interrupt source takes 16~19si the interrupt number.
③Establishes MAC, the BDMA controller’s starting value, namely the initialization BDMA receive/transmission control register and the MAC receive/controls the register, receives and dispatches the detail specifically.
④Disposes ethernet’s receiving and dispatching buffer. The transmission frame and the receive frame’s frame descrptor start address deposits separately in register BDMATXPTR and BDMARXPTR, they will renew in the BDMA operating process for the next frame address. And, the frame descrptor defined as the structure type, the syntagma member described the frame information.
⑤Enables BDMA to receive the interrupt and the MAC transmission interrupt. In the interrupt mask register INTMSK corresponding position reset, will respond BDMA and the MAC interrupt request.
3.1.3 receiving and dispatching ether data frame
①Transmission ether data frame: Transfer transmission function DrvEthWrite(), obtains the transmission frame address from BDMATXPTR, for the transmission frame cushion evaluation, gives the BDMA controller data frame’s domination, the ethernet controller adds on automatically for the transmission data with the step, the division position, the verification position as well as the packing field and transmits the ether frame.
②Receive ether data frame: When receive has the BDMA receive interrupt, interrupt processing function BDMA_Rx_isr() completes the data the receive, and makes related processing, like clear interrupt flag bit, inspection data frame property rights, gain next raw sewage frame structure indicator and so on.
The part main program is as follows:
/* disposition physical equipment */
MIIWrite (0×0, 0×2, 1<<13|1<<8); /* establishment physical equipment’s condition */
status = MIIRead (0×1, 0×0); /* read physical equipment’s condition */
/* disposes MAC address */
GetMyMacAddr():
/* closure receiving and dispatching interrupts */
Disable_Int(nMAC_RX_INT);
Disable_Int(nMAC_TX_INT);
Disable_Int(nBDMA_RX_INT);
Disable_Int(nBDMA_TX_INT);
/* establishes the MAC transmission interrupt and BDMA receive interrupt vector */
SetInterrupt (nMAC_TX_INT, MAC_Tx_isr);
SetInterrupt (nBDMA_RX_INT, BDMA_Rx_isr);
/* initialization MAC, BDMA controller */
BDMARXCON = BRxRS; /* establishes BDMA receive control register */
BDMATXCON = BTxRS; /* establishes BDMA transmission control register */
MACCON = Reset; /* repositions MAC control register */
BDMARXLSZ = MaxRxFrameSize 40; /* receive frame greatest size */
MACON = gMacCon; /* establishes as full-duplex way */
/* disposes ethernet’s receiving and dispatching cushion */
TxFDInitialize();
RxFDInitialize();
/* enables BDMA to receive the interrupt and the MAC transmission interrupts */
Enable_Int(nBDMA_RX_INT);
Enable_Int(nMAC_TX_INT);
3.2 communication protocols realize
This article uses structure type definition construction of data bootphdr, Udphdr, ip and arphdr, uses for to record BOOTP, UDP, IP and ARP agreement data newspaper masthead each kind of information separately.
3.2.1 disposition target machine IP address
The target machine first transmits BOOTP to the main engine to request that the main engine moves the DHCP service to assign the IP address for the target machine, transmits the BOOTP reply package to the target machine, after the target machine receives the reply package, according to agreement form gain main engine and this aircraft’s IP address as well as other related information.
①Produces the BOOTP request. In initialization bootphdr each syntagma member’s value, the customer IP address and the main engine IP address supposes separately for 0.0.0.0 and 255.255.255.255, when the system carries on the guidance 0.0.0.0 is an effective IP address, the target machine, in did not know when goal main engine’s IP address may use cast address 255.255.255.255, broadcasts the way transmits the BOOTP request. MAC address already when initialization obtains, coexisting places in global variable MyMacSrcAddr, other member variable may defer to the agreement the form establishment then.
②Transmits the BOOTP request. BOOTP requested that must seal in the UDP data newspaper transmits, the BOOTP server port and the customer port use the well-known port separately 67 and 68; UDP verification and through transfer function udpChksum() computation gain. IP masthead various members according to the IP data newspaper form establishment, the source IP address and the goal IP address respectively are 0.0.0.0 and 255.255.255.255, the IP verification and obtain through the transfer function ipChksum() computation. This aircraft MAC address takes the source MAC address, broadcast form MAC address 0xffffffff takes the goal MAC address, seals the ether data frame, the transfer writes the function DrvEthWrite() transmission. Transfer transmission interrupt processing function MAC_Tx_isr(), the renewal current frame structure description indicator and repositions the MAC controller.
③Receives the BOOTP reply package, gains the main engine and this aircraft’s IP address. Uses the interrupt mode to receive the BOOTP reply package. Interrupt processing function BDMA_Rx_isr() will receive the package deposits in receive frame descrptor RxFDBaseAddr, the extraction valid data puts in BOOTP in receive buffer BOOTP_REC_BUF, and repositions the corresponding BDMA control register and the interrupt control position.
③According to the agreement data newspaper form from BOOTP_REC_BUF the extraction data, records this aircraft and main engine’s IP address.
3.2.2 data receiving and dispatching
Data receiving and dispatching is mainly involves IP, UDP and the ARP three important agreements, in realized specifically acts according to embedded system’s characteristic to make the reduction target-oriented, both has guaranteed the net mouth normal work, and has saved embedded system’s resources.
①Has the ethernet data packet arrival, first carries on the judgment. If is the ARP request transmits a ARP reply; If is ARP replies, then record transmitting end IP address and ethernet address; If is the IP data packet, then starts to receive the data.
②Receive data: The IP data packet arrival, the interrupt processing function places the data packet in receive frame descrptor RxFDBaseAddr, withdraws the IP package to put in receive buffer IP_REC_BUF. Withdraws the valid data from IP_REC_BUF to give the debugger to carry on processing.
③Transmission data: The transmission data encapsulation in the UDP data newspaper, the target machine IP address and the main engine IP address records separately in global variable MyIpAddr and HostIpAddr, adds on the UDP masthead and the IP masthead according to UDP and the IP agreement’s data newspaper form for the data. Takes the source physical address by this aircraft MAC address, obtains the main engine physical address by the ARP reply to take the destination address, seals the ether data frame, the transfer writes the function DrvEthWrite() transmission, interrupt processing function MAC_Tx_isr() carries on the transmission interrupt processing.
The part main signal procedure is as follows:
SendBootpRequest(bootp_id); /* transmits BOOTP to request that bootp_id is this request random distribution marking number */
/* waited for that the BOOTP reply wraps */
/*BOOTP reply package of arrival, from receive cushion BOOTP_REC_BUF extraction data */
memcpy(MyIpAddr, bhdr->your_ip,4); /* the extraction goal board’s IP address places in global variable MyIpAddr */
memcpy(HostIpAddr, bhdr->server_ip,4); /* the extraction main engine IP address places in global variable HostIpAddr */
/* inspection arrival package */
if(pro_type==ETHERTYPE_IP) IpProcess(IP_REC_BUF); /* processing arrival’s IP wraps */
if(pro_type==ETHERTYPE_ARP) ArpProcess(IP_REC_BUF,42); /* processing arrival’s ARP wraps */
4. conclusion
The procedure code which realizes with the C language has debugged passes, and succeeds applies in the embedded debugger. This functional module the net mouth actuation which and the agreement stack designs in view of the concrete development board, reduced the redundancy function part, both can satisfy the embedded system the request which takes to the resources, and can guarantee the data accurately, the non-loss transmission. The test proved that regarding batch data’s transmission, the net mouth’s speed surpasses the serial port by far, has realized between the main engine and target machine’s debugging correspondence effectively, has certain practical significance.
This article author innovates the spot: Designed and has realized the embedded debugger’s ethernet connection mailing address, has made the reduction in view of the concrete development tablet couplet net mouth actuation and the agreement stack, both could satisfy embedded system’s resources to take the request, and could guarantee the data highly effective transmission.
Reference:
[1] Qiao accommodates, Peng Sipeng, cypress cassia twigs. The embedded software sound code level overlapping debugger’s design with realizes. Ships electronic engineering .2004,24(3):56-59.
[2] Pang Ji is brave, Li Weiying, king unexpectedly. Network service processor S3C4510B net mouth actuation design. The monolithic integrated circuit and the embedded system apply .2004,(4):26-28.
[3] Hood Bin. Based on ucOSⅡOperating system’s embedded network server’s design with realizes. Micro computer information .2005,21(8-2):24-26.
the [4] invader approaches the splendor, Chen Li studies, peasant family forest. Designs based on the S3C44BOX ucLinux embedded ethernet and analyzes .2005,(35):
[5] generation of brave, Li Chang auspiciousness. Based on embedded ethernet connection data acquisition processing system. The microcomputer develops .2005,15(5):125-127.
[6]ADAM DUNKELS. “uIP-A Free Small TCP/IP Stack”. Sweden:Swedish Institute of Computer Science,2003