Skip to content

Commit

Permalink
Merge branch 'blackmagic-debug:main' into fix/cortexar-resume-after-load
Browse files Browse the repository at this point in the history
  • Loading branch information
litui authored Aug 18, 2024
2 parents 6b3ac59 + c43c128 commit 8c72787
Show file tree
Hide file tree
Showing 39 changed files with 203 additions and 112 deletions.
22 changes: 11 additions & 11 deletions .github/workflows/build-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,31 +97,31 @@ jobs:

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

- name: Clean
run: make clean

# Build all the firmware variants that have more than 128kiB of Flash, with RTT enabled
- name: Build firmware with RTT
run: |
make PROBE_HOST=96b_carbon ENABLE_RTT=1
make PROBE_HOST=96b_carbon ENABLE_RTT=1 -j$(nproc) -Otarget
make -C src clean
make PROBE_HOST=blackpill-f401cc ENABLE_RTT=1
make PROBE_HOST=blackpill-f401cc ENABLE_RTT=1 -j$(nproc) -Otarget
make -C src clean
make PROBE_HOST=blackpill-f401ce ENABLE_RTT=1
make PROBE_HOST=blackpill-f401ce ENABLE_RTT=1 -j$(nproc) -Otarget
make -C src clean
make PROBE_HOST=blackpill-f411ce ENABLE_RTT=1
make PROBE_HOST=blackpill-f411ce ENABLE_RTT=1 -j$(nproc) -Otarget
make -C src clean
make PROBE_HOST=f3 ENABLE_RTT=1
make PROBE_HOST=f3 ENABLE_RTT=1 -j$(nproc) -Otarget
make -C src clean
make PROBE_HOST=f4discovery ENABLE_RTT=1
make PROBE_HOST=f4discovery ENABLE_RTT=1 -j$(nproc) -Otarget
make -C src clean
make PROBE_HOST=hydrabus ENABLE_RTT=1
make PROBE_HOST=hydrabus ENABLE_RTT=1 -j$(nproc) -Otarget
make -C src clean
make PROBE_HOST=launchpad-icdi ENABLE_RTT=1
make PROBE_HOST=launchpad-icdi ENABLE_RTT=1 -j$(nproc) -Otarget
make -C src clean
make PROBE_HOST=stlinkv3 ENABLE_RTT=1
make PROBE_HOST=stlinkv3 ENABLE_RTT=1 -j$(nproc) -Otarget
- name: Clean
run: make clean
Expand All @@ -132,7 +132,7 @@ jobs:

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

build-windows-msvc:
# Name the job more appropriately so we can tell which VS version is in use
Expand Down
1 change: 1 addition & 0 deletions src/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ bool cmd_help(target_s *t, int argc, const char **argv)
for (const command_s *cmd = cmd_list; cmd->cmd; cmd++)
gdb_outf("\t%s -- %s\n", cmd->cmd, cmd->help);
#ifdef PLATFORM_HAS_CUSTOM_COMMANDS
gdb_out("Platform commands:\n");
for (const command_s *cmd = platform_cmd_list; cmd->cmd; ++cmd)
gdb_outf("\t%s -- %s\n", cmd->cmd, cmd->help);
#endif
Expand Down
2 changes: 0 additions & 2 deletions src/platforms/96b_carbon/Makefile.inc
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ VPATH += platforms/common/stm32

SRC += \
platform.c \
traceswodecode.c \
traceswo.c \
serialno.c \
timing.c \
timing_stm32.c
Expand Down
2 changes: 1 addition & 1 deletion src/platforms/96b_carbon/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ probe_host = declare_dependency(
sources: probe_96b_carbon_sources,
compile_args: probe_96b_carbon_args,
link_args: probe_96b_carbon_link_args,
dependencies: [platform_common, platform_stm32f4, fixme_platform_stm32_traceswo],
dependencies: [platform_common, platform_stm32f4],
)

