Skip to content

Commit 8c72787

Browse files
authored
Merge branch 'blackmagic-debug:main' into fix/cortexar-resume-after-load
2 parents 6b3ac59 + c43c128 commit 8c72787

39 files changed

+203
-112
lines changed

.github/workflows/build-pr.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -97,31 +97,31 @@ jobs:
9797

9898
# Build the firmware for all platform variants and BMDA in BMP-only mode
9999
- name: Build all platform variants firmware and BMP only BMDA
100-
run: make all_platforms HOSTED_BMP_ONLY=1
100+
run: make all_platforms HOSTED_BMP_ONLY=1 -j$(nproc) -Otarget
101101

102102
- name: Clean
103103
run: make clean
104104

105105
# Build all the firmware variants that have more than 128kiB of Flash, with RTT enabled
106106
- name: Build firmware with RTT
107107
run: |
108-
make PROBE_HOST=96b_carbon ENABLE_RTT=1
108+
make PROBE_HOST=96b_carbon ENABLE_RTT=1 -j$(nproc) -Otarget
109109
make -C src clean
110-
make PROBE_HOST=blackpill-f401cc ENABLE_RTT=1
110+
make PROBE_HOST=blackpill-f401cc ENABLE_RTT=1 -j$(nproc) -Otarget
111111
make -C src clean
112-
make PROBE_HOST=blackpill-f401ce ENABLE_RTT=1
112+
make PROBE_HOST=blackpill-f401ce ENABLE_RTT=1 -j$(nproc) -Otarget
113113
make -C src clean
114-
make PROBE_HOST=blackpill-f411ce ENABLE_RTT=1
114+
make PROBE_HOST=blackpill-f411ce ENABLE_RTT=1 -j$(nproc) -Otarget
115115
make -C src clean
116-
make PROBE_HOST=f3 ENABLE_RTT=1
116+
make PROBE_HOST=f3 ENABLE_RTT=1 -j$(nproc) -Otarget
117117
make -C src clean
118-
make PROBE_HOST=f4discovery ENABLE_RTT=1
118+
make PROBE_HOST=f4discovery ENABLE_RTT=1 -j$(nproc) -Otarget
119119
make -C src clean
120-
make PROBE_HOST=hydrabus ENABLE_RTT=1
120+
make PROBE_HOST=hydrabus ENABLE_RTT=1 -j$(nproc) -Otarget
121121
make -C src clean
122-
make PROBE_HOST=launchpad-icdi ENABLE_RTT=1
122+
make PROBE_HOST=launchpad-icdi ENABLE_RTT=1 -j$(nproc) -Otarget
123123
make -C src clean
124-
make PROBE_HOST=stlinkv3 ENABLE_RTT=1
124+
make PROBE_HOST=stlinkv3 ENABLE_RTT=1 -j$(nproc) -Otarget
125125
126126
- name: Clean
127127
run: make clean
@@ -132,7 +132,7 @@ jobs:
132132

133133
# And build that full binary
134134
- name: Build full BMDA binary
135-
run: make PROBE_HOST=hosted HOSTED_BMP_ONLY=0
135+
run: make PROBE_HOST=hosted HOSTED_BMP_ONLY=0 -j$(nproc) -Otarget
136136

137137
build-windows-msvc:
138138
# Name the job more appropriately so we can tell which VS version is in use

src/command.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ bool cmd_help(target_s *t, int argc, const char **argv)
210210
for (const command_s *cmd = cmd_list; cmd->cmd; cmd++)
211211
gdb_outf("\t%s -- %s\n", cmd->cmd, cmd->help);
212212
#ifdef PLATFORM_HAS_CUSTOM_COMMANDS
213+
gdb_out("Platform commands:\n");
213214
for (const command_s *cmd = platform_cmd_list; cmd->cmd; ++cmd)
214215
gdb_outf("\t%s -- %s\n", cmd->cmd, cmd->help);
215216
#endif

src/platforms/96b_carbon/Makefile.inc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ VPATH += platforms/common/stm32
1717

1818
SRC += \
1919
platform.c \
20-
traceswodecode.c \
21-
traceswo.c \
2220
serialno.c \
2321
timing.c \
2422
timing_stm32.c

src/platforms/96b_carbon/meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ probe_host = declare_dependency(
4949
sources: probe_96b_carbon_sources,
5050
compile_args: probe_96b_carbon_args,
5151
link_args: probe_96b_carbon_link_args,
52-
dependencies: [platform_common, platform_stm32f4, fixme_platform_stm32_traceswo],
52+
dependencies: [platform_common, platform_stm32f4],
5353
)
5454

