The bootloader can only process the bootload record which be created from a hex file with Hex2Boot tool. And the bootload record is a pure binary file composed of the bootloader commands described in 5. Bootloader Protocol of AN945.
The figure as below illustrate the detailed structure of bootload record.
The bootload record file start with a setup command to pass the flash keys to the bootloader and selects the active flash bank. The followed erase command will be decoded by bootloader and erase the select flash page. And then the Write command will be decoded by bootloader to write the payload data to flash starting at the indicated address.
The Hex2Boot can also merge the Erase and Write as one single Erase command, after get the record bootloader will erase the page firstly, and then write flash with data in record.
Whether the bootloader erase the flash page or not just depend on the bootload record. By default, only the flash page which need to be written will be erased firstly.
The detailed structure of bootload record