80-N1008-1 J Sahara Protocol Specification
80-N1008-1 J Sahara Protocol Specification
Specification
80-N1008-1 J
November 3, 2014
Restricted Distribution: Not to be distributed to anyone who is not an employee of either Qualcomm or its
subsidiaries without the express approval of Qualcomm’s Configuration Management.
Not to be used, copied, reproduced, or modified in whole or in part, nor its contents revealed in any manner to others
without the express written permission of Qualcomm Technologies, Inc.
Qualcomm reserves the right to make changes to the product(s) or information contained herein without notice. No
liability is assumed for any damages arising directly or indirectly by their use or application. The information
provided in this document is provided on an “as is” basis.
This document contains confidential and proprietary information and must be shredded when discarded.
Qualcomm is a trademark of QUALCOMM Incorporated, registered in the United States and other countries. All
QUALCOMM Incorporated trademarks are used with permission. Other product and brand names may be
trademarks or registered trademarks of their respective owners.
This technical data may be subject to U.S. and international export, re-export, or transfer (“export”) laws. Diversion
contrary to U.S. and international law is strictly prohibited.
1 Introduction...................................................................................................... 6
1.1 Purpose.......................................................................................................................... 6
1.2 Conventions .................................................................................................................. 6
1.3 References..................................................................................................................... 6
1.4 Technical assistance ...................................................................................................... 6
1.5 Acronyms ...................................................................................................................... 7
2 Overview........................................................................................................... 8
3 Interface.......................................................................................................... 10
3.1 Overview..................................................................................................................... 10
3.2 Commands .................................................................................................................. 10
3.2.1 Hello packet ..................................................................................................... 12
3.2.2 Hello Response packet ..................................................................................... 13
3.2.3 Read Data packet ............................................................................................. 14
3.2.4 End of Image Transfer packet.......................................................................... 15
3.2.5 Done packet ..................................................................................................... 15
3.2.6 Done Response packet ..................................................................................... 16
3.2.7 Reset packet ..................................................................................................... 16
3.2.8 Reset Response packet ..................................................................................... 16
3.2.9 Memory Debug packet .................................................................................... 17
3.2.10 Memory Read packet ..................................................................................... 17
3.2.11 Command Ready packet ................................................................................ 18
3.2.12 Command Switch Mode packet ..................................................................... 18
3.2.13 Command Execute packet ............................................................................. 19
3.2.14 Command Execute Response packet ............................................................. 19
3.2.15 Command Execute Data packet ..................................................................... 20
3.2.16 64bit Memory Debug packet ......................................................................... 20
3.2.17 64bit Memory Read packet ............................................................................ 21
3.2.18 64bit Read Data packet .................................................................................. 22
3.3 Status codes................................................................................................................. 23
4 Operation........................................................................................................ 25
4.1 Overview..................................................................................................................... 25
4.2 Successful Image Transfer sequence .......................................................................... 25
4.3 Successful Memory Debug sequence ......................................................................... 28
4.4 Successful Command sequence .................................................................................. 30
4.5 Protocol implementation ............................................................................................. 32
4.5.1 Target state machine ........................................................................................ 32
4.5.2 Host state machine ........................................................................................... 38
Figures
Figure 3-1 Sahara packet structures ........................................................................................................... 10
Figure 4-1 Successful Sahara Image Transfer sequence ............................................................................ 27
Figure 4-2 Successful Sahara Memory Debug sequence ........................................................................... 29
Figure 4-3 Successful Sahara Command sequence..................................................................................... 31
Figure 4-4 Sahara state machine (target side) ............................................................................................ 34
Figure 4-5 Sahara state machine (target side) – Receive Image ................................................................ 35
Figure 4-6 Sahara state machine (target side) – Memory Debug mode ..................................................... 36
Figure 4-7 Sahara state machine (target side) – Command mode ............................................................. 37
Figure 4-8 Sahara state machine (host side) .............................................................................................. 39
Figure 4-9 Sahara state machine (host side) – Command mode ................................................................ 40
Figure 4-10 Sahara state machine (host side) – Memory Debug mode ..................................................... 41
Tables
Table 1-1 Reference documents and standards ............................................................................................ 6
Table 3-1 Commands ................................................................................................................................. 10
Table 3-2 Hello packet ............................................................................................................................... 12
Table 3-3 Modes supported ....................................................................................................................... 13
Table 3-4 Hello Response packet............................................................................................................... 13
Table 3-5 Read Data packet ....................................................................................................................... 14
Table 3-6 End of Image Transfer packet ................................................................................................... 15
Table 3-7 Done packet ............................................................................................................................... 15
Table 3-8 Done Response packet ............................................................................................................... 16
Table 3-9 Reset packet ............................................................................................................................... 16
Table 3-10 Reset Response packet............................................................................................................. 16
Table 3-11 Memory Debug packet ............................................................................................................ 17
Table 3-12 Memory Read packet ............................................................................................................... 17
Table 3-13 Command Ready packet .......................................................................................................... 18
Table 3-14 Command Switch Mode packet ............................................................................................... 18
Table 3-15 Command Execute packet ....................................................................................................... 19
Table 3-16 Supported client commands..................................................................................................... 19
Table 3-17 Command Execute Response packet ....................................................................................... 19
Table 3-18 Command Execute Data packet ............................................................................................... 20
Table 3-19 Memory Debug packet ............................................................................................................ 20
Table 3-20 Memory Read packet ............................................................................................................... 21
Table 3-21 Read Data packet ..................................................................................................................... 22
Table 3-22 Status and error codes .............................................................................................................. 23
Protocol
Revision Date Description
revision
A Apr 2010 1.0 Initial release
B May 2010 1.0 Defined additional status and error codes
C May 2010 1.0 Fixed incorrect value in Done Response packet table
D Jul 2010 2.0 Added Memory Debug support and updated Hello and Hello
Response packets
E Aug 2010 2.1 Added Command mode
F Jan 2011 2.2 Added Command Execute commands to switch to DMSS
download protocol and Streaming download protocol
G Feb 2011 2.3 Added support for switching modes while in Memory Debug;
fixed diagram for Command Mode – Host
H Dec 2011 2.4 Removed check for image ID type; added command to read
debug data, to get software version in SBL; returned hashes from
APPS/MBA/MSS segments by OEM PK Hash; removed MSM
reset; added image type check for SBL1/eDL type.
Jan 2013 2.5 Added error code of SAHARA_NAK_IMAGE_AUTH_FAILURE
J Nov 2014 2.8 Added command to support 64-bit read data packet
Note: There is no Rev. I, O, Q, S, X, or Z per Mil. standards.
1.1 Purpose
This document provides information on the Sahara protocol, which is used to transfer data to and
from memory. It describes the Sahara packet structures, packet flows, and intended use.
NOTE: Sahara does not provide a mechanism for authenticating/validating the data sent using the
protocol. Such mechanisms are beyond the scope of the protocol and can be implemented in
conjunction with this protocol as data is being transferred.
1.2 Conventions
Function declarations, function names, type declarations, and code samples appear in a different
font, e.g., #include.
Code variables appear in angle brackets, e.g., <number>.
Commands to be entered appear in a different font, e.g., copy a:*.* b:.
Shading indicates content that has been added or changed in this revision of the document.
1.3 References
Reference documents are listed in Table 1-1. Reference documents that are no longer applicable
are deleted from this table; therefore, reference numbers may not be sequential.
Qualcomm Technologies
Q1 Application Note: Software Glossary for Customers CL93-V3077-1
Q2 Application Note: Enable Secure Boot on MSM8974 ASICs 80-NA157-20
Standards
S1 Mobile Station-Base Station Compatibility Standard for TIA/EIA Interim Standard IS-95-A
Dual-mode Wideband Spread Spectrum Cellular System May 1995
1.5 Acronyms
For definitions of terms and abbreviations, see [Q1].
The Sahara protocol is designed primarily for transferring software images from a host to a target.
It provides a simple mechanism for requesting data to be transferred over any physical link.
The protocol supports two basic packet types: command packets and data packets. Command
packets are sent between the host and the target to set up transfers of data packets.
Target-driven protocol
The protocol minimizes data transfer overhead by minimizing the number of command packets
sent between the host and the target. This is accomplished by making the protocol completely
target-driven and by having the target perform all data processing. The host simply waits for a
data transfer request, which contains the following information:
The data image to transfer
The offset into the image to start reading from
The data transfer length
The host does not need to process or extract any information from the actual image data – it
simply sends the image data as “raw” data to the target, without any packet header attached to the
packet. Because the target initiates the data transfer request, it knows exactly how much data to
receive. This enables the host to send data without a packet header, and the target to directly
receive and store the data.
The target requests data from the host as needed. The first data item it requests is the image
header for a given image transfer. Once the target has processed the image header, it knows the
location and size of each data segment in the image. The image header also specifies the
destination address of the image in the target memory. With this information, the target can
request data from the host for each segment and directly transfer the data to the appropriate
location in the target memory.
Packet processing
The protocol minimizes packet processing by relying on the physical transport layer to provide
reliable transfer of data. No framing, HDLC (High-level Data Link Control) encoding, or CRC
(Cyclic Redundancy Check) is applied to the packets at the protocol level.
Each command packet type has a well-defined structure which minimally contains a command ID
and packet length. Using this information, the length of each command packet can be validated
by comparing the length of the command packet received to either of two values:
The expected packet length for the given command ID
The length field contained in the packet itself
NOTE: Sahara can easily be extended to support command packet validation by adding a CRC field to
the end of each packet. Data packets can also be validated for data integrity using various
authentication methods; however, this is beyond the scope of the protocol.
Synchronous communication
The protocol assumes that all communication between the host and the target is completely
synchronous. Each command packet sent from the target to the host is acknowledged with a
command or data packet sent from the host back to the target. Similarly, each command packet
sent from the host to the target is acknowledged with a command or data packet.
Although the link between the host and the target is expected to be reliable, if an error occurs
during the transmission of a command packet from the host to the target, and as a result the target
receives an erroneous packet, the target sends the host an error response and exits gracefully.
Timer mechanisms can be implemented on both the host and the target to support the
retransmission of packets in case of transmission failures. However, the implementation of such
mechanisms is outside the scope of the protocol – it specifies only what happens when
unexpected or erroneous packets are received on the target side.
Extensibility
The protocol defines a fixed set of command structures and packet flows. However, it can easily
be extended to support additional command structures and state transitions (as described later in
this document).
3.1 Overview
The Sahara protocol defines two types of packets:
Command packets
Data packets
The structure of these packets is shown in Figure 3-1.
Command Packet
COMMAND ID PACKET LENGTH OPTIONAL FIELD OPTIONAL FIELD
Data Packet
RAW DATA (arbitrary number of bytes)
Command packets contain at minimum a command ID and packet length. Depending on the
command, the packet may contain additional command-specific fields.
NOTE: The command packet structure enables future revisions of the protocol to easily add fields to the
end of a packet type, while preserving compatibility with the packet structure of previous
protocol versions.
3.2 Commands
The commands used in the Sahara command packets are listed in Table 3-1.
Table 3-1 Commands
Minimum
ID Value Sent
Command protocol Description
(HEX) by
revision
0x00 — — — Invalid
0x01 Hello Target 1.0 Initialize connection and protocol
0x02 Hello Host 1.0 Acknowledge connection and protocol sent by
Response target; also used to set mode of operation for target
to execute in
0x03 Read Data Target 1.0 Read specified number of bytes from host for a
given image
Minimum
ID Value Sent
Command protocol Description
(HEX) by
revision
0x04 End of Image Target 1.0 Indicate to host that a single image transfer is
Transfer complete; also used to indicate a target failure
during an image transfer
0x05 Done Host 1.0 Acknowledgement from host that a single image
transfer is complete
0x06 Done Target 1.0 Indicate to host:
Response Target is exiting protocol
Whether or not target expects to re-enter protocol
to transfer another image
0x07 Reset Host 1.0 Instruct target to perform a reset
0x08 Reset Target 1.0 Indicate to host that target is about to reset
Response
0x09 Memory Target 2.0 Indicate to host that target has entered a debug
Debug mode where it is ready to transfer its system
memory contents
0x0A Memory Host 2.0 Read specified number of bytes from target’s
Read system memory, starting from a specified address
0x0B Command Target 2.1 Indicate to host that target is ready to receive client
Ready commands
0x0C Command Host 2.1 Indicate to target to switch modes:
Switch Mode Image Transfer Pending mode
Image Transfer Complete mode
Memory Debug mode
Command mode
0x0D Command Host 2.1 Indicate to target to execute a given client command
Execute
0x0E Command Target 2.1 Indicate to host that target has executed client
Execute command; also used to indicate status of executed
Response command
0x0F Command Host 2.1 Indicate to target that host is ready to receive data
Execute Data resulting from executing previous client command
0x10 64bit Memory Target 2.5 Indicate to host that target has entered a debug
Debug mode where it is ready to transfer its 64-bit system
memory contents
0x11 64bit Memory Host 2.5 Read specified number of bytes from target’s
Read system memory, starting from a specified 64-bit
address
0x12 64bit Read Target 2.8 Read specified number of bytes from host for a
Data given 64-bit image
All others — — — Invalid
NOTE: The minimum protocol version indicates the lowest protocol version that supports the given
command.
The Hello packet is the first packet that the target sends to the host. If the host receives any other
packet, it sends a reset command to the target.
When the host receives a valid Hello packet, it first verifies that the protocol running on the target
is compatible with the protocol running on the host. If the protocols are mismatched, the host
sends a reset command to the target.
The target also sends the maximum length of the command packet that it supports – the host uses
this information to avoid sending more bytes than the target can support in the receiving
command buffer.
The target also sends the mode of operation it expects to enter based on the bootup sequence.
Sahara currently supports the following modes shown in Table 3-3:
Image Transfer Pending mode – Transfer image from the host; after completion, the host
should expect another image transfer request.
Image Transfer Complete mode – Transfer image from the host; after completion, the host
should not expect another image transfer request
Memory Debug mode – The host should prepare to receive a memory dump from the target
Command mode – The host executes operations on the target by sending the appropriate
client command to the Sahara client running on the target. The client command is interpreted
by the Sahara client and the corresponding response sent upon execution of the given
command.
Once the host validates the protocol running on the target, it sends the following information to
the target:
The protocol version that it is running
The minimum protocol version it supports
The mode of operation
The host sets the packet Status field to “success” if no errors occur on the host side. Once the
target receives this packet, it can proceed with data transfer requests or memory debug.
If any of the above fields are invalid, or if any other error occurs on the host, the host can send a
data packet with a length that does not match what the target was expecting. The resulting error
forces the target to send an End of Image Transfer packet with an error code in the Status field
(see packet structure in Table 3-6). This transaction enables both the target and the host to enter
an error handling state.
The current version of the protocol can be implemented by a state machine where any error that
occurs results in the host sending a Reset packet (see Section 4.5).
If an image transfer is successfully completed, the target sends the host an End of Image Transfer
packet with a “success” status. The target then waits for the host to send a Done packet.
If any error occurs during the transfer or processing of the image data, the status is set to the
corresponding error code, and the target waits for a different command packet.
The current version of the protocol can be implemented by a state machine where the target
assumes the host is always going to send a Reset packet after an error is sent in the End of Image
Transfer packet (see Section 4.5). However, the protocol allows the flexibility of other command
packets to be sent from the host to the target in response to the End of Image Transfer error
packet.
If the host receives an End of Image Transfer packet with a “success” status, the host sends a
Done packet to indicate to the target that it can exit the protocol and continue executing.
If the target wishes to transfer another image from the host, it must re-initiate the protocol by
starting with another Hello packet.
If the target receives a Done packet, it responds with a Done Response packet containing the
image transfer status:
If all the images have been transferred, the target sends a “complete” status to enable the host
to exit the protocol.
If all the images have not been transferred, the target sends a “pending” status. The target will
assume the host will continue to execute the protocol and wait for another Hello packet to
arrive.
The host sends a Reset packet whenever it wants to reset the target.
The target services a Reset request only if it is in a state where reset requests are valid. If the
target receives an invalid reset request, the target sends an error in an End of Image Transfer
packet.
From revision 2.4, target reset is no longer supported for B family chips.
If the target receives a valid reset request, it sends a Reset Response packet just before it resets.
The purpose of this response is for the target to acknowledge to the host that the target received
the reset request. If the host does not receive the Reset Response command from the target (or
receives a different command), it can attempt to resend the request.
The target initiates a memory dump by sending the host a Memory Debug packet. This packet
contains the address and length of the memory debug table. The memory debug table is a listing
of memory locations that can be accessed and dumped to the host. Each entry in the table is a data
structure with the following type:
struct sahara_packet_memory_debug
{
uint32 command; /* command ID */
uint32 length; /* packet length incl command and
length */
uint32 memory_table_addr; /* location of memory region table */
uint32 memory_table_length; /* length of memory table */
};
The length of the memory table is the size of the structure multiplied by the number of entries in
the table.
Given the memory table address and length, the host can issue a Memory Read to retrieve the
table. Once the host receives the memory table information, it can decode each entry and issue
Memory Read requests to dump each memory location.
The host repeatedly issues Memory Read commands for each section of memory it wishes to
dump. The accessible regions are defined in the memory debug table. For each Memory Read
command received, the target verifies that the specified memory (address and length) is
accessible and responds with a Raw Data packet. The content and length of the Raw Data packet
are the memory dump starting from the memory address and length specified in the Memory
Read packet. The memory debug table can also be read using a Memory Read command by
setting the address and length to the values specified in the Memory Debug packet.
If any error occurs on the target, an End of Image Transfer packet is sent with the corresponding
error code. The host must distinguish the data sent from the target to recognize whether it is
actual memory data or an End of Image Transfer packet. One way is to always request a memory
length that does not equal the size of the End of Image Transfer packet.
On completion of a successful memory dump, the expected behavior is for the host to issue a
reset command. However, the protocol does not force this implementation.
This packet is sent from the target to the host to indicate the target is ready to execute client
commands via the Command Execute packet.
The host sends this packet when it wishes the target to switch to another mode.
The host sends this packet to execute the given client command on the target. The supported
client commands are shown in Table 3-16. If the client command successfully executes, the target
sends a Command Execute Response packet. If an error occurs, the target sends an End of Image
Transfer packet with the corresponding error code.
Client Minimum
Command ID Command protocol Description
Value (HEX) revision
0x00 No Operation 2.1 No operation is performed on target.
0x01 Serial Number Read 2.1 Retrieve serial number from target.
0x02 MSM H/W ID Read 2.1 Retrieve chip hardware ID from target.
0x03 Public Key Hash Read1 2.1 Retrieve hash of the root of trust certificate
from target.
0x06 Read debug data 2.4 Retrieve error log from the supported target.
0x07 Get software version SBL 2.4 Provide the anti-roll back version
supported for SBL segment.
1From revision 2.4, PK Hash returns three hashes for APPS, MBA, and MSS code segments for B-family
chips.
The execution of the client commands is not defined by the protocol. That is outside the scope of
the protocol. The handling of the commands and the response data is provided by the Sahara
client on the target side. The Sahara protocol provides a unified set of client command IDs that
can be extended in the future.
The target sends this packet if it successfully executed the client command. The length of the data
response is sent to allow the host to prepare to receive the data.
The host sends this packet if the response length received in the Command Execute Response
packet was greater than 0. This packet indicates to the target to send the response data in a Raw
Data packet. Upon receiving this packet, the target sends the response data.
When the target sends a 64bit Memory Debug packet, it uses the format shown in Table 3-19.
The target initiates a memory dump by sending the host a 64bit Memory Debug packet. This
packet contains the 64-bit address and length of the memory debug table. The memory debug
table is a listing of memory locations that can be accessed and dumped to the host. Each entry in
the table is a data structure with the following type:
struct sahara_packet_memory_64bits_debug
{
uint32 command; /* command ID */
The memory table length is the structure size multiplied by the number of entries in the table.
Given the memory table address and length, the host can issue a Memory Read to retrieve the
table. Once the host receives the memory table information, it can decode each entry and issue
Memory Read requests to dump each memory location.
When the host sends a Memory Read packet, it uses the format shown in Table 3-20.
The host repeatedly issues 64bit Memory Read commands for each section of memory it wishes
to dump. The accessible regions are defined in the memory debug table. For each 64bit Memory
Read command received, the target verifies that the specified memory (address and length) is
accessible and responds with a Raw Data packet.
The content and length of the Raw Data packet are the memory dump starting from the memory
address and length specified in the 64bit Memory Read packet. The memory debug table can also
be read using a 64bit Memory Read command by setting the address and length to the values
specified in the 64bit Memory Debug packet.
If any error occurs on the target, an End of Image Transfer packet is sent with the corresponding
error code. The host must distinguish the data sent from the target to recognize whether it is
actual memory data or an End of Image Transfer packet. One way is to always request a memory
length that does not equal the size of the End of Image Transfer packet.
On completion of a successful memory dump, the expected behavior is for the host to issue a
reset command. However, the protocol does not force this implementation.
When the target sends a 64bit Read Data packet, it uses the format shown in Table 3-21.
To initiate a 64-bit image transfer, the target fills this packet with the image ID corresponding to
the 64-bit image it wants to receive. The target also sends the 64-bit offset into the image file and
the length of the data (in bytes) it wants to read from the image.
This packet serves as a generic data transfer packet when any 64-bit image data is to be
transferred from the host to the target. It allows flexibility in the way the image is transferred
from the host to the target.
Because the target controls what data gets transferred, it can determine what parts of the image
get transferred and in what order. The host does not need to know anything about the structure of
the image; it only needs to open the file and start transferring the data to the target based on the
parameters specified in the packet. This gives the target complete control over how the images are
transferred and processed.
As soon as the host receives this packet, the host is expected to respond with a data packet. The
data packet must contain just the image data and must be of the length specified in the Read Data
packet.
Several error conditions can occur if the host receives any of the following in a 64bit Read Data
packet:
Invalid or unsupported image ID
Invalid data offset
Invalid data length
If any of the above fields are invalid, or if any other error occurs on the host, the host can send a
data packet with a length that does not match what the target was expecting. The resulting error
forces the target to send an End of Image Transfer packet with an error code in the Status field
(see packet structure in Table 3-6). This transaction enables both the target and the host to enter
an error handling state.
The current version of the protocol can be implemented by a state machine where any error that
occurs results in the host sending a Reset packet (see Section 4.5).
4.1 Overview
This chapter covers the following topics:
How the Sahara protocol can be used to transfer an image from the host to the target, dump
memory from the target to the host, or execute commands on the target and retrieve data
An example state machine which implements the protocol and illustrates how to deal with
errors that can occur in each mode (Image Transfer Pending, Image Transfer Complete,
Memory Debug, Command)
How a system can use the protocol to parallelize image transfer requests
5. Upon receiving a Read Data request, the host parses the image ID, data offset, and data length
to transfer data from the corresponding image file. The host sends the data requested without
any packet header. The target directly transfers this data to the destination address without
any software processing or temporary buffering of the data in system memory. This is made
possible by transferring the image header to the target and setting the receive buffer for the
data to be just the destination address in system memory.
6. Once the target successfully receives all segments for an image, the target sends an End of
Image Transfer packet with the image ID of the corresponding image, and a “success” status.
This enables the host to stop reading and close the image file.
7. Upon receiving a successful End of Image Transfer, the host sends a Done packet to allow the
target to exit the protocol.
8. Once the target receives the Done packet, the target sends a Done Response packet to the
host. Within this packet, the target indicates whether it expects another image to be
transferred. If another image is to be transferred to the target, the host can continue to run the
protocol.
Host Target
Target initiates protocol by sending
HELLO
HELLO packet with
(mode = image transfer)
Host has the option of sending the Image Transfer mode
same mode as the target is expecting
in the HELLO_RESP, or send a HELLO_RESP
different mode for the target to enter, (mode = image transfer)
i.e. Memory Debug mode Once HELLO_RESP is received (and
host wants target to enter Image
Transfer mode), target initiates the
READ_DATA image transfer by first requesting the
(image ID, 0 offset, transfer of the image header from
size of image header) the host
READ_DATA
(image ID, segment N offset,
size of segment N)
NOTE: In step 6, the host can alternatively send a Command Switch Mode packet to allow the target to
switch modes and avoid a reset (this is not shown in Figure 4-2).
Host Target
Target initiates protocol by sending
HELLO
HELLO packet with
(mode = memory debug)
Host has the option of sending the Memory Debug mode
same mode as the target is expecting
in the HELLO_RESP, or send a
different mode for the target to enter, HELLO_RESP
i.e., Image Transfer mode (mode = memory debug)
Once HELLO_RESP is received (and
host wants target to enter Memory
Debug mode), target initiates the
memory debug by sending a
MEMORY_DEBUG MEMORY_DEBUG packet with the
(location of region table, memory location of the region table
size of region table) and the region table size
Host receives the memory region table
information and issues a request to MEMORY_READ
read the memory region table. (location of region table,
size of region table)
Target validates the location/size of
requested and sends the memory
RAW_DATA (size of region table)
region table as RAW_DATA
Host decodes the memory region table
to extract the accessible memory
regions. Host then sends a
MEMORY_READ for each MEMORY_READ
accessible region. (location of region 0, size of region 0)
Target validates the requested memory
region is accessible and sends the
RAW_DATA (size of region 0)
memory region as one
RAW_DATA transfer
MEMORY_READ
(location of region 1, size of region 1)
MEMORY_READ
(location of region N, size of region N)
Host Target
HELLO Target initiates protocol by sending
(mode = image transfer) HELLO packet with image transfer
Host has the option of sending the
same mode as the target is expecting
in the HELLO_RESP, or send a
different mode for the target to enter, HELLO_RESP
i.e., Command mode (mode = command)
Once HELLO_RESP is received (and
host wants target to enter Command
mode), target initiates the Command
CMD_READY mode by sending a
CMD_READY packet
Host receives the CMD_READY and
starts issuing commands to the target CMD_EXEC
with the appropriate client_commands. (client_command0)
Target executes command and sends
CMD_EXEC_RESP with response
CMD_EXEC_RESP
length corresponding to given
(response length > 0)
client_command
If response length > 0, then host sends
CMD_EXEC_DATA packet to indicate
CMD_EXEC_DATA
to target it is ready to receive the
(location of region 0, size of region 0)
response data
Target sends the response data
RAW_DATA (size of response length) corresponding to the last
command received
Once host receives and processes the
data, it moves on and executes the
CMD_EXEC
next command
(client_command1)
Target executes command and sends
CMD_EXEC_RESP with response
CMD_EXEC_RESP
length corresponding to given
(response length = 0)
client_command
If response length is 0, then the
command executed does not return
response data. Host moves on and CMD_EXEC
executes the next command. (client_command2)
CMD_EXEC_RESP
(response length > 0)
CMD_EXEC_DATA
(location of region 0, size of region 0)
DATA_ELF_PROG_HDR – The target has received the ELF program headers for an ELF
image. If anything is wrong with the program headers, the target sends an End of Image
Transfer packet with the corresponding error code. If valid program headers are received, the
target processes them to determine the location of a hash table segment. A hash table can be
used to validate the integrity of each data segment by applying a hash function to each data
segment and storing the hash value in the hash table. Upon loading each ELF data segment,
the hash function can be applied to each segment and the hash value compared to the one that
was stored in the hash table.
Specific hash algorithms and authentication routines are not described here, as they are
outside the scope of this protocol.
DATA_ELF_SEGMENTS – Once the location and size of each data segment is determined
from the program headers, the target repeatedly sends Read Data requests until each data
segment is transferred. Once all ELF segments are received, the target sends an End of Image
Transfer with “success” status.
WAIT_DONE – Once a single image transfer is complete, the target waits for a Done packet
to be sent. If an invalid or any other packet is received, the target sends an End of Image
Transfer packet with the corresponding error code. If a valid Done packet is received, the
target sends a Done Response to the host, with the Image Transfer Status field set to
“complete” or “pending” based on whether another image is to be transferred or not.
WAIT_RESET – Any time an error occurs on the target, the target expects the host to send a
Reset command. If the target receives a Reset command, it sends a Reset Response to the
host and then resets. If an invalid or any other command is received, the target sends an End
of Image Transfer packet with the corresponding error code.
WAIT_MEMORY_READ – Once a Memory Debug packet has been sent to the host, the
target continues to wait for a Memory Read packet, validates the incoming address and
length, and then sends the corresponding data in a Raw Data packet to the host. If the target
receives a Reset command, it sends a Reset Response to the host and then resets. If the target
receives a Command Switch Mode command, it switches to the received mode and sends a
Hello command. If an invalid or any other command is received, the target sends an End of
Image Transfer packet with the corresponding error code.
WAIT_CMD_EXEC – Once a Command Ready packet has been sent to the host, the target
continues to wait for a Command Execute packet. Upon receiving the Command Execute
packet, the target executes the given client command and sends the Command Execute
Response with the corresponding response data length. If the response length is greater than
0, the target waits for a Command Execute Data packet. Otherwise, the target waits for
another command. If the target receives a Reset command, it sends a Reset Response to the
host and then resets. If the target receives a Command Switch Mode command, it switches to
the received mode and sends a Hello command. If an invalid or any other command is
received, the target sends an End of Image Transfer packet with the corresponding error code.
WAIT_CMD_EXEC_DATA – If the response length is greater than 0 for an executed client
command, the target waits for the Command Execute Data packet and sends the
corresponding response data in a Raw Data packet to the host. Upon completion, the target
waits for another command. If an invalid or any other command is received, the target sends
an End of Image Transfer packet with the corresponding error code.
Entry
Send HELLO
CMD_SWITCH_MODE received
during command mode or
memory debug WAIT_RESET
State
WAIT_HELLO_RESP
State
Error during
Receive Image,
Command Mode,
No error during or Memory Debug
receive image
WAIT_DONE
State
Any error in
sending
END_IMAGE_TX
DONE received and all DONE received and NOT error response
Invalid or any other
images received for boot; all images received for
command received;
Shutdown Sahara boot;
Send
Send DONE_RESP with
IMAGE_TX_COMPLETE
Send DONE_RESP with
IMAGE_TX_PENDING
END_IMAGE_TX
error response
Reset *
status status
Exit and
*From revision 2.4, MSM reset is removed, and Sahara reset will spin in loop.
continue
with boot
Receive
Image
Entry
ELF
Image
Based on expected image,
determine image header size and
DATA_ELF_HDR
set offset=0 in host image;
State
Send READ_DATA
DATA_ELF_PROG_HDR
State
RAW_DATA received;
Store image header for
authentication;
Determine location/size of data in
host image; Valid program headers received;
send READ_DATA Determine location/size of hash
table segment in host image;
Send READ_DATA
DATA_BINARY DATA_ELF_HASH_TABLE
State State
DATA_ELF_SEGMENTS
State
Receive
Image Determine location/size of next Not all ELF
Exit ELF segment in host image; segments
Send READ_DATA received
Invalid binary header received
OR
Invalid data received RAW_DATA received;
OR Valid data received;
Invalid ELF header received
OR
Invalid program headers received
OR
Hash table authentication failed
OR All ELF segments received and
ELF segment authentication failed authenticated (if applicable);
OR Send END_IMAGE_TX success
Packet transmission error; response
Send END_IMAGE_TX error response
Memory
Debug
Entry
WAIT_MEMORY_READ
State
Memory
Reset
Debug
Exit
Figure 4-6 Sahara state machine (target side) – Memory Debug mode
Command
Mode Entry
Send CMD_READY
WAIT_CMD_EXEC
State
Response
Length = 0
Response
Length > 0
WAIT_CMD_EXEC_DATA
State
CMD_EXEC_DATA received;
Send RAW_DATA response CMD_EXEC received and failed
to execute received client
command
OR
Any other command received
OR
Invalid command received
OR
Packet transmission error;
Send END_IMAGE_TX error
response
Reset
Command
Mode Exit
Entry
WAIT_HELLO
State
WAIT_COMMAND
State
WAIT_RESET_RESP
CMD_SWITCH_MODE sent RESET sent State
during Command Mode or WAIT_DONE_RESP during Command
Memory Debug State Mode or Memory
Debug
Exit
Command
Mode Entry
WAIT_CMD_EXEC_RESP
State
CMD_EXEC_RESP received;
CMD_EXEC_RESP received;
Response length = 0;
Response length > 0;
Send CMD_EXEC_DATA
Command
Mode Exit
Memory
Debug
Entry
WAIT_MEMORY_TABLE
State
RAW_DATA received;
Valid memory region table
received;
Memory
Debug
Exit
Figure 4-10 Sahara state machine (host side) – Memory Debug mode