Kinetis Bootloader Host  2.0.0
Host Tools for Kinetis devices
blfwk::Updater Class Reference

Update class contains the functionality necessary to update the firmware on a device running Bootloader. More...

#include <Updater.h>

+ Inheritance diagram for blfwk::Updater:
+ Collaboration diagram for blfwk::Updater:

Public Member Functions

 Updater (const Peripheral::PeripheralConfigData &config)
 Default constructor.
 
virtual ~Updater ()
 Destructor.
 
uint32_vector_t getProperty (property_t tag)
 get Device's property by using get-property command. More...
 
uint32_t getSectorSize ()
 get Device's flash sector size. More...
 
uint32_t getFlshSize ()
 get Device's flash size. More...
 
void eraseFlashRegion (uint32_t start, uint32_t length)
 Execute the FlashEraseRegion bootloader command. More...
 
void eraseFlashAll (uint32_t memoryId)
 Execute the FlashEraseAll bootloader command. More...
 
void programOnce (uint32_t index, uint32_t byteCount, string data)
 Execute the FlashProgramOnce bootloader command. More...
 
- Public Member Functions inherited from blfwk::Bootloader
 Bootloader ()
 Default Constructor for Simulator.
 
 Bootloader (const Peripheral::PeripheralConfigData &config)
 Constructor.
 
virtual ~Bootloader ()
 Destructor.
 
void inject (Command &cmd)
 Inject a command into the bootloader. More...
 
void flush ()
 Flush state.
 
void execute (uint32_t entry_point, uint32_t param=0, uint32_t stack_pointer=0)
 Execute the execute command.
 
void reset ()
 Execute the reset command.
 
standard_version_t getVersion ()
 Execute the get-property(current-version) command.
 
uint32_t getSecurityState ()
 Execute the get-property(flash-security-state) command.
 
void ping (int retries, unsigned int delay, int comSpeed)
 Send a ping if applicable.
 
PacketizergetPacketizer () const
 Get the host packetizer.
 

Update API.

typedef void(* progress_callback_t) (updater_operation_t *op)
 Type for the progress callback routine.
 
updater_operation_t m_operation
 Struct used to monitor the Operation progress.
 
void setCallback (progress_callback_t callback)
 Set the user-defined function to call on progress events. More...
 
void registerCallback (void(*callback)(int, int, int), bool *abort)
 Set callback for progress and abort control. More...
 
status_t flashFirmware (const char *filename, uint32_t base_address)
 Program flash on the device. More...
 
void eraseAllUnsecure ()
 Erase all flash blocks and release MCU security. More...
 
void unlock (string backdoor_key)
 Release security using BackdoorKey. More...
 
bool isCommandSupported (const cmd_t &command)
 Checks if Kinetis Bootloader device supports a given command. More...
 

Bootloader commands

uint32_t m_base_address
 Base address of the image.
 
uint32_t m_sector_size
 Sector size of the flash on the device.
 
uint32_t m_flashStart
 Start address of the flash on the device.
 
uint32_t m_flashSize
 The flash size (in bytes) of the device.
 
SourceFilem_sourceFile
 SourceFile object.
 
progress_callback_t m_progressCallback
 Callback used to report update progress.
 
Progress m_progress
 Progress control.
 
void writeMemory (DataSource::Segment *segment)
 Execute the write-memory bootloader command. More...
 
void writeMemory (uint32_t address, const uchar_vector_t &data)
 Execute the write-memory bootloader command. More...
 
status_t flashFromSourceFile ()
 Program flash procedure for SourceFile types.
 
status_t flashFromSBFile (const char *filename)
 Program flash procedure for SB files.
 

Additional Inherited Members

- Protected Attributes inherited from blfwk::Bootloader
Packetizerm_hostPacketizer
 Packet interface to send commands on.
 
FileLoggerm_logger
 Singleton logger instance.
 

Detailed Description

Update class contains the functionality necessary to update the firmware on a device running Bootloader.

