cancel
Showing results for 
Search instead for 
Did you mean: 

disabled swd debuging

nelegalus
Associate
Posted on August 04, 2011 at 00:30

Hi,

i used to program my stm32 discovery board via usb cable using SWD. 

I used some example code and i think i disabled SWD debugging accidently. 

Now i cant enable it back, the Keil software i use says that no target is connected and flash download failed. Can anyone help me to enable SWD back ? Is there any ways to reset stm32. Here's the example code i used :

main.c

&sharpinclude ''stm32f10x_lib.h''

/* function prototypes */

void RCC_Configuration(void);

void GPIO_Configuration(void);

void Delay(vu32 nCount);

/* entry point */

int main(void)

{

  /* configure clock sources */

  RCC_Configuration();

  /* configure I/O ports */

  GPIO_Configuration();

  /* blinking loop */

  while (1) {

    /* change the PC7 state */

    GPIO_WriteBit(GPIOC, GPIO_Pin_8, (BitAction)(1 - GPIO_ReadOutputDataBit(GPIOC, GPIO_Pin_8)));

    /* wait */

    Delay(0x5FFFF);

    Delay(0x5FFFF);

    Delay(0x5FFFF);

    Delay(0x5FFFF);

    Delay(0x5FFFF);

    Delay(0x5FFFF);

  }

}

/* set up clock sources */

void RCC_Configuration(void)

{

  /* reset */

  RCC_DeInit();

  /* activate HSI (Internal High Speed oscillator) */

  RCC_HSICmd(ENABLE);

  while (RCC_GetFlagStatus(RCC_FLAG_HSIRDY) == RESET);

  /* configure prescalers */  

  RCC_HCLKConfig(RCC_SYSCLK_Div1);// HCLK = 64 MHz, AHB

  RCC_PCLK1Config(RCC_HCLK_Div2); // APB1 = 32 MHz

  RCC_PCLK2Config(RCC_HCLK_Div1); // APB2 = 64 MHz

  /* set up FLASH */

  FLASH_SetLatency(FLASH_Latency_2);

  FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);

  /* set up PLL */

  RCC_PLLConfig(RCC_PLLSource_HSI_Div2, RCC_PLLMul_16); // 64 MHz

  RCC_PLLCmd(ENABLE);

  while (RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET);

  /* set up SYSCLK */

  RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK); //SYSCLK = PLLCLK => 64 MHz

  while (RCC_GetSYSCLKSource() != 0x08);

  /* set up peripheral clock */

  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC | RCC_APB2Periph_AFIO, ENABLE); 

}        

/* configure I/O ports */

void GPIO_Configuration(void)

{

  /* pin configuration parameters */

  GPIO_InitTypeDef GPIO_InitStructure;

  /* disable SWJ debug port - comment if you are using JTAG */

 GPIO_PinRemapConfig(GPIO_Remap_SWJ_Disable, ENABLE);

  

  /* configure PC7 as output push-pull  */

  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8;

  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;

  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;

  GPIO_Init(GPIOC, &GPIO_InitStructure);

}

/* wait */

void Delay(vu32 nCount)

{

  while (nCount--);

}

#swd-disable #bootloader-rom
7 REPLIES 7
donald2
Associate II
Posted on August 04, 2011 at 07:28

If you change the boot jumpers you can boot from the ROM bootloader.  From there you can overwrite the flash using the STLink/SWD interface.

nelegalus
Associate
Posted on August 04, 2011 at 20:56

Thank you Donald Becker ! Your advice to boot from ROM bootloader helped. I didnt even had to do anything with jumpers. I put 240R resistor between 5V and Boot pins on my discovery board and pushed RST button. Then i erased flash using ST visual Programmer from ST Toolset. I removed resistor then and Keil recognized my board as it did before

kohchengsing
Associate II
Posted on October 12, 2011 at 04:57

Thank you Donald !

I recovered my STM32L-Discovery using your suggestion. 

kohchengsing
Associate II
Posted on October 12, 2011 at 04:58

Thank you for the 240R resistor suggestion.

ivitro
Associate II
Posted on October 14, 2011 at 12:31

how i change the boot pin? in CN3 connect 2-3 and 1-4 that this?

and next what i need to do?

donald2
Associate II
Posted on October 14, 2011 at 22:16

The CN3 jumpers control if the embedded STLink (the F103 chip section) is connected to the F100 chip.  They are only moved if you want to use the STLink to program an external board.

The Boot0 and Boot1 settings are controlled by ''solder bridge'' jumpers on the board, SB2 and SB16.  But it's easiest to just connect to the header pins rather than do anything with the solder bridges.

ivitro
Associate II
Posted on October 15, 2011 at 04:44

I have afraid to do this

1-I just plug a resistor between +5 and boot pin, like rata does

2- push reset bottom

3-Keil recognizer st link and at this time I will able to debug new program in F100

Big thanks for all