probe_bootloader = declare_dependency(
Expand Down
8 changes: 0 additions & 8 deletions src/platforms/96b_carbon/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#include "timing_stm32.h"
#include "version.h"

#define PLATFORM_HAS_TRACESWO
#define PLATFORM_IDENT "(Carbon)"

/*
Expand Down Expand Up @@ -86,14 +85,12 @@
#define USB_ISR otg_fs_isr
/*
* Interrupt priorities. Low numbers are high priority.
* TIM3 is used for traceswo capture and must be highest priority.
* USBUSART can be lowest priority as it is using DMA to transfer
* data to the buffer and thus is less critical than USB.
*/
#define IRQ_PRI_USB (1U << 4U)
#define IRQ_PRI_USBUSART (2U << 4U)
#define IRQ_PRI_USBUSART_DMA (2U << 4U)
#define IRQ_PRI_TRACE (0U << 4U)

#define USBUSART USART2
#define USBUSART_CR1 USART2_CR1
Expand Down Expand Up @@ -123,11 +120,6 @@
gpio_set_af(USBUSART_RX_PORT, GPIO_AF7, USBUSART_RX_PIN); \
} while (0)

#define TRACE_TIM TIM3
#define TRACE_TIM_CLK_EN() rcc_periph_clock_enable(RCC_TIM3)
#define TRACE_IRQ NVIC_TIM3_IRQ
#define TRACE_ISR(x) tim3_isr(x)

#define DEBUG(...) \
do { \
} while (false)
Expand Down
9 changes: 8 additions & 1 deletion src/platforms/common/blackpill-f4/Makefile.inc
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,18 @@ VPATH += \
SRC += \
blackpill-f4.c \
traceswodecode.c \
traceswoasync.c \
serialno.c \
timing.c \
timing_stm32.c

ifeq ($(TRACESWO_PROTOCOL), 1)
SRC += traceswo.c
CFLAGS += -DTRACESWO_PROTOCOL=1
else
SRC += traceswoasync.c
CFLAGS += -DTRACESWO_PROTOCOL=2
endif

ifneq ($(BMD_BOOTLOADER), 1)
all: blackmagic.bin
else
Expand Down
38 changes: 24 additions & 14 deletions src/platforms/common/blackpill-f4/blackpill-f4.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@
#include "timing.h"
#include "timing_stm32.h"

#define PLATFORM_HAS_TRACESWO
#define NUM_TRACE_PACKETS 256U /* 16K buffer */
#define TRACESWO_PROTOCOL 2U /* 1 = RZ/Manchester, 2 = NRZ/async/uart */

#if ENABLE_DEBUG == 1
#define PLATFORM_HAS_DEBUG
extern bool debug_bmp;
Expand Down Expand Up @@ -285,10 +281,22 @@ extern bool debug_bmp;
#define IRQ_PRI_TRACE (0U << 4U)
#define IRQ_PRI_SWO_DMA (0U << 4U)

#define TRACE_TIM TIM3
#define TRACE_TIM_CLK_EN() rcc_periph_clock_enable(RCC_TIM3)
#define TRACE_IRQ NVIC_TIM3_IRQ
#define TRACE_ISR(x) tim3_isr(x)
#define PLATFORM_HAS_TRACESWO
#define NUM_TRACE_PACKETS 256U /* 16K buffer */
//#define TRACESWO_PROTOCOL 2U /* 1 = RZ/Manchester, 2 = NRZ/async/uart */

#if TRACESWO_PROTOCOL == 1

/* Use TIM4 Input 2 (from PB7/TDO) or Input 1 (from PB6/TDO), AF2, trigger on Rising Edge */
#define TRACE_TIM TIM4
#define TRACE_TIM_CLK_EN() rcc_periph_clock_enable(RCC_TIM4)
#define TRACE_IRQ NVIC_TIM4_IRQ
#define TRACE_ISR(x) tim4_isr(x)
#define TRACE_IC_IN PINOUT_SWITCH(TIM_IC_IN_TI2, TIM_IC_IN_TI1)
#define TRACE_TRIG_IN TIM_SMCR_TS_TI1FP1
#define TRACE_TIM_PIN_AF GPIO_AF2

#elif TRACESWO_PROTOCOL == 2

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

/* Bind to the same DMA Rx channel */
#define SWO_DMA_BUS USBUSART1_DMA_BUS
#define SWO_DMA_CLK USBUSART1_DMA_CLK
#define SWO_DMA_CHAN USBUSART1_DMA_RX_CHAN
#define SWO_DMA_IRQ USBUSART1_DMA_RX_IRQ
#define SWO_DMA_ISR(x) USBUSART1_DMA_RX_ISRx(x)
#define SWO_DMA_TRG DMA_SxCR_CHSEL_4
#define SWO_DMA_BUS USBUSART1_DMA_BUS
#define SWO_DMA_CLK USBUSART1_DMA_CLK
#define SWO_DMA_CHAN USBUSART1_DMA_RX_CHAN
#define SWO_DMA_IRQ USBUSART1_DMA_RX_IRQ
#define SWO_DMA_ISR(x) USBUSART1_DMA_RX_ISRx(x)
#define SWO_DMA_TRG DMA_SxCR_CHSEL_4

