Erase a specified portion of SPI Flash.
.
- Parameters
-
[in] | u32Offset | Address (Offset) to erase from the SPI flash. |
[in] | u32Sz | Total number of bytes required to be erased. |
- Note
- It is blocking function
- Warning
- Address (offset) plus size of data must not exceed flash size.
- No firmware is required for writing to SPI flash.
- In case of there is a running firmware, it is required to pause your firmware first before any trial to access SPI flash to avoid any racing between host and running firmware on bus using m2m_wifi_download_mode
- See Also
- m2m_wifi_download_mode, spi_flash_get_size
- Returns
- The function returns M2M_SUCCESS for successful operations and a negative value otherwise.
Example
* #include "spi_flash.h"
*
* #define DATA_TO_REPLACE "THIS IS A NEW SECTOR IN FLASH"
*
* {
*
uint32 u32FlashTotalSize = 0;
*
* {
*
printf(
"Unable to enter download mode\r\n");
* }
* else
* {
* }
*
*
while((u32FlashTotalSize > u32FlashOffset) && (
M2M_SUCCESS == ret))
* {
* {
*
printf(
"Unable to read SPI sector\r\n");
* break;
* }
* memcpy(au8FlashContent, DATA_TO_REPLACE, strlen(DATA_TO_REPLACE));
*
* {
*
printf(
"Unable to erase SPI sector\r\n");
* break;
* }
*
* {
*
printf(
"Unable to write SPI sector\r\n");
* break;
* }
* }
*
* {
*
printf(
"Successful operations\r\n");
* }
* else
* {
*
printf(
"Failed operations\r\n");
* }
*
* while(1);
* }
*
- Parameters
-
[in] | u32Offset | Address (Offset) to erase from the SPI flash. |
[in] | u32Sz | Size of SPI flash required to be erased. |
- Note
- It is blocking function
- Warning
- Address (offset) plus size of data must not exceed flash size.
- No firmware is required for writing to SPI flash.
- In case of there is a running firmware, it is required to pause your firmware first before any trial to access SPI flash to avoid any racing between host and running firmware on bus using m2m_wifi_download_mode
- It is blocking function
- See Also
- m2m_wifi_download_mode, spi_flash_get_size
- Returns
- The function returns M2M_SUCCESS for successful operations and a negative value otherwise.
References FLASH_PAGE_SZ, i, j, M2M_DBG, M2M_ERR_FAIL, M2M_PRINT, M2M_SUCCESS, MAX_ATTEMPT_STATUS_READ, MAX_PROG_CNT, MAX_RETRY, ret, spi_flash_read_status_reg(), spi_flash_sector_erase(), and spi_flash_write_enable().
Referenced by m2m_flash_erase_sector(), and update_control_structure().