29 #ifndef POSIX_APP_CHILICTL_FLASH_FLASHER_HPP_
30 #define POSIX_APP_CHILICTL_FLASH_FLASHER_HPP_
101 Flasher(
const char *aAppFilePath,
102 const char *aOtaBootFilePath,
103 const char *aManufacturerDataFilePath,
144 kMaxRebootDiscoverAttempts = 10,
150 std::ifstream mAppFile;
151 std::ifstream mOtaBootFile;
152 std::ifstream mManuDataFile;
154 size_t mOtaBootFileSize;
155 size_t mManuDataFileSize;
156 size_t mAppMaxFileSize;
157 size_t mOtaBootMaxFileSize;
158 size_t mManuDataMaxFileSize;
159 uint32_t mAppStartAddr;
160 uint32_t mOtaBootStartAddr;
161 uint32_t mManuDataStartAddr;
162 size_t mCombinedFileSize;
165 DeviceInfo mDeviceInfo;
170 bool mEnumerateUartDevices;
171 bool mOtaBootFilePresent;
173 void set_state(
State aNextState);
196 void configure_size_and_addresses();
197 size_t get_page_count_for_erase();
198 uint32_t get_start_address();
200 static const char *state_string(
State aState);
C++ wrapper for the C ca_device_info struct, which owns its own memory.
Definition: DeviceInfo.hpp:40
Definition: Flasher.hpp:40
void SetIgnoreVersion(bool aIgnoreVersion)
Enable/Disable the version check for the connected device.
Definition: Flasher.hpp:137
void SetEnumerateUartDevices(bool aEnumerateUartDevices)
Definition: Flasher.hpp:139
Flasher(const char *aAppFilePath, const char *aOtaBootFilePath, const char *aManufacturerDataFilePath, const DeviceInfo &aDeviceInfo, FlashType aFlashType)
Construct a flasher instance.
Definition: Flasher.cpp:50
~Flasher()
Definition: Flasher.cpp:129
State
State enumeration for flasher state machine.
Definition: Flasher.hpp:80
@ ERASE
Erasing flash.
Definition: Flasher.hpp:84
@ COMPLETE
Flashing completed successfully.
Definition: Flasher.hpp:88
@ INIT
Initial state.
Definition: Flasher.hpp:81
@ FLASH
Flashing program.
Definition: Flasher.hpp:85
@ INVALID
Class not correctly instantiated.
Definition: Flasher.hpp:90
@ OTA_ERASE
Erase the metadata region of the external flash (only happens if OTA upgrade is enabled)
Definition: Flasher.hpp:82
@ REBOOT
Rebooted into DFU mode.
Definition: Flasher.hpp:83
@ FAIL
Flashing failed.
Definition: Flasher.hpp:89
@ VERIFY
Verifying correct flashing.
Definition: Flasher.hpp:86
@ VALIDATE
Validating new program functionality.
Definition: Flasher.hpp:87
bool IsComplete()
Is the instance complete and successful?
Definition: Flasher.cpp:742
ca_error Process()
Process the internal state, returning an error if no more processing can be done.
Definition: Flasher.cpp:134
FlashType
Enumeration of different areas of flash to rewrite.
Definition: Flasher.hpp:46
@ APROM_CLEAR_AND_PROGRAM
Rewrite the APROM and delete persistent APROM data.
Definition: Flasher.hpp:49
@ APROM_PROGRAM
Rewrite the APROM while preserving persistent APROM data.
Definition: Flasher.hpp:48
@ DFU
Rewrite the DFU area (boot loader)
Definition: Flasher.hpp:50
@ APROM_CLEAR
Clear the APROM (application)
Definition: Flasher.hpp:47
@ MANUFACTURER
Rewrite the manufacturer reserved page.
Definition: Flasher.hpp:51
State GetState()
Get the current state of the flasher.
Definition: Flasher.hpp:127
ca_error
Cascoda error type.
Definition: ca821x_error.h:51
EVBME Message command in Cascoda TLV format.
Definition: evbme_messages.h:258
CA-821x Device reference struct.
Definition: ca821x_api.h:123