CN111475445A - Method and system for converting USB or UART data and Ethernet data - Google Patents

Method and system for converting USB or UART data and Ethernet data Download PDF

Info

Publication number
CN111475445A
CN111475445A CN202010576593.1A CN202010576593A CN111475445A CN 111475445 A CN111475445 A CN 111475445A CN 202010576593 A CN202010576593 A CN 202010576593A CN 111475445 A CN111475445 A CN 111475445A
Authority
CN
China
Prior art keywords
frame
usb
uart
data
computer
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010576593.1A
Other languages
Chinese (zh)
Inventor
胡文
黄金华
于嘉
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Aojie Technology Shanghai Co ltd
Original Assignee
Aojie Technology Shanghai Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Aojie Technology Shanghai Co ltd filed Critical Aojie Technology Shanghai Co ltd
Priority to CN202010576593.1A priority Critical patent/CN111475445A/en
Publication of CN111475445A publication Critical patent/CN111475445A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • G06F13/382Information transfer, e.g. on bus using universal interface adapter
    • G06F13/385Information transfer, e.g. on bus using universal interface adapter for adaptation of a particular data processing system to different peripheral devices
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • G06F13/42Bus transfer protocol, e.g. handshake; Synchronisation
    • G06F13/4282Bus transfer protocol, e.g. handshake; Synchronisation on a serial bus, e.g. I2C bus, SPI bus
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2213/00Indexing scheme relating to interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F2213/0002Serial port, e.g. RS232C
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2213/00Indexing scheme relating to interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F2213/0042Universal serial bus [USB]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2213/00Indexing scheme relating to interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F2213/38Universal adapter
    • G06F2213/3852Converter between protocols

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Small-Scale Networks (AREA)

Abstract

The application discloses a method for converting USB or UART data and Ethernet data. The sending end packages the data format of the Ethernet into the data format of USB or UART, and sets a frame delimiter; when a transmitting end packages, if an original bit combination which is the same as a frame delimiter or an escape character appears in an information field of a USB or UART frame, the escape character and a deformed bit combination are adopted for replacing. And the transmitting end transmits the packed USB or UART frame to the receiving end. The receiving end finds out the starting and ending positions of the USB or UART frame from the received bit stream according to the frame delimiter; if the escape character appears in the information field of the USB or UART frame, the escape character is restored to the original bit combination, thereby completing the unpacking of the data format of the USB or UART into the data format of the Ethernet. The application realizes the rapid and reliable conversion between the data formats.

Description

