mirror of
https://github.com/Ralim/IronOS.git
synced 2025-02-26 07:53:55 +00:00
Allow SWD debugging when built with swd_enable=1
This commit is contained in:
@@ -33,9 +33,13 @@ static void MX_ADC2_Init(void);
|
|||||||
|
|
||||||
void Setup_HAL() {
|
void Setup_HAL() {
|
||||||
SystemClock_Config();
|
SystemClock_Config();
|
||||||
__HAL_AFIO_REMAP_SWJ_DISABLE()
|
|
||||||
;
|
#ifndef SWD_ENABLE
|
||||||
// __HAL_AFIO_REMAP_SWJ_NOJTAG();
|
__HAL_AFIO_REMAP_SWJ_DISABLE();
|
||||||
|
#else
|
||||||
|
__HAL_AFIO_REMAP_SWJ_NOJTAG();
|
||||||
|
#endif
|
||||||
|
|
||||||
MX_GPIO_Init();
|
MX_GPIO_Init();
|
||||||
MX_DMA_Init();
|
MX_DMA_Init();
|
||||||
MX_I2C1_Init();
|
MX_I2C1_Init();
|
||||||
@@ -244,7 +248,7 @@ static void MX_IWDG_Init(void) {
|
|||||||
hiwdg.Instance = IWDG;
|
hiwdg.Instance = IWDG;
|
||||||
hiwdg.Init.Prescaler = IWDG_PRESCALER_256;
|
hiwdg.Init.Prescaler = IWDG_PRESCALER_256;
|
||||||
hiwdg.Init.Reload = 100;
|
hiwdg.Init.Reload = 100;
|
||||||
#ifndef LOCAL_BUILD
|
#ifndef SWD_ENABLE
|
||||||
HAL_IWDG_Init(&hiwdg);
|
HAL_IWDG_Init(&hiwdg);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -425,8 +429,10 @@ static void MX_GPIO_Init(void) {
|
|||||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||||
|
|
||||||
#ifdef MODEL_TS100
|
#ifdef MODEL_TS100
|
||||||
/* Pull USB lines low to disable, pull down debug too*/
|
#ifndef SWD_ENABLE
|
||||||
GPIO_InitStruct.Pin = GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_14 | GPIO_PIN_13;
|
/* 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.Mode = GPIO_MODE_OUTPUT_PP;
|
||||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||||
@@ -434,6 +440,12 @@ static void MX_GPIO_Init(void) {
|
|||||||
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_12, GPIO_PIN_RESET);
|
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_12, GPIO_PIN_RESET);
|
||||||
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_13, GPIO_PIN_RESET);
|
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_13, GPIO_PIN_RESET);
|
||||||
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_14, 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
|
#else
|
||||||
/* TS80 */
|
/* TS80 */
|
||||||
/* Leave USB lines open circuit*/
|
/* Leave USB lines open circuit*/
|
||||||
|
|||||||
@@ -55,6 +55,10 @@ bootldr_size=0x4000
|
|||||||
# global defines ---------------------------------------------------------------
|
# 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
|
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
|
# Enable debug code generation
|
||||||
DEBUG=-g3
|
DEBUG=-g3
|
||||||
# Without debug code
|
# Without debug code
|
||||||
|
|||||||
Reference in New Issue
Block a user