5555
probe_bootloader = declare_dependency(

src/platforms/96b_carbon/platform.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
#include "timing_stm32.h"
2929
#include "version.h"
3030

31-
#define PLATFORM_HAS_TRACESWO
3231
#define PLATFORM_IDENT "(Carbon)"
3332

3433
/*
@@ -86,14 +85,12 @@
8685
#define USB_ISR otg_fs_isr
8786
/*
8887
* Interrupt priorities. Low numbers are high priority.
89-
* TIM3 is used for traceswo capture and must be highest priority.
9088
* USBUSART can be lowest priority as it is using DMA to transfer
9189
* data to the buffer and thus is less critical than USB.
9290
*/
9391
#define IRQ_PRI_USB (1U << 4U)
9492
#define IRQ_PRI_USBUSART (2U << 4U)
9593
#define IRQ_PRI_USBUSART_DMA (2U << 4U)
96-
#define IRQ_PRI_TRACE (0U << 4U)
9794

9895
#define USBUSART USART2
9996
#define USBUSART_CR1 USART2_CR1
@@ -123,11 +120,6 @@
123120
gpio_set_af(USBUSART_RX_PORT, GPIO_AF7, USBUSART_RX_PIN); \
124121
} while (0)
125122

126-
#define TRACE_TIM TIM3
127-
#define TRACE_TIM_CLK_EN() rcc_periph_clock_enable(RCC_TIM3)
128-
#define TRACE_IRQ NVIC_TIM3_IRQ
129-
#define TRACE_ISR(x) tim3_isr(x)
130-
131123
#define DEBUG(...) \
132124
do { \
133125
} while (false)

src/platforms/common/blackpill-f4/Makefile.inc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,18 @@ VPATH += \
5858
SRC += \
5959
blackpill-f4.c \
6060
traceswodecode.c \
61-
traceswoasync.c \
6261
serialno.c \
6362
timing.c \
6463
timing_stm32.c
6564

65+
ifeq ($(TRACESWO_PROTOCOL), 1)
66+
SRC += traceswo.c
67+
CFLAGS += -DTRACESWO_PROTOCOL=1
68+
else
69+
SRC += traceswoasync.c
70+
CFLAGS += -DTRACESWO_PROTOCOL=2
71+
endif
72+
6673
ifneq ($(BMD_BOOTLOADER), 1)
6774
all: blackmagic.bin
6875
else

src/platforms/common/blackpill-f4/blackpill-f4.h

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@
3232
#include "timing.h"
3333
#include "timing_stm32.h"
3434

35-
#define PLATFORM_HAS_TRACESWO
36-
#define NUM_TRACE_PACKETS 256U /* 16K buffer */
37-
#define TRACESWO_PROTOCOL 2U /* 1 = RZ/Manchester, 2 = NRZ/async/uart */
38-
3935
#if ENABLE_DEBUG == 1
4036
#define PLATFORM_HAS_DEBUG
4137
extern bool debug_bmp;
@@ -285,10 +281,22 @@ extern bool debug_bmp;
285281
#define IRQ_PRI_TRACE (0U << 4U)
286282
#define IRQ_PRI_SWO_DMA (0U << 4U)
287283

288-
#define TRACE_TIM TIM3
289-
#define TRACE_TIM_CLK_EN() rcc_periph_clock_enable(RCC_TIM3)
290-
#define TRACE_IRQ NVIC_TIM3_IRQ
291-
#define TRACE_ISR(x) tim3_isr(x)
284+
#define PLATFORM_HAS_TRACESWO
285+
#define NUM_TRACE_PACKETS 256U /* 16K buffer */
286+
//#define TRACESWO_PROTOCOL 2U /* 1 = RZ/Manchester, 2 = NRZ/async/uart */
287+
288+
#if TRACESWO_PROTOCOL == 1
289+
290+
/* Use TIM4 Input 2 (from PB7/TDO) or Input 1 (from PB6/TDO), AF2, trigger on Rising Edge */
291+
#define TRACE_TIM TIM4
292+
#define TRACE_TIM_CLK_EN() rcc_periph_clock_enable(RCC_TIM4)
293+
#define TRACE_IRQ NVIC_TIM4_IRQ
294+
#define TRACE_ISR(x) tim4_isr(x)
295+
#define TRACE_IC_IN PINOUT_SWITCH(TIM_IC_IN_TI2, TIM_IC_IN_TI1)
296+
#define TRACE_TRIG_IN TIM_SMCR_TS_TI1FP1
297+
#define TRACE_TIM_PIN_AF GPIO_AF2
298+
299+
#elif TRACESWO_PROTOCOL == 2
292300

293301
/* On F411 use USART1_RX mapped on PB7 for async capture */
294302
#define SWO_UART USBUSART1
@@ -299,12 +307,14 @@ extern bool debug_bmp;
299307
#define SWO_UART_PIN_AF GPIO_AF7
300308

