7
31
Fork
You've already forked blackmagic
23

Fix: Memory map formatting #2209

Merged
esden merged 4 commits from fix/memory-map-formatting into main 2026年03月14日 18:28:02 +01:00

Detailed description

In this PR we address a bug we spotted while trying to work with a device that has at least 2 Flash regions in its memory map. The bug would cause the map generator to skip the second region due to an issue in the formatting function itself. This issue is in the input parameter for snprintf() that tells the function how much space it may use for formatting in the provided buffer. When this is improperly tracked from an input of 0 to the map generation function, misexecution results.

This PR also shrinks the Flash usage for the map builder by about 32-40 bytes (depends on platform exactly how much) by simplifying the formatting function, thus fixing this bug. The alternative would have been to have to do a pile of accounting just like in the target description builder functions.

Your checklist for this pull request

Closing issues

<!-- Filling this template is mandatory --> ## Detailed description In this PR we address a bug we spotted while trying to work with a device that has at least 2 Flash regions in its memory map. The bug would cause the map generator to skip the second region due to an issue in the formatting function itself. This issue is in the input parameter for snprintf() that tells the function how much space it may use for formatting in the provided buffer. When this is improperly tracked from an input of 0 to the map generation function, misexecution results. This PR also shrinks the Flash usage for the map builder by about 32-40 bytes (depends on platform exactly how much) by simplifying the formatting function, thus fixing this bug. The alternative would have been to have to do a pile of accounting just like in the target description builder functions. ## Your checklist for this pull request * [x] I've read the [Code of Conduct](https://codeberg.org/blackmagic-debug/blackmagic/src/CODE_OF_CONDUCT.md) * [x] I've read the [guidelines for contributing](https://codeberg.org/blackmagic-debug/blackmagic/src/CONTRIBUTING.md) to this repository * [x] It builds for hardware native (see [Building the firmware](https://codeberg.org/blackmagic-debug/blackmagic?tab=readme-ov-file#building-the-firmware)) * [x] It builds as BMDA (see [Building the BMDA](https://codeberg.org/blackmagic-debug/blackmagic?tab=readme-ov-file#building-black-magic-debug-app)) * [x] I've tested it to the best of my ability * [x] My commit messages provide a useful short description of what the commits do ## Closing issues <!-- put "fixes #XXXX" here to auto-close the issue(s) that your PR fixes (if any). -->
esden requested changes 2026年03月14日 17:57:46 +01:00
Dismissed
esden left a comment
Copy link

I think I see only one potential issue. Otherwise it seems good to go.

I think I see only one potential issue. Otherwise it seems good to go.
@ -263,3 +263,3 @@
}
static ssize_t map_flash(char *buf, size_t len, target_flash_s *flash)
static ssize_t mem_map_flash(char *buffer, size_t length, target_flash_s *flash)
Owner
Copy link

should length not be const?

should length not be const?
Author
Owner
Copy link

All the parameters should be, indeed - fixed!

All the parameters should be, indeed - fixed!
dragonmux marked this conversation as resolved
esden left a comment
Copy link

LGTM

LGTM
esden deleted branch fix/memory-map-formatting 2026年03月14日 18:28:03 +01:00
Sign in to join this conversation.
No reviewers
Labels
Clear labels
BMD App
Black Magic Debug App (aka. PC hosted) (not firmware)
BMP Firmware
Black Magic Probe Firmware (not PC hosted software)
Bug
Confirmed bug
Build system
Build system
Can't reproduce
Maintainers can't reproduce this problem
CI
Continuous Integration System
Contribution wanted
User contributions welcome
Documentation
Project documentation
Draft
Work in progress draft
Duplicate
This issue or pull request already exists
Enhancement
General project improvement
Feedback wanted
Requires additional submitter feedback
Foreign Host Board
Non Native hardware to runing Black Magic firmware on
GDB
Issue/PR related to GDB
Good first issue
Good for newcommers
HwIssue Mitigation
Solving or mitigating a Hardware issue in Software
Information Needed
Maintainers need more information
NativeHardware
Official Black Magic Debug Hardware
New Host Board
New hardware to run Black Magic firmware on
New Target
New debug target
Off Topic
Something that does not involve the project in any way
Potential Bug
A potential, unconfirmed or very special circumstance bug
Regression
Bug caused by a regression
User Interest Needed
More user interest required before consideration
User Testing Needed
Looking for user testing reports
Won't fix
Outside of the project scope or works as intended
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
blackmagic-debug/blackmagic!2209
Reference in a new issue
blackmagic-debug/blackmagic
No description provided.
Delete branch "fix/memory-map-formatting"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?