7
31
Fork
You've already forked blackmagic
23

RFC: Support ROM regions in GDB memory-map.xml #2229

Open
opened 2026年04月09日 21:08:17 +02:00 by ALTracer · 0 comments
Contributor
Copy link

A few targets supported by BMD contain executable but read-only memory, which is not declared in the qXfer:memory-map sent to GDB. set inaccessible-by-default off is the quick workaround for this. However, then GDB will treat it as RAM, attempt to write to it (e.g. to set software breakpoints). Per documentation GDB supports <memory type="rom" start="0x1fff0000" length="0x7800"/> entries. BMD only generates type="ram" entries. BMD is tailored for debug from rewritable flash and RAM.

Examples 1: system memory bootloaders in STM32, Boot ROMs in Cortex-A. I could only find limited use for this, as in, I set a hardware breakpoint on AN2606 bootloader entrypoint, and get notified whenever STM32F411CE target attempts to reboot to DfuSe; or, I dumped hex memory of STM32MP15x BootROM and used that for 128 KiB compare-sections benchmark of cortexar_mem_read() routines and SWD/JTAG transport. Registering every such bootloader might bloat BMF (a function call with 3 arguments). Some Nordic chips famously have no bootloader.

Examples 2: RP2040 bootrom, which implements UF2 and Quinapalus softfloat library in 16 KiB; RP2350 bootrom, which contains UF2 in NSBoot and some flash routines; ESP32-C3/C6 ROM code, LPC chip IAP flash services, HPMicro HPM5E00 ROM API with flash services. In contrast, having these mapped suitably for GDB to auto-pick hardware breakpoints, should help during development of BMD flash drivers relying on such ROM code. Some chips are marketed as having faster/optimized routines in ROM outside the contested data bus fetch paths, and the routines have a public API and a pointer table, to be called from user firmware.

RFC: add new functions, i.e. target_add_rom32() that behave like target_add_ram32(), but instead of appending to a linked list of struct target_ram, either append to a similar linked list of struct_target_ram held in new target->rom pointer, or only allow registering a single region; and then expose it in the exec_q_memory_map()/target_mem_map_chunk() generator as mem_map_rom() method. Aforementioned target drivers would register suitable regions in a single call. I don't think BMF flash size impact would be large; RAM impact is 12 bytes per struct on heap (plus malloc housekeeping).

A few targets supported by BMD contain executable but read-only memory, which is not declared in the qXfer:memory-map sent to GDB. `set inaccessible-by-default off` is the quick workaround for this. However, then GDB will treat it as RAM, attempt to write to it (e.g. to set software breakpoints). Per [documentation](https://www.sourceware.org/gdb/current/onlinedocs/gdb.html/Memory-Map-Format.html) GDB supports `<memory type="rom" start="0x1fff0000" length="0x7800"/>` entries. BMD only generates `type="ram"` entries. BMD is tailored for debug from rewritable flash and RAM. Examples 1: system memory bootloaders in STM32, Boot ROMs in Cortex-A. *I could only find limited use for this, as in, I set a hardware breakpoint on [AN2606 bootloader](https://www.st.com/resource/en/application_note/an2606-introduction-to-system-memory-boot-mode-on-stm32-mcus-stmicroelectronics.pdf) entrypoint, and get notified whenever STM32F411CE target attempts to reboot to DfuSe; or, I dumped hex memory of STM32MP15x [BootROM](https://wiki.st.com/stm32mpu/wiki/STM32_MPU_ROM_code_overview) and used that for 128 KiB compare-sections benchmark of cortexar_mem_read() routines and SWD/JTAG transport.* Registering every such bootloader might bloat BMF (a function call with 3 arguments). Some Nordic chips famously have no bootloader. Examples 2: [RP2040 bootrom](https://github.com/raspberrypi/pico-bootrom-rp2040), which implements UF2 and Quinapalus softfloat library in 16 KiB; [RP2350 bootrom](https://github.com/raspberrypi/pico-bootrom-rp2350), which contains UF2 in NSBoot and some flash routines; ESP32-C3/C6 [ROM code](https://github.com/espressif/esp-rom-elfs), LPC chip IAP flash services, HPMicro [HPM5E00 ROM API](https://www.hpmicro.com/Public/Uploads/uploadfile2/files/20260324/HPM5E00UMENV0.3.pdf) with flash services. In contrast, having these mapped suitably for GDB to auto-pick hardware breakpoints, should help during development of BMD flash drivers relying on such ROM code. Some chips are marketed as having faster/optimized routines in ROM outside the contested data bus fetch paths, and the routines have a public API and a pointer table, to be called from user firmware. RFC: add new functions, i.e. target_add_rom32() that behave like target_add_ram32(), but instead of appending to a linked list of `struct target_ram`, either append to a similar linked list of `struct_target_ram` held in new `target->rom` pointer, or only allow registering a single region; and then expose it in the exec_q_memory_map()/target_mem_map_chunk() generator as `mem_map_rom()` method. Aforementioned target drivers would register suitable regions in a single call. I don't think BMF flash size impact would be large; RAM impact is 12 bytes per struct on heap (plus malloc housekeeping).
Sign in to join this conversation.
No Branch/Tag specified
main
feature/bmda-remote-comms
ALTracer/feature/aarch64-ident
feature/better-meson-optimisation-handling
feature/am335x-support
feature/esp32-c3-support
feature/cortex-ar-software-breakpoints
feature/unit-testing
feature/windows-usb-serial-interface-naming
fix/bmp-external-spi
ALTracer/feature/bluepillplus-platform
ALTracer/feature/at32f43x-unrdp
feature/const-correctness
ALTracer/feature/fault_handlers
ALTracer/feature/hazard3-ice40-support
fix/ci-cleanup
ALTracer/fix/gdb-10-12-thread
ALTracer/feature/blackpill-f4-adc
ALTracer/fix/cortex-desc-allocfail-report
ALTracer/feature/spi-perf
ALTracer/feature/calibrate_swd
ALTracer/feature/blank-check
feature/avr
v2.0
v1.9
v1.10
v1.8
v2.1.0-rc1
v2.0.0
v2.0.0-rc2
v2.0.0-rc1
v1.9.3
v1.10.2
v1.10.1
v1.10.0
v1.10.0-rc1
v1.10.0-rc0
v1.9.2
v1.8.3
v1.9.1
v1.9.0
v1.9.0-rc1
v1.9.0-rc0
v1.8.2
v1.8.1
v1.8.0
v1.7.1
v1.7
v1.6.2-rc1
1.6.2-rc0
v1.6.1
v1.6
v1.6-rc1
v1.6-rc0
production_01
production_00
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
1 participant
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#2229
Reference in a new issue
blackmagic-debug/blackmagic
No description provided.
Delete branch "%!s()"

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?