36 #include "DataSource.h" 37 #include "Packetizer.h" 38 #include "host_types.h" 39 #include "format_string.h" 40 #include "property/property.h" 41 #include "SourceFile.h" 57 const char *
const name;
59 cmd_t(uint8_t tag, uint32_t mask,
const char *name)
67 const cmd_t kCommand_FlashEraseAll(kCommandTag_FlashEraseAll, 0x00000001,
"flash-erase-all");
68 const cmd_t kCommand_FlashEraseRegion(kCommandTag_FlashEraseRegion, 0x00000002,
"flash-erase-region");
69 const cmd_t kCommand_ReadMemory(kCommandTag_ReadMemory, 0x00000004,
"read-memory");
70 const cmd_t kCommand_WriteMemory(kCommandTag_WriteMemory, 0x00000008,
"write-memory");
71 const cmd_t kCommand_FillMemory(kCommandTag_FillMemory, 0x00000010,
"fill-memory");
72 const cmd_t kCommand_FlashSecurityDisable(kCommandTag_FlashSecurityDisable, 0x00000020,
"flash-security-disable");
73 const cmd_t kCommand_GetProperty(kCommandTag_GetProperty, 0x00000040,
"get-property");
74 const cmd_t kCommand_ReceiveSbFile(kCommandTag_ReceiveSbFile, 0x00000080,
"receive-sb-file");
75 const cmd_t kCommand_Execute(kCommandTag_Execute, 0x00000100,
"execute");
76 const cmd_t kCommand_Call(kCommandTag_Call, 0x00000200,
"call");
77 const cmd_t kCommand_Reset(kCommandTag_Reset, 0x00000400,
"reset");
78 const cmd_t kCommand_SetProperty(kCommandTag_SetProperty, 0x00000800,
"set-property");
79 const cmd_t kCommand_FlashEraseAllUnsecure(kCommandTag_FlashEraseAllUnsecure, 0x00001000,
"flash-erase-all-unsecure");
80 const cmd_t kCommand_FlashProgramOnce(kCommandTag_FlashProgramOnce, 0x00002000,
"flash-program-once");
81 const cmd_t kCommand_FlashReadOnce(kCommandTag_FlashReadOnce, 0x00004000,
"flash-read-once");
82 const cmd_t kCommand_FlashReadResource(kCommandTag_FlashReadResource, 0x00008000,
"flash-read-resource");
83 const cmd_t kCommand_ConfigureQuadSpi(kCommandTag_ConfigureQuadSpi, 0x00010000,
"configure-quadspi");
84 const cmd_t kCommand_ReliableUpdate(kCommandTag_ReliableUpdate, 0x00100000,
"reliable-update");
86 const cmd_t kCommand_FlashImage(0x00, 0x00000000,
"flash-image");
87 const cmd_t kCommand_ConfigureI2c(kCommandTag_ConfigureI2c, 0x00020000,
"i2c");
88 const cmd_t kCommand_ConfigureSpi(kCommandTag_ConfigureSpi, 0x00040000,
"spi");
89 const cmd_t kCommand_ConfigureCan(kCommandTag_ConfigureCan, 0x00080000,
"can");
91 const array<const cmd_t, 22> kCommands = { kCommand_FlashEraseAll,
92 kCommand_FlashEraseRegion,
96 kCommand_FlashSecurityDisable,
98 kCommand_ReceiveSbFile,
102 kCommand_SetProperty,
103 kCommand_FlashEraseAllUnsecure,
104 kCommand_FlashProgramOnce,
105 kCommand_FlashReadOnce,
106 kCommand_FlashReadResource,
107 kCommand_ConfigureQuadSpi,
108 kCommand_ReliableUpdate,
110 kCommand_ConfigureI2c,
111 kCommand_ConfigureSpi,
112 kCommand_ConfigureCan };
120 const char *description;
122 property_t(uint8_t value,
const char *description)
124 , description(description)
128 string str()
const {
return format_string(
"0x%02x", value); }
130 const property_t kProperty_ListProperties(kPropertyTag_ListProperties,
"list-properties");
131 const property_t kProperty_CurrentVersion(kPropertyTag_BootloaderVersion,
"current-version");
132 const property_t kProperty_AvailablePeripherals(kPropertyTag_AvailablePeripherals,
"available-peripherals");
133 const property_t kProperty_FlashStartAddress(kPropertyTag_FlashStartAddress,
"flash-start-address");
134 const property_t kProperty_FlashSizeInBytes(kPropertyTag_FlashSizeInBytes,
"flash-size-in-bytes");
135 const property_t kProperty_FlashSectorSize(kPropertyTag_FlashSectorSize,
"flash-sector-size");
136 const property_t kProperty_FlashBlockCount(kPropertyTag_FlashBlockCount,
"flash-block-count");
137 const property_t kProperty_AvailableCommands(kPropertyTag_AvailableCommands,
"available-commands");
138 const property_t kProperty_CrcCheckStatus(kPropertyTag_CrcCheckStatus,
"crc-check-status");
139 const property_t kProperty_Reserved9(kPropertyTag_Reserved9,
"reserved");
140 const property_t kProperty_VerifyWrites(kPropertyTag_VerifyWrites,
"verify-writes");
141 const property_t kProperty_MaxPacketSize(kPropertyTag_MaxPacketSize,
"max-packet-size");
142 const property_t kProperty_ReservedRegions(kPropertyTag_ReservedRegions,
"reserved-regions");
143 const property_t kProperty_Reserved13(kPropertyTag_Reserved13,
"reserved");
144 const property_t kProperty_RAMStartAddress(kPropertyTag_RAMStartAddress,
"ram-start-address");
145 const property_t kProperty_RAMSizeInBytes(kPropertyTag_RAMSizeInBytes,
"ram-size-in-bytes");
146 const property_t kProperty_SystemDeviceId(kPropertyTag_SystemDeviceId,
"system-device-id");
147 const property_t kProperty_FlashSecurityState(kPropertyTag_FlashSecurityState,
"flash-security-state");
148 const property_t kProperty_UniqueDeviceId(kPropertyTag_UniqueDeviceId,
"unique-device-id");
149 const property_t kProperty_FacSupport(kPropertyTag_FacSupport,
"flash-fac-support");
150 const property_t kProperty_FlashAccessSegmentSize(kPropertyTag_FlashAccessSegmentSize,
"flash-access-segment-size");
151 const property_t kProperty_FlashAccessSegmentCount(kPropertyTag_FlashAccessSegmentCount,
"flash-access-segment-count");
152 const property_t kProperty_FlashReadMargin(kPropertyTag_FlashReadMargin,
"flash-read-margin");
153 const property_t kProperty_QspiInitStatus(kPropertyTag_QspiInitStatus,
"qspi/otfad-init-status");
154 const property_t kProperty_TargetVersion(kPropertyTag_TargetVersion,
"target-version");
155 const property_t kProperty_ExernalMemoryAttributes(kPropertyTag_ExternalMemoryAttributes,
"external-memory-attributes");
156 const property_t kProperty_ReliableUpdateStatus(kPropertyTag_ReliableUpdateStatus,
"reliable-update-status");
157 const property_t kProperty_Invalid(kPropertyTag_InvalidProperty,
"invalid-property");
159 typedef array<const property_t, 27> PropertyArray;
161 const PropertyArray kProperties = {
162 kProperty_ListProperties, kProperty_CurrentVersion,
163 kProperty_AvailablePeripherals, kProperty_FlashStartAddress,
164 kProperty_FlashSizeInBytes, kProperty_FlashSectorSize,
165 kProperty_FlashBlockCount, kProperty_AvailableCommands,
166 kProperty_CrcCheckStatus, kProperty_Reserved9,
167 kProperty_VerifyWrites, kProperty_MaxPacketSize,
168 kProperty_ReservedRegions, kProperty_Reserved13,
169 kProperty_RAMStartAddress, kProperty_RAMSizeInBytes,
170 kProperty_SystemDeviceId, kProperty_FlashSecurityState,
171 kProperty_UniqueDeviceId, kProperty_FacSupport,
172 kProperty_FlashAccessSegmentSize, kProperty_FlashAccessSegmentCount,
173 kProperty_FlashReadMargin, kProperty_QspiInitStatus,
174 kProperty_TargetVersion, kProperty_ExernalMemoryAttributes,
175 kProperty_ReliableUpdateStatus,
184 const char *description;
188 , description(description)
193 const peripheral_t kPeripheral_Uart(0x00000001,
"UART");
194 const peripheral_t kPeripheral_I2C(0x00000002,
"I2C Slave");
195 const peripheral_t kPeripheral_Spi(0x00000004,
"SPI Slave");
197 const peripheral_t kPeripheral_UsbHid(0x00000010,
"USB HID");
198 const peripheral_t kPeripheral_UsbCdc(0x00000020,
"USB CDC");
199 const peripheral_t kPeripheral_UsbDfu(0x00000040,
"USB DFU");
201 const array<const peripheral_t, 7> kPeripherals = { kPeripheral_Uart, kPeripheral_I2C, kPeripheral_Spi,
202 kPeripheral_Can, kPeripheral_UsbHid, kPeripheral_UsbCdc,
203 kPeripheral_UsbDfu };
232 , m_progressCallback(NULL)
238 Progress(
void (*callback)(
int,
int,
int),
bool *abortPhase)
241 , m_progressCallback(callback)
242 , m_abortPhase(abortPhase)
253 if (m_progressCallback != NULL)
255 m_progressCallback(percentage, m_segmentIndex, m_segmentCount);
262 if ((m_abortPhase) && (*m_abortPhase ==
true))
279 m_progressCallback = callback;
280 m_abortPhase = abortPhase;
288 void (*m_progressCallback)(
int percentage,
int segmentIndex,
int segmentCount);
322 static Command *create(
const string_vector_t *argv);
326 static std::string getStatusMessage(status_t code);
335 , m_responseDetails()
346 , m_responseDetails()
357 virtual bool init() {
return true; }
362 virtual std::string
getArg(
int arg)
const {
return m_argv.at(arg); }
364 virtual std::string
getName()
const {
return getArg(0); }
374 return const_cast<uint32_vector_t *
>(&m_responseValues);
378 virtual std::string getResponse()
const;
381 void logResponses()
const;
390 virtual bool processResponse(
const generic_response_packet_t *packet, uint8_t commandTag);
412 kMaxCommandArguments = (kDefaultMaxPacketSize -
sizeof(command_packet_t)) /
420 void init(uint8_t tag, uint8_t flags, uint8_t numArguments)
422 m_header.commandTag = tag;
423 m_header.flags = flags;
424 m_header.reserved = 0;
425 m_header.parameterCount = numArguments;
428 uint32_t m_arguments[kMaxCommandArguments];
436 m_packet.init(tag, flags, m_numArguments);
443 m_packet.init(tag, flags, m_numArguments);
444 m_packet.m_arguments[0] = arg;
451 m_packet.init(tag, flags, m_numArguments);
452 m_packet.m_arguments[0] = arg1;
453 m_packet.m_arguments[1] = arg2;
457 CommandPacket(uint8_t tag, uint8_t flags, uint32_t arg1, uint32_t arg2, uint32_t arg3)
460 m_packet.init(tag, flags, m_numArguments);
461 m_packet.m_arguments[0] = arg1;
462 m_packet.m_arguments[1] = arg2;
463 m_packet.m_arguments[2] = arg3;
467 CommandPacket(uint8_t tag, uint8_t flags, uint32_t arg1, uint32_t arg2, uint32_t arg3, uint32_t arg4)
470 m_packet.init(tag, flags, m_numArguments);
471 m_packet.m_arguments[0] = arg1;
472 m_packet.m_arguments[1] = arg2;
473 m_packet.m_arguments[2] = arg3;
474 m_packet.m_arguments[3] = arg4;
478 uint32_t
getSize()
const {
return sizeof(command_packet_t) + (m_numArguments *
sizeof(uint32_t)); }
480 const uint8_t *
getData() {
return reinterpret_cast<uint8_t *
>(&m_packet.m_header); }
484 const uint8_t *sendCommandGetResponse(
Packetizer &device);
506 virtual bool hasMoreData()
const = 0;
509 virtual uint32_t getDataSize()
const = 0;
515 virtual uint32_t getData(uint8_t *data, uint32_t size) = 0;
527 , m_filePointer(NULL)
536 fclose(m_filePointer);
540 bool init(std::string filePath, uint32_t count);
544 virtual bool hasMoreData()
const 547 assert(m_filePointer);
548 return (m_fileSize && !feof(m_filePointer));
552 virtual uint32_t
getDataSize()
const {
return (uint32_t)m_fileSize; }
557 virtual uint32_t getData(uint8_t *data, uint32_t size);
591 uint32_t initFromString(
const std::string hexData);
597 virtual bool hasMoreData()
const {
return (m_byteIndex < m_data.size()); }
605 virtual uint32_t getData(uint8_t *data, uint32_t size);
629 bool init(std::string filePath);
633 virtual bool hasMoreData()
const {
return (m_byteIndex < m_segment->getLength()); }
636 virtual uint32_t
getDataSize()
const {
return m_segment->getLength(); }
641 virtual uint32_t getData(uint8_t *data, uint32_t size);
656 virtual void processData(
const uint8_t *data, uint32_t size) = 0;
659 virtual void finalize() = 0;
671 , m_filePointer(NULL)
679 fclose(m_filePointer);
683 bool init(std::string filePath);
686 virtual void processData(
const uint8_t *data, uint32_t size);
716 if (((m_currentCount - 1) % kBytesPerLine) != 0)
719 for (
int i = ((m_currentCount - 1) % kBytesPerLine) * 3; i < 9; i++)
728 virtual void processData(
const uint8_t *data, uint32_t size);
738 assert(dataProducer);
739 m_dataProducer = dataProducer;
745 assert(dataConsumer);
746 m_dataConsumer = dataConsumer;
762 uint8_t m_packet[kMinPacketBufferSize];
795 return Command::processResponse(reinterpret_cast<const generic_response_packet_t *>(packet), kCommandTag_Reset);
808 , m_property(kProperty_Invalid.value, kProperty_Invalid.description)
814 :
Command(kCommand_GetProperty.name)
815 , m_property(property)
817 m_argv.push_back(format_string(
"0x%08x", property.value));
828 virtual bool processResponse(
const get_property_response_packet_t *packet);
833 return Command::processResponse(reinterpret_cast<const generic_response_packet_t *>(packet),
834 kCommandTag_GetProperty);
856 :
Command(kCommand_SetProperty.name)
857 , m_propertyTag(property.value)
858 , m_propertyValue(value)
860 m_argv.push_back(format_string(
"0x%08x", property.value));
861 m_argv.push_back(format_string(
"0x%08x", value));
874 return Command::processResponse(reinterpret_cast<const generic_response_packet_t *>(packet),
875 kCommandTag_SetProperty);
897 :
Command(kCommand_FlashEraseRegion.name)
898 , m_startAddress(start)
899 , m_byteCount(length)
901 m_argv.push_back(format_string(
"0x%08x", start));
902 m_argv.push_back(format_string(
"0x%08x", length));
915 return Command::processResponse(reinterpret_cast<const generic_response_packet_t *>(packet),
916 kCommandTag_FlashEraseRegion);
938 :
Command(kCommand_FlashEraseAll.name)
939 , m_memoryId(memoryId)
941 m_argv.push_back(format_string(
"%d", memoryId));
954 return Command::processResponse(reinterpret_cast<const generic_response_packet_t *>(packet),
955 kCommandTag_FlashEraseAll);
976 :
Command(kCommand_GetProperty.name)
990 return Command::processResponse(reinterpret_cast<const generic_response_packet_t *>(packet),
991 kCommandTag_FlashEraseAllUnsecure);
1009 virtual bool init();
1016 virtual bool processResponse(
const read_memory_response_packet_t *packet);
1021 return Command::processResponse(reinterpret_cast<const generic_response_packet_t *>(packet),
1022 kCommandTag_ReadMemory);
1050 :
Command(kCommand_WriteMemory.name)
1052 , m_segment(segment)
1057 m_argv.push_back(format_string(
"0x%08x", m_startAddress));
1058 m_argv.push_back(m_fileOrData);
1063 :
Command(kCommand_WriteMemory.name)
1066 , m_startAddress(address)
1070 m_argv.push_back(format_string(
"0x%08x", m_startAddress));
1071 m_argv.push_back(m_fileOrData);
1075 virtual bool init();
1084 return Command::processResponse(reinterpret_cast<const generic_response_packet_t *>(packet),
1085 kCommandTag_WriteMemory);
1109 virtual bool init();
1118 return Command::processResponse(reinterpret_cast<const generic_response_packet_t *>(packet),
1119 kCommandTag_FillMemory);
1143 :
Command(kCommand_ReceiveSbFile.name)
1144 , m_dataFile(filename)
1149 virtual bool init();
1158 return Command::processResponse(reinterpret_cast<const generic_response_packet_t *>(packet),
1159 kCommandTag_ReceiveSbFile);
1179 Execute(uint32_t entry_point, uint32_t param, uint32_t stack_pointer)
1180 :
Command(kCommand_Execute.name)
1181 , m_jumpAddress(entry_point)
1182 , m_wordArgument(param)
1183 , m_stackpointer(stack_pointer)
1185 m_argv.push_back(format_string(
"0x%08x", entry_point));
1186 m_argv.push_back(format_string(
"0x%08x", param));
1187 m_argv.push_back(format_string(
"0x%08x", stack_pointer));
1191 virtual bool init();
1200 return Command::processResponse(reinterpret_cast<const generic_response_packet_t *>(packet),
1201 kCommandTag_Execute);
1223 virtual bool init();
1232 return Command::processResponse(reinterpret_cast<const generic_response_packet_t *>(packet), kCommandTag_Call);
1254 :
Command(kCommand_FlashSecurityDisable.name)
1255 , m_keyHigh(keyHigh)
1261 virtual bool init();
1270 return Command::processResponse(reinterpret_cast<const generic_response_packet_t *>(packet),
1271 kCommandTag_FlashSecurityDisable);
1293 :
Command(kCommand_FlashProgramOnce.name)
1295 , m_byteCount(byteCount)
1296 , m_dataLow(dataLow)
1297 , m_dataHigh(dataHigh)
1302 virtual bool init();
1311 return Command::processResponse(reinterpret_cast<const generic_response_packet_t *>(packet),
1312 kCommandTag_FlashProgramOnce);
1335 virtual bool init();
1342 virtual bool processResponse(
const flash_read_once_response_packet_t *packet);
1347 return Command::processResponse(reinterpret_cast<const generic_response_packet_t *>(packet),
1348 kCommandTag_FlashReadOnce);
1370 virtual bool init();
1377 virtual bool processResponse(
const flash_read_resource_response_packet_t *packet);
1382 return Command::processResponse(reinterpret_cast<const generic_response_packet_t *>(packet),
1383 kCommandTag_FlashReadResource);
1406 virtual bool init();
1415 return Command::processResponse(reinterpret_cast<const generic_response_packet_t *>(packet),
1416 kCommandTag_ConfigureQuadSpi);
1437 virtual bool init();
1446 return Command::processResponse(reinterpret_cast<const generic_response_packet_t *>(packet),
1447 kCommandTag_ReliableUpdate);
1464 , m_sourceFile(NULL)
1465 , m_doEraseOpt(false)
1472 :
Command(kCommand_FlashImage.name)
1474 , m_sourceFile(sourceFile)
1475 , m_doEraseOpt(doEraseOpt)
1478 m_argv.push_back(m_sourceFile->getPath());
1479 m_argv.push_back(doEraseOpt ?
"erase" :
"none");
1483 virtual bool init();
1508 virtual bool init();
1517 return Command::processResponse(reinterpret_cast<const generic_response_packet_t *>(packet),
1518 kCommandTag_ConfigureI2c);
1522 uint8_t i2cAddress = 0x10;
1523 uint32_t i2cSpeedKHz = 100;
1539 virtual bool init();
1548 return Command::processResponse(reinterpret_cast<const generic_response_packet_t *>(packet),
1549 kCommandTag_ConfigureSpi);
1553 uint32_t spiSpeedKHz = 100;
1572 virtual bool init();
1581 return Command::processResponse(reinterpret_cast<const generic_response_packet_t *>(packet),
1582 kCommandTag_ConfigureCan);
1586 uint32_t canSpeed = 4;
1587 uint32_t canTxid = 0x321;
1588 uint32_t canRxid = 0x123;
1597 #endif // _Command_h_ virtual bool processResponse(const uint8_t *packet)
Check generic response packet.
Definition: Command.h:1380
Interface class for packetization of commands and data.
Definition: Packetizer.h:59
Represents the bootloader Flash Erase All command.
Definition: Command.h:927
Execute(const string_vector_t *argv)
Constructor that takes an argument vector.
Definition: Command.h:1173
Reset(const string_vector_t *argv)
Constructor that takes argument vector.
Definition: Command.h:774
Write file data for data phase receive.
Definition: Command.h:665
spi_shift_direction_t
SPI data shifter direction options.
Definition: BusPal.h:90
virtual bool processResponse(const uint8_t *packet)
Check generic response packet.
Definition: Command.h:1345
uint32_t m_keyLow
Bytes 0-3 of the flash backdoor key.
Definition: Command.h:1275
virtual uint32_t getDataSize() const
Query the total size of the data.
Definition: Command.h:600
uchar_vector_t m_data
Data byte vector.
Definition: Command.h:610
int m_segmentCount
The number of data segments.
Definition: Command.h:285
Progress()
Default constructor.
Definition: Command.h:229
Represents the bootloader Flash Security Disable command.
Definition: Command.h:1243
Command packet operations.
Definition: Command.h:406
uint32_vector_t m_responseValues
Vector of response values.
Definition: Command.h:397
uint32_t m_wordArgument
Word argument passed to function.
Definition: Command.h:1237
virtual bool processResponse(const uint8_t *packet)
Check response packet.
Definition: Command.h:1082
long m_fileSize
Size in bytes of data file.
Definition: Command.h:563
uint32_t m_wordArgument
Word argument passed to function.
Definition: Command.h:1206
SegmentDataProducer(blfwk::DataSource::Segment *segment)
Default constructor.
Definition: Command.h:620
Definition: BlfwkErrors.h:16
uint32_t getSize() const
Get size of command packet, including arguments.
Definition: Command.h:478
Represents a bootloader command.
Definition: Command.h:301
FlashImage(SourceFile *sourceFile, bool doEraseOpt)
Constructor that takes a SourceFile argument.
Definition: Command.h:1471
FlashEraseRegion(uint32_t start, uint32_t length)
Constructor that takes a start and length arguments.
Definition: Command.h:896
Abstract class to provide data for data phase.
Definition: Command.h:502
Call(const string_vector_t *argv)
Constructor that takes an argument vector.
Definition: Command.h:1217
blfwk::DataSource::Segment * m_segment
DataSource::Segment object.
Definition: Command.h:645
void progressCallback(int percentage)
execute the progress callback function.
Definition: Command.h:251
uint32_t m_patternWord
Fill pattern.
Definition: Command.h:1125
uint32_t m_memoryId
External memory identifier.
Definition: Command.h:839
uint32_t m_byteCount
Number of bytes to read.
Definition: Command.h:1028
uint32_t m_dataHigh
Bytes 4-7 of the data to be written.
Definition: Command.h:1319
FlashSecurityDisable(const string_vector_t *argv)
Constructor that takes an argument vector.
Definition: Command.h:1247
FlashEraseAllUnsecure()
Constructor that takes none argument.
Definition: Command.h:975
Abstract class to consume data from data phase.
Definition: Command.h:652
virtual void finalize()
Finalize processing.
Definition: Command.h:714
ReliableUpdate(const string_vector_t *argv)
Constructor that takes an argument vector.
Definition: Command.h:1431
Represents the bootloader GetProperty command.
Definition: Command.h:802
virtual bool processResponse(const uint8_t *packet)
Check response packet.
Definition: Command.h:1268
uint32_t m_propertyTag
Property tag.
Definition: Command.h:879
Command(const string_vector_t *argv)
Constructor that takes a command name and list of arguments.
Definition: Command.h:332
virtual bool processResponse(const uint8_t *packet)
Check response packet.
Definition: Command.h:1198
virtual uint32_t getDataSize() const
Query the total size of the data.
Definition: Command.h:636
virtual ~FileDataProducer()
Destructor.
Definition: Command.h:533
int m_segmentIndex
Index of data segment in progressing.
Definition: Command.h:284
virtual uint32_t getBaseAddress()
Returns the address associated with the segment.
Definition: src/blfwk/DataSource.h:95
const std::string message
Description of the status.
Definition: Command.h:212
void registerProgress(Progress *progress)
initial the process callback.
Definition: Command.h:384
virtual bool processResponse(const uint8_t *packet)
Check generic response packet.
Definition: Command.h:872
HexDataProducer(const uchar_vector_t &data)
Constructor that takes a vector<uchar> parameter.
Definition: Command.h:580
int32_t status
Status code value.
Definition: Command.h:211
Provide file data for data phase.
Definition: Command.h:521
Provide DataSource::Segment data for data phase.
Definition: Command.h:616
virtual void sendTo(Packetizer &packetizer)
Send command to packetizer and on to peripheral.
Definition: Command.h:370
CommandPacket(uint8_t tag, uint8_t flags=0)
Constructor that takes no command arguments.
Definition: Command.h:433
FlashSecurityDisable(uint32_t keyHigh, uint32_t keyLow)
Constructor that takes the key.
Definition: Command.h:1253
std::string m_filePath
Data file path.
Definition: Command.h:561
uint32_t m_address
Destination address.
Definition: Command.h:1451
SetProperty(const string_vector_t *argv)
Constructor that takes an argument vector.
Definition: Command.h:849
CommandPacket(uint8_t tag, uint8_t flags, uint32_t arg1, uint32_t arg2)
Constructor that takes two command arguments.
Definition: Command.h:448
WriteMemory(uint32_t address, const uchar_vector_t &data)
Constructor that takes an uchar_vector_t argument.
Definition: Command.h:1062
uint32_t m_startAddress
Destination memory address.
Definition: Command.h:1091
Represents the bootloader Flash Erase command.
Definition: Command.h:886
FlashEraseAllUnsecure(const string_vector_t *argv)
Constructor that takes an argument vector.
Definition: Command.h:969
virtual bool processResponse(const uint8_t *packet)
Check response packet.
Definition: Command.h:1116
uchar_vector_t m_data
The data to write to the device.
Definition: Command.h:1093
SourceFile * m_sourceFile
Sourcefile object containing the data and addresses.
Definition: Command.h:1491
uint32_t m_propertyValue
Value to set.
Definition: Command.h:880
ReceiveSbFile(const string_vector_t *argv)
Constructor that takes an argument vector.
Definition: Command.h:1135
FlashProgramOnce(const string_vector_t *argv)
Constructor that takes an argument vector.
Definition: Command.h:1286
virtual bool processResponse(const uint8_t *packet)
Check response packet.
Definition: Command.h:1309
uint32_t m_sectorSize
Flash sector size of current target.
Definition: Command.h:1489
Reset()
Default constructor.
Definition: Command.h:780
virtual ~HexDataProducer()
Destructor.
Definition: Command.h:594
std::string m_dataFile
Data file path.
Definition: Command.h:1026
virtual bool processResponse(const uint8_t *packet)
Check response packet.
Definition: Command.h:1444
uint32_t m_byteCount
Number of bytes to fill.
Definition: Command.h:1124
StdOutDataConsumer()
Constructor.
Definition: Command.h:708
Represents the bootloader Reset command.
Definition: Command.h:770
FlashImage(const string_vector_t *argv)
Constructor that takes an argument vector.
Definition: Command.h:1461
virtual std::string getArg(int arg) const
Get the specified argument.
Definition: Command.h:362
Definition: Command.h:181
DataPacket(DataConsumer *dataConsumer)
Constructor that takes a DataConsumer.
Definition: Command.h:743
uint32_t m_jumpAddress
Destination memory address to jump to.
Definition: Command.h:1205
uint32_t m_keyHigh
Bytes 4-7 of the flash backdoor key.
Definition: Command.h:1276
Represents the bootloader Flash Erase All Unsecure command.
Definition: Command.h:965
virtual bool processResponse(const uint8_t *packet)
Check response packet.
Definition: Command.h:1156
void registerCallback(void(*callback)(int, int, int), bool *abortPhase)
Definition: Command.h:277
Provide data from hex string for data phase.
Definition: Command.h:569
Represents the bootloader Read Memory command.
Definition: Command.h:998
uint32_t m_option
Resrouce to be read.
Definition: Command.h:1390
Command(const char *const name)
Constructor that takes a command name.
Definition: Command.h:343
uint32_t m_count
Number of bytes to write.
Definition: Command.h:1092
FlashEraseAll(uint32_t memoryId)
Constructor that takes memory ID argument.
Definition: Command.h:937
virtual bool processResponse(const uint8_t *packet)
Check response packet.
Definition: Command.h:793
uint32_t m_byteIndex
Current byte index.
Definition: Command.h:609
_command_packet_constants
Constants.
Definition: Command.h:410
std::string m_fileOrData
Data file path or hex data string.
Definition: Command.h:1089
virtual void finalize()
Finalize processing.
Definition: Command.h:689
Abstract base class for a source file containing executable code.
Definition: src/blfwk/SourceFile.h:56
bool m_doEraseOpt
Detemine if doing erase operation before writting image file to flash.
Definition: Command.h:1492
_constants
Definition: Command.h:701
FlashReadResource(const string_vector_t *argv)
Constructor that takes an argument vector.
Definition: Command.h:1363
virtual uint32_t getDataSize() const
Query the total size of the data.
Definition: Command.h:552
FileDataConsumer()
Default constructor.
Definition: Command.h:669
virtual std::string getName() const
Get the command name (i.e. argv[0]).
Definition: Command.h:364
Represents the Flash Image command used for downloading formatted file.
Definition: Command.h:1457
SetProperty(property_t property, uint32_t value)
Constructor that takes a property_t argument and the value to set.
Definition: Command.h:855
FlashProgramOnce(uint32_t index, uint32_t byteCount, uint32_t dataLow, uint32_t dataHigh)
Constructor that takes arguments.
Definition: Command.h:1292
FillMemory(const string_vector_t *argv)
Constructor that takes an argument vector.
Definition: Command.h:1103
blfwk::DataSource::Segment * m_segment
DataSource segment (instead of file or hex string).
Definition: Command.h:1090
uint32_t m_byteIndex
Current byte index.
Definition: Command.h:646
int m_numArguments
Number of command arguments.
Definition: Command.h:487
GetProperty(const string_vector_t *argv)
Constructor that takes an argument vector.
Definition: Command.h:806
void init(uint8_t tag, uint8_t flags, uint8_t numArguments)
Initialize the command packet.
Definition: Command.h:420
uint32_t m_currentCount
Current byte being processed, starts at 1.
Definition: Command.h:731
string m_responseDetails
Descriptive response.
Definition: Command.h:398
DataProducer * m_dataProducer
Provides data for the packet.
Definition: Command.h:760
Progress(void(*callback)(int, int, int), bool *abortPhase)
Constructor with initial callback.
Definition: Command.h:238
PacketWithArgs m_packet
Command packet data.
Definition: Command.h:488
virtual ~Command()
Destructor.
Definition: Command.h:353
FILE * m_filePointer
Data file pointer.
Definition: Command.h:692
FileDataProducer()
Default constructor.
Definition: Command.h:525
Format of command packet.
Definition: Command.h:417
uint32_t m_byteCount
Number of bytes to be read.
Definition: Command.h:1353
Discrete, contiguous part of the source's data.
Definition: src/blfwk/DataSource.h:65
CommandPacket(uint8_t tag, uint8_t flags, uint32_t arg)
Constructor that takes one command argument.
Definition: Command.h:440
spi_clock_polarity_t
SPI clock polarity configuration.
Definition: BusPal.h:74
property_t m_property
Property tag.
Definition: Command.h:838
command_packet_t m_header
Packet header.
Definition: Command.h:427
~Progress()
Default destructor.
Definition: Command.h:247
Represents the bootloader Reliable Update command.
Definition: Command.h:1427
spi_clock_phase_t
SPI clock phase configuration.
Definition: BusPal.h:81
Represents the bootloader Write Memory command.
Definition: Command.h:1034
uint32_t m_startAddress
Destination memory address.
Definition: Command.h:1123
FlashReadOnce(const string_vector_t *argv)
Constructor that takes an argument vector.
Definition: Command.h:1329
virtual bool processResponse(const uint8_t *packet)
Check response packet.
Definition: Command.h:1230
uint32_t m_index
Index of program once field to be programed.
Definition: Command.h:1316
Contains the callback function for progress and abort phase.
Definition: Command.h:225
FILE * m_filePointer
Data file pointer.
Definition: Command.h:562
HexDataProducer()
Default constructor.
Definition: Command.h:573
Represents the bootloader Call command.
Definition: Command.h:1213
uint32_t m_byteCount
Number of bytes to erase.
Definition: Command.h:921
uint32_t m_callAddress
Destination memory address to call.
Definition: Command.h:1236
virtual size_t getArgCount() const
Get the number of arguments, including the command name.
Definition: Command.h:366
Definition: Command.h:117
uint32_t m_byteCount
Number of bytes to read.
Definition: Command.h:1389
ReadMemory(const string_vector_t *argv)
Constructor that takes an argument vector.
Definition: Command.h:1002
bool abortPhase(void)
Check whether the data phase is canceled.
Definition: Command.h:260
Execute(uint32_t entry_point, uint32_t param, uint32_t stack_pointer)
Constructor that takes entry_point, param and stack_pointer arguments.
Definition: Command.h:1179
WriteMemory(const string_vector_t *argv)
Constructor that takes an argument vector.
Definition: Command.h:1038
uint32_t m_startAddress
Destination memory address.
Definition: Command.h:1388
uint32_t m_dataLow
Bytes 0-3 of the data to be written.
Definition: Command.h:1318
DataConsumer * m_dataConsumer
Process the data in the packet.
Definition: Command.h:761
std::string m_dataFile
Data file path.
Definition: Command.h:1387
FlashEraseRegion(const string_vector_t *argv)
Constructor that takes an argument vector.
Definition: Command.h:890
uint32_t m_memoryId
Flash Memory Identifier.
Definition: Command.h:959
virtual bool processResponse(const uint8_t *packet)
Check generic response packet.
Definition: Command.h:1019
std::string m_filePath
Data file path.
Definition: Command.h:691
FlashEraseAll(const string_vector_t *argv)
Constructor that takes an argument vector.
Definition: Command.h:931
Progress * m_progress
Variable for progress control.
Definition: Command.h:393
CommandPacket(uint8_t tag, uint8_t flags, uint32_t arg1, uint32_t arg2, uint32_t arg3)
Constructor that takes three command arguments.
Definition: Command.h:457
ReceiveSbFile(const char *const filename)
Constructor that takes a filename argument.
Definition: Command.h:1142
uint32_t m_startAddress
Starting address in flash.
Definition: Command.h:920
Represents the bootloader Fill Memory command.
Definition: Command.h:1099
GetProperty(property_t property)
Constructor that takes a property_t argument.
Definition: Command.h:813
virtual bool processResponse(const uint8_t *packet)
Check generic response packet.
Definition: Command.h:831
Represents the bootloader Read Resource command.
Definition: Command.h:1359
Represents the bootloader Receive SB File command.
Definition: Command.h:1131
virtual bool processResponse(const uint8_t *packet)
Check response packet.
Definition: Command.h:952
std::string m_fileName
Image file name with full path.
Definition: Command.h:1490
string_vector_t m_argv
Vector of argument strings.
Definition: Command.h:396
uint32_t m_stackpointer
Stack pointer.
Definition: Command.h:1207
std::string m_dataFile
SB file path.
Definition: Command.h:1163
Represents the bootloader GetProperty command.
Definition: Command.h:845
uint32_t m_startAddress
Destination memory address.
Definition: Command.h:1027
Represents the bootloader Execute command.
Definition: Command.h:1169
virtual ~SegmentDataProducer()
Destructor.
Definition: Command.h:627
Print data for data phase receive.
Definition: Command.h:698
Represents the bootloader Flash Program Once command.
Definition: Command.h:1282
virtual ~FileDataConsumer()
Destructor.
Definition: Command.h:676
Entry in a lookup table of status messages.
Definition: Command.h:209
const uint8_t * getData()
Get pointer to command packet data.
Definition: Command.h:480
virtual bool processResponse(const uint8_t *packet)
Check response packet.
Definition: Command.h:988
uint32_t m_byteCount
Number of bytes to be programmed.
Definition: Command.h:1317
DataPacket(DataProducer *dataProducer)
Constructor that takes a DataProducer.
Definition: Command.h:736
CommandPacket(uint8_t tag, uint8_t flags, uint32_t arg1, uint32_t arg2, uint32_t arg3, uint32_t arg4)
Constructor that takes four command arguments.
Definition: Command.h:467
WriteMemory(blfwk::DataSource::Segment *segment)
Constructor that takes an DataSource::Segment argument.
Definition: Command.h:1049
uint32_t m_index
Index of Program Once Field.
Definition: Command.h:1352
Represents the bootloader Flash Read Once command.
Definition: Command.h:1325
virtual const uint32_vector_t * getResponseValues() const
Get response values vector.
Definition: Command.h:372
Data packet operations.
Definition: Command.h:496
virtual bool init()
Initialize.
Definition: Command.h:357
virtual bool processResponse(const uint8_t *packet)
Check response packet.
Definition: Command.h:913