Kinetis Bootloader Host  2.0.0
Host Tools for Kinetis devices
Command.h
1 /*
2  * Copyright (c) 2013-2015, Freescale Semiconductor, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without modification,
6  * are permitted provided that the following conditions are met:
7  *
8  * o Redistributions of source code must retain the above copyright notice, this list
9  * of conditions and the following disclaimer.
10  *
11  * o Redistributions in binary form must reproduce the above copyright notice, this
12  * list of conditions and the following disclaimer in the documentation and/or
13  * other materials provided with the distribution.
14  *
15  * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
16  * contributors may be used to endorse or promote products derived from this
17  * software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
23  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 
31 #ifndef _Command_h_
32 #define _Command_h_
33 
34 #include <array>
35 #include <assert.h>
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"
42 #include "BusPal.h"
43 
46 
47 using namespace std;
48 
49 namespace blfwk
50 {
52 
53 struct cmd_t
54 {
55  uint8_t tag;
56  uint32_t mask;
57  const char *const name;
58 
59  cmd_t(uint8_t tag, uint32_t mask, const char *name)
60  : tag(tag)
61  , mask(mask)
62  , name(name)
63  {
64  }
65 };
66 
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");
85 // flash-image is not a ROM basic command, but a combination of several basic commands.
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");
90 
91 const array<const cmd_t, 22> kCommands = { kCommand_FlashEraseAll,
92  kCommand_FlashEraseRegion,
93  kCommand_ReadMemory,
94  kCommand_WriteMemory,
95  kCommand_FillMemory,
96  kCommand_FlashSecurityDisable,
97  kCommand_GetProperty,
98  kCommand_ReceiveSbFile,
99  kCommand_Execute,
100  kCommand_Call,
101  kCommand_Reset,
102  kCommand_SetProperty,
103  kCommand_FlashEraseAllUnsecure,
104  kCommand_FlashProgramOnce,
105  kCommand_FlashReadOnce,
106  kCommand_FlashReadResource,
107  kCommand_ConfigureQuadSpi,
108  kCommand_ReliableUpdate,
109  kCommand_FlashImage,
110  kCommand_ConfigureI2c,
111  kCommand_ConfigureSpi,
112  kCommand_ConfigureCan };
114 
116 
118 {
119  uint32_t value;
120  const char *description;
121 
122  property_t(uint8_t value, const char *description)
123  : value(value)
124  , description(description)
125  {
126  }
127 
128  string str() const { return format_string("0x%02x", value); }
129 };
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");
158 
159 typedef array<const property_t, 27> PropertyArray;
160 
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,
176 };
178 
180 
182 {
183  uint32_t mask;
184  const char *description;
185 
186  peripheral_t(uint32_t mask, const char *description)
187  : mask(mask)
188  , description(description)
189  {
190  }
191 };
192 
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");
196 const peripheral_t kPeripheral_Can(0x00000008, "CAN");
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");
200 
201 const array<const peripheral_t, 7> kPeripherals = { kPeripheral_Uart, kPeripheral_I2C, kPeripheral_Spi,
202  kPeripheral_Can, kPeripheral_UsbHid, kPeripheral_UsbCdc,
203  kPeripheral_UsbDfu };
205 
210 {
211  int32_t status;
212  const std::string message;
213 };
214 
219 extern StatusMessageTableEntry g_statusCodes[];
220 
225 class Progress
226 {
227 public:
230  : m_segmentIndex(1)
231  , m_segmentCount(1)
232  , m_progressCallback(NULL)
233  , m_abortPhase(NULL)
234  {
235  }
236 
238  Progress(void (*callback)(int, int, int), bool *abortPhase)
239  : m_segmentIndex(1)
240  , m_segmentCount(1)
241  , m_progressCallback(callback)
242  , m_abortPhase(abortPhase)
243  {
244  }
245 
251  void progressCallback(int percentage)
252  {
253  if (m_progressCallback != NULL)
254  {
255  m_progressCallback(percentage, m_segmentIndex, m_segmentCount);
256  }
257  }
258 
260  bool abortPhase(void)
261  {
262  if ((m_abortPhase) && (*m_abortPhase == true))
263  {
264  return true;
265  }
266  else
267  {
268  return false;
269  }
270  }
271 
277  void registerCallback(void (*callback)(int, int, int), bool *abortPhase)
278  {
279  m_progressCallback = callback;
280  m_abortPhase = abortPhase;
281  }
282 
283 public:
286 
287 private:
288  void (*m_progressCallback)(int percentage, int segmentIndex, int segmentCount);
289  bool *m_abortPhase;
290 };
291 
293 
294 
301 class Command
302 {
303 public:
322  static Command *create(const string_vector_t *argv);
323 
324 public:
326  static std::string getStatusMessage(status_t code);
327 
328 protected:
332  Command(const string_vector_t *argv)
333  : m_argv(*argv)
334  , m_responseValues()
335  , m_responseDetails()
336  , m_progress()
337  {
338  }
339 
343  Command(const char *const name)
344  : m_argv(1, name)
345  , m_responseValues()
346  , m_responseDetails()
347  , m_progress()
348  {
349  }
350 
351 public:
353  virtual ~Command() {}
357  virtual bool init() { return true; }
359 
360 
362  virtual std::string getArg(int arg) const { return m_argv.at(arg); }
364  virtual std::string getName() const { return getArg(0); }
366  virtual size_t getArgCount() const { return m_argv.size(); }
368 
370  virtual void sendTo(Packetizer &packetizer) {}
372  virtual const uint32_vector_t *getResponseValues() const
373  {
374  return const_cast<uint32_vector_t *>(&m_responseValues);
375  }
376 
378  virtual std::string getResponse() const;
379 
381  void logResponses() const;
382 
384  void registerProgress(Progress *progress) { m_progress = progress; }
385 protected:
390  virtual bool processResponse(const generic_response_packet_t *packet, uint8_t commandTag);
391 
392 public:
394 
395 protected:
396  string_vector_t m_argv;
397  uint32_vector_t m_responseValues;
399 };
400 
407 {
408 protected:
411  {
412  kMaxCommandArguments = (kDefaultMaxPacketSize - sizeof(command_packet_t)) /
413  sizeof(uint32_t)
414  };
415 
418  {
420  void init(uint8_t tag, uint8_t flags, uint8_t numArguments)
421  {
422  m_header.commandTag = tag;
423  m_header.flags = flags;
424  m_header.reserved = 0;
425  m_header.parameterCount = numArguments;
426  }
427  command_packet_t m_header;
428  uint32_t m_arguments[kMaxCommandArguments];
429  };
430 
431 public:
433  CommandPacket(uint8_t tag, uint8_t flags = 0)
434  {
435  m_numArguments = 0;
436  m_packet.init(tag, flags, m_numArguments);
437  }
438 
440  CommandPacket(uint8_t tag, uint8_t flags, uint32_t arg)
441  {
442  m_numArguments = 1;
443  m_packet.init(tag, flags, m_numArguments);
444  m_packet.m_arguments[0] = arg;
445  }
446 
448  CommandPacket(uint8_t tag, uint8_t flags, uint32_t arg1, uint32_t arg2)
449  {
450  m_numArguments = 2;
451  m_packet.init(tag, flags, m_numArguments);
452  m_packet.m_arguments[0] = arg1;
453  m_packet.m_arguments[1] = arg2;
454  }
455 
457  CommandPacket(uint8_t tag, uint8_t flags, uint32_t arg1, uint32_t arg2, uint32_t arg3)
458  {
459  m_numArguments = 3;
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;
464  }
465 
467  CommandPacket(uint8_t tag, uint8_t flags, uint32_t arg1, uint32_t arg2, uint32_t arg3, uint32_t arg4)
468  {
469  m_numArguments = 4;
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;
475  }
476 
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);
485 
486 protected:
489 };
490 
497 {
498 public:
503  {
504  public:
506  virtual bool hasMoreData() const = 0;
507 
509  virtual uint32_t getDataSize() const = 0;
510 
515  virtual uint32_t getData(uint8_t *data, uint32_t size) = 0;
516  };
517 
522  {
523  public:
526  : m_filePath()
527  , m_filePointer(NULL)
528  , m_fileSize(0)
529  {
530  }
531 
534  {
535  if (m_filePointer)
536  fclose(m_filePointer);
537  }
538 
540  bool init(std::string filePath, uint32_t count);
541 
543 
544  virtual bool hasMoreData() const
546  {
547  assert(m_filePointer);
548  return (m_fileSize && !feof(m_filePointer));
549  }
550 
552  virtual uint32_t getDataSize() const { return (uint32_t)m_fileSize; }
557  virtual uint32_t getData(uint8_t *data, uint32_t size);
559 
560  protected:
561  std::string m_filePath;
563  long m_fileSize;
564  };
565 
570  {
571  public:
574  : m_byteIndex(0)
575  , m_data()
576  {
577  }
578 
580  HexDataProducer(const uchar_vector_t &data)
581  : m_byteIndex(0)
582  , m_data(data)
583  {
584  }
585 
591  uint32_t initFromString(const std::string hexData);
592 
594  virtual ~HexDataProducer() {}
596 
597  virtual bool hasMoreData() const { return (m_byteIndex < m_data.size()); }
600  virtual uint32_t getDataSize() const { return m_data.size(); }
605  virtual uint32_t getData(uint8_t *data, uint32_t size);
607 
608  protected:
609  uint32_t m_byteIndex;
610  uchar_vector_t m_data;
611  };
612 
617  {
618  public:
621  : m_segment(segment)
622  , m_byteIndex(0)
623  {
624  }
625 
627  virtual ~SegmentDataProducer() {}
629  bool init(std::string filePath);
630 
632 
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);
643 
644  protected:
646  uint32_t m_byteIndex;
647  };
648 
653  {
654  public:
656  virtual void processData(const uint8_t *data, uint32_t size) = 0;
657 
659  virtual void finalize() = 0;
660  };
661 
666  {
667  public:
670  : m_filePath()
671  , m_filePointer(NULL)
672  {
673  }
674 
677  {
678  if (m_filePointer)
679  fclose(m_filePointer);
680  }
681 
683  bool init(std::string filePath);
684 
686  virtual void processData(const uint8_t *data, uint32_t size);
687 
689  virtual void finalize() {}
690  protected:
691  std::string m_filePath;
693  };
694 
699  {
700  public:
702  {
703  kBytesPerLine = 16
704  };
705 
706  public:
709  : m_currentCount(1)
710  {
711  }
712 
714  virtual void finalize()
715  {
716  if (((m_currentCount - 1) % kBytesPerLine) != 0)
717  {
718  // Fill space to clean the progress text.
719  for (int i = ((m_currentCount - 1) % kBytesPerLine) * 3; i < 9; i++)
720  {
721  printf(" ");
722  }
723  printf("\n");
724  }
725  }
726 
728  virtual void processData(const uint8_t *data, uint32_t size);
729 
730  protected:
731  uint32_t m_currentCount;
732  };
733 
734 public:
736  DataPacket(DataProducer *dataProducer)
737  {
738  assert(dataProducer);
739  m_dataProducer = dataProducer;
740  }
741 
743  DataPacket(DataConsumer *dataConsumer)
744  {
745  assert(dataConsumer);
746  m_dataConsumer = dataConsumer;
747  }
748 
752  uint8_t *sendTo(Packetizer &device, uint32_t *bytesWritten, Progress *progress);
753 
757  uint8_t *receiveFrom(Packetizer &device, uint32_t *byteCount, Progress *progress);
758 
759 protected:
762  uint8_t m_packet[kMinPacketBufferSize];
763 };
764 
770 class Reset : public Command
771 {
772 public:
774  Reset(const string_vector_t *argv)
775  : Command(argv)
776  {
777  }
778 
781  : Command(kCommand_Reset.name)
782  {
783  }
784 
786  virtual bool init();
787 
789  virtual void sendTo(Packetizer &packetizer);
790 
791 protected:
793  virtual bool processResponse(const uint8_t *packet)
794  {
795  return Command::processResponse(reinterpret_cast<const generic_response_packet_t *>(packet), kCommandTag_Reset);
796  }
797 };
798 
802 class GetProperty : public Command
803 {
804 public:
806  GetProperty(const string_vector_t *argv)
807  : Command(argv)
808  , m_property(kProperty_Invalid.value, kProperty_Invalid.description)
809  {
810  }
811 
814  : Command(kCommand_GetProperty.name)
815  , m_property(property)
816  {
817  m_argv.push_back(format_string("0x%08x", property.value));
818  }
819 
821  virtual bool init();
822 
824  virtual void sendTo(Packetizer &packetizer);
825 
826 protected:
828  virtual bool processResponse(const get_property_response_packet_t *packet);
829 
831  virtual bool processResponse(const uint8_t *packet)
832  {
833  return Command::processResponse(reinterpret_cast<const generic_response_packet_t *>(packet),
834  kCommandTag_GetProperty);
835  }
836 
837 protected:
839  uint32_t m_memoryId;
840 };
841 
845 class SetProperty : public Command
846 {
847 public:
849  SetProperty(const string_vector_t *argv)
850  : Command(argv)
851  {
852  }
853 
855  SetProperty(property_t property, uint32_t value)
856  : Command(kCommand_SetProperty.name)
857  , m_propertyTag(property.value)
858  , m_propertyValue(value)
859  {
860  m_argv.push_back(format_string("0x%08x", property.value));
861  m_argv.push_back(format_string("0x%08x", value));
862  }
863 
865  virtual bool init();
866 
868  virtual void sendTo(Packetizer &packetizer);
869 
870 protected:
872  virtual bool processResponse(const uint8_t *packet)
873  {
874  return Command::processResponse(reinterpret_cast<const generic_response_packet_t *>(packet),
875  kCommandTag_SetProperty);
876  }
877 
878 protected:
879  uint32_t m_propertyTag;
880  uint32_t m_propertyValue;
881 };
882 
886 class FlashEraseRegion : public Command
887 {
888 public:
890  FlashEraseRegion(const string_vector_t *argv)
891  : Command(argv)
892  {
893  }
894 
896  FlashEraseRegion(uint32_t start, uint32_t length)
897  : Command(kCommand_FlashEraseRegion.name)
898  , m_startAddress(start)
899  , m_byteCount(length)
900  {
901  m_argv.push_back(format_string("0x%08x", start));
902  m_argv.push_back(format_string("0x%08x", length));
903  }
904 
906  virtual bool init();
907 
909  virtual void sendTo(Packetizer &packetizer);
910 
911 protected:
913  virtual bool processResponse(const uint8_t *packet)
914  {
915  return Command::processResponse(reinterpret_cast<const generic_response_packet_t *>(packet),
916  kCommandTag_FlashEraseRegion);
917  }
918 
919 protected:
920  uint32_t m_startAddress;
921  uint32_t m_byteCount;
922 };
923 
927 class FlashEraseAll : public Command
928 {
929 public:
931  FlashEraseAll(const string_vector_t *argv)
932  : Command(argv)
933  {
934  }
935 
937  FlashEraseAll(uint32_t memoryId)
938  : Command(kCommand_FlashEraseAll.name)
939  , m_memoryId(memoryId)
940  {
941  m_argv.push_back(format_string("%d", memoryId));
942  }
943 
945  virtual bool init();
946 
948  virtual void sendTo(Packetizer &packetizer);
949 
950 protected:
952  virtual bool processResponse(const uint8_t *packet)
953  {
954  return Command::processResponse(reinterpret_cast<const generic_response_packet_t *>(packet),
955  kCommandTag_FlashEraseAll);
956  }
957 
958 protected:
959  uint32_t m_memoryId;
960 };
961 
966 {
967 public:
969  FlashEraseAllUnsecure(const string_vector_t *argv)
970  : Command(argv)
971  {
972  }
973 
976  : Command(kCommand_GetProperty.name)
977  {
978  }
979 
981  virtual bool init();
982 
984  virtual void sendTo(Packetizer &packetizer);
985 
986 protected:
988  virtual bool processResponse(const uint8_t *packet)
989  {
990  return Command::processResponse(reinterpret_cast<const generic_response_packet_t *>(packet),
991  kCommandTag_FlashEraseAllUnsecure);
992  }
993 };
994 
998 class ReadMemory : public Command
999 {
1000 public:
1002  ReadMemory(const string_vector_t *argv)
1003  : Command(argv)
1004  , m_dataFile()
1005  {
1006  }
1007 
1009  virtual bool init();
1010 
1012  virtual void sendTo(Packetizer &packetizer);
1013 
1014 protected:
1016  virtual bool processResponse(const read_memory_response_packet_t *packet);
1017 
1019  virtual bool processResponse(const uint8_t *packet)
1020  {
1021  return Command::processResponse(reinterpret_cast<const generic_response_packet_t *>(packet),
1022  kCommandTag_ReadMemory);
1023  }
1024 
1025 protected:
1026  std::string m_dataFile;
1027  uint32_t m_startAddress;
1028  uint32_t m_byteCount;
1029 };
1030 
1034 class WriteMemory : public Command
1035 {
1036 public:
1038  WriteMemory(const string_vector_t *argv)
1039  : Command(argv)
1040  , m_fileOrData()
1041  , m_segment(NULL)
1042  , m_startAddress(0)
1043  , m_count(0)
1044  , m_data()
1045  {
1046  }
1047 
1050  : Command(kCommand_WriteMemory.name)
1051  , m_fileOrData()
1052  , m_segment(segment)
1053  , m_count(0)
1054  , m_data()
1055  {
1056  m_startAddress = segment->getBaseAddress();
1057  m_argv.push_back(format_string("0x%08x", m_startAddress));
1058  m_argv.push_back(m_fileOrData);
1059  }
1060 
1062  WriteMemory(uint32_t address, const uchar_vector_t &data)
1063  : Command(kCommand_WriteMemory.name)
1064  , m_fileOrData()
1065  , m_segment(NULL)
1066  , m_startAddress(address)
1067  , m_count(0)
1068  , m_data(data)
1069  {
1070  m_argv.push_back(format_string("0x%08x", m_startAddress));
1071  m_argv.push_back(m_fileOrData);
1072  }
1073 
1075  virtual bool init();
1076 
1078  virtual void sendTo(Packetizer &packetizer);
1079 
1080 protected:
1082  virtual bool processResponse(const uint8_t *packet)
1083  {
1084  return Command::processResponse(reinterpret_cast<const generic_response_packet_t *>(packet),
1085  kCommandTag_WriteMemory);
1086  }
1087 
1088 protected:
1089  std::string m_fileOrData;
1091  uint32_t m_startAddress;
1092  uint32_t m_count;
1093  uchar_vector_t m_data;
1094 };
1095 
1099 class FillMemory : public Command
1100 {
1101 public:
1103  FillMemory(const string_vector_t *argv)
1104  : Command(argv)
1105  {
1106  }
1107 
1109  virtual bool init();
1110 
1112  virtual void sendTo(Packetizer &packetizer);
1113 
1114 protected:
1116  virtual bool processResponse(const uint8_t *packet)
1117  {
1118  return Command::processResponse(reinterpret_cast<const generic_response_packet_t *>(packet),
1119  kCommandTag_FillMemory);
1120  }
1121 
1122 protected:
1123  uint32_t m_startAddress;
1124  uint32_t m_byteCount;
1125  uint32_t m_patternWord;
1126 };
1127 
1131 class ReceiveSbFile : public Command
1132 {
1133 public:
1135  ReceiveSbFile(const string_vector_t *argv)
1136  : Command(argv)
1137  , m_dataFile()
1138  {
1139  }
1140 
1142  ReceiveSbFile(const char *const filename)
1143  : Command(kCommand_ReceiveSbFile.name)
1144  , m_dataFile(filename)
1145  {
1146  }
1147 
1149  virtual bool init();
1150 
1152  virtual void sendTo(Packetizer &packetizer);
1153 
1154 protected:
1156  virtual bool processResponse(const uint8_t *packet)
1157  {
1158  return Command::processResponse(reinterpret_cast<const generic_response_packet_t *>(packet),
1159  kCommandTag_ReceiveSbFile);
1160  }
1161 
1162 protected:
1163  std::string m_dataFile;
1164 };
1165 
1169 class Execute : public Command
1170 {
1171 public:
1173  Execute(const string_vector_t *argv)
1174  : Command(argv)
1175  {
1176  }
1177 
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)
1184  {
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));
1188  }
1189 
1191  virtual bool init();
1192 
1194  virtual void sendTo(Packetizer &packetizer);
1195 
1196 protected:
1198  virtual bool processResponse(const uint8_t *packet)
1199  {
1200  return Command::processResponse(reinterpret_cast<const generic_response_packet_t *>(packet),
1201  kCommandTag_Execute);
1202  }
1203 
1204 protected:
1205  uint32_t m_jumpAddress;
1206  uint32_t m_wordArgument;
1207  uint32_t m_stackpointer;
1208 };
1209 
1213 class Call : public Command
1214 {
1215 public:
1217  Call(const string_vector_t *argv)
1218  : Command(argv)
1219  {
1220  }
1221 
1223  virtual bool init();
1224 
1226  virtual void sendTo(Packetizer &packetizer);
1227 
1228 protected:
1230  virtual bool processResponse(const uint8_t *packet)
1231  {
1232  return Command::processResponse(reinterpret_cast<const generic_response_packet_t *>(packet), kCommandTag_Call);
1233  }
1234 
1235 protected:
1236  uint32_t m_callAddress;
1237  uint32_t m_wordArgument;
1238 };
1239 
1244 {
1245 public:
1247  FlashSecurityDisable(const string_vector_t *argv)
1248  : Command(argv)
1249  {
1250  }
1251 
1253  FlashSecurityDisable(uint32_t keyHigh, uint32_t keyLow)
1254  : Command(kCommand_FlashSecurityDisable.name)
1255  , m_keyHigh(keyHigh)
1256  , m_keyLow(keyLow)
1257  {
1258  }
1259 
1261  virtual bool init();
1262 
1264  virtual void sendTo(Packetizer &packetizer);
1265 
1266 protected:
1268  virtual bool processResponse(const uint8_t *packet)
1269  {
1270  return Command::processResponse(reinterpret_cast<const generic_response_packet_t *>(packet),
1271  kCommandTag_FlashSecurityDisable);
1272  }
1273 
1274 protected:
1275  uint32_t m_keyLow;
1276  uint32_t m_keyHigh;
1277 };
1278 
1283 {
1284 public:
1286  FlashProgramOnce(const string_vector_t *argv)
1287  : Command(argv)
1288  {
1289  }
1290 
1292  FlashProgramOnce(uint32_t index, uint32_t byteCount, uint32_t dataLow, uint32_t dataHigh)
1293  : Command(kCommand_FlashProgramOnce.name)
1294  , m_index(index)
1295  , m_byteCount(byteCount)
1296  , m_dataLow(dataLow)
1297  , m_dataHigh(dataHigh)
1298  {
1299  }
1300 
1302  virtual bool init();
1303 
1305  virtual void sendTo(Packetizer &packetizer);
1306 
1307 protected:
1309  virtual bool processResponse(const uint8_t *packet)
1310  {
1311  return Command::processResponse(reinterpret_cast<const generic_response_packet_t *>(packet),
1312  kCommandTag_FlashProgramOnce);
1313  }
1314 
1315 protected:
1316  uint32_t m_index;
1317  uint32_t m_byteCount;
1318  uint32_t m_dataLow;
1319  uint32_t m_dataHigh;
1320 };
1321 
1325 class FlashReadOnce : public Command
1326 {
1327 public:
1329  FlashReadOnce(const string_vector_t *argv)
1330  : Command(argv)
1331  {
1332  }
1333 
1335  virtual bool init();
1336 
1338  virtual void sendTo(Packetizer &packetizer);
1339 
1340 protected:
1342  virtual bool processResponse(const flash_read_once_response_packet_t *packet);
1343 
1345  virtual bool processResponse(const uint8_t *packet)
1346  {
1347  return Command::processResponse(reinterpret_cast<const generic_response_packet_t *>(packet),
1348  kCommandTag_FlashReadOnce);
1349  }
1350 
1351 protected:
1352  uint32_t m_index;
1353  uint32_t m_byteCount;
1354 };
1355 
1360 {
1361 public:
1363  FlashReadResource(const string_vector_t *argv)
1364  : Command(argv)
1365  , m_dataFile()
1366  {
1367  }
1368 
1370  virtual bool init();
1371 
1373  virtual void sendTo(Packetizer &packetizer);
1374 
1375 protected:
1377  virtual bool processResponse(const flash_read_resource_response_packet_t *packet);
1378 
1380  virtual bool processResponse(const uint8_t *packet)
1381  {
1382  return Command::processResponse(reinterpret_cast<const generic_response_packet_t *>(packet),
1383  kCommandTag_FlashReadResource);
1384  }
1385 
1386 protected:
1387  std::string m_dataFile;
1388  uint32_t m_startAddress;
1389  uint32_t m_byteCount;
1390  uint32_t m_option;
1391 };
1392 
1397 {
1398 public:
1400  ConfigureQuadSpi(const string_vector_t *argv)
1401  : Command(argv)
1402  {
1403  }
1404 
1406  virtual bool init();
1407 
1409  virtual void sendTo(Packetizer &packetizer);
1410 
1411 protected:
1413  virtual bool processResponse(const uint8_t *packet)
1414  {
1415  return Command::processResponse(reinterpret_cast<const generic_response_packet_t *>(packet),
1416  kCommandTag_ConfigureQuadSpi);
1417  }
1418 
1419 protected:
1420  uint32_t m_flashMemId;
1422 };
1423 
1427 class ReliableUpdate : public Command
1428 {
1429 public:
1431  ReliableUpdate(const string_vector_t *argv)
1432  : Command(argv)
1433  {
1434  }
1435 
1437  virtual bool init();
1438 
1440  virtual void sendTo(Packetizer &packetizer);
1441 
1442 protected:
1444  virtual bool processResponse(const uint8_t *packet)
1445  {
1446  return Command::processResponse(reinterpret_cast<const generic_response_packet_t *>(packet),
1447  kCommandTag_ReliableUpdate);
1448  }
1449 
1450 protected:
1451  uint32_t m_address;
1452 };
1453 
1457 class FlashImage : public Command
1458 {
1459 public:
1461  FlashImage(const string_vector_t *argv)
1462  : Command(argv)
1463  , m_fileName()
1464  , m_sourceFile(NULL)
1465  , m_doEraseOpt(false)
1466  , m_sectorSize()
1467  {
1468  }
1469 
1471  FlashImage(SourceFile *sourceFile, bool doEraseOpt)
1472  : Command(kCommand_FlashImage.name)
1473  , m_fileName()
1474  , m_sourceFile(sourceFile)
1475  , m_doEraseOpt(doEraseOpt)
1476  , m_sectorSize()
1477  {
1478  m_argv.push_back(m_sourceFile->getPath());
1479  m_argv.push_back(doEraseOpt ? "erase" : "none");
1480  }
1481 
1483  virtual bool init();
1484 
1486  virtual void sendTo(Packetizer &packetizer);
1487 
1488 protected:
1489  uint32_t m_sectorSize;
1490  std::string m_fileName;
1493 };
1494 
1498 class ConfigureI2c : public Command
1499 {
1500 public:
1502  ConfigureI2c(const string_vector_t *argv)
1503  : Command(argv)
1504  {
1505  }
1506 
1508  virtual bool init();
1509 
1511  virtual void sendTo(Packetizer &packetizer);
1512 
1513 protected:
1515  virtual bool processResponse(const uint8_t *packet)
1516  {
1517  return Command::processResponse(reinterpret_cast<const generic_response_packet_t *>(packet),
1518  kCommandTag_ConfigureI2c);
1519  }
1520 
1521 protected:
1522  uint8_t i2cAddress = 0x10;
1523  uint32_t i2cSpeedKHz = 100;
1524 };
1525 
1529 class ConfigureSpi : public Command
1530 {
1531 public:
1533  ConfigureSpi(const string_vector_t *argv)
1534  : Command(argv)
1535  {
1536  }
1537 
1539  virtual bool init();
1540 
1542  virtual void sendTo(Packetizer &packetizer);
1543 
1544 protected:
1546  virtual bool processResponse(const uint8_t *packet)
1547  {
1548  return Command::processResponse(reinterpret_cast<const generic_response_packet_t *>(packet),
1549  kCommandTag_ConfigureSpi);
1550  }
1551 
1552 protected:
1553  uint32_t spiSpeedKHz = 100;
1554  BusPal::spi_clock_polarity_t spiPolarity = BusPal::kSpiClockPolarity_ActiveLow;
1555  BusPal::spi_clock_phase_t spiPhase = BusPal::kSpiClockPhase_SecondEdge;
1556  BusPal::spi_shift_direction_t spiDirection = BusPal::kSpiMsbFirst;
1557 };
1558 
1562 class ConfigureCan : public Command
1563 {
1564 public:
1566  ConfigureCan(const string_vector_t *argv)
1567  : Command(argv)
1568  {
1569  }
1570 
1572  virtual bool init();
1573 
1575  virtual void sendTo(Packetizer &packetizer);
1576 
1577 protected:
1579  virtual bool processResponse(const uint8_t *packet)
1580  {
1581  return Command::processResponse(reinterpret_cast<const generic_response_packet_t *>(packet),
1582  kCommandTag_ConfigureCan);
1583  }
1584 
1585 protected:
1586  uint32_t canSpeed = 4;
1587  uint32_t canTxid = 0x321;
1588  uint32_t canRxid = 0x123;
1589 };
1590 
1592 
1593 } // namespace blfwk
1594 
1596 
1597 #endif // _Command_h_
1598 
1600 // EOF
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
Represents the bootloader Configure SPI command.
Definition: Command.h:1529
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
uint32_t m_configBlockAddress
Qspi config block address (in RAM or in internal Flash).
Definition: Command.h:1421
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
ConfigureSpi(const string_vector_t *argv)
Constructor that takes an argument vector.
Definition: Command.h:1533
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
STL namespace.
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
virtual bool processResponse(const uint8_t *packet)
Check generic response packet.
Definition: Command.h:1515
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 bool processResponse(const uint8_t *packet)
Check generic response packet.
Definition: Command.h:1546
virtual ~HexDataProducer()
Destructor.
Definition: Command.h:594
std::string m_dataFile
Data file path.
Definition: Command.h:1026
ConfigureCan(const string_vector_t *argv)
Constructor that takes an argument vector.
Definition: Command.h:1566
ConfigureQuadSpi(const string_vector_t *argv)
Constructor that takes an argument vector.
Definition: Command.h:1400
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
Definition: Command.h:53
Represents the bootloader Flash Erase All Unsecure command.
Definition: Command.h:965
Represents the bootloader Configure I2C command.
Definition: Command.h:1498
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
Represents the bootloader Configure QuadSpi command.
Definition: Command.h:1396
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
virtual bool processResponse(const uint8_t *packet)
Check generic response packet.
Definition: Command.h:1579
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&#39;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
Represents the bootloader Configure CAN command.
Definition: Command.h:1562
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
virtual bool processResponse(const uint8_t *packet)
Check generic response packet.
Definition: Command.h:1413
Contains the callback function for progress and abort phase.
Definition: Command.h:225
uint32_t m_flashMemId
Flash memory ID.
Definition: Command.h:1420
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
ConfigureI2c(const string_vector_t *argv)
Constructor that takes an argument vector.
Definition: Command.h:1502
virtual bool init()
Initialize.
Definition: Command.h:357
virtual bool processResponse(const uint8_t *packet)
Check response packet.
Definition: Command.h:913