Implementation of internal flash loader.
Copyright (c) 2020 Microchip Technology Inc. and its subsidiaries.
Data Structures | |
union | FlashWord_t |
Macros | |
#define | FIRST_PAGE 0 |
#define | FLASH_READY() (NVMCTRL_INTFLAG_s.ready) |
#define | LAST_PAGE 1023 |
Typedefs | |
typedef enum flash_cmd_tag | flash_cmd_t |
Enumerations | |
enum | flash_cmd_tag { ERASE_ROW = 0x02, WRITE_PAGE = 0x04, ERASE_AUXILARYROW = 0x05, WRITE_AUXILARYPAGE = 0x06, LOCK_REGION = 0x40, UNLOCK_REGION = 0x41, SET_POWERREDUCTIONMODE = 0x42, CLEAR_POWERREDUCTIONMODE = 0x43, PAGE_BUFFERCLEAR = 0x44, SET_SECURITYBIT = 0x45, INVALID_ALLCACHE = 0x46 } |
Functions | |
void | flashFlushPage (void) |
Flush unloaded data before exit from bootloader. More... | |
void | flashPacketToPage (void) |
Load received date to the flash. More... | |
void | flashUpdateAppStartAddr (void) |
Updates application start address in end of flash. More... | |
void | hwEraseFlashPage (uint32_t pageStartAddress) |
Erases specified flash page. More... | |
void | hwFillFlashPageBuffer (uint32_t startOffset, uint16_t length, uint8_t *data) |
Writes data to the page buffer. More... | |
void | hwFlashWriteEepromPage (HW_EepromParams_t *eeprom) |
Writes a page to the EEPROM. More... | |
void | hwWriteFlashPage (uint32_t pageStartAddress) |
Writes flash page buffer without erasing. More... | |
void | nvm_init (void) |
Variables | |
uint32_t | appStartAddr |
static uint16_t | currentPage = 0 |
BootBuffer_t | dataBuffer |
static uint16_t | pageBufferToFill [ROW_SIZE_IN_HALF_WORDS] |
static uint8_t | temporaryPageBuffer [FLASH_PAGESIZE] |
#define FIRST_PAGE 0 |
#define FLASH_READY | ( | ) | (NVMCTRL_INTFLAG_s.ready) |
#define LAST_PAGE 1023 |
typedef enum flash_cmd_tag flash_cmd_t |
enum flash_cmd_tag |
void flashFlushPage | ( | void | ) |
Flush unloaded data before exit from bootloader.
References currentPage, FLASH_PAGESIZE, flashUpdateAppStartAddr(), hwEraseFlashPage(), hwFillFlashPageBuffer(), hwWriteFlashPage(), and temporaryPageBuffer.
Referenced by srecProtocol().
void flashPacketToPage | ( | void | ) |
Load received date to the flash.
References BootBuffer_t::address, appStartAddr, currentPage, BootBuffer_t::data, BootBuffer_t::dataSize, FLASH_PAGESIZE, hwEraseFlashPage(), hwFillFlashPageBuffer(), hwWriteFlashPage(), PAGE_POSITION_OFFSET_MASK, and temporaryPageBuffer.
Referenced by srecProtocol().
void flashUpdateAppStartAddr | ( | void | ) |
Updates application start address in end of flash.
References appStartAddr, FLASH_PAGESIZE, hwEraseFlashPage(), hwFillFlashPageBuffer(), hwWriteFlashPage(), and memcpy_P.
Referenced by clear_updateaction(), and flashFlushPage().
void hwEraseFlashPage | ( | uint32_t | pageStartAddress | ) |
Erases specified flash page.
[in] | pageStartAddress | - address within the target page |
References nvm_erase_row().
Referenced by flashFlushPage(), flashPacketToPage(), flashUpdateAppStartAddr(), hwFlashWriteEepromPage(), memcopy(), update_boot_info(), and writeapp_infotable().
void hwFillFlashPageBuffer | ( | uint32_t | startOffset, |
uint16_t | length, | ||
uint8_t * | data | ||
) |
Writes data to the page buffer.
[in] | startOffset | - start position for writing within the page |
[in] | length | - data to write length in bytes |
[in] | data | - pointer to data to write |
References pageBufferToFill, ROW_SIZE, and ROW_SIZE_IN_HALF_WORDS.
Referenced by flashFlushPage(), flashPacketToPage(), flashUpdateAppStartAddr(), hwFlashWriteEepromPage(), memcopy(), update_boot_info(), and writeapp_infotable().
void hwFlashWriteEepromPage | ( | HW_EepromParams_t * | eeprom | ) |
Writes a page to the EEPROM.
[in] | address | - address of data byte. |
[in] | data | - data for saving. |
References HW_EepromParams_t::address, HW_EepromParams_t::data, hwEraseFlashPage(), hwFillFlashPageBuffer(), hwWriteFlashPage(), HW_EepromParams_t::length, memcpy_P, and ROW_SIZE.
Referenced by eepromPacketToPage().
void hwWriteFlashPage | ( | uint32_t | pageStartAddress | ) |
Writes flash page buffer without erasing.
[in] | pageStartAddress | - address within the target page |
References MCU_PAGE_SIZE, NO_OF_PAGES_PER_ROW, nvm_write_buffer(), pageBufferToFill, and ROW_SIZE.
Referenced by flashFlushPage(), flashPacketToPage(), flashUpdateAppStartAddr(), hwFlashWriteEepromPage(), memcopy(), update_boot_info(), and writeapp_infotable().
void nvm_init | ( | void | ) |
References nvm_config::manual_page_write, nvm_get_config_defaults(), nvm_set_config(), and nvm_config::wait_states.
Referenced by FUOTA_NVM_Init(), lowLevelInit(), pal_init(), and pdsNvmInit().
uint32_t appStartAddr |
Referenced by clear_updateaction(), flashPacketToPage(), and flashUpdateAppStartAddr().
|
static |
Referenced by flashFlushPage(), and flashPacketToPage().
BootBuffer_t dataBuffer |
|
static |
Referenced by hwFillFlashPageBuffer(), and hwWriteFlashPage().
|
static |
Referenced by flashFlushPage(), and flashPacketToPage().