Transmission method of general purpose serial bus instruction and related electronic device
By temporarily storing and aggregating USB commands in memory, the number of handshakes is reduced, solving the performance degradation problem caused by frequent read and write operations of USB devices in the prior art, and achieving more efficient USB command transmission.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- REALTEK SEMICON CORP
- Filing Date
- 2021-12-07
- Publication Date
- 2026-07-14
AI Technical Summary
In the prior art, frequent read and write operations of USB devices in certain states lead to a decrease in the performance of electronic devices, mainly due to the excessive number of handshakes in receiving and processing confirmation information.
By configuring a temporary storage area in the memory to temporarily store the control transmission information of USB commands, and then aggregating these commands under certain conditions and transmitting them all at once, the number of times confirmation information is exchanged is reduced.
By reducing the number of times confirmation information is exchanged, the performance of electronic devices is improved, while processing time and computing resource consumption are reduced.
Smart Images

Figure CN116243973B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to Universal Serial Bus (USB), and more particularly to a method for transmitting USB commands and related electronic devices. Background Technology
[0002] In existing technology, the host-side USB controller operates the USB device by sending USB commands. See also... Figure 1 , Figure 1 This diagram illustrates how the host sends USB commands and receives acknowledgments (ACK). Figure 1 As shown, for each USB command (e.g., control transfer command) (CMD_A, CMD_B, CMD_C, and CMD_D) sent by the application layer on the host side to the hardware layer, it must wait for an acknowledgment (ACK) message returned by the hardware layer (e.g., ACK_A, ACK_B, ACK_C, and ACK_D, corresponding to the USB commands CMD_A, CMD_B, CMD_C, and CMD_D, respectively). Each ACK message represents one handshake process. Therefore, when the USB controller performs multiple operations on the USB device consecutively, time is spent receiving and processing these acknowledgment messages, resulting in degraded performance of the electronic device. Especially when the USB device requires frequent read and write operations in certain states (e.g., initialization, waking up from sleep), a more efficient method is needed to reduce the number of bus I / O requests. Summary of the Invention
[0003] In view of the shortcomings of the prior art, one object of the present invention is to provide a method for transmitting USB commands and related electronic devices to improve the shortcomings of the prior art.
[0004] An embodiment of the present invention provides an electronic device for transmitting USB commands, comprising: a USB controller, a memory, and a computing circuit. The memory stores a plurality of program codes or program instructions. The computing circuit executes the program codes or program instructions to perform the following steps: (A) configuring a temporary storage area in the memory; (B) receiving a USB command; (C) loading control transfer information of the USB command; (D) storing the control transfer information in the temporary storage area; (E) re-executing steps (B) to (D) until a condition for ending control aggregation is met; (F) generating an aggregated USB command based on the contents of the temporary storage area; and (G) transmitting the aggregated USB command to the USB controller.
[0005] Another embodiment of the present invention provides a method for transmitting a USB command, comprising: (A) configuring a temporary storage area in a memory; (B) receiving a USB command; (C) loading control transmission information of the USB command; (D) storing the control transmission information in the temporary storage area; (E) re-executing steps (B) to (D) until a condition for ending control aggregation is met; (F) generating an aggregated USB command based on the contents of the temporary storage area; and (G) transmitting the aggregated USB command.
[0006] The USB command transmission method and related electronic device of the present invention can aggregate multiple USB commands to reduce the number of handshakes for confirmation information. Compared with the prior art, the USB command transmission method and related electronic device of the present invention do not spend a lot of time on information handshakes, thus improving performance.
[0007] The features, practical operation, and effects of this invention are described in detail below with reference to the accompanying drawings. Attached Figure Description
[0008] Figure 1 A diagram showing the host sending USB commands and receiving confirmation messages;
[0009] Figure 2 This is a functional block diagram of an embodiment of the electronic device of the present invention;
[0010] Figure 3 This is a schematic diagram of one embodiment of the controlled polymerization of the present invention;
[0011] Figure 4 This is a flowchart of an embodiment of the USB command transmission method of the present invention;
[0012] Figure 5 An example showing the contents of the temporary storage area;
[0013] Figure 6 Showing step S255, a sub-step of step S250; and
[0014] Figure 7 This is a schematic diagram of another embodiment of the controlled polymerization of the present invention. Detailed Implementation
[0015] The technical terms used in the following description are based on the customary terms in this technical field. If this specification provides explanations or definitions for certain terms, the explanations or definitions in this specification shall prevail.
[0016] The disclosure of this invention includes a method for transmitting USB commands and related electronic devices. Since some components of the electronic device of this invention may be known individually, details of known components will be omitted in the following description without affecting the full disclosure and implementability of the invention. Furthermore, part or all of the process of the USB command transmission method of this invention can be in the form of software and / or firmware, and can be executed by the electronic device of this invention or its equivalent. Without affecting the full disclosure and implementability of the method invention, the following description of the method invention will focus on the steps rather than the hardware.
[0017] Figure 2 This is a functional block diagram of an embodiment of the electronic device of the present invention. The electronic device 100 includes a computing circuit 120, a memory 140, and a USB controller 160. The computing circuit 120, memory 140, and USB controller 160 are coupled to each other. The memory 140 includes a temporary storage area 145. In some embodiments, the electronic device 100 acts as a host device and communicates or collaborates with a USB device (not shown) using the USB controller 160. For example, the computing circuit 120 may be a processor, microprocessor unit, digital signal processor, application-specific integrated circuit (ASIC), or equivalent circuit of a computer, tablet, or mobile phone, and the computing circuit 120 communicates with a network interface card (NIC) (i.e., a USB device) via the USB controller 160 to transmit or receive network packets.
[0018] The memory 140 stores program code or program instructions, which the computing circuit 120 executes to implement some or all of the functions of the electronic device 100. The program code or program instructions stored in the memory 140 include the firmware of the USB controller 160, which the computing circuit 120 also executes to control the USB controller 160. For example, when the application layer executed by the computing circuit 120 issues a USB command, the firmware of the USB controller 160 controls the USB controller 160 to perform corresponding operations (e.g., read, write, transmit, receive, etc.) according to the USB command.
[0019] Figure 3 This is a schematic diagram of an embodiment of the control aggregation of the present invention. Figure 4 This is a flowchart illustrating an embodiment of the USB command transmission method of the present invention, comprising the following steps. Please refer to the following description as well. Figures 2 to 4 .
[0020] Step S210: The computing circuit 120 (more specifically, the firmware of the USB controller 160 executed by the computing circuit 120) receives a control aggregation request. In some embodiments, the control aggregation request is issued by an application program (application layer) executed by the computing circuit 120.
[0021] Step S220: The computing circuit 120 (more specifically, the firmware of the USB controller 160 executed by the computing circuit 120) initializes the control aggregation. In some embodiments, step S220 includes sub-step S225: The computing circuit 120 (more specifically, the firmware of the USB controller 160 executed by the computing circuit 120) configures a temporary storage area 145 in the memory 140, sets a timeout length (or timeout value), and / or sets an instruction count threshold. The temporary storage area 145 is used to temporarily store USB instructions; that is, when the firmware of the USB controller 160 receives a USB instruction, it can first temporarily store the USB instruction in the temporary storage area 145, instead of immediately controlling the USB controller 160 to process the USB instruction. Figure 3 As shown in the example, when the firmware of the USB controller 160 receives USB commands CMD_1, CMD_2, and CMD_3 at time points T1, T2, and T3 respectively, the firmware of the USB controller 160 temporarily does not issue USB commands. Instead, it executes the control aggregation program 200, and then issues the aggregated USB command CMD_agg at time point T5. The control aggregation program 200 includes steps S240 and S250, which will be discussed in detail below.
[0022] Step S230: The computing circuit 120 (more specifically, the firmware of the USB controller 160 executed by the computing circuit 120) determines whether to terminate the control aggregation program 200. In some embodiments, the firmware of the USB controller 160 terminates the control aggregation program 200 and generates the aggregated USB instruction CMD_agg (step S260) when any of the following conditions are met (i.e., the result of step S230 is yes): (1) the buffer 145 is full (i.e., there is no available space or the available space is insufficient to store more USB instructions (e.g., control transfer information for storing USB instructions)); (2) a timeout occurs; (3) an instruction to flush the buffer 145 is received; or (4) the number of USB instructions currently buffered in the buffer 145 is greater than the instruction count threshold. In some embodiments, when none of the above conditions (1) to (4) are met (i.e., the result of step S230 is no), the firmware of the USB controller 160 continues to execute the control aggregation program 200 (i.e., continues to execute steps S240 and S250).
[0023] In some embodiments, conditions (2) and (4) can be achieved using a timer and a counter, respectively. For example, for condition (2), the firmware of the USB controller 160 can time and control the execution time of the aggregation program 200; when the execution time exceeds the timeout value, the result of step S230 is yes. As another example, for condition (4), the firmware of the USB controller 160 increments the counter value by 1 each time step S240 is executed; when the counter value exceeds the instruction count threshold, the result of step S230 is yes.
[0024] Step S240: The computing circuit 120 (more specifically, the firmware of the USB controller 160 executed by the computing circuit 120) receives USB commands issued by the application layer. For example... Figure 3 As shown in the example, step S240 occurs at time point T1 (receiving USB command CMD_1), time point T2 (receiving USB command CMD_2), or time point T3 (receiving USB command CMD_3).
[0025] Step S250: The computing circuit 120 (more specifically, the firmware of the USB controller 160 executed by the computing circuit 120) loads the control transfer information of the USB command and stores the control transfer information in the temporary storage area 145. The control transfer information includes the type of USB command (e.g., read command, write command, or control command), address (e.g., read address or write address), and data (e.g., data to be written, control data). Figure 5Here's an example showing the contents of scratchpad 145. The aggregation header can represent the type of USB command. The scratchpad address can represent the address of the USB command. The scratchpad data can represent the data of the USB command. Reserved bytes can represent or specify the type of scratchpad (e.g., a physical layer scratchpad or a media access control layer scratchpad).
[0026] More specifically, such as Figure 3 and Figure 5 As shown in the example, after receiving the USB command CMD_1 (i.e., time point T1), the firmware of the USB controller 160 first loads the control transmission information of the USB command CMD_1, and then stores the control transmission information in columns 1 to 4 of the temporary storage area 145; after receiving the USB command CMD_2 (i.e., time point T2), the firmware of the USB controller 160 first loads the control transmission information of the USB command CMD_2, and then stores the control transmission information in columns 5 to 8 of the temporary storage area 145; after receiving the USB command CMD_3 (i.e., time point T3), the firmware of the USB controller 160 first loads the control transmission information of the USB command CMD_3, and then stores the control transmission information in columns 9 to 12 of the temporary storage area 145. Figure 5 This is for illustrative purposes only and is not intended to limit the invention; those skilled in the art can arrange or arrange the control transmission information of USB commands in other ways.
[0027] Those skilled in the art can complete the "Loading Control Transfer Information for USB Commands" according to Chapters 4 and 8 of the USB 3.0 specification, so it will not be described in detail here.
[0028] Step S260: The computing circuit 120 (more specifically, the firmware of the USB controller 160 executed by the computing circuit 120) generates the aggregated USB command CMD_agg based on the contents of the temporary storage area 145, and transmits the aggregated USB command CMD_agg. For example, as Figure 3 As shown, assuming the firmware of the USB controller 160 ends the control aggregation program 200 at time T4 (i.e., the result of step S230 is yes), and the contents of the temporary storage area 145 at time T4 are as follows: Figure 5As shown (i.e., the firmware of USB controller 160 has aggregated USB commands CMD_1, CMD_2, and CMD_3 so far), the firmware of USB controller 160 generates the aggregated USB command CMD_agg (equivalent to including USB commands CMD_1, CMD_2, and CMD_3) based on the contents of the temporary storage area 145, and then transmits the aggregated USB command CMD_agg to USB controller 160 at time T5.
[0029] In some embodiments, the difference between time point T4 and time point T5 is related to the computing power of computing circuit 120; the stronger the computing power of computing circuit 120, the smaller the difference between time point T4 and time point T5. In some embodiments, the difference between time point T4 and time point T5 approaches 0.
[0030] After receiving the aggregated USB command CMD_agg, the USB controller 160 executes operations based on the aggregated USB command CMD_agg. More specifically, the USB controller 160 sets its internal registers based on the control transmission information of multiple USB commands in the aggregated USB command CMD_agg to execute corresponding operations. For example, if USB commands CMD_1, CMD_2, and CMD_3 are all write operations, the USB controller 160 sends an acknowledgment message, ACK_agg, to the application layer at time T6 only after completing three write operations according to the content of the aggregated USB command CMD_agg. Therefore, this invention can reduce the number of bus input / output requests and the number of handshake procedures that the computing circuit 120 needs to process. In other words, it can improve the performance of the electronic device 100.
[0031] In some embodiments, multiple USB commands corresponding to the same aggregated USB command CMD_agg are commands of the same type, for example, all of them are read commands, write commands, or control commands.
[0032] In some embodiments, such as Figure 6 As shown, step S250 includes sub-step S255: the computing circuit 120 (more specifically, the firmware of the USB controller 160 executed by the computing circuit 120) sends a control signal Ct to notify the USB controller 160 that it has completed storing the control transmission information of the USB command into the temporary storage area 145. Corresponding to... Figure 6 A schematic diagram of controlled aggregation is shown in Figure 7 Please also refer to the following instructions. Figure 2 , Figure 6 andFigure 7 The firmware of USB controller 160 sends control signals Ct1 and Ct2 to USB controller 160 near time point T1 and time point T2, respectively. Control signal Ct1 is used to notify USB controller 160 that the control transmission information of USB command CMD_1 has been successfully stored in the temporary storage area 145, and control signal Ct2 is used to notify USB controller 160 that the control transmission information of USB command CMD_2 has been successfully stored in the temporary storage area 145. USB controller 160 can decide whether to instruct calculation circuit 120 (more specifically, firmware of USB controller 160) to clear the temporary storage area 145 based on control signals Ct1 and Ct2. Figure 7 In the example, the USB controller 160 issues the instruction FLS at time T4. The instruction FLS can trigger the firmware of the USB controller 160 to end the control aggregation program 200 (i.e., the result of step S230 is yes). In other words, the USB controller 160 can actively request the computing circuit 120 to transmit the aggregated USB instruction CMD_agg by issuing the instruction FLS, which provides more flexibility for the design or application of the electronic device 100.
[0033] In summary, the electronic device and USB command transmission method of this invention can first aggregate USB commands and then transmit the aggregated USB commands, which are equivalent to multiple USB commands. Therefore, this invention can reduce the time and computing resources consumed in processing confirmation information, thereby improving the performance of the electronic device.
[0034] Since those skilled in the art can understand the implementation details and variations of the method invention in this case through the disclosure of the device invention, to avoid redundancy, repeated descriptions are omitted here without affecting the disclosure requirements and implementability of the method invention. Please note that the shapes, sizes, and proportions of the elements in the foregoing drawings are merely illustrative and are intended for those skilled in the art to understand the invention, and are not intended to limit the invention. Furthermore, in some embodiments, the order of the steps mentioned in the foregoing flowchart can be adjusted according to actual operation, and they can even be executed simultaneously or partially simultaneously.
[0035] While the embodiments of the present invention have been described above, these embodiments are not intended to limit the present invention. Those skilled in the art can make changes to the technical features of the present invention based on the explicit or implicit content of the present invention, and all such changes may fall within the scope of patent protection sought by the present invention. In other words, the scope of patent protection of the present invention shall be determined by the scope of the claims in this specification.
[0036] [Symbol Explanation]
[0037] CMD_A, CMD_B, CMD_C, CMD_D, CMD_1, CMD_2, CMD_3: USB commands
[0038] ACK_A, ACK_B, ACK_C, ACK_D, ACK_agg: Acknowledgment messages
[0039] 100: Electronic devices
[0040] 120: Calculation Circuit
[0041] 140: Memory
[0042] 145: Temporary Storage Area
[0043] 160: USB controller
[0044] CMD_agg: Aggregated USB commands
[0045] FLS: Commands
[0046] Ct, Ct1, Ct2: Control signals
[0047] T1, T2, T3, T5, T4, T6: Time points
[0048] 200: Control Aggregator Program
[0049] S210, S220, S225, S230, S240, S250, S255, S260: Steps.
Claims
1. An electronic device for transmitting General Sequence Bus (GSBC) instructions, comprising: A general-purpose sequential bus controller; A memory, coupled to the general-purpose serial bus controller, stores multiple program codes or program instructions; and A computing circuit, coupled to the general-purpose serial bus controller and the memory, is used to execute the program code or program instructions to perform the following steps: (A) Configure a temporary storage area in the memory; (B) Receive a general sequence bus instruction; (C) A control transfer message loaded with the generic sequence bus instruction; (D) Store the control transmission information in the temporary storage area; (E) Repeat steps (B) through (D) until a condition for ending the control aggregation is met; (F) Generate an aggregated general sequence bus instruction based on the contents of the temporary storage area; and (G) The aggregated generic sequence bus instruction is transmitted to the generic sequence bus controller.
2. The electronic device as claimed in claim 1, wherein, The condition for ending the control aggregation is that there is insufficient available space in the temporary storage area.
3. The electronic device of claim 1, further comprising: (H) When step (D) is completed, a control signal is sent to the general sequence bus controller to notify that the control transmission information of the general sequence bus instruction has been stored in the temporary storage area.
4. The electronic device as claimed in claim 3, wherein, The general sequence bus controller responds to the control signal by sending an instruction to clear the temporary storage area, and the condition for ending control aggregation is receiving this instruction.
5. The electronic device as claimed in claim 1, wherein, The condition for ending the aggregation control is a timeout.
6. The electronic device as claimed in claim 1, wherein, The condition for ending the control aggregation is that the number of general sequence bus instructions stored in the temporary storage area is greater than a threshold.
7. The electronic device as claimed in claim 1, wherein, The aggregated generic sequence bus instruction is an aggregation of multiple read instructions.
8. The electronic device as claimed in claim 1, wherein, The aggregated generic sequence bus instruction is an aggregation of multiple write instructions.
9. The electronic device as claimed in claim 1, wherein, The aggregated generic sequence bus instruction is an aggregation of multiple control instructions.
10. A method for transmitting general sequence bus instructions, comprising: (A) Configure a temporary storage area in a memory; (B) Receive a general sequence bus instruction; (C) A control transfer message loaded with the generic sequence bus instruction; (D) Store the control transmission information in the temporary storage area; (E) Repeat steps (B) through (D) until a condition for ending the control aggregation is met; (F) Generate an aggregated general sequence bus instruction based on the contents of the temporary storage area; and (G) Transmit the aggregated generic sequence bus instruction.