s[t|w]link: Implement ENABLE_DEBUG.
This commit is contained in:
parent
ce1ef6e41b
commit
4966168802
|
@ -8,11 +8,17 @@ CFLAGS += -mcpu=cortex-m3 -mthumb \
|
|||
-I platforms/stm32
|
||||
LDFLAGS_BOOT := $(LDFLAGS) --specs=nano.specs \
|
||||
-lopencm3_stm32f1 -Wl,--defsym,_stack=0x20005000 \
|
||||
-Wl,-T,platforms/stm32/stlink.ld -nostartfiles -lc -lnosys \
|
||||
-Wl,-T,platforms/stm32/stlink.ld -nostartfiles -lc \
|
||||
-Wl,-Map=mapfile -mthumb -mcpu=cortex-m3 -Wl,-gc-sections \
|
||||
-L../libopencm3/lib
|
||||
LDFLAGS = $(LDFLAGS_BOOT) -Wl,-Ttext=0x8002000
|
||||
|
||||
ifeq ($(ENABLE_DEBUG), 1)
|
||||
LDFLAGS += --specs=rdimon.specs
|
||||
else
|
||||
LDFLAGS += --specs=nosys.specs
|
||||
endif
|
||||
|
||||
VPATH += platforms/stm32
|
||||
|
||||
SRC += cdcacm.c \
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
#include <libopencm3/stm32/rcc.h>
|
||||
#include <libopencm3/cm3/scb.h>
|
||||
#include <libopencm3/cm3/scs.h>
|
||||
#include <libopencm3/cm3/nvic.h>
|
||||
#include <libopencm3/stm32/usart.h>
|
||||
#include <libopencm3/usb/usbd.h>
|
||||
|
@ -47,6 +48,11 @@ int platform_hwversion(void)
|
|||
void platform_init(void)
|
||||
{
|
||||
rev = detect_rev();
|
||||
SCS_DEMCR |= SCS_DEMCR_VC_MON_EN;
|
||||
#ifdef ENABLE_DEBUG
|
||||
void initialise_monitor_handles(void);
|
||||
initialise_monitor_handles();
|
||||
#endif
|
||||
rcc_clock_setup_in_hse_8mhz_out_72mhz();
|
||||
if (rev == 0) {
|
||||
led_idle_run = GPIO8;
|
||||
|
@ -77,6 +83,8 @@ void platform_init(void)
|
|||
if (rev > 1) /* Reconnect USB */
|
||||
gpio_set(GPIOA, GPIO15);
|
||||
cdcacm_init();
|
||||
/* Don't enable UART if we're being debugged. */
|
||||
if (!(SCS_DEMCR & SCS_DEMCR_TRCENA))
|
||||
usbuart_init();
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,11 @@
|
|||
#include <libopencm3/stm32/f1/memorymap.h>
|
||||
#include <libopencm3/usb/usbd.h>
|
||||
|
||||
#ifdef ENABLE_DEBUG
|
||||
# define PLATFORM_HAS_DEBUG
|
||||
# define USBUART_DEBUG
|
||||
#endif
|
||||
|
||||
#define BOARD_IDENT "Black Magic Probe (STLINK), (Firmware " FIRMWARE_VERSION ")"
|
||||
#define BOARD_IDENT_DFU "Black Magic (Upgrade) for STLink/Discovery, (Firmware " FIRMWARE_VERSION ")"
|
||||
#define BOARD_IDENT_UPD "Black Magic (DFU Upgrade) for STLink/Discovery, (Firmware " FIRMWARE_VERSION ")"
|
||||
|
@ -102,7 +107,13 @@
|
|||
#define USBUSART_TIM_IRQ NVIC_TIM4_IRQ
|
||||
#define USBUSART_TIM_ISR tim4_isr
|
||||
|
||||
#ifdef ENABLE_DEBUG
|
||||
extern bool debug_bmp;
|
||||
int usbuart_debug_write(const char *buf, size_t len);
|
||||
# define DEBUG printf
|
||||
#else
|
||||
# define DEBUG(...)
|
||||
#endif
|
||||
|
||||
extern uint16_t led_idle_run;
|
||||
#define LED_IDLE_RUN led_idle_run
|
||||
|
|
|
@ -8,11 +8,17 @@ CFLAGS += -mcpu=cortex-m3 -mthumb \
|
|||
-I platforms/stm32
|
||||
LDFLAGS_BOOT := $(LDFLAGS) --specs=nano.specs \
|
||||
-lopencm3_stm32f1 -Wl,--defsym,_stack=0x20005000 \
|
||||
-Wl,-T,platforms/stm32/stlink.ld -nostartfiles -lc -lnosys \
|
||||
-Wl,-T,platforms/stm32/stlink.ld -nostartfiles -lc\
|
||||
-Wl,-Map=mapfile -mthumb -mcpu=cortex-m3 -Wl,-gc-sections \
|
||||
-L../libopencm3/lib
|
||||
LDFLAGS = $(LDFLAGS_BOOT) -Wl,-Ttext=0x8002000
|
||||
|
||||
ifeq ($(ENABLE_DEBUG), 1)
|
||||
LDFLAGS += --specs=rdimon.specs
|
||||
else
|
||||
LDFLAGS += --specs=nosys.specs
|
||||
endif
|
||||
|
||||
VPATH += platforms/stm32
|
||||
|
||||
SRC += cdcacm.c \
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
#include <libopencm3/stm32/f1/rcc.h>
|
||||
#include <libopencm3/cm3/scb.h>
|
||||
#include <libopencm3/cm3/scs.h>
|
||||
#include <libopencm3/cm3/nvic.h>
|
||||
#include <libopencm3/stm32/usart.h>
|
||||
#include <libopencm3/usb/usbd.h>
|
||||
|
@ -36,6 +37,11 @@
|
|||
void platform_init(void)
|
||||
{
|
||||
uint32_t data;
|
||||
SCS_DEMCR |= SCS_DEMCR_VC_MON_EN;
|
||||
#ifdef ENABLE_DEBUG
|
||||
void initialise_monitor_handles(void);
|
||||
initialise_monitor_handles();
|
||||
#endif
|
||||
rcc_clock_setup_in_hse_8mhz_out_72mhz();
|
||||
|
||||
/* Enable peripherals */
|
||||
|
@ -83,6 +89,9 @@ void platform_init(void)
|
|||
|
||||
platform_timing_init();
|
||||
cdcacm_init();
|
||||
/* Don't enable UART if we're being debugged. */
|
||||
if (!(SCS_DEMCR & SCS_DEMCR_TRCENA))
|
||||
usbuart_init();
|
||||
usbuart_init();
|
||||
}
|
||||
|
||||
|
|
|
@ -106,7 +106,15 @@
|
|||
#define TRACE_IC_IN TIM_IC_IN_TI2
|
||||
#define TRACE_TRIG_IN TIM_SMCR_TS_IT1FP2
|
||||
|
||||
#ifdef ENABLE_DEBUG
|
||||
# define PLATFORM_HAS_DEBUG
|
||||
# define USBUART_DEBUG
|
||||
extern bool debug_bmp;
|
||||
int usbuart_debug_write(const char *buf, size_t len);
|
||||
# define DEBUG printf
|
||||
#else
|
||||
# define DEBUG(...)
|
||||
#endif
|
||||
|
||||
#define SET_RUN_STATE(state) {running_status = (state);}
|
||||
#define SET_IDLE_STATE(state) {gpio_set_val(LED_PORT, LED_IDLE_RUN, state);}
|
||||
|
|
Loading…
Reference in New Issue