DFU PUSH_TO_ROM

Role

Write the MCU’s firmware into the MCU’s internal ROM. This instruction is available only when the bootloader is running (rescue mode).

Command

Field Value
CLA 5D (DFU)
INS 0A
Data See below

Data

First packet

Bytes Description
0-1 ID of target storage area - must be 0000 for the MCU
2-5 CRC32 of the following binary content
6-9 Length of the following binary content

Next packets

Bytes Description
0-x Binary chunk (max 128 bytes per packet)

Response

Byte Name Description
0 STAtus 00 (SUCCESS) if execution is OK; see List of STAtus for error codes

PUSH_TO_ROM how-to

The PUSH_TO_ROM command writes the MCU’s ROM according to the following sequence:

  • The first packet of the sequence provides the CRC and the length of the firmware; upon receiving this packet, the bootloader erases the ROM
  • The next packets convey the content to be written into the selected area; the sequence terminates when the expected length has been received or the device is resetted

To write a new firmware into a device,

  1. Invoke GET_CONTEXT to retrieve the device’s characteristics,
  2. Confirm the device’s bootloader is currently running (rescue mode). Otherwise use either PUSH_TO_STORAGE or PUSH_TO_STORAGE_FAST instead of PUSH_TO_ROM,
  3. Open the firmware file and locate all parts – every part maps to an area in the SPI flash. See Format of Firmware files for details. Consider only the part having Part ID=0000 that targets the MCU ROM,
  4. Send the first 10-byte packet containing the Part ID, the CRC32 and the length of the following binary content, and then loop sending the actual content by pieces of 128 bytes (last packet could be truncated to a smaller length),
  5. Reset the device using either DFU CLAss’ RESET.