Method and system for converting USB or UART data and Ethernet data
Technical Field
The application relates to a method for data transmission between a computer and an embedded system, wherein the transmitted data is a firmware file of the embedded system.
Background
An embedded system (embedded system) is a computer system that contains processors, memory, input and/or output peripherals for performing specialized functions in a larger mechanical and/or electrical system. The memory of the embedded system stores a control program.
In mass production of the embedded system, firmware (firmware) needs to be programmed into memories such as NAND Flash (NAND Flash), NOR Flash (NOR Flash), eMMC (embedded multimedia card) and the like as an operating system object code. The firmware is a program solidified in a storage medium and determines the functions and performance of the embedded system. Generally, the firmware cannot be directly read or modified by a user after being written into the embedded system, and if data output is abnormal in the programming process, a product cannot be normally started, so that the programmed firmware is safe and reliable.
The existing embedded system generally adopts the USB mode to carry out mass production burning of firmware data.
The UART (universal asynchronous receiver-transmitter) standard works on the principle that each character of the transmitted data is transmitted bit by bit. Compared to the USB (universal serial bus) standard, the UART standard has the disadvantage of having no packet format and cannot support retransmission. However, the UART standard has simple and practical characteristics, and is often used as an important tool for debugging the system, so that it is also considered to upgrade firmware using the UART standard.
In order to support both USB and UART standards for firmware upgrade and also to provide reliable data transmission, the data format of ethernet (ethernet) was introduced for transmission. The Ethernet data transmission has an automatic error correction function, stable communication quality and is not easy to be interfered by the outside. In the firmware downloading process, the data format of the USB or UART is converted with the data format of the Ethernet, so that the downloading command and/or data for firmware upgrading are used as application layer data of a TCP/IP protocol, and are packaged and transmitted by the TCP/IP protocol. After the data packet of the Ethernet arrives at the receiving end, how the receiving end knows the start and the end of the data; and how to identify a plurality of different embedded systems accessed by a mass production host in the mass production process, all of which require a method of packaging (pack) and unpacking (unpack) to solve the conversion between the data format of USB or UART and the data format of ethernet.
Disclosure of Invention
The technical problem to be solved by the application is to provide a conversion method between a data format of a UART or USB standard and a data format of an Ethernet communication protocol, and the conversion method has the characteristics of accuracy, real time and stability.
In order to solve the above technical problem, the present application provides a method for converting between data of USB or UART and data of ethernet, including the following steps. Step S10: the method comprises the steps that a sending end packages the data format of Ethernet into the data format of USB or UART, and a frame delimiter is set in the frame structure of the packaged USB or UART and used for marking the start and the end of a USB or UART frame; when a transmitting end packages, if an original bit combination which is the same as a frame delimiter or an escape character appears in an information field of a USB or UART frame, the escape character and a deformed bit combination are adopted for replacing. Step S20: and the transmitting end transmits the packed USB or UART frame to the receiving end. Step S30: the receiving end finds out the starting and ending positions of the USB or UART frame from the received bit stream according to the frame delimiter; if the escape character appears in the information field of the USB or UART frame, the receiving end also reduces the escape character and the deformed bit combination into the original bit combination, thereby completing the unpacking of the data format of the USB or UART into the data format of the Ethernet. The method realizes the rapid and reliable conversion between the data formats.
Further, the sending end is a computer, and the receiving end is a target board card of an embedded system connected with the computer, or vice versa. This shows that the method is suitable for data transmission between a computer and a target board card of an embedded system.
Further, the computer is connected to the USB interfaces of one or more target boards through USB interfaces, and the USB interfaces of the target boards transmit data in a data format of UART standard or USB standard. This is a typical application scenario of the present application.
Furthermore, the USB interfaces all adopt mini USB interfaces. This helps to reduce the volume occupied by the USB interface.
Furthermore, the software architecture in the computer is that the computer production tool software is connected with a TCP/IP protocol layer, a serial transmission driving layer of a network interface, a serial transmission driving layer, a USB driving layer and a USB interface in turn; the conversion method is performed in a serial transmission driver layer of the network interface. This is an exemplary illustration of the software architecture of a computer.
Furthermore, a software architecture in a target board card of the embedded system is formed by connecting a TCP/IP protocol layer, a serial transmission driving layer of a network interface and a universal serial transmission driving layer in sequence from a target board card downloading program downwards; the conversion method is executed in a serial transmission driving layer of a network interface; the universal serial transmission driving layer simultaneously supports a UART driving layer and a USB driving layer; the UART driver layer and the USB driver layer are respectively connected with different USB interfaces. This is an exemplary illustration of the software architecture of the target board of the embedded system.
Furthermore, the data format is downloading command and/or data at the software level of the computer production tool and the downloading program level of the target board card. At the TCP/IP layer, an ethernet header, an IP header, and a TCP header are added in sequence before downloading the command and/or data fields, and the whole data format is an ethernet data format and is called an IP datagram. In a serial transmission driving layer of a network interface, a frame head is added before an IP datagram, a frame tail is added after the IP datagram, and the whole data format is that of a USB or UART. The specific contents of the various data formats and respectively at which layer are used are explained here.
Further, the USB or UART frame comprises a data frame, a text frame, a handshake frame and a handshake acknowledgement frame. The frame structure of the data frame comprises a frame head, an information field and a frame tail; the information field is an IP datagram. The frame structure of the text frame comprises a frame head, a protocol field, an information field and a frame tail; the protocol field records the protocol number of the text frame; the information portion records text data. The frame structure of the handshake frame comprises a frame head, a protocol field, an information field and a frame tail; the protocol field records the protocol number of the handshake frame; the information field records the MAC address of the local terminal. The frame structure of the handshake response frame comprises a frame head, a protocol field, an information field and a frame tail; the length of the protocol field records the protocol number of the handshake response frame; the information field records the MAC address of the remote end. In all USB or UART frame structures, a frame head and a frame tail adopt preset frame delimiters. This is a detailed description of the data format of the four types of USB or UART frames provided herein.
Further, in the text frame, the handshake frame, and the handshake response frame, the protocol field starts with a preset escape character, followed by the operation result after the protocol number performs the preset operation. In the information fields of the data frame and the text frame, a deformation bit combination is immediately followed by the escape character, and the deformation bit combination is obtained by carrying out preset operation on an original bit combination. This is an instruction for the use of escape characters in packing.
Further, when unpacking, the receiving end firstly obtains the start and end positions of each USB or UART frame according to the frame delimiter; then searching an escape character in each USB or UART frame; if the escape character exists, the escape character and the rear deformed bit combination thereof are restored to the original bit combination, and whether the escape character corresponds to a certain protocol number or not is judged, so that the type of the USB or UART frame is known; if no escape character is found, or the original bit combination after restoration is different from all protocol numbers, it is determined that this is a data frame. This is a description of the use of frame delimiters and escape characters in unpacking.
Further, the frame delimiter is 0x7E, the escape character is 0x7D, and the preset operation is the original bit combination exclusive-or 0x 20. This is a preferred example.
Further, the following steps are included in knowing each other's MAC address between the transmitting end and the receiving end through negotiation. Step S61: the computer is physically connected with a target board card of the embedded system, the target board card enters a USB or UART downloading mode, the target board card sends a handshake frame to the computer, and the information field is the MAC address of the target board card. Step S62: and the computer receives the handshake frame and stores the MAC address of the target board card. Step S63: and the computer sends a handshake response frame to the target board card, and the information field is the MAC address of the computer. Step S64: and the target board card receives the handshake response frame and stores the MAC address of the computer. Step S65: after the computer and the target board card both obtain the MAC address of the opposite terminal, the TCP/IP links of the upper layers of the computer and the target board card are established. The mass production tool software of the computer uses the IP datagram as the information field to pack the data frame of the USB or UART and sends the bit stream to the target board card. Step S66: and the target board card receives the bit stream, unpacks the bit stream from the data frame of the USB or UART to obtain the IP datagram, and performs the next processing. This can make the sending end and the receiving end mutually obtain the MAC address of the other side, which is convenient for the two sides to identify.
Further, the steps S61 to S64 are changed to steps S61a to S64 a. Step S61 a: the computer is physically connected with a target board card of the embedded system, and the target board card enters a USB or UART downloading mode; and the computer sends a handshake frame to the target board card, and the information field is the MAC address of the computer. Step S62 a: and the target board card receives the handshake frame and stores the MAC address of the computer. Step S63 a: and the target board sends a handshake response frame to the computer, and the information field is the MAC address of the target board. Step S64 a: and the computer receives the handshake response frame and stores the MAC address of the target board card. This is a variant implementation.
Further, the steps S65 to S66 are changed to step S65 a. Step S65 a: the target board card sends a data frame to the computer, and the information field of the data frame is an IP datagram; the IP datagram comprises reply information of a download command and/or data. And at the same time, sending the text frame to the computer for informing the computer of progress information or log programming, and recording the contents in the information field of the text frame. This is another variant implementation.
The application also provides a conversion system of the data of the USB or UART and the data of the Ethernet, which comprises a packing unit, a transmission unit and an unpacking unit. The packaging unit is used for packaging the data format of the Ethernet into the data format of the USB or UART, and a frame delimiter is set in the packaged USB or UART frame structure and used for marking the start and the end of one USB or UART frame; when the packing unit packs, if the original bit combination same as the frame delimiter or the escape character appears in the information field of the USB or UART frame, the escape character and the deformed bit combination are adopted for replacing. And the transmission unit is used for sending the packed USB or UART frame to the unpacking unit. The unpacking unit is used for finding out the positions of the start and the end of the USB or UART frame from the received bit stream according to the frame delimiter; if the information field of the USB or UART frame has a preset escape character, the unpacking unit also restores the escape character and the deformed bit combination into an original bit combination, thereby completing the unpacking of the data format of the USB or UART into the data format of the Ethernet
The technical effect that this application obtained is: a serial transmission driving layer with a network interface is additionally designed between a serial transmission driving layer (or a universal serial transmission driving layer) and a TCP/IP protocol layer and is used for converting the data format of the USB or the UART and the data format of the Ethernet. The serial transmission driving layer has expandability and can support various standards of serial transmission, such as USB, UART and the like, and various data of serial transmission can be converted into a unified data frame structure of USB or UART through the application, so that data transmission is carried out between devices. The method and the device have the advantages of high real-time performance, high stability and high expansibility in data transmission (for example, for firmware upgrading).
Drawings
Fig. 1 is a flowchart of a method for converting USB or UART data format to ethernet data format according to the present invention.
Fig. 2 is a schematic diagram of the hardware connection between the computer and the target board of the embedded system.
Fig. 3 is a schematic diagram of a data format corresponding to each layer.
Fig. 4 is a schematic diagram of a structure of a data frame of a USB or UART.
Fig. 5a to 5c are schematic diagrams illustrating structures of three special frames of USB or UART.
Fig. 6 is a flowchart for knowing each other's MAC address through negotiation between a computer and a connected embedded system.
Fig. 7 is a schematic structural diagram of a conversion system between USB or UART data format and ethernet data format according to the present application.
The reference numbers in the figures illustrate: 10 is a packing unit; 20 is a transmission unit; and 30 is an unpacking unit.
Detailed Description
Referring to fig. 1, the method for converting between the data format of USB or UART and the data format of ethernet according to the present application includes the following steps.
Step S10: the method comprises the steps that a sending end packages the data format of the Ethernet into the data format of the USB or UART, and a frame delimiter is set in the frame structure of the packaged USB or UART and used for marking the start and the end of a USB or UART frame. When a transmitting end packages, if an original bit combination which is the same as a frame delimiter or an escape character appears in a USB or UART frame, the escape character and a deformed bit combination are adopted to replace the original bit combination.
Step S20: and the transmitting end transmits the packed USB or UART frame to the receiving end.
Step S30: the receiving end accurately finds out the start and end positions of the USB or UART frame from the received bit stream according to the frame delimiter. If the preset escape character appears in the USB or UART frame, the receiving end also reduces the escape character and the deformed bit combination into the original bit combination, thereby completing the unpacking of the data format of the USB or UART into the data format of the Ethernet.
The sending end is, for example, a computer, and the receiving end is, for example, a target board card of an embedded system connected to the computer, or vice versa.
Please refer to fig. 2, which is a typical application scenario of the present application. The computer is provided with mass production tool software, a downloading program is installed in a target board card of the embedded system, the computer is connected to a USB hub (hub) through a USB interface, and the USB hub is connected to the USB interfaces of one or more target board cards. The USB hub is not necessary, and the computer can be directly connected with the USB interfaces of one or more target boards through the USB interfaces. Two USB interfaces to connect to the target board are exemplarily shown in fig. 2. The first USB interface transmits data in a data format of UART standard, and the peripheral circuit converts the USB data format and the UART data format, which is not shown in fig. 2. And the second USB interface transmits data by adopting a data format of a USB standard. In other embodiments, only one USB interface of the target board may be connected, and a data format of the UART standard or the USB standard may be adopted. Preferably, the USB interfaces are mini USB interfaces, so that the size of the interfaces is reduced.
The software architecture in the computer is formed by connecting a TCP/IP protocol layer, a serial transmission driving layer of a network interface, a serial transmission driving layer, a USB driving layer and a USB interface in sequence from the bottom to the bottom by computer production tool software. The conversion method between the data format of USB or UART and the data format of ethernet proposed in the present application is performed, for example, in the serial transmission driver layer of the network interface.
The software architecture in the target board card of the embedded system is that a target board card downloading program is connected with a TCP/IP protocol layer, a serial transmission driving layer of a network interface and a universal serial transmission driving layer in sequence. The conversion method between the data format of USB or UART and the data format of ethernet proposed in the present application is performed, for example, in the serial transmission driver layer of the network interface. The universal serial transmission driving layer simultaneously supports a UART driving layer and a USB driving layer. Then divided into two paths downwards; one path is a UART driving layer and a USB interface I; the other path is a USB driving layer and a USB interface II.
As can be seen from fig. 2, in the present application, a serial transmission driver layer with a network interface is added between a serial transmission driver layer (or a universal serial transmission driver layer) and a TCP/IP protocol layer of a target board of a computer and an embedded system, so as to implement the functions of packetization and depacketization, that is, to perform conversion between a data format of a USB or UART and a data format of an ethernet.
Referring to fig. 3, at the software level of the computer production tool and the downloading program level of the target board, the data format is downloading command and/or data. At the TCP/IP layer, an ethernet header, an IP header, and a TCP header are added in sequence before downloading the command and/or data fields, and the whole data format is the data format of the ethernet, which is called an IP Datagram (IP Datagram). In a serial transmission driving layer of a network interface, a frame head is added before an IP datagram, a frame tail is added after the IP datagram, and the whole data format is the data format of USB or UART.
Please refer to fig. 4, which shows the data frame of the USB or UART according to the present invention. The frame structure of the data frame includes a frame header, an information field, and a frame trailer. The frame head and the frame tail adopt preset frame delimiters. The present application exemplarily adopts 0x7E with a length of one byte (byte) as a frame delimiter for marking the start and end of a data frame of the USB or UART, so that the receiving end can accurately find the start and end positions of the data frame of the USB or UART from the received bit stream. Where 0x represents a hexadecimal number. The information field is an IP datagram of the ethernet protocol.
Referring to fig. 2 to 4, the data frame is a download command and/or data sent by software or a program of the sending end, and an IP datagram is formed downward through a TCP/IP layer, and is converted into a data frame of a USB or UART through a serial transmission driving layer of a network interface, and then is converted into an IP datagram through layer-by-layer transmission to reach a serial transmission driving layer of a network interface of the receiving end, and all headers are removed upward through the TCP/IP layer to obtain the download command and/or data, and then the download command and/or data are received and processed upward by the software or the program of the receiving end.
Besides the data frame, the application also designs three special frames of USB or UART, namely a text frame, a handshake frame and a handshake response frame. Different from the data frame, the three special frames are initiated by the serial transmission driving layer of the network interface of the sending end and finally reach the serial transmission driving layer of the network interface of the receiving end. The special frame does not reach the TCP/IP layer and the higher software or program layers of the sender or receiver.
Referring to fig. 5a, the frame structure of the text frame includes a frame head, a protocol field, an information field, and a frame end. The frame head and the frame tail adopt preset frame delimiters. The length of the protocol field is, for example, two bytes, and the protocol number 0x1 of the text frame is recorded. The information portion records text data.
Referring to fig. 5b, the frame structure of the handshake frame includes a frame head, a protocol field, an information field, and a frame end. The frame head and the frame tail adopt preset frame delimiters. The length of the protocol field is, for example, two bytes, and the protocol number 0x2 of the handshake frame is recorded. The information field records the MAC address of the home terminal, and has a length of 6 bytes, for example.
Referring to fig. 5c, the frame structure of the handshake acknowledgement frame includes a frame header, a protocol field, an information field, and a frame trailer. The frame head and the frame tail adopt preset frame delimiters. The length of the protocol field is, for example, two bytes, and the protocol number 0x3 of the handshake reply frame is recorded. The information field records the MAC address of the remote end, which is, for example, 6 bytes in length.
Preferably, in the text frame, handshake frame and handshake reply frame, the protocol field starts with a preset escape character, for example 0x7D, as the content of the first byte of the protocol field. The protocol number recorded in the protocol field is exclusive-ored with 0x20 to obtain the second byte of the protocol field.
When unpacking, a serial transmission driving layer (or a universal serial transmission driving layer) of a receiving end firstly obtains the start and end positions of each USB or UART frame according to a frame delimiter; then searching an escape character in each USB or UART frame; if the escape character exists, the escape character and the deformed bit combination behind the escape character are restored to the original bit combination, and whether the escape character corresponds to a certain protocol number or not is judged, so that the type of the frame is decoded. If no escape character is found, or the original bit combination after restoration is different from all protocol numbers, it is determined that this is a data frame.
The following describes the steps S10 and S30 with a specific example. In order to ensure the transparency of data transmission, the sender may find that the original bit combination 0x7E, which is the same as the frame delimiter, appears in the information field of the data frame or the text frame when packing. At this time, the sender converts the original bit combination 0x7E into 0x7D and 0x5E, where 0x7D is a preset escape character, and 0x5E is a modified bit combination obtained by xoring the original bit combination 0x7E or 0x 20. Similarly, when the sender packs, if it finds that the original bit combination 0x7D identical to the escape character appears in the information field of the data frame or text frame, the original bit combination 0x7D is converted into 0x7D and 0x5D, 0x7D is the preset escape character, and 0x5D is the original bit combination 0x7D or the deformed bit combination 0x 20. In the unpacking process, if 0x7D and 0x5E are found to be continuously present in the bit stream, the receiving end restores the bit stream to the original bit combination of 0x 7E. If 0x7D and 0x5D are found to be present in the bitstream consecutively, they are restored to the original bit combination 0x 7D.
In order to ensure the transparency of data transmission, the present application also provides a mechanism for the sender and the receiver to know each other's MAC (media access control) address through negotiation. Specifically, the MAC addresses of the computer and the target boards of the connected embedded systems are known through negotiation, so that the computer can distinguish the target boards of different embedded systems simultaneously accessed in mass production by using different MAC addresses.
Referring to fig. 6, this is an example of knowing MAC addresses of a computer and a target board card of a connected embedded system through negotiation, and taking mass production of firmware burning from the computer to the target board card of the embedded system as an example, the following steps are included.
Step S61: the computer is physically connected with a target board card of the embedded system, the target board card enters a USB or UART downloading mode, the target board card sends a handshake frame to the computer, and the information field is the MAC address of the target board card.
Step S62: and the computer receives the handshake frame and stores the MAC address of the target board card.
Step S63: and the computer sends a handshake response frame to the target board card, and the information field is the MAC address of the computer.
Step S64: and the target board card receives the handshake response frame and stores the MAC address of the computer.
Step S65: after the computer and the target board card both obtain the MAC address of the opposite terminal, the TCP/IP links of the upper layers of the computer and the target board card are established. The mass production tool software of the computer uses the IP datagram as the information field to pack the data frame of the USB or UART and sends the bit stream to the target board card.
Step S66: and the target board card receives the bit stream, unpacks the bit stream, obtains the IP datagram, obtains the download command and/or data in the IP datagram, and performs the next processing. The download command is, for example, to request the target board to receive the firmware file. The downloaded data is, for example, a firmware file stored in the computer and applicable to the target board.
Alternatively, the steps S61 to S64 may be changed to the steps S61a to S64 a.
Step S61 a: the computer is physically connected with a target board card of the embedded system, and the target board card enters a USB or UART downloading mode. And the computer sends a handshake frame to the target board card, and the information field is the MAC address of the computer.
Step S62 a: and the target board card receives the handshake frame and stores the MAC address of the computer.
Step S63 a: and the target board sends a handshake response frame to the computer, and the information field is the MAC address of the target board.
Step S64 a: and the computer receives the handshake response frame and stores the MAC address of the target board card.
Alternatively, the steps S65 to S66 may be changed to step S65 a.
Step S65 a: the target board sends data frames to the computer, and the information fields of the data frames are IP datagrams. The IP datagram includes reply information of the download command and/or data, for example, reply information of the client in the fastboot download protocol. And simultaneously, the target board sends a text frame to the computer, the function of the target board is to inform the computer of progress information or write logs, and the contents are recorded in the information field of the text frame.
Referring to fig. 7, the system for converting the data format of USB or UART and the data format of ethernet according to the present invention includes a packing unit 10, a transmission unit 20 and an unpacking unit 30.
The packetizing unit 10 is configured to packetize the data format of the ethernet into the data format of the USB or UART, and set a frame delimiter in the frame structure of the packetized USB or UART to mark the start and end of a USB or UART frame. When the packing unit 10 is used for packing, if the original bit combination identical to the frame delimiter or the escape character appears in the USB or UART frame, the escape character and the deformed bit combination are adopted to replace the original bit combination.
The transmission unit 20 is used to send the packed USB or UART frames to the unpacking unit 30.
The unpacking unit 30 is used to find out the positions of the beginning and the end of the USB or UART frame from the received bit stream according to the frame delimiter. If the USB or UART frame is found to have the preset escape character, the unpacking unit 30 further reduces the escape character and the distorted bit combination to the original bit combination, thereby completing the unpacking of the data format of the USB or UART to the data format of the ethernet.
The packing unit 10 is, for example, a computer, and the unpacking unit 30 is a target board of an embedded system connected to the computer, or vice versa.
The above are merely preferred embodiments of the present application and are not intended to limit the present application. Various modifications and changes may occur to those skilled in the art. Any modification, equivalent replacement, improvement and the like made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims (15)

