The "cmsis_flash" is a generic driver which uses the standard CMSIS flash loaders to program the flash. On Infineon devices, this driver is typically used for external flash programming but it also can be used for other purposes.

cmsis_flash init

Some types of flash banks are not mapped to the CPU address space right after reset. For example, the external flash connected to an SMIF peripheral requires special configuration of the MCU's hardware blocks in order to be mapped to the CPU address space. Usually, the flash loader's

Init()

function is responsible for enabling such mapping.

cmsis_flash init [bank_num]

This command loads the flash loader to the RAM and executes the

Init()

function. Beware that this function is intrusive. It requires that the MCU is acquired in "good-state" and all CPUs are halted (e.g.,

reset init

is performed) before it can be called.

This command takes one optional argument – the number of the flash bank to be initialized. This command will initialize all cmsis_flash banks if no argument is specified.

cmsis_flash prefer_sector_erase

Controls driver strategy used during mass-erase of the flash bank. There are two possible strategies:

  • Use the

    EraseChip

    API (if available)

  • Use per-sector erase using the

    EraseSector

    API

The

EraseChip

method is used by default. This method is usually faster but it does not display the progress of the erase operation. The EraseChip API is optional; the driver will fall back to per-sector erase if the

EraseChip

API is not implemented in the flash loader. The other downside of this method is that depending on the flash loader implementation, it may erase all external memory banks, not only the bank specified in the

erase_sector

command.

Per-sector erase is usually slower but it displays the progress information and always erases the single flash bank specified in the

erase_sector

command.

cmsis_flash prefer_sector_erase [bank_num] <0/1|false/true>

Command takes two arguments:

  • bank_num

    – (Optional) Flash bank number to enable/disable the per-sector erase strategy. This option will be applied to all cmsis_flash banks if this argument is omitted.

  • parameter_value

    – Mandatory boolean value specifying whether per-sector strategy should be enabled or disabled.