The purpose of this class is to provide a common interface for updating any device running the Kinetis Bootloader from several different file formats.

Member Function Documentation

void Updater::eraseAllUnsecure ( )

Erase all flash blocks and release MCU security.

Exceptions
std::runtime_errorRaised if the FlashEraseAllUnsecure command does not return success. Raised if the FlashEraseAllUnsecure command is not supported.
void Updater::eraseFlashAll ( uint32_t  memoryId)

Execute the FlashEraseAll bootloader command.

Exceptions
std::runtime_errorThrown if an error occurred while sending the FlashEraseAll bootloader command.
void Updater::eraseFlashRegion ( uint32_t  start,
uint32_t  length 
)

Execute the FlashEraseRegion bootloader command.

Exceptions
std::runtime_errorThrown if an error occurred while sending the FlashEraseRegion(start, length) bootloader command.
Parameters
startThe beginning address of the memory region to be erased.
lengthThe length in bytes of the memory region to be erased.
status_t Updater::flashFirmware ( const char *  filename,
uint32_t  base_address 
)

Program flash on the device.

Exceptions
std::runtime_errorRaised if the file could not be opened successfully.
Parameters
filenameThe file to program into the device.
base_addressThe address on the device where the file wiill be written.
uint32_t blfwk::Updater::getFlshSize ( )
inline

get Device's flash size.

Returns
the value of flash size.
uint32_vector_t Updater::getProperty ( property_t  tag)

get Device's property by using get-property command.

Exceptions
std::runtime_errorThrown if an error occurred while sending the GetProperty(property) bootloader command.
Parameters
propertytag
Returns
vector of the response values.
uint32_t blfwk::Updater::getSectorSize ( )
inline

get Device's flash sector size.

Returns
the value of sector size.
bool Updater::isCommandSupported ( const cmd_t command)

Checks if Kinetis Bootloader device supports a given command.

Exceptions
std::runtime_errorThrown if an error occurred while sending the GetProperty(kProperty_AvailableCommands) bootloader command.
Parameters
commandThe command to check.
Returns
true if command is supported, false if not.
void Updater::programOnce ( uint32_t  index,
uint32_t  byteCount,
string  data 
)

Execute the FlashProgramOnce bootloader command.

Exceptions
std::runtime_errorThrown if an error occurred while sending the FlashEraseAll bootloader command.
Parameters
indexThe index of a specific program once field.
byteCountThe length in bytes of a specific program once field.
dataThe 8/16 hex digitals to write.
void blfwk::Updater::registerCallback ( void(*)(int, int, int)  callback,
bool *  abort 
)
inline

Set callback for progress and abort control.

Parameters
callbackThe function to callback with the progress data.
abortThe variable used for abort phase control.
void blfwk::Updater::setCallback ( progress_callback_t  callback)
inline

Set the user-defined function to call on progress events.

Parameters
callbackThe function to callback with the progress data.
void Updater::unlock ( string  backdoor_key)

Release security using BackdoorKey.

Exceptions
std::runtime_errorRaised if the FlashSecurityDisable command does not return success. Raised if the FlashSecurityDisable command is not supported. Raised if the parameter is illegal
Parameters
backdoor_keyThe 16 hex digitals used to release the security
void Updater::writeMemory ( DataSource::Segment segment)
protected

Execute the write-memory bootloader command.

Exceptions
std::runtime_errorThrown if an error occurred while sending the WriteMemory(segment) bootloader command.
Parameters
[in,out]segmentThe DatSource::Segment that represents the data to be written to the device.
void Updater::writeMemory ( uint32_t  address,
const uchar_vector_t &  data 
)
protected

Execute the write-memory bootloader command.

Exceptions
std::runtime_errorThrown if an error occurred while sending the WriteMemory(vector<uint8_t) bootloader command.
Parameters
[in]dataA vector<uchar> refernce that contains the data to be written to the device.
[in]addressThe address on the device where the data will be written.

The documentation for this class was generated from the following files: