SWRA466D February 2015 – August 2021 CC1310 , CC1310 , CC1352R , CC1352R , CC2538 , CC2538 , CC2620 , CC2620 , CC2630 , CC2630 , CC2640 , CC2640 , CC2640R2F , CC2640R2F , CC2640R2F-Q1 , CC2640R2F-Q1 , CC2642R , CC2642R , CC2642R-Q1 , CC2642R-Q1 , CC2650 , CC2650 , CC2650MODA , CC2650MODA , CC2652R , CC2652R , CC2652R7 , CC2652R7 , CC2652RB , CC2652RB , CC2652RSIP , CC2652RSIP
The eraseFlashRange function uses the bootloader command CMD_ERASE for CC2538 and CMD_SECTOR_ERASE for CC26x0 and CC26x2.
The CC26x0 and CC26x2 CMD_SECTOR_ERASE takes an address parameter and erases the flash sector (4 KB for CC26x0 devices and 8 KB for CC26x2 devices) in which the address is located.
The CC2538 CMD_ERASE command requires a second argument for specifying the erase size. The CC2538 bootloader erases the flash sectors (2 KB) that are covered by the range [address, address + size].
After each bootloader erase command, eraseFlashRange checks the bootloader status using the CMD_GET_STATUS command.
Figure 4-5 shows the sequence chart for a flash erase using the serial bootloader protocol. The last four bytes in the command (datasize) is specific for CC2538. For CC26x0 and CC26x2, the CMD_SECTOR_ERASE command (and consequent CMD_GET_STATUS) must be repeated for each flash sector to erase.
If the whole Flash memory is to be erased on CC26x0 and CC26x2, the CMD_BANK_ERASE command should be used. This erases the whole Flash memory in one operation, which is faster than deleting sectors individually.