command_packet.h
/*
* Copyright (c) 2013 - 2015, Freescale Semiconductor, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* o Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* o Neither the name of Freescale Semiconductor, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if !defined(__COMMAND_PACKET_H__)
#define __COMMAND_PACKET_H__
#include "bootloader_common.h"
// Declarations
enum _command_packet_constants
{
kMinPacketBufferSize = 32,
kDefaultMaxPacketSize = kMinPacketBufferSize,
kMaxPropertyReturnValues =
(kMinPacketBufferSize / sizeof(uint32_t)) - 2,
kMaxProgramOnceValues =
(kMinPacketBufferSize / sizeof(uint32_t)) - 3,
kCommandTagCount = 12
};
enum _command_tags
{
kCommandTag_GenericResponse = 0xa0,
kCommandTag_FlashEraseAll = 0x01,
kCommandTag_FlashEraseRegion = 0x02,
kCommandTag_ReadMemory = 0x03,
kCommandTag_ReadMemoryResponse = 0xa3,
kCommandTag_WriteMemory = 0x04,
kCommandTag_FillMemory = 0x05,
kCommandTag_FlashSecurityDisable = 0x06,
kCommandTag_GetProperty = 0x07,
kCommandTag_GetPropertyResponse = 0xa7,
kCommandTag_ReceiveSbFile = 0x08,
kCommandTag_Execute = 0x09,
kCommandTag_Call = 0x0a,
kCommandTag_Reset = 0x0b,
kCommandTag_SetProperty = 0x0c,
kCommandTag_FlashEraseAllUnsecure = 0x0d,
kCommandTag_FlashProgramOnce = 0x0e,
kCommandTag_FlashReadOnce = 0x0f,
kCommandTag_FlashReadOnceResponse = 0xaf,
kCommandTag_FlashReadResource = 0x10,
kCommandTag_FlashReadResourceResponse = 0xb0,
kCommandTag_ConfigureQuadSpi = 0x11,
kCommandTag_ReliableUpdate = 0x12,
kCommandTag_ConfigureI2c = 0xc1,
kCommandTag_ConfigureSpi = 0xc2,
kCommandTag_ConfigureCan = 0xc3,
kFirstCommandTag = kCommandTag_FlashEraseAll,
kLastCommandTag = kCommandTag_ReliableUpdate,
kResponseCommandHighNibbleMask =
0xa0
};
enum _command_packet_flags
{
kCommandFlag_None = 0,
kCommandFlag_HasDataPhase = 1
};
enum _flash_mem_id
{
kFlashMemInternal = 0,
kFlashMemQuadSpi0 = 1,
kFlashMemExecuteOnly = 0x10
};
typedef struct CommandPacket
{
uint8_t commandTag;
uint8_t flags;
uint8_t reserved;
uint8_t parameterCount;
} command_packet_t;
typedef struct FlashEraseAllPacket
{
command_packet_t commandPacket;
uint32_t memoryId;
} flash_erase_all_packet_t;
typedef struct FlashEraseRegionPacket
{
command_packet_t commandPacket;
uint32_t startAddress;
uint32_t byteCount;
} flash_erase_region_packet_t;
typedef struct GetPropertyPacket
{
command_packet_t commandPacket;
uint32_t propertyTag;
uint32_t memoryId;
} get_property_packet_t;
typedef struct SetPropertyPacket
{
command_packet_t commandPacket;
uint32_t propertyTag;
uint32_t propertyValue;
} set_property_packet_t;
typedef struct ReceiveSbFilePacket
{
command_packet_t commandPacket;
uint32_t byteCount;
} receive_sb_file_packet_t;
typedef struct WriteMemoryPacket
{
command_packet_t commandPacket;
uint32_t startAddress;
uint32_t byteCount;
} write_memory_packet_t;
typedef struct ReadMemoryPacket
{
command_packet_t commandPacket;
uint32_t startAddress;
uint32_t byteCount;
} read_memory_packet_t;
typedef struct FillMemoryPacket
{
command_packet_t commandPacket;
uint32_t startAddress;
uint32_t byteCount;
uint32_t patternWord;
} fill_memory_packet_t;
typedef status_t (*call_function_t)(uint32_t);
typedef struct ExecuteCallPacket
{
command_packet_t commandPacket;
uint32_t callAddress;
uint32_t argumentWord;
uint32_t stackpointer;
} execute_call_packet_t;
typedef struct FlashSecurityDisablePacket
{
command_packet_t commandPacket;
uint32_t keyLow;
uint32_t keyHigh;
} flash_security_disable_packet_t;
typedef struct ProgramOncePacket
{
command_packet_t commandPacket;
uint32_t index;
uint32_t byteCount;
uint32_t data[kMaxProgramOnceValues];
} flash_program_once_packet_t;
typedef struct ReadOncePacket
{
command_packet_t commandPacket;
uint32_t index;
uint32_t byteCount;
} flash_read_once_packet_t;
typedef struct FlashReadResourcePacket
{
command_packet_t commandPacket;
uint32_t startAddress;
uint32_t byteCount;
uint32_t option;
} flash_read_resource_packet_t;
typedef struct ConfigureQuadSpiPacket
{
command_packet_t commandPacket;
uint32_t flashMemId;
uint32_t configBlockAddress;
} configure_quadspi_packet_t;
typedef struct ReliableUpdatePacket
{
command_packet_t commandPacket;
uint32_t address;
} reliable_update_packet_t;
typedef struct ConfigureI2cPacket
{
command_packet_t commandPacket;
uint32_t address;
uint32_t speed;
} configure_i2c_packet_t;
typedef struct ConfigureSpiPacket
{
command_packet_t commandPacket;
uint32_t speedKhz;
uint32_t polarity;
uint32_t phase;
uint32_t direction;
} configure_spi_packet_t;
typedef struct ConfigureCanPacket
{
command_packet_t commandPacket;
uint32_t speed;
uint32_t txid;
uint32_t rxid;
} configure_can_packet_t;
typedef struct GenericResponsePacket
{
command_packet_t commandPacket;
uint32_t status;
uint32_t commandTag;
} generic_response_packet_t;
typedef struct GetPropertyResponsePacket
{
command_packet_t commandPacket;
uint32_t status;
uint32_t propertyValue[kMaxPropertyReturnValues];
} get_property_response_packet_t;
typedef struct ReadMemoryResponsePacket
{
command_packet_t commandPacket;
uint32_t status;
uint32_t dataByteCount;
} read_memory_response_packet_t;
typedef struct FlashReadOnceResponsePacket
{
command_packet_t commandPacket;
uint32_t status;
uint32_t byteCount;
uint32_t data[kMaxProgramOnceValues];
} flash_read_once_response_packet_t;
typedef struct FlashReadResourceResponsePacket
{
command_packet_t commandPacket;
uint32_t status;
uint32_t dataByteCount;
} flash_read_resource_response_packet_t;
#endif // __COMMAND_PACKET_H__
// EOF
configure_spi_packet_t::phase
uint32_t phase
Parameter 2: phase.
Definition: command_packet.h:263
read_memory_response_packet_t::dataByteCount
uint32_t dataByteCount
parameter 1
Definition: command_packet.h:302
reliable_update_packet_t
ReliableUpdate packet format.
Definition: command_packet.h:242
set_property_packet_t::propertyValue
uint32_t propertyValue
Parameter 1: value to set.
Definition: command_packet.h:152
kResponseCommandHighNibbleMask
Mask for the high nibble of a command tag that identifies it as a response command.
Definition: command_packet.h:93
_command_tags
_command_tags
Commands codes.
Definition: command_packet.h:58
configure_quadspi_packet_t
ConfigureQuadSpi packet format.
Definition: command_packet.h:234
read_memory_response_packet_t
Read Memory response packet format.
Definition: command_packet.h:298
flash_security_disable_packet_t::keyLow
uint32_t keyLow
Paremeter 0: key bytes 0-3.
Definition: command_packet.h:203
flash_erase_region_packet_t::byteCount
uint32_t byteCount
Parameter 1: number of bytes.
Definition: command_packet.h:136
read_memory_packet_t
ReadMemory packet format.
Definition: command_packet.h:171
generic_response_packet_t::commandTag
uint32_t commandTag
parameter 1
Definition: command_packet.h:286
receive_sb_file_packet_t
ReceiveSbFile packet format.
Definition: command_packet.h:156
kMaxPropertyReturnValues
Definition: command_packet.h:47
_flash_mem_id
_flash_mem_id
Flash memory identifiers.
Definition: command_packet.h:105
execute_call_packet_t::callAddress
uint32_t callAddress
Paremeter 0: function address.
Definition: command_packet.h:194
write_memory_packet_t
WriteMemory packet format.
Definition: command_packet.h:163
flash_read_resource_packet_t::option
uint32_t option
Parameter 2: option for flash read resource command.
Definition: command_packet.h:230
execute_call_packet_t::argumentWord
uint32_t argumentWord
Parameter 1: argument.
Definition: command_packet.h:195
command_packet_t
Command packet format.
Definition: command_packet.h:113
get_property_packet_t
GetProperty packet format.
Definition: command_packet.h:140
command_packet_t::commandTag
uint8_t commandTag
A command tag.
Definition: command_packet.h:115
get_property_response_packet_t
Get Property response packet format.
Definition: command_packet.h:290
flash_erase_all_packet_t
FlashEraseAll packet format.
Definition: command_packet.h:125
configure_can_packet_t::rxid
uint32_t rxid
Parameter 2: rxid.
Definition: command_packet.h:273
flash_security_disable_packet_t::keyHigh
uint32_t keyHigh
Parameter 1: key bytes 4-7.
Definition: command_packet.h:204
generic_response_packet_t
Generic response packet format.
Definition: command_packet.h:282
configure_can_packet_t
ConfigureCan packet format.
Definition: command_packet.h:268
configure_spi_packet_t
ConfigureSpi packet format.
Definition: command_packet.h:258
flash_read_once_packet_t
FlashReadOnce packet format.
Definition: command_packet.h:217
kFirstCommandTag
Reserved command tag for Bus Pal.
Definition: command_packet.h:88
flash_erase_all_packet_t::commandPacket
command_packet_t commandPacket
header
Definition: command_packet.h:127
kCommandTag_ConfigureSpi
Reserved command tag for Bus Pal.
Definition: command_packet.h:85
generic_response_packet_t::status
uint32_t status
parameter 0
Definition: command_packet.h:285
configure_i2c_packet_t::speed
uint32_t speed
Parameter 1: speed.
Definition: command_packet.h:254
kCommandTagCount
One word is header, two parameters reserved for index and byteCount.
Definition: command_packet.h:54
flash_read_once_response_packet_t
Flash Read Once response packet format.
Definition: command_packet.h:306
configure_quadspi_packet_t::configBlockAddress
uint32_t configBlockAddress
Parameter 1: address of config block to use.
Definition: command_packet.h:238
_command_packet_constants
_command_packet_constants
Command/Data Packet constants.
Definition: command_packet.h:43
flash_read_resource_response_packet_t
Flash Read Resource response packet format.
Definition: command_packet.h:315
kCommandTag_ConfigureCan
Reserved command tag for Bus Pal.
Definition: command_packet.h:86
configure_quadspi_packet_t::flashMemId
uint32_t flashMemId
Parameter 0: quadspi ID.
Definition: command_packet.h:237
configure_i2c_packet_t
ConfigureI2c packet format.
Definition: command_packet.h:250
flash_erase_region_packet_t
FlashEraseRegion packet format.
Definition: command_packet.h:132
kLastCommandTag
Maximum linearly incrementing command tag value, excluding the response commands and bus pal commands...
Definition: command_packet.h:91
flash_erase_region_packet_t::startAddress
uint32_t startAddress
Paremeter 0: start address.
Definition: command_packet.h:135
_command_packet_flags
_command_packet_flags
Command packet flags.
Definition: command_packet.h:98
flash_program_once_packet_t::index
uint32_t index
Parameter 0: index of pragram once field.
Definition: command_packet.h:211
flash_program_once_packet_t
FlashProgramOnce packet format.
Definition: command_packet.h:208
execute_call_packet_t
Execute/Call packet format.
Definition: command_packet.h:191
kMaxProgramOnceValues
Definition: command_packet.h:51
flash_read_resource_packet_t
FlashReadResource packet format.
Definition: command_packet.h:225
command_packet_t::flags
uint8_t flags
Combination of packet flags.
Definition: command_packet.h:116
flash_erase_all_packet_t::memoryId
uint32_t memoryId
Paremeter 0: Flash memory identifiers.
Definition: command_packet.h:128
command_packet_t::parameterCount
uint8_t parameterCount
Number of parameters that follow in buffer.
Definition: command_packet.h:118
configure_spi_packet_t::polarity
uint32_t polarity
Parameter 1: polarity.
Definition: command_packet.h:262
fill_memory_packet_t
FillMemory packet format.
Definition: command_packet.h:179
fill_memory_packet_t::patternWord
uint32_t patternWord
Parameter 1: pattern word.
Definition: command_packet.h:184
configure_can_packet_t::txid
uint32_t txid
Parameter 1: txid.
Definition: command_packet.h:272
reliable_update_packet_t::address
uint32_t address
Definition: command_packet.h:245
configure_spi_packet_t::speedKhz
uint32_t speedKhz
Parameter 0: spped Khz.
Definition: command_packet.h:261
set_property_packet_t
SetProperty packet format.
Definition: command_packet.h:148
call_function_t
status_t(* call_function_t)(uint32_t)
Execute/Call command function pointer definition.
Definition: command_packet.h:188
execute_call_packet_t::stackpointer
uint32_t stackpointer
Parameter 2: stack pointer.
Definition: command_packet.h:196
status_t
int32_t status_t
Type used for all status and error return values.
Definition: fsl_common.h:121
flash_security_disable_packet_t
FlashSecurityDisable packet format.
Definition: command_packet.h:200
configure_spi_packet_t::direction
uint32_t direction
Parameter 3: directionpolarity.
Definition: command_packet.h:264
get_property_packet_t::propertyTag
uint32_t propertyTag
Parameter 0: requested property tag.
Definition: command_packet.h:143
command_packet_t::reserved
uint8_t reserved
Reserved, helpful for alignment, set to zero.
Definition: command_packet.h:117