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
To write data to the flash memory, the SBL function writeFlashRange can be used; this function sends the CMD_DOWNLOAD command to the bootloader together with the start address and the download size in bytes. The bootloader is now prepared to receive the specified amount of data and write it to flash, starting at the specified address.
To transfer the data, the CMD_SEND_DATA command is used. A maximum of 252 bytes of data can be transferred per CMD_SEND_DATA command. If the data to be downloaded is larger than 252 bytes, the CMD_SEND_DATA command must be repeated. The SBL writeFlashRange function handles splitting data transfer into multiple CMD_SEND_DATA commands.
The status of the bootloader is read after both the CMD_DOWNLOAD command and after each CMD_SEND_DATA command by using the CMD_GET_STATUS command. This is to ensure that the start address and firmware size are valid, and that the data was successfully programmed into the flash. If the status indicates an error, the bootloader’s internal address pointer is not incremented, allowing the data to be re-transferred.
Figure 4-6 demonstrates the flash write sequence using the SBL function writeFlashRange.