ARMmbed / ARMmbed/DAPLink

Issues in `source/daplink/drag-n-drop/iap_flash_intf.c`

Open
#1,006 0 comments 0 reactions 0 assignees View on GitHub
enhancement help wanted needs work to do
Dominant language
C
Stars
2.8k
Forks
1.1k
Avg merge
3d 12h
Merged PRs (30d)
1

Description

Background: The file `source/daplink/drag-n-drop/iap_flash_intf.c` contains the implementation of the `flash_intf_t` interface to flash the probe in order to update the bootloader or interface firmware. One of the feature it contains is that it will erase the first "sector" but cache it's content and only write the sector at the end. This is to minimize the time window in which an interrupted update might start anyway (whereas if the interrupt vector is missing, the failure will be immediate).

The constants `DAPLINK_SECTOR_SIZE` and `DAPLINK_MIN_WRITE_SIZE` are defined in the interface. The use of `DAPLINK_SECTOR_SIZE` in the design is wrong for two reasons:
- It assumes that all erase sectors have the same size (STM32F4x1xx have sectors of size 16 KiB, 64 KiB and 128 KiB).
- It assumes a sector is always a reasonable amount of data to cache in RAM (STM32H7 have sectors of 128 KiB).

The following changes are needed:
- The Flash HAL should be extended to add a function that returns the size of the sector (given the address of the start of the sector).
- Either remove the functionality that caches the first sector, or reduce the size of the buffer to mainly cover the reset vector. In the latter case, a possible enhancement would be to share the buffer with the flash interface used to flash targets.

Contributor guide

Open the contributing guide

Research direction

Start by reading source/daplink/drag-n-drop/iap_flash_intf.c and the Flash HAL interface it uses. Trace how the first sector is erased, cached, and written, then determine how the HAL can provide a sector size for a given address. Done means the implementation no longer assumes uniform, RAM-sized sectors and the chosen caching behavior is documented by its tests or build validation.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
tooling
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.