7
31
Fork
You've already forked blackmagic
23

Feature: Multi-AP handling on STM32MP15 #1757

Merged
ALTracer merged 4 commits from ALTracer/feature/stm32mp15-ca7-axi into main 2026年03月30日 02:23:43 +02:00
ALTracer commented 2024年01月30日 17:35:09 +01:00 (Migrated from github.com)
Copy link

Detailed description

  • This is a completely new feature.
  • There are existing problems on multi-AP chips like STM32H7, H5, MP15 regarding miscellaneous Debug features setup, some of which has to go through APB-D AP and not MCU's MEM-AP (AHB-AP).
  • This PR solves some of these problems by introducing runtime management and hooks for AXI-AP AP0 and APB-D AP1 of MP15.

This was written as a PoC in December, before the cortexar STC/LDC DTRRX speedups got developed and tested. Using AXI-AP may provide background access to entire DDR3 and SYSRAM without halting either CA7 of the platform (or single CA7 on MP151).
I need in particular the APB-D to be able to setup the CoreSight SWO block in SoC system scope, which is shared between CA7 MPCore and CM4 and hence neither of them can write to its configuration registers page. The rest (ITM, DWT, RCC) are accessible in some sort and can be poked via Orbuculum's gdbtrace.init script.

Your checklist for this pull request

Closing issues

## Detailed description * This is a completely new feature. * There are existing problems on multi-AP chips like STM32H7, H5, MP15 regarding miscellaneous Debug features setup, some of which has to go through APB-D AP and not MCU's MEM-AP (AHB-AP). * This PR solves some of these problems by introducing runtime management and hooks for AXI-AP AP0 and APB-D AP1 of MP15. This was written as a PoC in December, before the cortexar STC/LDC DTRRX speedups got developed and tested. Using AXI-AP may provide background access to entire DDR3 and SYSRAM without halting either CA7 of the platform (or single CA7 on MP151). I need in particular the APB-D to be able to setup the CoreSight SWO block in SoC system scope, which is shared between CA7 MPCore and CM4 and hence neither of them can write to its configuration registers page. The rest (ITM, DWT, RCC) are accessible in some sort and can be poked via Orbuculum's gdbtrace.init script. ## Your checklist for this pull request * [x] I've read the [Code of Conduct](https://github.com/blackmagic-debug/blackmagic/blob/main/CODE_OF_CONDUCT.md) * [x] I've read the [guidelines for contributing](https://github.com/blackmagic-debug/blackmagic/blob/main/CONTRIBUTING.md) to this repository * [x] It builds for hardware native (see [Building the firmware](https://github.com/blackmagic-debug/blackmagic?tab=readme-ov-file#building-black-magic-debug-firmware)) * [x] It builds as BMDA (see [Building the BMDA](https://github.com/blackmagic-debug/blackmagic?tab=readme-ov-file#building-black-magic-debug-app)) * [ ] 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
dragonmux left a comment
Copy link

This is looking pretty decent and we can mostly work out the rationale behind each change (even if it took us a minute). We have some suggestions to improve that and a request to write out a little more of the intent in comments to aid with that, but with those taken care of we think this will be good to merge.

This is looking pretty decent and we can mostly work out the rationale behind each change (even if it took us a minute). We have some suggestions to improve that and a request to write out a little more of the intent in comments to aid with that, but with those taken care of we think this will be good to merge.

Think it's fine to name this command just swo instead of mp15_swo, or conf_swo if you still want to prefix it.

Think it's fine to name this command just `swo` instead of `mp15_swo`, or `conf_swo` if you still want to prefix it.
dragonmux marked this conversation as resolved

Given how the setup functions are named (and we agree with this naming, though aren't sure where the d comes from in apbd here?), we suggest being absolutely consistent below - apb_ap, axi_ap, so the code's a little easier to follow. Either that or using the AP number instead of bus type for the naming - ap0, ap1? That one's up to you which you think would be more beneficial here.

Given how the setup functions are named (and we agree with this naming, though aren't sure where the `d` comes from in `apbd` here?), we suggest being absolutely consistent below - `apb_ap`, `axi_ap`, so the code's a little easier to follow. Either that or using the AP number instead of bus type for the naming - `ap0`, `ap1`? That one's up to you which you think would be more beneficial here.
dragonmux marked this conversation as resolved
@ -121,3 +173,4 @@
static bool stm32mp15_cm4_configure_dbgmcu(target_s *const target)
{
/* If we're in the probe phase */

This needs to go in cortexar.h and the extern dropped - otherwise we run a high risk of things getting out of sync in a UB way.

This needs to go in cortexar.h and the `extern` dropped - otherwise we run a high risk of things getting out of sync in a UB way.
dragonmux marked this conversation as resolved
@ -170,0 +257,4 @@
static void stm32mp15_ca7_detach(target_s *target)
{
/* Deallocate any extra AP */

Given the Cortex-A attach/detach functions introduced above, we suggest these get refactored in name to include that they're specifically for the Cortex-M core - to help reduce code soupiness and confusion.

Given the Cortex-A attach/detach functions introduced above, we suggest these get refactored in name to include that they're specifically for the Cortex-M core - to help reduce code soupiness and confusion.
dragonmux marked this conversation as resolved
@ -176,0 +272,4 @@
stm32mp15_ca7_setup_axi_ap(target);
target->mem_read = stm32mp15_ca7_mem_read;
target->mem_write = stm32mp15_ca7_mem_write;
target->detach = stm32mp15_ca7_detach;

They're all MEM-AP's, think you mean AXI AP (AP0)?

They're all MEM-AP's, think you mean `AXI AP (AP0)`?
dragonmux marked this conversation as resolved

Correction to this - now that mon swo is taken by the in-probe SWO implementation, either mp15_swo or conf_swo - think the latter is a little more clear as to what it does, but both are acceptable.

Correction to this - now that `mon swo` is taken by the in-probe SWO implementation, either `mp15_swo` or `conf_swo` - think the latter is a little more clear as to what it does, but both are acceptable.
dragonmux marked this conversation as resolved
ALTracer (Migrated from github.com) reviewed 2024年09月29日 23:01:45 +02:00
ALTracer (Migrated from github.com) commented 2024年09月29日 23:01:45 +02:00
Copy link

Renamed to conf_swo in hopes that h7/h5 get a similar command. OTOH it is redundant if C5ACCE55 is used (possibly on PE-visible alias at 0x50083000). This is for orbuculum gdbtrace.init scripts, not BMF executable code (historically, at least)

Renamed to `conf_swo` in hopes that h7/h5 get a similar command. OTOH it is redundant if C5ACCE55 is used (possibly on PE-visible alias at 0x50083000). This is for orbuculum gdbtrace.init scripts, not BMF executable code (historically, at least)
dragonmux marked this conversation as resolved
ALTracer (Migrated from github.com) reviewed 2024年09月29日 23:10:19 +02:00
@ -121,3 +173,4 @@
static bool stm32mp15_cm4_configure_dbgmcu(target_s *const target)
{
/* If we're in the probe phase */
ALTracer (Migrated from github.com) commented 2024年09月29日 23:10:19 +02:00
Copy link

Introduced a commit touching cortexar.c/h to allow for this.

Introduced a commit touching cortexar.c/h to allow for this.
dragonmux marked this conversation as resolved
ALTracer (Migrated from github.com) reviewed 2024年09月29日 23:11:38 +02:00
@ -170,0 +257,4 @@
static void stm32mp15_ca7_detach(target_s *target)
{
/* Deallocate any extra AP */
ALTracer (Migrated from github.com) commented 2024年09月29日 23:11:38 +02:00
Copy link

They're not CM4-specific, SoC SWO the peripheral is shared; but I don't see it being useful for CA7 (yet) and I wrote this PR such that it reuses target_storage for AXI-AP, so those are exclusive. Renaming.

They're not CM4-specific, SoC SWO the peripheral is shared; but I don't see it being useful for CA7 (yet) and I wrote this PR such that it reuses target_storage for AXI-AP, so those are exclusive. Renaming.
dragonmux marked this conversation as resolved
@ -170,0 +257,4 @@
static void stm32mp15_ca7_detach(target_s *target)
{
/* Deallocate any extra AP */

The statement that it's core specific comes from it calling cortexm_ functions directly. It would require extra work to make it generic to both cores (probably in the form of having the core common code in one function and having a stm32mp15_cm4_detach() and a stm32mp15_ca7_detach() that call that common routine and the core-type-specific detach routines. Thank you for doing the rename.

The statement that it's core specific comes from it calling `cortexm_` functions directly. It would require extra work to make it generic to both cores (probably in the form of having the core common code in one function and having a `stm32mp15_cm4_detach()` and a `stm32mp15_ca7_detach()` that call that common routine and the core-type-specific detach routines. Thank you for doing the rename.
dragonmux marked this conversation as resolved
@ -121,2 +172,4 @@
}
static bool stm32mp15_cm4_configure_dbgmcu(target_s *const target)
{

As with the other places this apbd naming has come up, we do not know where this d is coming from in the naming - please either name by the AP number this AP represents, or just say ap_apb - if it's supposed to mean "debug", that's already implied by it being the bus attached to the AP, but those busses aren't some special thing.. they are normal APB's and AHB's, so including the d in the nomenclature just muddies things in our opinion. Readers not familiar with things would try searching for an APBD and get no results which is counter-productive, for example.

As with the other places this `apbd` naming has come up, we do not know where this `d` is coming from in the naming - please either name by the AP number this AP represents, or just say `ap_apb` - if it's supposed to mean "debug", that's already implied by it being the bus attached to the AP, but those busses aren't some special thing.. they are normal APB's and AHB's, so including the `d` in the nomenclature just muddies things in our opinion. Readers not familiar with things would try searching for an `APBD` and get no results which is counter-productive, for example.
dragonmux marked this conversation as resolved
dragonmux force-pushed ALTracer/feature/stm32mp15-ca7-axi from 74e35f4e45 to b1581047dd
Some checks failed
ci/woodpecker/pr/build-firmware/1 Pipeline was successful
ci/woodpecker/pr/build-firmware/3 Pipeline was successful
ci/woodpecker/pr/build-firmware/4 Pipeline was successful
ci/woodpecker/pr/build-firmware/5 Pipeline was successful
ci/woodpecker/pr/build-firmware/6 Pipeline was successful
ci/woodpecker/pr/build-firmware/2 Pipeline was successful
ci/woodpecker/pr/build-firmware/7 Pipeline was successful
ci/woodpecker/pr/build-firmware/9 Pipeline was successful
ci/woodpecker/pr/build-firmware/8 Pipeline failed
ci/woodpecker/pr/build-firmware/13 Pipeline failed
ci/woodpecker/pr/build-firmware/14 Pipeline was successful
ci/woodpecker/pr/build-firmware/15 Pipeline was successful
ci/woodpecker/pr/build-firmware/17 Pipeline was successful
ci/woodpecker/pr/build-firmware/16 Pipeline was successful
ci/woodpecker/pr/build-firmware/10 Pipeline was successful
ci/woodpecker/pr/build-firmware/11 Pipeline was successful
ci/woodpecker/pr/build-firmware/12 Pipeline was successful
ci/woodpecker/pr/build-firmware/18 Pipeline was successful
ci/woodpecker/pr/build-linux/1 Pipeline was successful
ci/woodpecker/pr/build-firmware/20 Pipeline was successful
ci/woodpecker/pr/build-firmware/19 Pipeline was successful
ci/woodpecker/pr/build-linux/2 Pipeline was successful
ci/woodpecker/pr/build-windows Pipeline was successful
2026年03月25日 16:20:28 +01:00
Compare
Contributor
Copy link

RM0436 by ST calls it APB-D, the MEM-AP number 1 with access to Debug APB, APB-AP with Debug components.
Sometime later I think I've discovered SWO_LAR, which

Enables write access to some SWO registers by processor cores (debuggers do not need to unlock the component).

So carrying AP1 around just for conf_swo helper command to do a couple pokes is not exactly relevant -- it's entirely possible that CoreSight SWO register page is writable from normal AP2 AHB-AP of Cortex-M4F.

As for MEM-AP number 0 with access to AXI, I've renamed any variables to ap0. It is unclear to me whether physical addressing is useful for a VMSA processor; if only during bootloader bringup with MMU in identity mapping (U-Boot does this), or baremetal CA7.

RM0436 by ST calls it APB-D, the MEM-AP number 1 with access to Debug APB, APB-AP with Debug components. Sometime later I think I've discovered SWO_LAR, which > Enables write access to some SWO registers by processor cores (debuggers do not need to unlock the component). So carrying AP1 around just for conf_swo helper command to do a couple pokes is not exactly relevant -- it's entirely possible that CoreSight SWO register page is writable from normal AP2 AHB-AP of Cortex-M4F. As for MEM-AP number 0 with access to AXI, I've renamed any variables to ap0. It is unclear to me whether physical addressing is useful for a VMSA processor; if only during bootloader bringup with MMU in identity mapping (U-Boot does this), or baremetal CA7.
dragonmux force-pushed ALTracer/feature/stm32mp15-ca7-axi from b1581047dd
Some checks failed
ci/woodpecker/pr/build-firmware/1 Pipeline was successful
ci/woodpecker/pr/build-firmware/3 Pipeline was successful
ci/woodpecker/pr/build-firmware/4 Pipeline was successful
ci/woodpecker/pr/build-firmware/5 Pipeline was successful
ci/woodpecker/pr/build-firmware/6 Pipeline was successful
ci/woodpecker/pr/build-firmware/2 Pipeline was successful
ci/woodpecker/pr/build-firmware/7 Pipeline was successful
ci/woodpecker/pr/build-firmware/9 Pipeline was successful
ci/woodpecker/pr/build-firmware/8 Pipeline failed
ci/woodpecker/pr/build-firmware/13 Pipeline failed
ci/woodpecker/pr/build-firmware/14 Pipeline was successful
ci/woodpecker/pr/build-firmware/15 Pipeline was successful
ci/woodpecker/pr/build-firmware/17 Pipeline was successful
ci/woodpecker/pr/build-firmware/16 Pipeline was successful
ci/woodpecker/pr/build-firmware/10 Pipeline was successful
ci/woodpecker/pr/build-firmware/11 Pipeline was successful
ci/woodpecker/pr/build-firmware/12 Pipeline was successful
ci/woodpecker/pr/build-firmware/18 Pipeline was successful
ci/woodpecker/pr/build-linux/1 Pipeline was successful
ci/woodpecker/pr/build-firmware/20 Pipeline was successful
ci/woodpecker/pr/build-firmware/19 Pipeline was successful
ci/woodpecker/pr/build-linux/2 Pipeline was successful
ci/woodpecker/pr/build-windows Pipeline was successful
to 541cedf0ae
Some checks failed
ci/woodpecker/pr/build-firmware/1 Pipeline was successful
ci/woodpecker/pr/build-firmware/2 Pipeline was successful
ci/woodpecker/pr/build-firmware/3 Pipeline was successful
ci/woodpecker/pr/build-firmware/4 Pipeline was successful
ci/woodpecker/pr/build-firmware/5 Pipeline was successful
ci/woodpecker/pr/build-firmware/6 Pipeline was successful
ci/woodpecker/pr/build-firmware/7 Pipeline was successful
ci/woodpecker/pr/build-firmware/8 Pipeline failed
ci/woodpecker/pr/build-firmware/9 Pipeline was successful
ci/woodpecker/pr/build-firmware/10 Pipeline was successful
ci/woodpecker/pr/build-firmware/11 Pipeline was successful
ci/woodpecker/pr/build-firmware/12 Pipeline was successful
ci/woodpecker/pr/build-firmware/13 Pipeline failed
ci/woodpecker/pr/build-firmware/15 Pipeline was successful
ci/woodpecker/pr/build-firmware/14 Pipeline was successful
ci/woodpecker/pr/build-linux/1 Pipeline was successful
ci/woodpecker/pr/build-firmware/18 Pipeline was successful
ci/woodpecker/pr/build-firmware/16 Pipeline was successful
ci/woodpecker/pr/build-firmware/20 Pipeline was successful
ci/woodpecker/pr/build-firmware/17 Pipeline was successful
ci/woodpecker/pr/build-firmware/19 Pipeline was successful
ci/woodpecker/pr/build-linux/2 Pipeline was successful
ci/woodpecker/pr/build-windows Pipeline was successful
2026年03月27日 23:37:10 +01:00
Compare
dragonmux requested changes 2026年03月27日 23:45:39 +01:00
Dismissed
dragonmux left a comment
Copy link

Please address the one note we spotted, and then we'll get this approved and merged. This looks great.

Please address the one note we spotted, and then we'll get this approved and merged. This looks great.
@ -121,0 +167,4 @@
ap1->base = adiv5_ap_read(ap1, ADIV5_AP_BASE_LOW);
ap1->csw = adiv5_ap_read(ap1, ADIV5_AP_CSW);
adiv5_ap_ref(ap1);

Because of the memcpy() done just above, the ref count for the AP will already be non-zero - we strongly suggest resetting the count right after the memcpy() so this has the right effect.

Because of the `memcpy()` done just above, the ref count for the AP will already be non-zero - we strongly suggest resetting the count right after the memcpy() so this has the right effect.
dragonmux marked this conversation as resolved
dragonmux force-pushed ALTracer/feature/stm32mp15-ca7-axi from 541cedf0ae
Some checks failed
ci/woodpecker/pr/build-firmware/1 Pipeline was successful
ci/woodpecker/pr/build-firmware/2 Pipeline was successful
ci/woodpecker/pr/build-firmware/3 Pipeline was successful
ci/woodpecker/pr/build-firmware/4 Pipeline was successful
ci/woodpecker/pr/build-firmware/5 Pipeline was successful
ci/woodpecker/pr/build-firmware/6 Pipeline was successful
ci/woodpecker/pr/build-firmware/7 Pipeline was successful
ci/woodpecker/pr/build-firmware/8 Pipeline failed
ci/woodpecker/pr/build-firmware/9 Pipeline was successful
ci/woodpecker/pr/build-firmware/10 Pipeline was successful
ci/woodpecker/pr/build-firmware/11 Pipeline was successful
ci/woodpecker/pr/build-firmware/12 Pipeline was successful
ci/woodpecker/pr/build-firmware/13 Pipeline failed
ci/woodpecker/pr/build-firmware/15 Pipeline was successful
ci/woodpecker/pr/build-firmware/14 Pipeline was successful
ci/woodpecker/pr/build-linux/1 Pipeline was successful
ci/woodpecker/pr/build-firmware/18 Pipeline was successful
ci/woodpecker/pr/build-firmware/16 Pipeline was successful
ci/woodpecker/pr/build-firmware/20 Pipeline was successful
ci/woodpecker/pr/build-firmware/17 Pipeline was successful
ci/woodpecker/pr/build-firmware/19 Pipeline was successful
ci/woodpecker/pr/build-linux/2 Pipeline was successful
ci/woodpecker/pr/build-windows Pipeline was successful
to b92174082b
Some checks failed
ci/woodpecker/pr/build-linux/2 Pipeline was successful
ci/woodpecker/pr/build-firmware/16 Pipeline was successful
ci/woodpecker/pr/build-firmware/19 Pipeline was successful
ci/woodpecker/pr/build-firmware/17 Pipeline was successful
ci/woodpecker/pr/build-firmware/20 Pipeline was successful
ci/woodpecker/pr/build-firmware/18 Pipeline failed
ci/woodpecker/pr/build-windows Pipeline was successful
ci/woodpecker/push/build-firmware/5 Pipeline was successful
ci/woodpecker/push/build-firmware/4 Pipeline was successful
ci/woodpecker/push/build-firmware/1 Pipeline was successful
ci/woodpecker/push/build-firmware/7 Pipeline was successful
ci/woodpecker/push/build-firmware/3 Pipeline was successful
ci/woodpecker/push/build-firmware/6 Pipeline was successful
ci/woodpecker/push/build-firmware/2 Pipeline was successful
ci/woodpecker/push/build-firmware/8 Pipeline was successful
ci/woodpecker/push/build-firmware/9 Pipeline was successful
ci/woodpecker/push/build-firmware/11 Pipeline was successful
ci/woodpecker/push/build-firmware/13 Pipeline was successful
ci/woodpecker/push/build-firmware/10 Pipeline was successful
ci/woodpecker/push/build-firmware/15 Pipeline was successful
ci/woodpecker/push/build-firmware/14 Pipeline was successful
ci/woodpecker/push/build-firmware/12 Pipeline was successful
ci/woodpecker/push/build-linux/1 Pipeline was successful
ci/woodpecker/push/build-firmware/17 Pipeline was successful
ci/woodpecker/push/build-firmware/18 Pipeline failed
ci/woodpecker/push/build-firmware/16 Pipeline was successful
ci/woodpecker/push/build-firmware/20 Pipeline was successful
ci/woodpecker/push/build-linux/2 Pipeline was successful
ci/woodpecker/push/build-firmware/19 Pipeline was successful
ci/woodpecker/push/build-windows Pipeline was successful
2026年03月30日 02:15:59 +02:00
Compare
dragonmux left a comment
Copy link

This LGTM, merging. Thank you for the contribution!

This LGTM, merging. Thank you for the contribution!
dragonmux deleted branch ALTracer/feature/stm32mp15-ca7-axi 2026年03月30日 02:23:44 +02: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
3 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!1757
Reference in a new issue
blackmagic-debug/blackmagic
No description provided.
Delete branch "ALTracer/feature/stm32mp15-ca7-axi"

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?