diff options
author | Paul Fertser <[email protected]> | 2020-06-15 15:22:52 +0300 |
---|---|---|
committer | Paul Fertser <[email protected]> | 2020-08-26 11:54:29 +0300 |
commit | c1dd88ba532bdc87d73eb82cd926a5cfc7848787 (patch) | |
tree | cc45a6d54fe31f9d65152a9a4036ab231b3b6625 | |
parent | 780f1f35ca47f2ba6b92e2fdd078ef0b81d550d9 (diff) | |
download | IronOS-c1dd88ba532bdc87d73eb82cd926a5cfc7848787.tar.gz IronOS-c1dd88ba532bdc87d73eb82cd926a5cfc7848787.zip |
Allow SWD debugging when built with swd_enable=1
-rw-r--r-- | workspace/TS100/Core/BSP/Miniware/Setup.c | 24 | ||||
-rw-r--r-- | workspace/TS100/Makefile | 4 |
2 files changed, 22 insertions, 6 deletions
diff --git a/workspace/TS100/Core/BSP/Miniware/Setup.c b/workspace/TS100/Core/BSP/Miniware/Setup.c index 2d7f2c15..9f50feec 100644 --- a/workspace/TS100/Core/BSP/Miniware/Setup.c +++ b/workspace/TS100/Core/BSP/Miniware/Setup.c @@ -33,9 +33,13 @@ static void MX_ADC2_Init(void); void Setup_HAL() { SystemClock_Config(); - __HAL_AFIO_REMAP_SWJ_DISABLE() - ; -// __HAL_AFIO_REMAP_SWJ_NOJTAG(); + +#ifndef SWD_ENABLE + __HAL_AFIO_REMAP_SWJ_DISABLE(); +#else + __HAL_AFIO_REMAP_SWJ_NOJTAG(); +#endif + MX_GPIO_Init(); MX_DMA_Init(); MX_I2C1_Init(); @@ -244,7 +248,7 @@ static void MX_IWDG_Init(void) { hiwdg.Instance = IWDG; hiwdg.Init.Prescaler = IWDG_PRESCALER_256; hiwdg.Init.Reload = 100; -#ifndef LOCAL_BUILD +#ifndef SWD_ENABLE HAL_IWDG_Init(&hiwdg); #endif } @@ -425,8 +429,10 @@ static void MX_GPIO_Init(void) { HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); #ifdef MODEL_TS100 - /* Pull USB lines low to disable, pull down debug too*/ - GPIO_InitStruct.Pin = GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_14 | GPIO_PIN_13; +#ifndef SWD_ENABLE + /* Pull USB and SWD lines low to prevent enumeration attempts and EMI affecting + * the debug core */ + GPIO_InitStruct.Pin = GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); @@ -435,6 +441,12 @@ static void MX_GPIO_Init(void) { HAL_GPIO_WritePin(GPIOA, GPIO_PIN_13, GPIO_PIN_RESET); HAL_GPIO_WritePin(GPIOA, GPIO_PIN_14, GPIO_PIN_RESET); #else + /* Make all lines affecting SWD floating to allow debugging */ + GPIO_InitStruct.Pin = GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_14 | GPIO_PIN_13; + GPIO_InitStruct.Mode = GPIO_MODE_INPUT; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); +#endif +#else /* TS80 */ /* Leave USB lines open circuit*/ diff --git a/workspace/TS100/Makefile b/workspace/TS100/Makefile index 222aea12..1d4af101 100644 --- a/workspace/TS100/Makefile +++ b/workspace/TS100/Makefile @@ -55,6 +55,10 @@ bootldr_size=0x4000 # global defines ---------------------------------------------------------------
GLOBAL_DEFINES += -D STM32F103T8Ux -D STM32F1 -D STM32 -D USE_HAL_DRIVER -D STM32F103xB -D USE_RTOS_SYSTICK -D LANG_$(lang) -D LANG -D MODEL_$(model) -DVECT_TAB_OFFSET=$(bootldr_size)U
+ifdef swd_enable
+ GLOBAL_DEFINES += -DSWD_ENABLE
+endif
+
# Enable debug code generation
DEBUG=-g3
# Without debug code
|