#endif /* TRACESWO_PROTOCOL */

#define SET_RUN_STATE(state) \
{ \
Expand Down
1 change: 1 addition & 0 deletions src/platforms/common/blackpill-f4/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ probe_blackpill_load_address = bmd_bootloader ? '0x08004000' : '0x08000000'
probe_blackpill_args = [
f'-DDFU_SERIAL_LENGTH=@probe_blackpill_dfu_serial_length@',
f'-DAPP_START=@probe_blackpill_load_address@',
'-DTRACESWO_PROTOCOL=2',
]

blackpill_alternative_pinout = get_option('alternative_pinout')
Expand Down
12 changes: 9 additions & 3 deletions src/platforms/common/stm32/traceswo.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ void traceswo_init(uint32_t swo_chan_bitmask)
*/

/* Use TI1 as capture input for CH1 and CH2 */
timer_ic_set_input(TRACE_TIM, TIM_IC1, TIM_IC_IN_TI1);
timer_ic_set_input(TRACE_TIM, TIM_IC2, TIM_IC_IN_TI1);
timer_ic_set_input(TRACE_TIM, TIM_IC1, TRACE_IC_IN);
timer_ic_set_input(TRACE_TIM, TIM_IC2, TRACE_IC_IN);

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

/* Trigger on Filtered Timer Input 1 (TI1FP1) */
timer_slave_set_trigger(TRACE_TIM, TIM_SMCR_TS_TI1FP1);
timer_slave_set_trigger(TRACE_TIM, TRACE_TRIG_IN);

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

timer_enable_counter(TRACE_TIM);

#if defined(STM32F4) || defined(STM32F0) || defined(STM32F3)
/* AF2: TIM3/TIM4/TIM5 */
gpio_mode_setup(TDO_PORT, GPIO_MODE_AF, GPIO_PUPD_NONE, TDO_PIN);
gpio_set_af(TDO_PORT, TRACE_TIM_PIN_AF, TDO_PIN);
#endif

traceswo_setmask(swo_chan_bitmask);
decoding = (swo_chan_bitmask != 0);
}
Expand Down
4 changes: 4 additions & 0 deletions src/platforms/ctxlink/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,14 @@
#define IRQ_PRI_USBUSART_DMA (2U << 4U)
#define IRQ_PRI_TRACE (0U << 4U)

/* Use TIM3 Input 2 (from PC7/TDO) AF2, trigger on Rising Edge */
#define TRACE_TIM TIM3
#define TRACE_TIM_CLK_EN() rcc_periph_clock_enable(RCC_TIM3)
#define TRACE_IRQ NVIC_TIM3_IRQ
#define TRACE_ISR(x) tim3_isr(x)
#define TRACE_IC_IN TIM_IC_IN_TI2
#define TRACE_TRIG_IN TIM_SMCR_TS_TI1FP1
#define TRACE_TIM_PIN_AF GPIO_AF2

