'No Target Connected & Error: Flash Download Failed- Target DLL has been cancelled

I am stuck with a weird problem with STM32F103RC and ST-Link V2. Whenever i try to flash a program to my stm there is this error.

No Target Connected & ERROR: Flash Download Failed - Target DLL has been cancelled.

Few Methods i tried to solve this problems are:

1. Disconnecting the Device. making the BOOT0 High and connecting the device and erasing the chip.

What happens in this case is Chip is erased at first. Then i could Flash the program. But again after few mins if i try to flash the same error occurs.

At first i though there was some problem with the code (as i was doing SPI) so i wrote a simple Blink LED code using HAL Library but same thing occurred. So i thought there might be some problem with the HAL library so i wrote the whole code using CMSIS core but same thing occurs.

2. Upgrading and Downgrading the ST-Link Firmware

Here after upgrading i got an ERROR: USB CONNECTION ERROR. SO i downgraded it again and came to the same place.

3. Following the steps from this YouTube video

I found this great video in YouTube from NewbieHack. Here basically what he did was to reset the device and erase the chip. I also followed the same steps but nothing happened. Here is the link of the video

https://www.youtube.com/watch?v=jEz0C2bT2M0

I Almost tried everything and couldn't understand that where the problem reside. Is it with STM32 or ST-Link or some software issue.

and sometimes i could erase the device but again after a min the same error occurs. I don't know whats going on.

In all the above cases i used "Connect under reset" option form target->settings. Although i have explored all the options but nothing seems to work and PC is running on windows 10(if it's imp)

Any Suggestions??

Thanks in Advance.



Solution 1:[1]

if you using STM32CUBE, in SYS select serial wire debug.

Solution 2:[2]

In device manager, go to the serial port and see if your programmer is detected there or not.. then uninstall the driver. then remove and replug it into the usb port and let Windows automatically reinstall the serial driver. This worked for me(MindMotion programmer)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Hamed Sazgaran
Solution 2 sukhbir1996