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:
[legend]
Collaboration diagram for blfwk::Updater:
[legend]

## 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.
Packetizer * | getPacketizer () 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.
SourceFile * | m_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
Packetizer * | m_hostPacketizer
| Packet interface to send commands on.
FileLogger * | m_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_error | Raised 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_error | Thrown 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_error | Thrown if an error occurred while sending the FlashEraseRegion(start, length) bootloader command.

Parameters

  start | The beginning address of the memory region to be erased.
  length | The 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_error | Raised if the file could not be opened successfully.

Parameters

  filename | The file to program into the device.
  base_address | The 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_error | Thrown if an error occurred while sending the GetProperty(property) bootloader command.

Parameters

  property | tag

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_error | Thrown if an error occurred while sending the GetProperty(kProperty_AvailableCommands) bootloader command.

Parameters

  command | The 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_error | Thrown if an error occurred while sending the FlashEraseAll bootloader command.

Parameters

  index | The index of a specific program once field.
  byteCount | The length in bytes of a specific program once field.
  data | The 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

  callback | The function to callback with the progress data.
  abort | The 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

  callback | The function to callback with the progress data.

void Updater::unlock | ( | string | backdoor_key | ) |

Release security using BackdoorKey.

Exceptions

  std::runtime_error | Raised if the FlashSecurityDisable command does not return success. Raised if the FlashSecurityDisable command is not supported. Raised if the parameter is illegal

Parameters

  backdoor_key | The 16 hex digitals used to release the security

void Updater::writeMemory | ( | DataSource::Segment * | segment | ) |

protected

Execute the write-memory bootloader command.

Exceptions

  std::runtime_error | Thrown if an error occurred while sending the WriteMemory(segment) bootloader command.

Parameters

  [in,out] | segment | The 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_error | Thrown if an error occurred while sending the WriteMemory(vector<uint8_t) bootloader command.

Parameters

  [in] | data | A vector<uchar> refernce that contains the data to be written to the device.
  [in] | address | The address on the device where the data will be written.

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

- Updater.h
- Updater.cpp