Command.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.
*/
#ifndef _Command_h_
#define _Command_h_
#include <array>
#include <assert.h>
#include "DataSource.h"
#include "Packetizer.h"
#include "host_types.h"
#include "format_string.h"
#include "property/property.h"
#include "SourceFile.h"
#include "BusPal.h"
using namespace std;
namespace blfwk
{
struct cmd_t
{
uint8_t tag;
uint32_t mask;
const char *const name;
cmd_t(uint8_t tag, uint32_t mask, const char *name)
: tag(tag)
, mask(mask)
, name(name)
{
}
};
const cmd_t kCommand_FlashEraseAll(kCommandTag_FlashEraseAll, 0x00000001, "flash-erase-all");
const cmd_t kCommand_FlashEraseRegion(kCommandTag_FlashEraseRegion, 0x00000002, "flash-erase-region");
const cmd_t kCommand_ReadMemory(kCommandTag_ReadMemory, 0x00000004, "read-memory");
const cmd_t kCommand_WriteMemory(kCommandTag_WriteMemory, 0x00000008, "write-memory");
const cmd_t kCommand_FillMemory(kCommandTag_FillMemory, 0x00000010, "fill-memory");
const cmd_t kCommand_FlashSecurityDisable(kCommandTag_FlashSecurityDisable, 0x00000020, "flash-security-disable");
const cmd_t kCommand_GetProperty(kCommandTag_GetProperty, 0x00000040, "get-property");
const cmd_t kCommand_ReceiveSbFile(kCommandTag_ReceiveSbFile, 0x00000080, "receive-sb-file");
const cmd_t kCommand_Execute(kCommandTag_Execute, 0x00000100, "execute");
const cmd_t kCommand_Call(kCommandTag_Call, 0x00000200, "call");
const cmd_t kCommand_Reset(kCommandTag_Reset, 0x00000400, "reset");
const cmd_t kCommand_SetProperty(kCommandTag_SetProperty, 0x00000800, "set-property");
const cmd_t kCommand_FlashEraseAllUnsecure(kCommandTag_FlashEraseAllUnsecure, 0x00001000, "flash-erase-all-unsecure");
const cmd_t kCommand_FlashProgramOnce(kCommandTag_FlashProgramOnce, 0x00002000, "flash-program-once");
const cmd_t kCommand_FlashReadOnce(kCommandTag_FlashReadOnce, 0x00004000, "flash-read-once");
const cmd_t kCommand_FlashReadResource(kCommandTag_FlashReadResource, 0x00008000, "flash-read-resource");
const cmd_t kCommand_ConfigureQuadSpi(kCommandTag_ConfigureQuadSpi, 0x00010000, "configure-quadspi");
const cmd_t kCommand_ReliableUpdate(kCommandTag_ReliableUpdate, 0x00100000, "reliable-update");
// flash-image is not a ROM basic command, but a combination of several basic commands.
const cmd_t kCommand_FlashImage(0x00, 0x00000000, "flash-image");
const cmd_t kCommand_ConfigureI2c(kCommandTag_ConfigureI2c, 0x00020000, "i2c");
const cmd_t kCommand_ConfigureSpi(kCommandTag_ConfigureSpi, 0x00040000, "spi");
const cmd_t kCommand_ConfigureCan(kCommandTag_ConfigureCan, 0x00080000, "can");
const array<const cmd_t, 22> kCommands = { kCommand_FlashEraseAll,
kCommand_FlashEraseRegion,
kCommand_ReadMemory,
kCommand_WriteMemory,
kCommand_FillMemory,
kCommand_FlashSecurityDisable,
kCommand_GetProperty,
kCommand_ReceiveSbFile,
kCommand_Execute,
kCommand_Call,
kCommand_Reset,
kCommand_SetProperty,
kCommand_FlashEraseAllUnsecure,
kCommand_FlashProgramOnce,
kCommand_FlashReadOnce,
kCommand_FlashReadResource,
kCommand_ConfigureQuadSpi,
kCommand_ReliableUpdate,
kCommand_FlashImage,
kCommand_ConfigureI2c,
kCommand_ConfigureSpi,
kCommand_ConfigureCan };
struct property_t
{
uint32_t value;
const char *description;
property_t(uint8_t value, const char *description)
: value(value)
, description(description)
{
}
string str() const { return format_string("0x%02x", value); }
};
const property_t kProperty_ListProperties(kPropertyTag_ListProperties, "list-properties");
const property_t kProperty_CurrentVersion(kPropertyTag_BootloaderVersion, "current-version");
const property_t kProperty_AvailablePeripherals(kPropertyTag_AvailablePeripherals, "available-peripherals");
const property_t kProperty_FlashStartAddress(kPropertyTag_FlashStartAddress, "flash-start-address");
const property_t kProperty_FlashSizeInBytes(kPropertyTag_FlashSizeInBytes, "flash-size-in-bytes");
const property_t kProperty_FlashSectorSize(kPropertyTag_FlashSectorSize, "flash-sector-size");
const property_t kProperty_FlashBlockCount(kPropertyTag_FlashBlockCount, "flash-block-count");
const property_t kProperty_AvailableCommands(kPropertyTag_AvailableCommands, "available-commands");
const property_t kProperty_CrcCheckStatus(kPropertyTag_CrcCheckStatus, "crc-check-status");
const property_t kProperty_Reserved9(kPropertyTag_Reserved9, "reserved");
const property_t kProperty_VerifyWrites(kPropertyTag_VerifyWrites, "verify-writes");
const property_t kProperty_MaxPacketSize(kPropertyTag_MaxPacketSize, "max-packet-size");
const property_t kProperty_ReservedRegions(kPropertyTag_ReservedRegions, "reserved-regions");
const property_t kProperty_Reserved13(kPropertyTag_Reserved13, "reserved");
const property_t kProperty_RAMStartAddress(kPropertyTag_RAMStartAddress, "ram-start-address");
const property_t kProperty_RAMSizeInBytes(kPropertyTag_RAMSizeInBytes, "ram-size-in-bytes");
const property_t kProperty_SystemDeviceId(kPropertyTag_SystemDeviceId, "system-device-id");
const property_t kProperty_FlashSecurityState(kPropertyTag_FlashSecurityState, "flash-security-state");
const property_t kProperty_UniqueDeviceId(kPropertyTag_UniqueDeviceId, "unique-device-id");
const property_t kProperty_FacSupport(kPropertyTag_FacSupport, "flash-fac-support");
const property_t kProperty_FlashAccessSegmentSize(kPropertyTag_FlashAccessSegmentSize, "flash-access-segment-size");
const property_t kProperty_FlashAccessSegmentCount(kPropertyTag_FlashAccessSegmentCount, "flash-access-segment-count");
const property_t kProperty_FlashReadMargin(kPropertyTag_FlashReadMargin, "flash-read-margin");
const property_t kProperty_QspiInitStatus(kPropertyTag_QspiInitStatus, "qspi/otfad-init-status");
const property_t kProperty_TargetVersion(kPropertyTag_TargetVersion, "target-version");
const property_t kProperty_ExernalMemoryAttributes(kPropertyTag_ExternalMemoryAttributes, "external-memory-attributes");
const property_t kProperty_ReliableUpdateStatus(kPropertyTag_ReliableUpdateStatus, "reliable-update-status");
const property_t kProperty_Invalid(kPropertyTag_InvalidProperty, "invalid-property");
typedef array<const property_t, 27> PropertyArray;
const PropertyArray kProperties = {
kProperty_ListProperties, kProperty_CurrentVersion,
kProperty_AvailablePeripherals, kProperty_FlashStartAddress,
kProperty_FlashSizeInBytes, kProperty_FlashSectorSize,
kProperty_FlashBlockCount, kProperty_AvailableCommands,
kProperty_CrcCheckStatus, kProperty_Reserved9,
kProperty_VerifyWrites, kProperty_MaxPacketSize,
kProperty_ReservedRegions, kProperty_Reserved13,
kProperty_RAMStartAddress, kProperty_RAMSizeInBytes,
kProperty_SystemDeviceId, kProperty_FlashSecurityState,
kProperty_UniqueDeviceId, kProperty_FacSupport,
kProperty_FlashAccessSegmentSize, kProperty_FlashAccessSegmentCount,
kProperty_FlashReadMargin, kProperty_QspiInitStatus,
kProperty_TargetVersion, kProperty_ExernalMemoryAttributes,
kProperty_ReliableUpdateStatus,
};
struct peripheral_t
{
uint32_t mask;
const char *description;
peripheral_t(uint32_t mask, const char *description)
: mask(mask)
, description(description)
{
}
};
const peripheral_t kPeripheral_Uart(0x00000001, "UART");
const peripheral_t kPeripheral_I2C(0x00000002, "I2C Slave");
const peripheral_t kPeripheral_Spi(0x00000004, "SPI Slave");
const peripheral_t kPeripheral_Can(0x00000008, "CAN");
const peripheral_t kPeripheral_UsbHid(0x00000010, "USB HID");
const peripheral_t kPeripheral_UsbCdc(0x00000020, "USB CDC");
const peripheral_t kPeripheral_UsbDfu(0x00000040, "USB DFU");
const array<const peripheral_t, 7> kPeripherals = { kPeripheral_Uart, kPeripheral_I2C, kPeripheral_Spi,
kPeripheral_Can, kPeripheral_UsbHid, kPeripheral_UsbCdc,
kPeripheral_UsbDfu };
struct StatusMessageTableEntry
{
int32_t status;
const std::string message;
};
extern StatusMessageTableEntry g_statusCodes[];
class Progress
{
public:
Progress()
: m_segmentIndex(1)
, m_segmentCount(1)
, m_progressCallback(NULL)
, m_abortPhase(NULL)
{
}
Progress(void (*callback)(int, int, int), bool *abortPhase)
: m_segmentIndex(1)
, m_segmentCount(1)
, m_progressCallback(callback)
, m_abortPhase(abortPhase)
{
}
~Progress() {}
void progressCallback(int percentage)
{
if (m_progressCallback != NULL)
{
m_progressCallback(percentage, m_segmentIndex, m_segmentCount);
}
}
bool abortPhase(void)
{
if ((m_abortPhase) && (*m_abortPhase == true))
{
return true;
}
else
{
return false;
}
}
void registerCallback(void (*callback)(int, int, int), bool *abortPhase)
{
m_progressCallback = callback;
m_abortPhase = abortPhase;
}
public:
int m_segmentIndex;
int m_segmentCount;
private:
void (*m_progressCallback)(int percentage, int segmentIndex, int segmentCount);
bool *m_abortPhase;
};
class Command
{
public:
static Command *create(const string_vector_t *argv);
public:
static std::string getStatusMessage(status_t code);
protected:
Command(const string_vector_t *argv)
: m_argv(*argv)
, m_responseValues()
, m_responseDetails()
, m_progress()
{
}
Command(const char *const name)
: m_argv(1, name)
, m_responseValues()
, m_responseDetails()
, m_progress()
{
}
public:
virtual ~Command() {}
virtual bool init() { return true; }
virtual std::string getArg(int arg) const { return m_argv.at(arg); }
virtual std::string getName() const { return getArg(0); }
virtual size_t getArgCount() const { return m_argv.size(); }
virtual void sendTo(Packetizer &packetizer) {}
virtual const uint32_vector_t *getResponseValues() const
{
return const_cast<uint32_vector_t *>(&m_responseValues);
}
virtual std::string getResponse() const;
void logResponses() const;
void registerProgress(Progress *progress) { m_progress = progress; }
protected:
virtual bool processResponse(const generic_response_packet_t *packet, uint8_t commandTag);
public:
Progress *m_progress;
protected:
string_vector_t m_argv;
uint32_vector_t m_responseValues;
string m_responseDetails;
};
class CommandPacket
{
protected:
enum _command_packet_constants
{
kMaxCommandArguments = (kDefaultMaxPacketSize - sizeof(command_packet_t)) /
sizeof(uint32_t)
};
struct PacketWithArgs
{
void init(uint8_t tag, uint8_t flags, uint8_t numArguments)
{
m_header.commandTag = tag;
m_header.flags = flags;
m_header.reserved = 0;
m_header.parameterCount = numArguments;
}
command_packet_t m_header;
uint32_t m_arguments[kMaxCommandArguments];
};
public:
CommandPacket(uint8_t tag, uint8_t flags = 0)
{
m_numArguments = 0;
m_packet.init(tag, flags, m_numArguments);
}
CommandPacket(uint8_t tag, uint8_t flags, uint32_t arg)
{
m_numArguments = 1;
m_packet.init(tag, flags, m_numArguments);
m_packet.m_arguments[0] = arg;
}
CommandPacket(uint8_t tag, uint8_t flags, uint32_t arg1, uint32_t arg2)
{
m_numArguments = 2;
m_packet.init(tag, flags, m_numArguments);
m_packet.m_arguments[0] = arg1;
m_packet.m_arguments[1] = arg2;
}
CommandPacket(uint8_t tag, uint8_t flags, uint32_t arg1, uint32_t arg2, uint32_t arg3)
{
m_numArguments = 3;
m_packet.init(tag, flags, m_numArguments);
m_packet.m_arguments[0] = arg1;
m_packet.m_arguments[1] = arg2;
m_packet.m_arguments[2] = arg3;
}
CommandPacket(uint8_t tag, uint8_t flags, uint32_t arg1, uint32_t arg2, uint32_t arg3, uint32_t arg4)
{
m_numArguments = 4;
m_packet.init(tag, flags, m_numArguments);
m_packet.m_arguments[0] = arg1;
m_packet.m_arguments[1] = arg2;
m_packet.m_arguments[2] = arg3;
m_packet.m_arguments[3] = arg4;
}
uint32_t getSize() const { return sizeof(command_packet_t) + (m_numArguments * sizeof(uint32_t)); }
const uint8_t *getData() { return reinterpret_cast<uint8_t *>(&m_packet.m_header); }
const uint8_t *sendCommandGetResponse(Packetizer &device);
protected:
int m_numArguments;
PacketWithArgs m_packet;
};
class DataPacket
{
public:
class DataProducer
{
public:
virtual bool hasMoreData() const = 0;
virtual uint32_t getDataSize() const = 0;
virtual uint32_t getData(uint8_t *data, uint32_t size) = 0;
};
class FileDataProducer : public DataProducer
{
public:
FileDataProducer()
: m_filePath()
, m_filePointer(NULL)
, m_fileSize(0)
{
}
virtual ~FileDataProducer()
{
if (m_filePointer)
fclose(m_filePointer);
}
bool init(std::string filePath, uint32_t count);
virtual bool hasMoreData() const
{
assert(m_filePointer);
return (m_fileSize && !feof(m_filePointer));
}
virtual uint32_t getDataSize() const { return (uint32_t)m_fileSize; }
virtual uint32_t getData(uint8_t *data, uint32_t size);
protected:
std::string m_filePath;
FILE *m_filePointer;
long m_fileSize;
};
class HexDataProducer : public DataProducer
{
public:
HexDataProducer()
: m_byteIndex(0)
, m_data()
{
}
HexDataProducer(const uchar_vector_t &data)
: m_byteIndex(0)
, m_data(data)
{
}
uint32_t initFromString(const std::string hexData);
virtual ~HexDataProducer() {}
virtual bool hasMoreData() const { return (m_byteIndex < m_data.size()); }
virtual uint32_t getDataSize() const { return m_data.size(); }
virtual uint32_t getData(uint8_t *data, uint32_t size);
protected:
uint32_t m_byteIndex;
uchar_vector_t m_data;
};
class SegmentDataProducer : public DataProducer
{
public:
SegmentDataProducer(blfwk::DataSource::Segment *segment)
: m_segment(segment)
, m_byteIndex(0)
{
}
virtual ~SegmentDataProducer() {}
bool init(std::string filePath);
virtual bool hasMoreData() const { return (m_byteIndex < m_segment->getLength()); }
virtual uint32_t getDataSize() const { return m_segment->getLength(); }
virtual uint32_t getData(uint8_t *data, uint32_t size);
protected:
blfwk::DataSource::Segment *m_segment;
uint32_t m_byteIndex;
};
class DataConsumer
{
public:
virtual void processData(const uint8_t *data, uint32_t size) = 0;
virtual void finalize() = 0;
};
class FileDataConsumer : public DataConsumer
{
public:
FileDataConsumer()
: m_filePath()
, m_filePointer(NULL)
{
}
virtual ~FileDataConsumer()
{
if (m_filePointer)
fclose(m_filePointer);
}
bool init(std::string filePath);
virtual void processData(const uint8_t *data, uint32_t size);
virtual void finalize() {}
protected:
std::string m_filePath;
FILE *m_filePointer;
};
class StdOutDataConsumer : public DataConsumer
{
public:
enum _constants
{
kBytesPerLine = 16
};
public:
StdOutDataConsumer()
: m_currentCount(1)
{
}
virtual void finalize()
{
if (((m_currentCount - 1) % kBytesPerLine) != 0)
{
// Fill space to clean the progress text.
for (int i = ((m_currentCount - 1) % kBytesPerLine) * 3; i < 9; i++)
{
printf(" ");
}
printf("\n");
}
}
virtual void processData(const uint8_t *data, uint32_t size);
protected:
uint32_t m_currentCount;
};
public:
DataPacket(DataProducer *dataProducer)
{
assert(dataProducer);
m_dataProducer = dataProducer;
}
DataPacket(DataConsumer *dataConsumer)
{
assert(dataConsumer);
m_dataConsumer = dataConsumer;
}
uint8_t *sendTo(Packetizer &device, uint32_t *bytesWritten, Progress *progress);
uint8_t *receiveFrom(Packetizer &device, uint32_t *byteCount, Progress *progress);
protected:
DataProducer *m_dataProducer;
DataConsumer *m_dataConsumer;
uint8_t m_packet[kMinPacketBufferSize];
};
class Reset : public Command
{
public:
Reset(const string_vector_t *argv)
: Command(argv)
{
}
Reset()
: Command(kCommand_Reset.name)
{
}
virtual bool init();
virtual void sendTo(Packetizer &packetizer);
protected:
virtual bool processResponse(const uint8_t *packet)
{
return Command::processResponse(reinterpret_cast<const generic_response_packet_t *>(packet), kCommandTag_Reset);
}
};
class GetProperty : public Command
{
public:
GetProperty(const string_vector_t *argv)
: Command(argv)
, m_property(kProperty_Invalid.value, kProperty_Invalid.description)
{
}
GetProperty(property_t property)
: Command(kCommand_GetProperty.name)
, m_property(property)
{
m_argv.push_back(format_string("0x%08x", property.value));
}
virtual bool init();
virtual void sendTo(Packetizer &packetizer);
protected:
virtual bool processResponse(const get_property_response_packet_t *packet);
virtual bool processResponse(const uint8_t *packet)
{
return Command::processResponse(reinterpret_cast<const generic_response_packet_t *>(packet),
kCommandTag_GetProperty);
}
protected:
property_t m_property;
uint32_t m_memoryId;
};
class SetProperty : public Command
{
public:
SetProperty(const string_vector_t *argv)
: Command(argv)
{
}
SetProperty(property_t property, uint32_t value)
: Command(kCommand_SetProperty.name)
, m_propertyTag(property.value)
, m_propertyValue(value)
{
m_argv.push_back(format_string("0x%08x", property.value));
m_argv.push_back(format_string("0x%08x", value));
}
virtual bool init();
virtual void sendTo(Packetizer &packetizer);
protected:
virtual bool processResponse(const uint8_t *packet)
{
return Command::processResponse(reinterpret_cast<const generic_response_packet_t *>(packet),
kCommandTag_SetProperty);
}
protected:
uint32_t m_propertyTag;
uint32_t m_propertyValue;
};
class FlashEraseRegion : public Command
{
public:
FlashEraseRegion(const string_vector_t *argv)
: Command(argv)
{
}
FlashEraseRegion(uint32_t start, uint32_t length)
: Command(kCommand_FlashEraseRegion.name)
, m_startAddress(start)
, m_byteCount(length)
{
m_argv.push_back(format_string("0x%08x", start));
m_argv.push_back(format_string("0x%08x", length));
}
virtual bool init();
virtual void sendTo(Packetizer &packetizer);
protected:
virtual bool processResponse(const uint8_t *packet)
{
return Command::processResponse(reinterpret_cast<const generic_response_packet_t *>(packet),
kCommandTag_FlashEraseRegion);
}
protected:
uint32_t m_startAddress;
uint32_t m_byteCount;
};
class FlashEraseAll : public Command
{
public:
FlashEraseAll(const string_vector_t *argv)
: Command(argv)
{
}
FlashEraseAll(uint32_t memoryId)
: Command(kCommand_FlashEraseAll.name)
, m_memoryId(memoryId)
{
m_argv.push_back(format_string("%d", memoryId));
}
virtual bool init();
virtual void sendTo(Packetizer &packetizer);
protected:
virtual bool processResponse(const uint8_t *packet)
{
return Command::processResponse(reinterpret_cast<const generic_response_packet_t *>(packet),
kCommandTag_FlashEraseAll);
}
protected:
uint32_t m_memoryId;
};
class FlashEraseAllUnsecure : public Command
{
public:
FlashEraseAllUnsecure(const string_vector_t *argv)
: Command(argv)
{
}
FlashEraseAllUnsecure()
: Command(kCommand_GetProperty.name)
{
}
virtual bool init();
virtual void sendTo(Packetizer &packetizer);
protected:
virtual bool processResponse(const uint8_t *packet)
{
return Command::processResponse(reinterpret_cast<const generic_response_packet_t *>(packet),
kCommandTag_FlashEraseAllUnsecure);
}
};
class ReadMemory : public Command
{
public:
ReadMemory(const string_vector_t *argv)
: Command(argv)
, m_dataFile()
{
}
virtual bool init();
virtual void sendTo(Packetizer &packetizer);
protected:
virtual bool processResponse(const read_memory_response_packet_t *packet);
virtual bool processResponse(const uint8_t *packet)
{
return Command::processResponse(reinterpret_cast<const generic_response_packet_t *>(packet),
kCommandTag_ReadMemory);
}
protected:
std::string m_dataFile;
uint32_t m_startAddress;
uint32_t m_byteCount;
};
class WriteMemory : public Command
{
public:
WriteMemory(const string_vector_t *argv)
: Command(argv)
, m_fileOrData()
, m_segment(NULL)
, m_startAddress(0)
, m_count(0)
, m_data()
{
}
WriteMemory(blfwk::DataSource::Segment *segment)
: Command(kCommand_WriteMemory.name)
, m_fileOrData()
, m_segment(segment)
, m_count(0)
, m_data()
{
m_startAddress = segment->getBaseAddress();
m_argv.push_back(format_string("0x%08x", m_startAddress));
m_argv.push_back(m_fileOrData);
}
WriteMemory(uint32_t address, const uchar_vector_t &data)
: Command(kCommand_WriteMemory.name)
, m_fileOrData()
, m_segment(NULL)
, m_startAddress(address)
, m_count(0)
, m_data(data)
{
m_argv.push_back(format_string("0x%08x", m_startAddress));
m_argv.push_back(m_fileOrData);
}
virtual bool init();
virtual void sendTo(Packetizer &packetizer);
protected:
virtual bool processResponse(const uint8_t *packet)
{
return Command::processResponse(reinterpret_cast<const generic_response_packet_t *>(packet),
kCommandTag_WriteMemory);
}
protected:
std::string m_fileOrData;
blfwk::DataSource::Segment *m_segment;
uint32_t m_startAddress;
uint32_t m_count;
uchar_vector_t m_data;
};
class FillMemory : public Command
{
public:
FillMemory(const string_vector_t *argv)
: Command(argv)
{
}
virtual bool init();
virtual void sendTo(Packetizer &packetizer);
protected:
virtual bool processResponse(const uint8_t *packet)
{
return Command::processResponse(reinterpret_cast<const generic_response_packet_t *>(packet),
kCommandTag_FillMemory);
}
protected:
uint32_t m_startAddress;
uint32_t m_byteCount;
uint32_t m_patternWord;
};
class ReceiveSbFile : public Command
{
public:
ReceiveSbFile(const string_vector_t *argv)
: Command(argv)
, m_dataFile()
{
}
ReceiveSbFile(const char *const filename)
: Command(kCommand_ReceiveSbFile.name)
, m_dataFile(filename)
{
}
virtual bool init();
virtual void sendTo(Packetizer &packetizer);
protected:
virtual bool processResponse(const uint8_t *packet)
{
return Command::processResponse(reinterpret_cast<const generic_response_packet_t *>(packet),
kCommandTag_ReceiveSbFile);
}
protected:
std::string m_dataFile;
};
class Execute : public Command
{
public:
Execute(const string_vector_t *argv)
: Command(argv)
{
}
Execute(uint32_t entry_point, uint32_t param, uint32_t stack_pointer)
: Command(kCommand_Execute.name)
, m_jumpAddress(entry_point)
, m_wordArgument(param)
, m_stackpointer(stack_pointer)
{
m_argv.push_back(format_string("0x%08x", entry_point));
m_argv.push_back(format_string("0x%08x", param));
m_argv.push_back(format_string("0x%08x", stack_pointer));
}
virtual bool init();
virtual void sendTo(Packetizer &packetizer);
protected:
virtual bool processResponse(const uint8_t *packet)
{
return Command::processResponse(reinterpret_cast<const generic_response_packet_t *>(packet),
kCommandTag_Execute);
}
protected:
uint32_t m_jumpAddress;
uint32_t m_wordArgument;
uint32_t m_stackpointer;
};
class Call : public Command
{
public:
Call(const string_vector_t *argv)
: Command(argv)
{
}
virtual bool init();
virtual void sendTo(Packetizer &packetizer);
protected:
virtual bool processResponse(const uint8_t *packet)
{
return Command::processResponse(reinterpret_cast<const generic_response_packet_t *>(packet), kCommandTag_Call);
}
protected:
uint32_t m_callAddress;
uint32_t m_wordArgument;
};
class FlashSecurityDisable : public Command
{
public:
FlashSecurityDisable(const string_vector_t *argv)
: Command(argv)
{
}
FlashSecurityDisable(uint32_t keyHigh, uint32_t keyLow)
: Command(kCommand_FlashSecurityDisable.name)
, m_keyHigh(keyHigh)
, m_keyLow(keyLow)
{
}
virtual bool init();
virtual void sendTo(Packetizer &packetizer);
protected:
virtual bool processResponse(const uint8_t *packet)
{
return Command::processResponse(reinterpret_cast<const generic_response_packet_t *>(packet),
kCommandTag_FlashSecurityDisable);
}
protected:
uint32_t m_keyLow;
uint32_t m_keyHigh;
};
class FlashProgramOnce : public Command
{
public:
FlashProgramOnce(const string_vector_t *argv)
: Command(argv)
{
}
FlashProgramOnce(uint32_t index, uint32_t byteCount, uint32_t dataLow, uint32_t dataHigh)
: Command(kCommand_FlashProgramOnce.name)
, m_index(index)
, m_byteCount(byteCount)
, m_dataLow(dataLow)
, m_dataHigh(dataHigh)
{
}
virtual bool init();
virtual void sendTo(Packetizer &packetizer);
protected:
virtual bool processResponse(const uint8_t *packet)
{
return Command::processResponse(reinterpret_cast<const generic_response_packet_t *>(packet),
kCommandTag_FlashProgramOnce);
}
protected:
uint32_t m_index;
uint32_t m_byteCount;
uint32_t m_dataLow;
uint32_t m_dataHigh;
};
class FlashReadOnce : public Command
{
public:
FlashReadOnce(const string_vector_t *argv)
: Command(argv)
{
}
virtual bool init();
virtual void sendTo(Packetizer &packetizer);
protected:
virtual bool processResponse(const flash_read_once_response_packet_t *packet);
virtual bool processResponse(const uint8_t *packet)
{
return Command::processResponse(reinterpret_cast<const generic_response_packet_t *>(packet),
kCommandTag_FlashReadOnce);
}
protected:
uint32_t m_index;
uint32_t m_byteCount;
};
class FlashReadResource : public Command
{
public:
FlashReadResource(const string_vector_t *argv)
: Command(argv)
, m_dataFile()
{
}
virtual bool init();
virtual void sendTo(Packetizer &packetizer);
protected:
virtual bool processResponse(const flash_read_resource_response_packet_t *packet);
virtual bool processResponse(const uint8_t *packet)
{
return Command::processResponse(reinterpret_cast<const generic_response_packet_t *>(packet),
kCommandTag_FlashReadResource);
}
protected:
std::string m_dataFile;
uint32_t m_startAddress;
uint32_t m_byteCount;
uint32_t m_option;
};
class ConfigureQuadSpi : public Command
{
public:
ConfigureQuadSpi(const string_vector_t *argv)
: Command(argv)
{
}
virtual bool init();
virtual void sendTo(Packetizer &packetizer);
protected:
virtual bool processResponse(const uint8_t *packet)
{
return Command::processResponse(reinterpret_cast<const generic_response_packet_t *>(packet),
kCommandTag_ConfigureQuadSpi);
}
protected:
uint32_t m_flashMemId;
uint32_t m_configBlockAddress;
};
class ReliableUpdate : public Command
{
public:
ReliableUpdate(const string_vector_t *argv)
: Command(argv)
{
}
virtual bool init();
virtual void sendTo(Packetizer &packetizer);
protected:
virtual bool processResponse(const uint8_t *packet)
{
return Command::processResponse(reinterpret_cast<const generic_response_packet_t *>(packet),
kCommandTag_ReliableUpdate);
}
protected:
uint32_t m_address;
};
class FlashImage : public Command
{
public:
FlashImage(const string_vector_t *argv)
: Command(argv)
, m_fileName()
, m_sourceFile(NULL)
, m_doEraseOpt(false)
, m_sectorSize()
{
}
FlashImage(SourceFile *sourceFile, bool doEraseOpt)
: Command(kCommand_FlashImage.name)
, m_fileName()
, m_sourceFile(sourceFile)
, m_doEraseOpt(doEraseOpt)
, m_sectorSize()
{
m_argv.push_back(m_sourceFile->getPath());
m_argv.push_back(doEraseOpt ? "erase" : "none");
}
virtual bool init();
virtual void sendTo(Packetizer &packetizer);
protected:
uint32_t m_sectorSize;
std::string m_fileName;
SourceFile *m_sourceFile;
bool m_doEraseOpt;
};
class ConfigureI2c : public Command
{
public:
ConfigureI2c(const string_vector_t *argv)
: Command(argv)
{
}
virtual bool init();
virtual void sendTo(Packetizer &packetizer);
protected:
virtual bool processResponse(const uint8_t *packet)
{
return Command::processResponse(reinterpret_cast<const generic_response_packet_t *>(packet),
kCommandTag_ConfigureI2c);
}
protected:
uint8_t i2cAddress = 0x10;
uint32_t i2cSpeedKHz = 100;
};
class ConfigureSpi : public Command
{
public:
ConfigureSpi(const string_vector_t *argv)
: Command(argv)
{
}
virtual bool init();
virtual void sendTo(Packetizer &packetizer);
protected:
virtual bool processResponse(const uint8_t *packet)
{
return Command::processResponse(reinterpret_cast<const generic_response_packet_t *>(packet),
kCommandTag_ConfigureSpi);
}
protected:
uint32_t spiSpeedKHz = 100;
BusPal::spi_clock_polarity_t spiPolarity = BusPal::kSpiClockPolarity_ActiveLow;
BusPal::spi_clock_phase_t spiPhase = BusPal::kSpiClockPhase_SecondEdge;
BusPal::spi_shift_direction_t spiDirection = BusPal::kSpiMsbFirst;
};
class ConfigureCan : public Command
{
public:
ConfigureCan(const string_vector_t *argv)
: Command(argv)
{
}
virtual bool init();
virtual void sendTo(Packetizer &packetizer);
protected:
virtual bool processResponse(const uint8_t *packet)
{
return Command::processResponse(reinterpret_cast<const generic_response_packet_t *>(packet),
kCommandTag_ConfigureCan);
}
protected:
uint32_t canSpeed = 4;
uint32_t canTxid = 0x321;
uint32_t canRxid = 0x123;
};
} // namespace blfwk
#endif // _Command_h_
// EOF
blfwk::FlashReadResource::processResponse
virtual bool processResponse(const uint8_t *packet)
Check generic response packet.
Definition: Command.h:1380
blfwk::Packetizer
Interface class for packetization of commands and data.
Definition: Packetizer.h:59
blfwk::FlashEraseAll
Represents the bootloader Flash Erase All command.
Definition: Command.h:927
blfwk::Execute::Execute
Execute(const string_vector_t *argv)
Constructor that takes an argument vector.
Definition: Command.h:1173
blfwk::Reset::Reset
Reset(const string_vector_t *argv)
Constructor that takes argument vector.
Definition: Command.h:774
blfwk::DataPacket::FileDataConsumer
Write file data for data phase receive.
Definition: Command.h:665
blfwk::BusPal::spi_shift_direction_t
spi_shift_direction_t
SPI data shifter direction options.
Definition: BusPal.h:90
blfwk::FlashReadOnce::processResponse
virtual bool processResponse(const uint8_t *packet)
Check generic response packet.
Definition: Command.h:1345
blfwk::FlashSecurityDisable::m_keyLow
uint32_t m_keyLow
Bytes 0-3 of the flash backdoor key.
Definition: Command.h:1275
blfwk::DataPacket::HexDataProducer::getDataSize
virtual uint32_t getDataSize() const
Query the total size of the data.
Definition: Command.h:600
blfwk::DataPacket::HexDataProducer::m_data
uchar_vector_t m_data
Data byte vector.
Definition: Command.h:610
blfwk::Progress::m_segmentCount
int m_segmentCount
The number of data segments.
Definition: Command.h:285
blfwk::Progress::Progress
Progress()
Default constructor.
Definition: Command.h:229
blfwk::FlashSecurityDisable
Represents the bootloader Flash Security Disable command.
Definition: Command.h:1243
blfwk::CommandPacket
Command packet operations.
Definition: Command.h:406
blfwk::Command::m_responseValues
uint32_vector_t m_responseValues
Vector of response values.
Definition: Command.h:397
blfwk::Call::m_wordArgument
uint32_t m_wordArgument
Word argument passed to function.
Definition: Command.h:1237
blfwk::WriteMemory::processResponse
virtual bool processResponse(const uint8_t *packet)
Check response packet.
Definition: Command.h:1082
blfwk::DataPacket::FileDataProducer::m_fileSize
long m_fileSize
Size in bytes of data file.
Definition: Command.h:563
blfwk::ConfigureSpi
Represents the bootloader Configure SPI command.
Definition: Command.h:1529
blfwk::Execute::m_wordArgument
uint32_t m_wordArgument
Word argument passed to function.
Definition: Command.h:1206
blfwk::DataPacket::SegmentDataProducer::SegmentDataProducer
SegmentDataProducer(blfwk::DataSource::Segment *segment)
Default constructor.
Definition: Command.h:620
blfwk
Definition: BlfwkErrors.h:16
blfwk::CommandPacket::getSize
uint32_t getSize() const
Get size of command packet, including arguments.
Definition: Command.h:478
blfwk::Command
Represents a bootloader command.
Definition: Command.h:301
blfwk::ConfigureQuadSpi::m_configBlockAddress
uint32_t m_configBlockAddress
Qspi config block address (in RAM or in internal Flash).
Definition: Command.h:1421
blfwk::FlashImage::FlashImage
FlashImage(SourceFile *sourceFile, bool doEraseOpt)
Constructor that takes a SourceFile argument.
Definition: Command.h:1471
blfwk::FlashEraseRegion::FlashEraseRegion
FlashEraseRegion(uint32_t start, uint32_t length)
Constructor that takes a start and length arguments.
Definition: Command.h:896
blfwk::DataPacket::DataProducer
Abstract class to provide data for data phase.
Definition: Command.h:502
blfwk::Call::Call
Call(const string_vector_t *argv)
Constructor that takes an argument vector.
Definition: Command.h:1217
blfwk::ConfigureSpi::ConfigureSpi
ConfigureSpi(const string_vector_t *argv)
Constructor that takes an argument vector.
Definition: Command.h:1533
blfwk::DataPacket::SegmentDataProducer::m_segment
blfwk::DataSource::Segment * m_segment
DataSource::Segment object.
Definition: Command.h:645
blfwk::Progress::progressCallback
void progressCallback(int percentage)
execute the progress callback function.
Definition: Command.h:251
blfwk::FillMemory::m_patternWord
uint32_t m_patternWord
Fill pattern.
Definition: Command.h:1125
blfwk::GetProperty::m_memoryId
uint32_t m_memoryId
External memory identifier.
Definition: Command.h:839
blfwk::ReadMemory::m_byteCount
uint32_t m_byteCount
Number of bytes to read.
Definition: Command.h:1028
blfwk::FlashProgramOnce::m_dataHigh
uint32_t m_dataHigh
Bytes 4-7 of the data to be written.
Definition: Command.h:1319
blfwk::FlashSecurityDisable::FlashSecurityDisable
FlashSecurityDisable(const string_vector_t *argv)
Constructor that takes an argument vector.
Definition: Command.h:1247
blfwk::FlashEraseAllUnsecure::FlashEraseAllUnsecure
FlashEraseAllUnsecure()
Constructor that takes none argument.
Definition: Command.h:975
blfwk::DataPacket::DataConsumer
Abstract class to consume data from data phase.
Definition: Command.h:652
blfwk::DataPacket::StdOutDataConsumer::finalize
virtual void finalize()
Finalize processing.
Definition: Command.h:714
blfwk::ReliableUpdate::ReliableUpdate
ReliableUpdate(const string_vector_t *argv)
Constructor that takes an argument vector.
Definition: Command.h:1431
blfwk::GetProperty
Represents the bootloader GetProperty command.
Definition: Command.h:802
blfwk::FlashSecurityDisable::processResponse
virtual bool processResponse(const uint8_t *packet)
Check response packet.
Definition: Command.h:1268
blfwk::SetProperty::m_propertyTag
uint32_t m_propertyTag
Property tag.
Definition: Command.h:879
blfwk::Command::Command
Command(const string_vector_t *argv)
Constructor that takes a command name and list of arguments.
Definition: Command.h:332
blfwk::Execute::processResponse
virtual bool processResponse(const uint8_t *packet)
Check response packet.
Definition: Command.h:1198
blfwk::DataPacket::SegmentDataProducer::getDataSize
virtual uint32_t getDataSize() const
Query the total size of the data.
Definition: Command.h:636
blfwk::DataPacket::FileDataProducer::~FileDataProducer
virtual ~FileDataProducer()
Destructor.
Definition: Command.h:533
blfwk::Progress::m_segmentIndex
int m_segmentIndex
Index of data segment in progressing.
Definition: Command.h:284
blfwk::DataSource::Segment::getBaseAddress
virtual uint32_t getBaseAddress()
Returns the address associated with the segment.
Definition: src/blfwk/DataSource.h:95
blfwk::StatusMessageTableEntry::message
const std::string message
Description of the status.
Definition: Command.h:212
blfwk::Command::registerProgress
void registerProgress(Progress *progress)
initial the process callback.
Definition: Command.h:384
blfwk::SetProperty::processResponse
virtual bool processResponse(const uint8_t *packet)
Check generic response packet.
Definition: Command.h:872
blfwk::DataPacket::HexDataProducer::HexDataProducer
HexDataProducer(const uchar_vector_t &data)
Constructor that takes a vector<uchar> parameter.
Definition: Command.h:580
std
STL namespace.
blfwk::StatusMessageTableEntry::status
int32_t status
Status code value.
Definition: Command.h:211
blfwk::DataPacket::FileDataProducer
Provide file data for data phase.
Definition: Command.h:521
blfwk::DataPacket::SegmentDataProducer
Provide DataSource::Segment data for data phase.
Definition: Command.h:616
blfwk::Command::sendTo
virtual void sendTo(Packetizer &packetizer)
Send command to packetizer and on to peripheral.
Definition: Command.h:370
blfwk::CommandPacket::CommandPacket
CommandPacket(uint8_t tag, uint8_t flags=0)
Constructor that takes no command arguments.
Definition: Command.h:433
blfwk::FlashSecurityDisable::FlashSecurityDisable
FlashSecurityDisable(uint32_t keyHigh, uint32_t keyLow)
Constructor that takes the key.
Definition: Command.h:1253
blfwk::DataPacket::FileDataProducer::m_filePath
std::string m_filePath
Data file path.
Definition: Command.h:561
blfwk::ReliableUpdate::m_address
uint32_t m_address
Destination address.
Definition: Command.h:1451
blfwk::ConfigureI2c::processResponse
virtual bool processResponse(const uint8_t *packet)
Check generic response packet.
Definition: Command.h:1515
blfwk::SetProperty::SetProperty
SetProperty(const string_vector_t *argv)
Constructor that takes an argument vector.
Definition: Command.h:849
blfwk::CommandPacket::CommandPacket
CommandPacket(uint8_t tag, uint8_t flags, uint32_t arg1, uint32_t arg2)
Constructor that takes two command arguments.
Definition: Command.h:448
blfwk::WriteMemory::WriteMemory
WriteMemory(uint32_t address, const uchar_vector_t &data)
Constructor that takes an uchar_vector_t argument.
Definition: Command.h:1062
blfwk::WriteMemory::m_startAddress
uint32_t m_startAddress
Destination memory address.
Definition: Command.h:1091
blfwk::FlashEraseRegion
Represents the bootloader Flash Erase command.
Definition: Command.h:886
blfwk::FlashEraseAllUnsecure::FlashEraseAllUnsecure
FlashEraseAllUnsecure(const string_vector_t *argv)
Constructor that takes an argument vector.
Definition: Command.h:969
blfwk::FillMemory::processResponse
virtual bool processResponse(const uint8_t *packet)
Check response packet.
Definition: Command.h:1116
blfwk::WriteMemory::m_data
uchar_vector_t m_data
The data to write to the device.
Definition: Command.h:1093
blfwk::FlashImage::m_sourceFile
SourceFile * m_sourceFile
Sourcefile object containing the data and addresses.
Definition: Command.h:1491
blfwk::SetProperty::m_propertyValue
uint32_t m_propertyValue
Value to set.
Definition: Command.h:880
blfwk::ReceiveSbFile::ReceiveSbFile
ReceiveSbFile(const string_vector_t *argv)
Constructor that takes an argument vector.
Definition: Command.h:1135
blfwk::FlashProgramOnce::FlashProgramOnce
FlashProgramOnce(const string_vector_t *argv)
Constructor that takes an argument vector.
Definition: Command.h:1286
blfwk::FlashProgramOnce::processResponse
virtual bool processResponse(const uint8_t *packet)
Check response packet.
Definition: Command.h:1309
blfwk::FlashImage::m_sectorSize
uint32_t m_sectorSize
Flash sector size of current target.
Definition: Command.h:1489
blfwk::Reset::Reset
Reset()
Default constructor.
Definition: Command.h:780
blfwk::ConfigureSpi::processResponse
virtual bool processResponse(const uint8_t *packet)
Check generic response packet.
Definition: Command.h:1546
blfwk::DataPacket::HexDataProducer::~HexDataProducer
virtual ~HexDataProducer()
Destructor.
Definition: Command.h:594
blfwk::ReadMemory::m_dataFile
std::string m_dataFile
Data file path.
Definition: Command.h:1026
blfwk::ConfigureCan::ConfigureCan
ConfigureCan(const string_vector_t *argv)
Constructor that takes an argument vector.
Definition: Command.h:1566
blfwk::ConfigureQuadSpi::ConfigureQuadSpi
ConfigureQuadSpi(const string_vector_t *argv)
Constructor that takes an argument vector.
Definition: Command.h:1400
blfwk::ReliableUpdate::processResponse
virtual bool processResponse(const uint8_t *packet)
Check response packet.
Definition: Command.h:1444
blfwk::FillMemory::m_byteCount
uint32_t m_byteCount
Number of bytes to fill.
Definition: Command.h:1124
blfwk::DataPacket::StdOutDataConsumer::StdOutDataConsumer
StdOutDataConsumer()
Constructor.
Definition: Command.h:708
blfwk::Reset
Represents the bootloader Reset command.
Definition: Command.h:770
blfwk::FlashImage::FlashImage
FlashImage(const string_vector_t *argv)
Constructor that takes an argument vector.
Definition: Command.h:1461
blfwk::Command::getArg
virtual std::string getArg(int arg) const
Get the specified argument.
Definition: Command.h:362
blfwk::peripheral_t
Definition: Command.h:181
blfwk::DataPacket::DataPacket
DataPacket(DataConsumer *dataConsumer)
Constructor that takes a DataConsumer.
Definition: Command.h:743
blfwk::Execute::m_jumpAddress
uint32_t m_jumpAddress
Destination memory address to jump to.
Definition: Command.h:1205
blfwk::FlashSecurityDisable::m_keyHigh
uint32_t m_keyHigh
Bytes 4-7 of the flash backdoor key.
Definition: Command.h:1276
blfwk::cmd_t
Definition: Command.h:53
blfwk::FlashEraseAllUnsecure
Represents the bootloader Flash Erase All Unsecure command.
Definition: Command.h:965
blfwk::ConfigureI2c
Represents the bootloader Configure I2C command.
Definition: Command.h:1498
blfwk::ReceiveSbFile::processResponse
virtual bool processResponse(const uint8_t *packet)
Check response packet.
Definition: Command.h:1156
blfwk::Progress::registerCallback
void registerCallback(void(*callback)(int, int, int), bool *abortPhase)
Definition: Command.h:277
blfwk::DataPacket::HexDataProducer
Provide data from hex string for data phase.
Definition: Command.h:569
blfwk::ReadMemory
Represents the bootloader Read Memory command.
Definition: Command.h:998
blfwk::ConfigureQuadSpi
Represents the bootloader Configure QuadSpi command.
Definition: Command.h:1396
blfwk::FlashReadResource::m_option
uint32_t m_option
Resrouce to be read.
Definition: Command.h:1390
blfwk::Command::Command
Command(const char *const name)
Constructor that takes a command name.
Definition: Command.h:343
blfwk::WriteMemory::m_count
uint32_t m_count
Number of bytes to write.
Definition: Command.h:1092
blfwk::FlashEraseAll::FlashEraseAll
FlashEraseAll(uint32_t memoryId)
Constructor that takes memory ID argument.
Definition: Command.h:937
blfwk::Reset::processResponse
virtual bool processResponse(const uint8_t *packet)
Check response packet.
Definition: Command.h:793
blfwk::DataPacket::HexDataProducer::m_byteIndex
uint32_t m_byteIndex
Current byte index.
Definition: Command.h:609
blfwk::CommandPacket::_command_packet_constants
_command_packet_constants
Constants.
Definition: Command.h:410
blfwk::WriteMemory::m_fileOrData
std::string m_fileOrData
Data file path or hex data string.
Definition: Command.h:1089
blfwk::DataPacket::FileDataConsumer::finalize
virtual void finalize()
Finalize processing.
Definition: Command.h:689
blfwk::SourceFile
Abstract base class for a source file containing executable code.
Definition: src/blfwk/SourceFile.h:56
blfwk::FlashImage::m_doEraseOpt
bool m_doEraseOpt
Detemine if doing erase operation before writting image file to flash.
Definition: Command.h:1492
blfwk::DataPacket::StdOutDataConsumer::_constants
_constants
Definition: Command.h:701
blfwk::FlashReadResource::FlashReadResource
FlashReadResource(const string_vector_t *argv)
Constructor that takes an argument vector.
Definition: Command.h:1363
blfwk::DataPacket::FileDataProducer::getDataSize
virtual uint32_t getDataSize() const
Query the total size of the data.
Definition: Command.h:552
blfwk::DataPacket::FileDataConsumer::FileDataConsumer
FileDataConsumer()
Default constructor.
Definition: Command.h:669
blfwk::Command::getName
virtual std::string getName() const
Get the command name (i.e. argv[0]).
Definition: Command.h:364
blfwk::FlashImage
Represents the Flash Image command used for downloading formatted file.
Definition: Command.h:1457
blfwk::SetProperty::SetProperty
SetProperty(property_t property, uint32_t value)
Constructor that takes a property_t argument and the value to set.
Definition: Command.h:855
blfwk::FlashProgramOnce::FlashProgramOnce
FlashProgramOnce(uint32_t index, uint32_t byteCount, uint32_t dataLow, uint32_t dataHigh)
Constructor that takes arguments.
Definition: Command.h:1292
blfwk::FillMemory::FillMemory
FillMemory(const string_vector_t *argv)
Constructor that takes an argument vector.
Definition: Command.h:1103
blfwk::WriteMemory::m_segment
blfwk::DataSource::Segment * m_segment
DataSource segment (instead of file or hex string).
Definition: Command.h:1090
blfwk::DataPacket::SegmentDataProducer::m_byteIndex
uint32_t m_byteIndex
Current byte index.
Definition: Command.h:646
blfwk::CommandPacket::m_numArguments
int m_numArguments
Number of command arguments.
Definition: Command.h:487
blfwk::GetProperty::GetProperty
GetProperty(const string_vector_t *argv)
Constructor that takes an argument vector.
Definition: Command.h:806
blfwk::CommandPacket::PacketWithArgs::init
void init(uint8_t tag, uint8_t flags, uint8_t numArguments)
Initialize the command packet.
Definition: Command.h:420
blfwk::DataPacket::StdOutDataConsumer::m_currentCount
uint32_t m_currentCount
Current byte being processed, starts at 1.
Definition: Command.h:731
blfwk::Command::m_responseDetails
string m_responseDetails
Descriptive response.
Definition: Command.h:398
blfwk::DataPacket::m_dataProducer
DataProducer * m_dataProducer
Provides data for the packet.
Definition: Command.h:760
blfwk::ConfigureCan::processResponse
virtual bool processResponse(const uint8_t *packet)
Check generic response packet.
Definition: Command.h:1579
blfwk::Progress::Progress
Progress(void(*callback)(int, int, int), bool *abortPhase)
Constructor with initial callback.
Definition: Command.h:238
blfwk::CommandPacket::m_packet
PacketWithArgs m_packet
Command packet data.
Definition: Command.h:488
blfwk::Command::~Command
virtual ~Command()
Destructor.
Definition: Command.h:353
blfwk::DataPacket::FileDataConsumer::m_filePointer
FILE * m_filePointer
Data file pointer.
Definition: Command.h:692
blfwk::DataPacket::FileDataProducer::FileDataProducer
FileDataProducer()
Default constructor.
Definition: Command.h:525
blfwk::CommandPacket::PacketWithArgs
Format of command packet.
Definition: Command.h:417
blfwk::FlashReadOnce::m_byteCount
uint32_t m_byteCount
Number of bytes to be read.
Definition: Command.h:1353
blfwk::DataSource::Segment
Discrete, contiguous part of the source&#39;s data.
Definition: src/blfwk/DataSource.h:65
blfwk::CommandPacket::CommandPacket
CommandPacket(uint8_t tag, uint8_t flags, uint32_t arg)
Constructor that takes one command argument.
Definition: Command.h:440
blfwk::BusPal::spi_clock_polarity_t
spi_clock_polarity_t
SPI clock polarity configuration.
Definition: BusPal.h:74
blfwk::ConfigureCan
Represents the bootloader Configure CAN command.
Definition: Command.h:1562
blfwk::GetProperty::m_property
property_t m_property
Property tag.
Definition: Command.h:838
blfwk::CommandPacket::PacketWithArgs::m_header
command_packet_t m_header
Packet header.
Definition: Command.h:427
blfwk::Progress::~Progress
~Progress()
Default destructor.
Definition: Command.h:247
blfwk::ReliableUpdate
Represents the bootloader Reliable Update command.
Definition: Command.h:1427
blfwk::BusPal::spi_clock_phase_t
spi_clock_phase_t
SPI clock phase configuration.
Definition: BusPal.h:81
blfwk::WriteMemory
Represents the bootloader Write Memory command.
Definition: Command.h:1034
blfwk::FillMemory::m_startAddress
uint32_t m_startAddress
Destination memory address.
Definition: Command.h:1123
blfwk::FlashReadOnce::FlashReadOnce
FlashReadOnce(const string_vector_t *argv)
Constructor that takes an argument vector.
Definition: Command.h:1329
blfwk::Call::processResponse
virtual bool processResponse(const uint8_t *packet)
Check response packet.
Definition: Command.h:1230
blfwk::FlashProgramOnce::m_index
uint32_t m_index
Index of program once field to be programed.
Definition: Command.h:1316
blfwk::ConfigureQuadSpi::processResponse
virtual bool processResponse(const uint8_t *packet)
Check generic response packet.
Definition: Command.h:1413
blfwk::Progress
Contains the callback function for progress and abort phase.
Definition: Command.h:225
blfwk::ConfigureQuadSpi::m_flashMemId
uint32_t m_flashMemId
Flash memory ID.
Definition: Command.h:1420
blfwk::DataPacket::FileDataProducer::m_filePointer
FILE * m_filePointer
Data file pointer.
Definition: Command.h:562
blfwk::DataPacket::HexDataProducer::HexDataProducer
HexDataProducer()
Default constructor.
Definition: Command.h:573
blfwk::Call
Represents the bootloader Call command.
Definition: Command.h:1213
blfwk::FlashEraseRegion::m_byteCount
uint32_t m_byteCount
Number of bytes to erase.
Definition: Command.h:921
blfwk::Call::m_callAddress
uint32_t m_callAddress
Destination memory address to call.
Definition: Command.h:1236
blfwk::Command::getArgCount
virtual size_t getArgCount() const
Get the number of arguments, including the command name.
Definition: Command.h:366
blfwk::property_t
Definition: Command.h:117
blfwk::FlashReadResource::m_byteCount
uint32_t m_byteCount
Number of bytes to read.
Definition: Command.h:1389
blfwk::ReadMemory::ReadMemory
ReadMemory(const string_vector_t *argv)
Constructor that takes an argument vector.
Definition: Command.h:1002
blfwk::Progress::abortPhase
bool abortPhase(void)
Check whether the data phase is canceled.
Definition: Command.h:260
blfwk::Execute::Execute
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
blfwk::WriteMemory::WriteMemory
WriteMemory(const string_vector_t *argv)
Constructor that takes an argument vector.
Definition: Command.h:1038
blfwk::FlashReadResource::m_startAddress
uint32_t m_startAddress
Destination memory address.
Definition: Command.h:1388
blfwk::FlashProgramOnce::m_dataLow
uint32_t m_dataLow
Bytes 0-3 of the data to be written.
Definition: Command.h:1318
blfwk::DataPacket::m_dataConsumer
DataConsumer * m_dataConsumer
Process the data in the packet.
Definition: Command.h:761
blfwk::FlashReadResource::m_dataFile
std::string m_dataFile
Data file path.
Definition: Command.h:1387
blfwk::FlashEraseRegion::FlashEraseRegion
FlashEraseRegion(const string_vector_t *argv)
Constructor that takes an argument vector.
Definition: Command.h:890
blfwk::FlashEraseAll::m_memoryId
uint32_t m_memoryId
Flash Memory Identifier.
Definition: Command.h:959
blfwk::ReadMemory::processResponse
virtual bool processResponse(const uint8_t *packet)
Check generic response packet.
Definition: Command.h:1019
blfwk::DataPacket::FileDataConsumer::m_filePath
std::string m_filePath
Data file path.
Definition: Command.h:691
blfwk::FlashEraseAll::FlashEraseAll
FlashEraseAll(const string_vector_t *argv)
Constructor that takes an argument vector.
Definition: Command.h:931
blfwk::Command::m_progress
Progress * m_progress
Variable for progress control.
Definition: Command.h:393
blfwk::CommandPacket::CommandPacket
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
blfwk::ReceiveSbFile::ReceiveSbFile
ReceiveSbFile(const char *const filename)
Constructor that takes a filename argument.
Definition: Command.h:1142
blfwk::FlashEraseRegion::m_startAddress
uint32_t m_startAddress
Starting address in flash.
Definition: Command.h:920
blfwk::FillMemory
Represents the bootloader Fill Memory command.
Definition: Command.h:1099
blfwk::GetProperty::GetProperty
GetProperty(property_t property)
Constructor that takes a property_t argument.
Definition: Command.h:813
blfwk::GetProperty::processResponse
virtual bool processResponse(const uint8_t *packet)
Check generic response packet.
Definition: Command.h:831
blfwk::FlashReadResource
Represents the bootloader Read Resource command.
Definition: Command.h:1359
blfwk::ReceiveSbFile
Represents the bootloader Receive SB File command.
Definition: Command.h:1131
blfwk::FlashEraseAll::processResponse
virtual bool processResponse(const uint8_t *packet)
Check response packet.
Definition: Command.h:952
blfwk::FlashImage::m_fileName
std::string m_fileName
Image file name with full path.
Definition: Command.h:1490
blfwk::Command::m_argv
string_vector_t m_argv
Vector of argument strings.
Definition: Command.h:396
blfwk::Execute::m_stackpointer
uint32_t m_stackpointer
Stack pointer.
Definition: Command.h:1207
blfwk::ReceiveSbFile::m_dataFile
std::string m_dataFile
SB file path.
Definition: Command.h:1163
blfwk::SetProperty
Represents the bootloader GetProperty command.
Definition: Command.h:845
blfwk::ReadMemory::m_startAddress
uint32_t m_startAddress
Destination memory address.
Definition: Command.h:1027
blfwk::Execute
Represents the bootloader Execute command.
Definition: Command.h:1169
blfwk::DataPacket::SegmentDataProducer::~SegmentDataProducer
virtual ~SegmentDataProducer()
Destructor.
Definition: Command.h:627
blfwk::DataPacket::StdOutDataConsumer
Print data for data phase receive.
Definition: Command.h:698
blfwk::FlashProgramOnce
Represents the bootloader Flash Program Once command.
Definition: Command.h:1282
blfwk::DataPacket::FileDataConsumer::~FileDataConsumer
virtual ~FileDataConsumer()
Destructor.
Definition: Command.h:676
blfwk::StatusMessageTableEntry
Entry in a lookup table of status messages.
Definition: Command.h:209
blfwk::CommandPacket::getData
const uint8_t * getData()
Get pointer to command packet data.
Definition: Command.h:480
blfwk::FlashEraseAllUnsecure::processResponse
virtual bool processResponse(const uint8_t *packet)
Check response packet.
Definition: Command.h:988
blfwk::FlashProgramOnce::m_byteCount
uint32_t m_byteCount
Number of bytes to be programmed.
Definition: Command.h:1317
blfwk::DataPacket::DataPacket
DataPacket(DataProducer *dataProducer)
Constructor that takes a DataProducer.
Definition: Command.h:736
blfwk::CommandPacket::CommandPacket
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
blfwk::WriteMemory::WriteMemory
WriteMemory(blfwk::DataSource::Segment *segment)
Constructor that takes an DataSource::Segment argument.
Definition: Command.h:1049
blfwk::FlashReadOnce::m_index
uint32_t m_index
Index of Program Once Field.
Definition: Command.h:1352
blfwk::FlashReadOnce
Represents the bootloader Flash Read Once command.
Definition: Command.h:1325
blfwk::Command::getResponseValues
virtual const uint32_vector_t * getResponseValues() const
Get response values vector.
Definition: Command.h:372
blfwk::DataPacket
Data packet operations.
Definition: Command.h:496
blfwk::ConfigureI2c::ConfigureI2c
ConfigureI2c(const string_vector_t *argv)
Constructor that takes an argument vector.
Definition: Command.h:1502
blfwk::Command::init
virtual bool init()
Initialize.
Definition: Command.h:357
blfwk::FlashEraseRegion::processResponse
virtual bool processResponse(const uint8_t *packet)
Check response packet.
Definition: Command.h:913