Skip to content

CMD_CLEAR_FLASH clears sectors beyond the user-data partition, bricks the interface firmware #9

@nedseb

Description

@nedseb

Summary

Running the CMD_CLEAR_FLASH command from the host I2C bridge protocol
(used by both steamicc/arduino-steami-lib and
steamicc/micropython-steami-lib via their respective daplink_flash
drivers) puts the STeaMi's on-board STM32F103 into DAPLink maintenance
mode. After the command lands, the board no longer enumerates as a
normal CMSIS-DAP + mass-storage device — the interface firmware has
to be re-flashed by drag-dropping the firmware binary onto the
maintenance mass-storage volume.

Reproduction

From a clean Arduino sketch on a STeaMi with DaplinkBridge +
DaplinkFlash from steamicc/arduino-steami-lib:

DaplinkBridge bridge(internalI2C);
DaplinkFlash flash(bridge);
flash.begin();
flash.clearFlash();   // ← chip reboots into maintenance mode here

Equivalent reproduction from the integration suite in
steamicc/arduino-steami-lib PR ARMmbed#167 (since reverted exactly because
of this bug):

make test-integration   # against integration/test_daplink_flash

Expected behaviour

CMD_CLEAR_FLASH should clear only the user-data partition (where
filenames and file content live), and leave the interface firmware
sectors and the bootloader untouched. The driver advertises this as a
user-data wipe — the contract should hold.

Observed behaviour

The whole F103 internal flash (or at least the interface-firmware
section) is erased. On the next reset / reboot the STM32 falls back
to its hardware DFU bootloader and re-enumerates as maintenance.

Suggested fix

Audit the sector-erase loop that backs CMD_CLEAR_FLASH: cap the
erase range to the user-data partition only. Anything covering the
interface firmware, bootloader, or maintenance metadata should be
protected.

Cross-references

  • arduino-steami-lib: integration test reverted in commit 7108328
    on branch feat/daplink-flash-driver (will land in PR Update board_id for FRDM-KW24 ARMmbed/DAPLink#167).
  • micropython-steami-lib: likely affected too — WSEN_HIDS-style
    cross-impl confirmation issue can be filed there once this is
    understood.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions