7
31
Fork
You've already forked blackmagic
23

Feature: re-enable non-halting RTT on a few targets #2037

Merged
ALTracer merged 10 commits from ALTracer/feature/mem_nohalt into main 2026年03月27日 23:29:55 +01:00
ALTracer commented 2024年12月30日 15:01:28 +01:00 (Migrated from github.com)
Copy link

Detailed description

  • This is not a new feature, this restores BMD behaviour before #1962.
  • The existing problem is BMP with RTT halts all its targets by default to check controlblock contents in SRAM. This is incompatible with any real-time firmware, we get packet loss and CRC errors.
  • The PR solves it by enabling the provisioned target flag on targets where I've tested RTT to return non-garbage data even if the processor keeps running.

Testcases are Arduino/stm32duino RTT_Stream speedtest.ino sketch and Eclipse uOS++ ilie with Segger's RTT sources from their examples zip. Unfortunately I haven't been able to find an independent opensource implementation of RTT to include in libopencm3-based firmware testcases, and I don't want to dip in Rust for this.
Confirmed to increase RTT data read speed on Nucleo-G071RB and GD32E508ZE, to stop dropping Rx SPI words on WeAct Studio AT32F403ACG.
Pending testing on STM32F103CB, GD32F103CB, GD32F303CC (all WeAct Studio BluePill-Plus boards).
BMP platform used is mostly blackpill-f411ce but stlink/swlink is also possible. BMDA is likewise affected.

Note I cannot test GD32F2 and GD32E230, where it is unknown to work. Especially so I cannot test on TM4C123 which is the one and only reported problematic Cortex-M4F core.

A good metric of detecting DUT halts without parsing SWD traffic or BMP advanced logging or running any realtime communication protocols (or wiggling GPIOs) is running a peripheral TIMer in Output PWM mode at 100% duty cycle with DBGMCU APB freeze bit set for it -- as soon as Processing Element gets halted, TIM_OCx goes low (confirmed on oscilloscope watching SWD), and goes back high on resuming, and there's no extra spurious transitions.

First commit (which touches target/cortexm.c) is obviously not intended to land on main as part of this PR, it is only provided for convenience of A/B-testing without reflashing BMPs (there's a runtime switch for monitor mem_nohalt enable)

If wildcard-enabling this behaviour on entire families not flavours is acceptable, then I can move the flag-setting code out of branches and simplify firmware further.

Your checklist for this pull request

Closing issues

## Detailed description * This is not a **new** feature, this restores BMD behaviour before #1962. * The existing problem is BMP with RTT halts all its targets by default to check controlblock contents in SRAM. This is incompatible with any real-time firmware, we get packet loss and CRC errors. * The PR solves it by enabling the provisioned target flag on targets where I've tested RTT to return non-garbage data even if the processor keeps running. Testcases are Arduino/stm32duino RTT_Stream speedtest.ino sketch and Eclipse uOS++ ilie with Segger's RTT sources from their examples zip. Unfortunately I haven't been able to find an independent opensource implementation of RTT to include in libopencm3-based firmware testcases, and I don't want to dip in Rust for this. Confirmed to increase RTT data read speed on Nucleo-G071RB and GD32E508ZE, to stop dropping Rx SPI words on WeAct Studio AT32F403ACG. Pending testing on STM32F103CB, GD32F103CB, GD32F303CC (all WeAct Studio BluePill-Plus boards). BMP platform used is mostly `blackpill-f411ce` but stlink/swlink is also possible. BMDA is likewise affected. Note I cannot test GD32F2 and GD32E230, where it is unknown to work. Especially so I cannot test on TM4C123 which is the one and only reported problematic Cortex-M4F core. A good metric of detecting DUT halts without parsing SWD traffic or BMP advanced logging or running any realtime communication protocols (or wiggling GPIOs) is running a peripheral TIMer in Output PWM mode at 100% duty cycle with DBGMCU APB freeze bit set for it -- as soon as Processing Element gets halted, TIM_OCx goes low (confirmed on oscilloscope watching SWD), and goes back high on resuming, and there's no extra spurious transitions. First commit (which touches target/cortexm.c) is obviously not intended to land on `main` as part of this PR, it is only provided for convenience of A/B-testing without reflashing BMPs (there's a runtime switch for `monitor mem_nohalt enable`) If wildcard-enabling this behaviour on entire families not flavours is acceptable, then I can move the flag-setting code out of branches and simplify firmware further. ## 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)) * [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
beefdeadbeef commented 2025年09月06日 14:16:08 +02:00 (Migrated from github.com)
Copy link

FWIW i've tested this on AT32F42x (namely at32f425f8p7) and AT32F437 found on at-start-f437 eval board.
works for me.

FWIW i've tested this on AT32F42x (namely at32f425f8p7) and AT32F437 found on at-start-f437 eval board. works for me.
markrages commented 2025年12月17日 19:04:48 +01:00 (Migrated from github.com)
Copy link

Please also add non-halting for nRF54L target.

Please also add non-halting for nRF54L target.
markrages commented 2025年12月17日 22:17:39 +01:00 (Migrated from github.com)
Copy link

Thank you

Thank you
Copper280z commented 2025年12月20日 17:16:32 +01:00 (Migrated from github.com)
Copy link

Tested non-halting access on an STM32H723 nucleo using BMDA+stlink and got good data via RTT.

Tested non-halting access on an STM32H723 nucleo using BMDA+stlink and got good data via RTT.
dragonmux force-pushed ALTracer/feature/mem_nohalt from a39ae13847 to 9ccf57cc67
Some checks failed
ci/woodpecker/pr/build-firmware/5 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/2 Pipeline was successful
ci/woodpecker/pr/build-firmware/1 Pipeline was successful
ci/woodpecker/pr/build-firmware/6 Pipeline was successful
ci/woodpecker/pr/build-firmware/8 Pipeline failed
ci/woodpecker/pr/build-firmware/13 Pipeline failed
ci/woodpecker/pr/build-firmware/11 Pipeline was successful
ci/woodpecker/pr/build-firmware/7 Pipeline was successful
ci/woodpecker/pr/build-firmware/10 Pipeline was successful
ci/woodpecker/pr/build-firmware/12 Pipeline was successful
ci/woodpecker/pr/build-firmware/9 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/15 Pipeline was successful
ci/woodpecker/pr/build-firmware/14 Pipeline was successful
ci/woodpecker/pr/build-firmware/18 Pipeline was successful
ci/woodpecker/pr/build-firmware/19 Pipeline was successful
ci/woodpecker/pr/build-firmware/20 Pipeline was successful
ci/woodpecker/pr/build-linux/1 Pipeline was successful
ci/woodpecker/pr/build-linux/2 Pipeline was successful
ci/woodpecker/pr/build-windows Pipeline was successful
2026年03月25日 16:16:29 +01:00
Compare
dragonmux requested changes 2026年03月27日 11:39:17 +01:00
Dismissed
dragonmux left a comment
Copy link

This all looks pretty good - we'll have to go through documenting on the website about all the targets this enables non-halting mem I/O for, as we need notes on what impact this has on the target, however as we included support for this for the U5 in our support PR, we'll take care of starting said table off and won't hold merging this off any longer. Please address the small number of review notes in cortexm.c and then we'll get this merged.

This all looks pretty good - we'll have to go through documenting on the website about all the targets this enables non-halting mem I/O for, as we need notes on what impact this has on the target, however as we included support for this for the U5 in our support PR, we'll take care of starting said table off and won't hold merging this off any longer. Please address the small number of review notes in cortexm.c and then we'll get this merged.
@ -53,1 +53,4 @@
static bool cortexm_vector_catch(target_s *target, int argc, const char **argv);
#ifdef ENABLE_RTT
static bool cortexm_mem_nohalt(target_s *target, int argc, const char **argv);
#include "rtt.h"

#include comes before definitins please - ideally it would go at the top with the other includes so they're grouped and all change file and compiler state together before any of the things they do are used. This way things are less confusing if something important in the compilation state changes in a header (like is the case for general.h).

`#include` comes before definitins please - ideally it would go at the top with the other includes so they're grouped and all change file and compiler state together before any of the things they do are used. This way things are less confusing if something important in the compilation state changes in a header (like is the case for general.h).
dragonmux marked this conversation as resolved
@ -55,2 +59,4 @@
const command_s cortexm_cmd_list[] = {
{"vector_catch", cortexm_vector_catch, "Catch exception vectors"},
#ifdef ENABLE_RTT
{"mem_nohalt", cortexm_mem_nohalt, "Toggle halting during memory accesses (affects RTT)"},

The paren'd expession should be dropped - while yes, it is true, that's the sort of thing that should go on the website as documentation of the firmware's monitor command set and not here. Space is still at a premium on smaller Flash probes, and so terseness is still unfortunately the name of the game here.

The paren'd expession should be dropped - while yes, it is true, that's the sort of thing that should go on the website as documentation of the firmware's monitor command set and not here. Space is still at a premium on smaller Flash probes, and so terseness is still unfortunately the name of the game here.
dragonmux marked this conversation as resolved
@ -1293,0 +1319,4 @@
target->target_options & TOPT_NON_HALTING_MEM_IO ? "yes" : "no");
return true;
}

Please remove this extra new line.

Please remove this extra new line.
dragonmux marked this conversation as resolved
Contributor
Copy link

@dragonmux wrote in #2037 (comment):

Please address the small number of review notes in cortexm.c and then we'll get this merged.

They are about first commit in cortexm.c adding a helper command to toggle whether RTT access functions halts the processor or not; I will drop this commit altogether, it was only a measure to accelerate retesting without recompiling and reflashing BMF. Configurables are against the idea of automatic Black Magic Debug, and RTT should Just Work for every Cortex-M SoC (that has been tested so far). If anyone needs it, I'll keep it as a text patch here.

From 1779ee5021e765cd4d0c59b0a780341109f4eca5 Mon Sep 17 00:00:00 2001
From: ALTracer <11005378+ALTracer@users.noreply.github.com>
Date: 2024年11月21日 13:16:56 +0300
Subject: [PATCH] cortexm: Allow toggling non-halting option via a runtime
 command
---
 src/target/cortexm.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
diff --git a/src/target/cortexm.c b/src/target/cortexm.c
index ce59bf5c..90394069 100644
--- a/src/target/cortexm.c
+++ b/src/target/cortexm.c
@@ -51,9 +51,16 @@
 #define CORTEXM_MAX_REG_COUNT (CORTEXM_GENERAL_REG_COUNT + CORTEX_FLOAT_REG_COUNT + CORTEXM_TRUSTZONE_REG_COUNT)
 
 static bool cortexm_vector_catch(target_s *target, int argc, const char **argv);
+#ifdef ENABLE_RTT
+static bool cortexm_mem_nohalt(target_s *target, int argc, const char **argv);
+#include "rtt.h"
+#endif
 
 const command_s cortexm_cmd_list[] = {
 	{"vector_catch", cortexm_vector_catch, "Catch exception vectors"},
+#ifdef ENABLE_RTT
+	{"mem_nohalt", cortexm_mem_nohalt, "Toggle halting during memory accesses (affects RTT)"},
+#endif
 	{NULL, NULL, NULL},
 };
 
@@ -1290,6 +1297,31 @@ static bool cortexm_vector_catch(target_s *target, int argc, const char **argv)
 	return true;
 }
 
+#ifdef ENABLE_RTT
+static bool cortexm_mem_nohalt(target_s *target, int argc, const char **argv)
+{
+	bool enable = false;
+	if (argc > 2) {
+		tc_printf(target, "Usage: monitor mem_nohalt <enable|disable>");
+		return false;
+	}
+	if ((argc == 2) && parse_enable_or_disable(argv[1], &enable)) {
+		if (enable)
+			target->target_options |= TOPT_NON_HALTING_MEM_IO;
+		else
+			target->target_options &= ~TOPT_NON_HALTING_MEM_IO;
+		/* Force reapplying halt settings in rtt.c */
+		rtt_found = false;
+
+		return true;
+	}
+	tc_printf(target, "Target allows non-halting memory IO: %s\n",
+		target->target_options & TOPT_NON_HALTING_MEM_IO ? "yes" : "no");
+	return true;
+}
+
+#endif
+
 static bool cortexm_hostio_request(target_s *const target)
 {
 	/* Read out the information from the target needed to complete the request */
-- 
2.34.1
@dragonmux wrote in https://codeberg.org/blackmagic-debug/blackmagic/pulls/2037#issuecomment-12231498: > Please address the small number of review notes in cortexm.c and then we'll get this merged. They are about first commit in cortexm.c adding a helper command to toggle whether RTT access functions halts the processor or not; I will drop this commit altogether, it was only a measure to accelerate retesting without recompiling and reflashing BMF. Configurables are against the idea of automatic Black Magic Debug, and RTT should Just Work for every Cortex-M SoC (that has been tested so far). If anyone needs it, I'll keep it as a text patch here. ```diff From 1779ee5021e765cd4d0c59b0a780341109f4eca5 Mon Sep 17 00:00:00 2001 From: ALTracer <11005378+ALTracer@users.noreply.github.com> Date: 2024年11月21日 13:16:56 +0300 Subject: [PATCH] cortexm: Allow toggling non-halting option via a runtime command --- src/target/cortexm.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/target/cortexm.c b/src/target/cortexm.c index ce59bf5c..90394069 100644 --- a/src/target/cortexm.c +++ b/src/target/cortexm.c @@ -51,9 +51,16 @@ #define CORTEXM_MAX_REG_COUNT (CORTEXM_GENERAL_REG_COUNT + CORTEX_FLOAT_REG_COUNT + CORTEXM_TRUSTZONE_REG_COUNT) static bool cortexm_vector_catch(target_s *target, int argc, const char **argv); +#ifdef ENABLE_RTT +static bool cortexm_mem_nohalt(target_s *target, int argc, const char **argv); +#include "rtt.h" +#endif const command_s cortexm_cmd_list[] = { {"vector_catch", cortexm_vector_catch, "Catch exception vectors"}, +#ifdef ENABLE_RTT + {"mem_nohalt", cortexm_mem_nohalt, "Toggle halting during memory accesses (affects RTT)"}, +#endif {NULL, NULL, NULL}, }; @@ -1290,6 +1297,31 @@ static bool cortexm_vector_catch(target_s *target, int argc, const char **argv) return true; } +#ifdef ENABLE_RTT +static bool cortexm_mem_nohalt(target_s *target, int argc, const char **argv) +{ + bool enable = false; + if (argc > 2) { + tc_printf(target, "Usage: monitor mem_nohalt <enable|disable>"); + return false; + } + if ((argc == 2) && parse_enable_or_disable(argv[1], &enable)) { + if (enable) + target->target_options |= TOPT_NON_HALTING_MEM_IO; + else + target->target_options &= ~TOPT_NON_HALTING_MEM_IO; + /* Force reapplying halt settings in rtt.c */ + rtt_found = false; + + return true; + } + tc_printf(target, "Target allows non-halting memory IO: %s\n", + target->target_options & TOPT_NON_HALTING_MEM_IO ? "yes" : "no"); + return true; +} + +#endif + static bool cortexm_hostio_request(target_s *const target) { /* Read out the information from the target needed to complete the request */ -- 2.34.1 ```
dragonmux force-pushed ALTracer/feature/mem_nohalt from 9ccf57cc67
Some checks failed
ci/woodpecker/pr/build-firmware/5 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/2 Pipeline was successful
ci/woodpecker/pr/build-firmware/1 Pipeline was successful
ci/woodpecker/pr/build-firmware/6 Pipeline was successful
ci/woodpecker/pr/build-firmware/8 Pipeline failed
ci/woodpecker/pr/build-firmware/13 Pipeline failed
ci/woodpecker/pr/build-firmware/11 Pipeline was successful
ci/woodpecker/pr/build-firmware/7 Pipeline was successful
ci/woodpecker/pr/build-firmware/10 Pipeline was successful
ci/woodpecker/pr/build-firmware/12 Pipeline was successful
ci/woodpecker/pr/build-firmware/9 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/15 Pipeline was successful
ci/woodpecker/pr/build-firmware/14 Pipeline was successful
ci/woodpecker/pr/build-firmware/18 Pipeline was successful
ci/woodpecker/pr/build-firmware/19 Pipeline was successful
ci/woodpecker/pr/build-firmware/20 Pipeline was successful
ci/woodpecker/pr/build-linux/1 Pipeline was successful
ci/woodpecker/pr/build-linux/2 Pipeline was successful
ci/woodpecker/pr/build-windows Pipeline was successful
to e0f72c1087
Some checks failed
ci/woodpecker/pr/build-linux/2 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/18 Pipeline was successful
ci/woodpecker/pr/build-firmware/19 Pipeline was successful
ci/woodpecker/pr/build-firmware/20 Pipeline was successful
ci/woodpecker/pr/build-windows 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/3 Pipeline was successful
ci/woodpecker/push/build-firmware/2 Pipeline was successful
ci/woodpecker/push/build-firmware/5 Pipeline was successful
ci/woodpecker/push/build-firmware/6 Pipeline was successful
ci/woodpecker/push/build-firmware/8 Pipeline was successful
ci/woodpecker/push/build-firmware/10 Pipeline was successful
ci/woodpecker/push/build-firmware/7 Pipeline was successful
ci/woodpecker/push/build-firmware/12 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 failed
ci/woodpecker/push/build-firmware/14 Pipeline was successful
ci/woodpecker/push/build-firmware/15 Pipeline was successful
ci/woodpecker/push/build-firmware/20 Pipeline was successful
ci/woodpecker/push/build-firmware/19 Pipeline was successful
ci/woodpecker/push/build-firmware/18 Pipeline was successful
ci/woodpecker/push/build-firmware/16 Pipeline was successful
ci/woodpecker/push/build-firmware/17 Pipeline was successful
ci/woodpecker/push/build-linux/1 Pipeline was successful
ci/woodpecker/push/build-linux/2 Pipeline was successful
ci/woodpecker/push/build-windows Pipeline was successful
2026年03月27日 23:17:23 +01:00
Compare

Okay, that works. We'll approve and merge this once the pipeline completes then as the rest all looked good

Okay, that works. We'll approve and merge this once the pipeline completes then as the rest all looked good
dragonmux left a comment
Copy link

LGTM, merging. Thank you for the contribution!

LGTM, merging. Thank you for the contribution!
dragonmux deleted branch ALTracer/feature/mem_nohalt 2026年03月27日 23:29:56 +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
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!2037
Reference in a new issue
blackmagic-debug/blackmagic
No description provided.
Delete branch "ALTracer/feature/mem_nohalt"

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?