3.3 Host Command Generation and Response Processing Algorithm
The following sections detail the process the host goes through to generate/send commands and process responses from the client.
3.3.1 Host Command Generation
All communications in the Microchip Device Firmware Update Protocol are initiated by the host. The host uses the Firmware Update Algorithm to determine the commands it needs to generate and send to walk a client through the process of a firmware update.
The host forms these commands and uses a Transport Layer definition for one of the physical communications busses supported to send the commands to the client.
The host follows the Flow Control rules to know when it is ok to send the next command.
3.3.2 Host Response Processing
Each command that the host sends should result in a response that is returned from the client.
The response from the client is received by the Transport Layer.
When the response arrives, the host checks the response for a number of different conditions. These response conditions allow the host to determine if the command was executed successfully and the response data to the command is available. It also allows the host to determine if there were errors which occurred and what to do about those errors. Detected Recoverable Errors activate the host’s automatic recovery mechanism. Detected Unrecoverable Errors terminate the update process and deliver error messages with debug information to the user.
The host checks for a number of different types of errors in the response including:
- Transport Errors: Response corruption or framing errors (i.e., noise bit flips)
- Sequence Number Errors
- Status Errors such as ABORT_FILE_TRANSFER
If the response does not contain any detectable errors and has the SUCCESS status, this status and data payload are used by the host to complete the processing of the successfully transmitted and executed command-response pair. The current command-response pair has now been completed, and the host uses the firmware update algorithm to begin working on the next command-response pair in the update.
3.3.3 Host Command Generation and Response Processing Algorithm Diagram
The following diagrams show the process the host goes through to generate/send commands and process responses from the client.
A host developer can decide to place the flow control time-out mechanism in either the host Firmware Update Protocol Layer or in the host Transport Layer. The first figure shows the time-out implemented in the host Firmware Update Protocol Layer. The second figure shows the time-out implemented in the host Transport Layer.
Figure Notes | |
Note 1: | See Host Command Sequence Number Selection for more details. |
Note 2: | The response sequence number is valid if R_SEQUENCE is equal to C_SEQUENCE. |
Note 3: | The response sequence number is valid for a resend request if R_SEQUENCE is equal to C_SEQUENCE or if R_SEQUENCE is equal to (C_SEQUENCE + 1) % 32. |
Figure Notes | |
Note 1: | See Host Command Sequence Number Selection for more details. |
Note 2: | The response sequence number is valid if R_SEQUENCE is equal to C_SEQUENCE. |
Note 3: | The response sequence number is valid for a resend request if R_SEQUENCE is equal to C_SEQUENCE or if R_SEQUENCE is equal to (C_SEQUENCE + 1) % 32. |
3.3.4 Host Command and Response Buffer Sizing
The MDFU Protocol enables the development of hosts which are capable of updating any attached client provided that the host has allocated enough buffer memory to store the largest command and largest response of the attached client.
Hosts must have enough command buffer space to send WriteChunk commands containing MaxCommandDataLength byte chunks of the file. MaxCommandDataLength is a client specific parameter which can have different values for different clients. Additionally, different clients may also have different maximum response data payload sizes. See Command-Response Pairs for more information on command and response sizes.
Since the maximum command and response sizes are client dependent, ensuring that the host has large enough command and response buffers is an integration task that must be performed to make sure that a specific host has enough memory allocated to update the attached clients.
PC hosts with plenty of memory and dynamic memory allocation can be written in a way that is unlikely to require modification of the host to support most clients. However, embedded hosts with fixed size statically allocated buffers may need to be rebuilt to allocate more memory to the command and response buffers to accommodate the needs of specific clients. It is the MDFU user’s responsibility to ensure that their host has enough memory allocated to update their attached clients.