1. A conversion method between data of USB or UART and data of Ethernet is characterized in that the method comprises the following steps;
step S10: the method comprises the steps that a sending end packages the data format of Ethernet into the data format of USB or UART, and a frame delimiter is set in the frame structure of the packaged USB or UART and used for marking the start and the end of a USB or UART frame; when a transmitting end packages, if an original bit combination which is the same as a frame delimiter or an escape character appears in an information field of a USB or UART frame, the escape character and a deformed bit combination are adopted for replacing;
step S20: the transmitting end transmits the packed USB or UART frame to the receiving end;
step S30: the receiving end finds out the starting and ending positions of the USB or UART frame from the received bit stream according to the frame delimiter; if the escape character appears in the information field of the USB or UART frame, the receiving end also reduces the escape character and the deformed bit combination into the original bit combination, thereby completing the unpacking of the data format of the USB or UART into the data format of the Ethernet.
2. The method of claim 1, wherein the transmitting end is a computer, and the receiving end is a target board of an embedded system connected to the computer, or vice versa.
3. The method as claimed in claim 2, wherein the computer is connected to the USB interface of one or more target boards through USB interfaces, and the USB interface of the target board transmits data in data format of UART standard or USB standard.
4. The method for converting between USB or UART data and Ethernet data according to claim 3, wherein the USB interfaces are mini USB interfaces.
5. The method for converting between USB or UART data and Ethernet data according to claim 3, wherein the software architecture in the computer is formed by connecting a TCP/IP protocol layer, a serial transmission driver layer of a network interface, a serial transmission driver layer, a USB driver layer and a USB interface in sequence from the bottom to the top by computer production tool software; the conversion method is performed in a serial transmission driver layer of the network interface.
6. The method for converting between USB or UART data and Ethernet data according to claim 3, wherein the software architecture of the target board card of the embedded system is that the target board card downloads a program and connects sequentially to the TCP/IP protocol layer, the serial transmission driver layer of the network interface, and the USB driver layer; the conversion method is executed in a serial transmission driving layer of a network interface; the universal serial transmission driving layer simultaneously supports a UART driving layer and a USB driving layer; the UART driver layer and the USB driver layer are respectively connected with different USB interfaces.
7. The method for converting between USB or UART data and Ethernet data according to claim 5 or 6, wherein the data format is download command and/or data at the software level of the computer production tool and the downloading program level of the target board card;
in a TCP/IP layer, an Ethernet header, an IP header and a TCP header are sequentially added before a command and/or data field is downloaded, and the whole data format is an Ethernet data format and is called an IP datagram;
in a serial transmission driving layer of a network interface, a frame head is added before an IP datagram, a frame tail is added after the IP datagram, and the whole data format is that of a USB or UART.
8. The method of claim 7, wherein the USB or UART frame comprises a data frame, a text frame, a handshake reply frame;
the frame structure of the data frame comprises a frame head, an information field and a frame tail; the information field is an IP datagram;
the frame structure of the text frame comprises a frame head, a protocol field, an information field and a frame tail; the protocol field records the protocol number of the text frame; the information part records text data;
the frame structure of the handshake frame comprises a frame head, a protocol field, an information field and a frame tail; the protocol field records the protocol number of the handshake frame; the information field records the MAC address of the local terminal;
the frame structure of the handshake response frame comprises a frame head, a protocol field, an information field and a frame tail; the length of the protocol field records the protocol number of the handshake response frame; the information field records the MAC address of the remote end;
in all USB or UART frame structures, a frame head and a frame tail adopt preset frame delimiters.
9. The method for converting between data of USB or UART and data of ethernet according to claim 8, wherein in the text frame, the handshake frame and the handshake response frame, the protocol field starts with a predetermined escape character, followed by the operation result after the predetermined operation of the protocol number;
in the information fields of the data frame and the text frame, a deformation bit combination is immediately followed by the escape character, and the deformation bit combination is obtained by carrying out preset operation on an original bit combination.
10. The method for converting between USB or UART data and ethernet data according to claim 9, wherein the receiving end first knows the start and end positions of each USB or UART frame according to a frame delimiter when unpacking the data; then searching an escape character in each USB or UART frame; if the escape character exists, the escape character and the deformed bit combination behind the escape character are restored to the original bit combination, and whether the escape character corresponds to a certain protocol number or not is judged, so that the type of the USB or UART frame is known; if no escape character is found, or the original bit combination after restoration is different from all protocol numbers, it is determined that this is a data frame.
11. The method of claim 9, wherein the frame delimiter is 0x7E, the escape character is 0x7D, and the predetermined operation is xor 0x 20.
12. The method of claim 1, wherein the step of knowing each other's MAC address between the transmitting end and the receiving end through negotiation comprises the steps of;
step S61: the method comprises the following steps that physical connection is achieved between a computer and a target board card of an embedded system, the target board card enters a USB or UART downloading mode, the target board card sends a handshake frame to the computer, and an information field is an MAC address of the target board card;
step S62: the computer receives the handshake frame and stores the MAC address of the target board card;
step S63: the computer sends a handshake response frame to the target board card, and the information field is the MAC address of the computer;
step S64: the target board card receives the handshake response frame and stores the MAC address of the computer;
step S65: after the computer and the target board card both obtain the MAC address of the opposite terminal, both establish the TCP/IP link of the upper layer of each; the mass production tool software of the computer uses the IP datagram as an information field to pack into a data frame of USB or UART, and sends bit stream to a target board card;
step S66: and the target board card receives the bit stream, unpacks the data frame of the USB or UART to obtain the IP datagram, and performs the next processing.
13. The method for converting between data of USB or UART and data of Ethernet according to claim 12, wherein the steps S61 to S64 are changed to steps S61a to S64 a;
step S61 a: the computer is physically connected with a target board card of the embedded system, and the target board card enters a USB or UART downloading mode; the computer sends a handshake frame to the target board card, and the information field is the MAC address of the computer;
step S62 a: the target board card receives the handshake frame and stores the MAC address of the computer;
step S63 a: the target board card sends a handshake response frame to the computer, and the information field is the MAC address of the target board card;
step S64 a: and the computer receives the handshake response frame and stores the MAC address of the target board card.
14. The method for converting between data of USB or UART and data of ethernet according to claim 12, wherein the steps S65 to S66 are changed to step S65 a;
step S65 a: the target board card sends a data frame to the computer, and the information field of the data frame is an IP datagram; the IP datagram comprises a download command and/or reply information of data; the target board also sends a text frame to the computer at the same time, and the text frame is used for notifying the computer of progress information or writing logs, and the contents are recorded in an information field of the text frame.
15. A conversion system of data of USB or UART and data of Ethernet is characterized by comprising a packing unit, a transmission unit and an unpacking unit;
the packaging unit is used for packaging the data format of the Ethernet into the data format of the USB or UART, and a frame delimiter is set in the packaged USB or UART frame structure and used for marking the start and the end of one USB or UART frame; when the packing unit packs, if an original bit combination which is the same as a frame delimiter or an escape character appears in an information field of a USB or UART frame, the escape character and a deformed bit combination are adopted for replacing;
the transmission unit is used for sending the packed USB or UART frame to the unpacking unit;
the unpacking unit is used for finding out the positions of the start and the end of the USB or UART frame from the received bit stream according to the frame delimiter; if the information field of the USB or UART frame is found to have the preset escape character, the unpacking unit also restores the escape character and the deformed bit combination into the original bit combination, thereby completing the unpacking of the data format of the USB or UART into the data format of the Ethernet.
CN202010576593.1A 2020-06-23 2020-06-23 Method and system for converting USB or UART data and Ethernet data Pending CN111475445A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010576593.1A CN111475445A (en) 2020-06-23 2020-06-23 Method and system for converting USB or UART data and Ethernet data

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010576593.1A CN111475445A (en) 2020-06-23 2020-06-23 Method and system for converting USB or UART data and Ethernet data