301309
/* Bind to the same DMA Rx channel */
302-
#define SWO_DMA_BUS USBUSART1_DMA_BUS
303-
#define SWO_DMA_CLK USBUSART1_DMA_CLK
304-
#define SWO_DMA_CHAN USBUSART1_DMA_RX_CHAN
305-
#define SWO_DMA_IRQ USBUSART1_DMA_RX_IRQ
306-
#define SWO_DMA_ISR(x) USBUSART1_DMA_RX_ISRx(x)
307-
#define SWO_DMA_TRG DMA_SxCR_CHSEL_4
310+
#define SWO_DMA_BUS USBUSART1_DMA_BUS
311+
#define SWO_DMA_CLK USBUSART1_DMA_CLK
312+
#define SWO_DMA_CHAN USBUSART1_DMA_RX_CHAN
313+
#define SWO_DMA_IRQ USBUSART1_DMA_RX_IRQ
314+
#define SWO_DMA_ISR(x) USBUSART1_DMA_RX_ISRx(x)
315+
#define SWO_DMA_TRG DMA_SxCR_CHSEL_4
316+
317+
#endif /* TRACESWO_PROTOCOL */
308318

309319
#define SET_RUN_STATE(state) \
310320
{ \

src/platforms/common/blackpill-f4/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ probe_blackpill_load_address = bmd_bootloader ? '0x08004000' : '0x08000000'
5353
probe_blackpill_args = [
5454
f'-DDFU_SERIAL_LENGTH=@probe_blackpill_dfu_serial_length@',
5555
f'-DAPP_START=@probe_blackpill_load_address@',
56+
'-DTRACESWO_PROTOCOL=2',
5657
]
5758

5859
blackpill_alternative_pinout = get_option('alternative_pinout')

src/platforms/common/stm32/traceswo.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,15 @@ void traceswo_init(uint32_t swo_chan_bitmask)
5757
*/
5858

5959
/* Use TI1 as capture input for CH1 and CH2 */
60-
timer_ic_set_input(TRACE_TIM, TIM_IC1, TIM_IC_IN_TI1);
61-
timer_ic_set_input(TRACE_TIM, TIM_IC2, TIM_IC_IN_TI1);
60+
timer_ic_set_input(TRACE_TIM, TIM_IC1, TRACE_IC_IN);
61+
timer_ic_set_input(TRACE_TIM, TIM_IC2, TRACE_IC_IN);
6262

6363
/* Capture CH1 on rising edge, CH2 on falling edge */
6464
timer_ic_set_polarity(TRACE_TIM, TIM_IC1, TIM_IC_RISING);
6565
timer_ic_set_polarity(TRACE_TIM, TIM_IC2, TIM_IC_FALLING);
6666

6767
/* Trigger on Filtered Timer Input 1 (TI1FP1) */
68-
timer_slave_set_trigger(TRACE_TIM, TIM_SMCR_TS_TI1FP1);
68+
timer_slave_set_trigger(TRACE_TIM, TRACE_TRIG_IN);
6969

7070
/* Slave reset mode: reset counter on trigger */
7171
timer_slave_set_mode(TRACE_TIM, TIM_SMCR_SMS_RM);
@@ -81,6 +81,12 @@ void traceswo_init(uint32_t swo_chan_bitmask)
8181

8282
timer_enable_counter(TRACE_TIM);
8383

84+
#if defined(STM32F4) || defined(STM32F0) || defined(STM32F3)
85+
/* AF2: TIM3/TIM4/TIM5 */
86+
gpio_mode_setup(TDO_PORT, GPIO_MODE_AF, GPIO_PUPD_NONE, TDO_PIN);
87+
gpio_set_af(TDO_PORT, TRACE_TIM_PIN_AF, TDO_PIN);
88+
#endif
89+
8490
traceswo_setmask(swo_chan_bitmask);
8591
decoding = (swo_chan_bitmask != 0);
8692
}

src/platforms/ctxlink/platform.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,14 @@
173173
#define IRQ_PRI_USBUSART_DMA (2U << 4U)
174174
#define IRQ_PRI_TRACE (0U << 4U)
175175

176+
/* Use TIM3 Input 2 (from PC7/TDO) AF2, trigger on Rising Edge */
176177
#define TRACE_TIM TIM3
177178
#define TRACE_TIM_CLK_EN() rcc_periph_clock_enable(RCC_TIM3)
178179
#define TRACE_IRQ NVIC_TIM3_IRQ
179180
#define TRACE_ISR(x) tim3_isr(x)
181+
#define TRACE_IC_IN TIM_IC_IN_TI2
182+
#define TRACE_TRIG_IN TIM_SMCR_TS_TI1FP1
183+
#define TRACE_TIM_PIN_AF GPIO_AF2
180184

181185
#define SET_RUN_STATE(state) \
182186
{ \

0 commit comments

Comments
 (0)