#define SET_RUN_STATE(state) \
{ \
Expand Down
3 changes: 3 additions & 0 deletions src/platforms/f072/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@
#define TRACE_TIM_CLK_EN() rcc_periph_clock_enable(RCC_TIM3)
#define TRACE_IRQ NVIC_TIM3_IRQ
#define TRACE_ISR tim3_isr
#define TRACE_IC_IN TIM_IC_IN_TI1
#define TRACE_TRIG_IN TIM_SMCR_TS_TI1FP1
#define TRACE_TIM_PIN_AF GPIO_AF1

#if ENABLE_DEBUG == 1
extern bool debug_bmp;
Expand Down
3 changes: 3 additions & 0 deletions src/platforms/f3/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@
#define TRACE_TIM_CLK_EN() rcc_periph_clock_enable(RCC_TIM3)
#define TRACE_IRQ NVIC_TIM3_IRQ
#define TRACE_ISR tim3_isr
#define TRACE_IC_IN TIM_IC_IN_TI1
#define TRACE_TRIG_IN TIM_SMCR_TS_TI1FP1
#define TRACE_TIM_PIN_AF GPIO_AF2

#if ENABLE_DEBUG == 1
extern bool debug_bmp;
Expand Down
3 changes: 3 additions & 0 deletions src/platforms/f4discovery/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@
#define TRACE_TIM_CLK_EN() rcc_periph_clock_enable(RCC_TIM3)
#define TRACE_IRQ NVIC_TIM3_IRQ
#define TRACE_ISR(x) tim3_isr(x)
#define TRACE_IC_IN TIM_IC_IN_TI1
#define TRACE_TRIG_IN TIM_SMCR_TS_TI1FP1
#define TRACE_TIM_PIN_AF GPIO_AF2

#define SET_RUN_STATE(state) \
{ \
Expand Down
4 changes: 4 additions & 0 deletions src/platforms/hydrabus/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,14 @@
/* For STM32F4 DMA trigger source must be specified */
#define USBUSART_DMA_TRG DMA_SxCR_CHSEL_4

/* Use TIM3 Input 1 (from PC6), AF2, trigger on Rising Edge. FIXME: TDO is on PC2. */
#define TRACE_TIM TIM3
#define TRACE_TIM_CLK_EN() rcc_periph_clock_enable(RCC_TIM3)
#define TRACE_IRQ NVIC_TIM3_IRQ
#define TRACE_ISR(x) tim3_isr(x)
#define TRACE_IC_IN TIM_IC_IN_TI1
#define TRACE_TRIG_IN TIM_SMCR_TS_TI1FP1
#define TRACE_TIM_PIN_AF GPIO_AF2

#define SET_RUN_STATE(state) \
{ \
Expand Down
6 changes: 6 additions & 0 deletions src/platforms/native/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "timing.h"
#include "timing_stm32.h"

#define TRACESWO_PROTOCOL 1U /* 1 = Manchester, 2 = NRZ / async */
#define PLATFORM_HAS_TRACESWO
#define PLATFORM_HAS_POWER_SWITCH

Expand Down Expand Up @@ -288,10 +289,15 @@ extern int hwversion;
#define USBUSART2_DMA_RX_IRQ NVIC_DMA1_CHANNEL6_IRQ
#define USBUSART2_DMA_RX_ISR(x) dma1_channel6_isr(x)

#if TRACESWO_PROTOCOL == 1
/* Use TIM3 Input 1 (from PA6/TDO) */
#define TRACE_TIM TIM3
#define TRACE_TIM_CLK_EN() rcc_periph_clock_enable(RCC_TIM3)
#define TRACE_IRQ NVIC_TIM3_IRQ
#define TRACE_ISR(x) tim3_isr(x)
#define TRACE_IC_IN TIM_IC_IN_TI1
#define TRACE_TRIG_IN TIM_SMCR_TS_TI1FP1
#endif

#define SET_RUN_STATE(state) running_status = (state)
#define SET_IDLE_STATE(state) gpio_set_val(LED_PORT, LED_IDLE_RUN, state)
Expand Down
6 changes: 6 additions & 0 deletions src/platforms/stlink/Makefile.inc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,13 @@ endif
ifeq ($(SWIM_NRST_AS_UART), 1)
CFLAGS += -DSWIM_NRST_AS_UART=1
else
ifeq ($(TRACESWO_PROTOCOL), 1)
SRC += traceswo.c
CFLAGS += -DTRACESWO_PROTOCOL=1
else
SRC += traceswoasync.c
CFLAGS += -DTRACESWO_PROTOCOL=2
endif
endif

ifeq ($(BLUEPILL), 1)
Expand Down
3 changes: 3 additions & 0 deletions src/platforms/stlink/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,11 @@ stlink_swim_nrst_as_uart = get_option('stlink_swim_nrst_as_uart')

if probe == 'stlink' and stlink_swim_nrst_as_uart
probe_stlink_args += ['-DSWIM_NRST_AS_UART=1']
probe_stlink_dependencies += fixme_platform_stm32_traceswo
probe_stlink_args += ['-DTRACESWO_PROTOCOL=1']
else
probe_stlink_dependencies += fixme_platform_stm32_traceswoasync
probe_stlink_args += ['-DTRACESWO_PROTOCOL=2']
endif

probe_host = declare_dependency(
Expand Down
Loading

0 comments on commit 8c72787

Please sign in to comment.