0
\$\begingroup\$

I'm a beginner and I'm using STM32F10x family to learn about electronics.I was using STM32F103 blue pill in the past few months and I can debug it and upload code to it while both boot0 and boot1 are equal to 0.
When I switched to STM32F105 which has only boot0 and exposed since I couldn't find boot1 in the pinout in the datasheet.I have to hook boot0 into vcc in order to flash the elf file.now this also happens on the blue pill I can't flash it wihout turning boot0 into 1.

the problem is I can't debug it while boot0 is equal to 1 i'm getting
Target is not responding, retrying...
Target is not responding, retrying...
Error! Failed to read target status
Debugger connection lost.
Shutting down...
I think its because boot0 is equal to 1.
and when I turn back boot0 into zero the debugger can't flash the file and can't debug.

I'm trying to debug it since I have a problem I done a simple code to toggle led after 1 second but the code only execute for 16 seconds and stop executing. and I want to debug it to see why. on the STM32F103 the this problem don't happen

\$\endgroup\$
6
  • \$\begingroup\$ With what are you debugging? If you have a debugger, why use BOOT0 pin, if you can upload new firmware with the debugger? \$\endgroup\$ – Justme Jul 22 '20 at 17:30
  • \$\begingroup\$ i'm using STM32cubeIDE with local GDB server that connect tru STLink.the problem is when I click the debug button while boot0 is equal to 1 is the code compiles fine and the IDE write the resulting elf file to the microcontroller memory and then give that error that the target is not responding \$\endgroup\$ – Jwdsoft Jul 22 '20 at 17:36
  • \$\begingroup\$ Well set BOOT0 to 0 then. If you are using the debugger, why do you have BOOT0 set to 1? \$\endgroup\$ – Justme Jul 22 '20 at 17:44
  • \$\begingroup\$ Because the IDE can't program it nor debug it while BOOT0 is 0 when it is 1 It can program but can't debug it \$\endgroup\$ – Jwdsoft Jul 22 '20 at 22:43
  • \$\begingroup\$ That should not happen. Post your code. I have used CubeIDE and ST-Link with multiple different STM32 MCUs and not single one of them has behaved that way. BOOT0 has been 0 always except when I need to use the bootloader to update via UART or DFU. Post schematics too. \$\endgroup\$ – Justme Jul 22 '20 at 22:49
1
\$\begingroup\$

Your code won't run while the BOOT0 pin is high.

But if your code re-purposes or disables the SWD, or is simply bad in various ways, then you can't reprogram it.

The solution is to:

  1. set BOOT0 high
  2. reset
  3. use the ST/LINK to perform a mass erase
  4. set BOOT0 low
  5. reset
  6. load good code

There are ways to do this with having the ST/LINK manipulate the hardware reset rather than changing the boot pin, but they can be tricky, software configuration needs to be just right, and fake ST/LINK adapters generally aren't able to actually drive their reset output

\$\endgroup\$
3
  • \$\begingroup\$ What do you mean with good code ? I'm using just the Boilerplate that the IDE gave with those two lines GPIO_Toggle... and HAL_Delay to make a simple blink program and it can't debug it.is there a way to attach the debugger without reflashing the micro \$\endgroup\$ – Jwdsoft Jul 22 '20 at 22:45
  • \$\begingroup\$ You only have to reflash the MCU to attach the debugger if the code presently in the MCU is invalid in some way and disables the debug interface. Perhaps you need to figure out why you are building invalid code. \$\endgroup\$ – Chris Stratton Jul 22 '20 at 22:55
  • \$\begingroup\$ depending on the part you can hang the clock system or you can mess up the gpio, in those and perhaps other cases swd alone wont program the part you still have to boot into the bootloader to reprogram the application flash. Or you have to design in your own equivalent into the code and have your own strap pin independent of boot0 (in well debugged code that wont break nor change that you possibly needed boot0 to debug). \$\endgroup\$ – old_timer Oct 28 '20 at 5:05
0
\$\begingroup\$

I have solved the problem.the problem was that I activated SWDIO and SWCLK from Micro pinout.
Now when I chose SWD under System Core -> SYS.
it works fine and i'm able to upload software and debug while BOOT0 is equal to 0.

\$\endgroup\$
3
  • \$\begingroup\$ This is exactly what I mean, you loaded coded which re-purposes the SWD as GPIO. Needless to say there's some danger in GUI configuration tools that write code without telling you what it is going to do... SWD is the default state of the pins, if you don't write any code that touches them, they stay in that role. \$\endgroup\$ – Chris Stratton Jul 22 '20 at 23:44
  • \$\begingroup\$ Yes that's the problem and since I'm a beginner i'm counting a lot on the GUI and I don't write all the initialization from scratch that's why I screwed up but its fixed now THanks \$\endgroup\$ – Jwdsoft Jul 23 '20 at 9:31
  • \$\begingroup\$ this is not a complete solution as if your application code hangs or messes with the gpio pins in the right way then you cannot recover the chip with swd, you need to use the boot pins to boot into the bootloader then either load through the bootloader or then use swd to stop the bootloader, which is debugged and ideally wont hang. Clearly documented per chip many of the st parts dont have a boot1 pin you only use boot0, of the dozens I have used they all work the same and all....work. Now the protocol can vary, and some blue pills come locked, so you need extra steps. \$\endgroup\$ – old_timer Oct 28 '20 at 5:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.