Publications (1)

Publication Number Publication Date
CN111475445A true CN111475445A (en) 2020-07-31

Family

ID=71763954

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010576593.1A Pending CN111475445A (en) 2020-06-23 2020-06-23 Method and system for converting USB or UART data and Ethernet data

Country Status (1)

Country Link
CN (1) CN111475445A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114389895A (en) * 2022-02-15 2022-04-22 北京国基科技股份有限公司 Ethernet frame secure transmission method, device and system
CN115174496A (en) * 2022-05-23 2022-10-11 北京大学 Processing terminal and switch for intra-network aggregation transmission
CN116112356A (en) * 2023-02-06 2023-05-12 星河智联汽车科技有限公司 Configuration system, data transmission method and medium of vehicle-mounted USB port virtual Ethernet

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103118441A (en) * 2011-11-17 2013-05-22 中兴通讯股份有限公司 Terminal expanding device and system and method
CN105162792A (en) * 2015-09-23 2015-12-16 苏州昭创光电技术有限公司 USB network card and Ethernet data conversion method
CN109861795A (en) * 2019-02-28 2019-06-07 广州小鹏汽车科技有限公司 CANFD bus system sampled point configures and test method and corresponding data transmission method

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103118441A (en) * 2011-11-17 2013-05-22 中兴通讯股份有限公司 Terminal expanding device and system and method
CN105162792A (en) * 2015-09-23 2015-12-16 苏州昭创光电技术有限公司 USB network card and Ethernet data conversion method
CN109861795A (en) * 2019-02-28 2019-06-07 广州小鹏汽车科技有限公司 CANFD bus system sampled point configures and test method and corresponding data transmission method

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114389895A (en) * 2022-02-15 2022-04-22 北京国基科技股份有限公司 Ethernet frame secure transmission method, device and system
CN114389895B (en) * 2022-02-15 2024-01-23 北京国基科技股份有限公司 Ethernet frame safe transmission method, device and system
CN115174496A (en) * 2022-05-23 2022-10-11 北京大学 Processing terminal and switch for intra-network aggregation transmission
CN115174496B (en) * 2022-05-23 2024-02-13 北京大学 Processing terminal and switch for intra-network combined transmission
CN116112356A (en) * 2023-02-06 2023-05-12 星河智联汽车科技有限公司 Configuration system, data transmission method and medium of vehicle-mounted USB port virtual Ethernet

Similar Documents

Publication Publication Date Title
CN111475445A (en) Method and system for converting USB or UART data and Ethernet data
US6987961B1 (en) Ethernet emulation using a shared mailbox between two processors in a feature phone
CN102681957B (en) Enhanced wireless USB protocol and hub
EP2005656B1 (en) Methods of resolving datagram corruption over an internetworking protocol
KR102173089B1 (en) Interface circuit and packet transmission method thereof
US12021955B2 (en) Method and apparatus for processing data in a network
US9325519B2 (en) Distributed proxy for bi-directional network connectivity over point-to-point connection
US20090286489A1 (en) Wireless Communications Between Wired Devices with Adaptive Data Rates
TW201009588A (en) Information processing apparatus, information processing system, method of processing information, and computer program
JP4541949B2 (en) Data transfer device
US7680944B1 (en) Rapid transport service in a network to peripheral device servers
US20230147131A1 (en) Data transmission method, apparatus, and system
KR100578080B1 (en) Sending and Receiving Method of Command and Data in Serial Transmission Protocol
CN111416778B (en) Single serial port gateway platform for multi-device Internet of things
JP2007088775A (en) Radio communication system, device, and method
EP4175231A1 (en) Message processing method, network device and related device
CN112346665B (en) PCIE-based communication method, device, equipment, system and storage medium
CN101212480B (en) Method and apparatus for communication between universal serial bus (USB) host and USB device
US7822040B2 (en) Method for increasing network transmission efficiency by increasing a data updating rate of a memory
CN109800202B (en) PCIE (peripheral component interface express) -based data transmission system, method and device
US5948079A (en) System for non-sequential transfer of data packet portions with respective portion descriptions from a computer network peripheral device to host memory
CN115604070A (en) Message transmission method, device, equipment and medium based on MCTP (Multi-function peripheral protocol)
CN111371799A (en) Method, device and equipment for controlling data transmission and reception of MCTP (Multi-channel media processing protocol) controller
JP4581925B2 (en) Data transfer apparatus and data transfer method
CN114172897B (en) Method and system for transmitting files of PC (personal computer) end and Android end

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20200731