Hello @LQC_ , @llcc ,
I moved your messages to a new thread as it was unrelated with the other error.
First, please make sure to use a USBC to USB C cable.
I did some research and here is what I found:
First Possible solution:
debugging - ST-LINK error on STM32CubeProgrammer: Problem occurred while trying to connect - Stack Overflow
I know this is an old question, but I had a similar problem, and I wasted 2 hrs solving it on Linux...
There are 2 potential causes for this:
- Problem with a physical connection
- Missing udev rule
Udev rule
What I found is that STM32CubeProgrammer is not adding the udev rules necessary for the controller...
From this post: https://wiki.st.com/stm32mpu/wiki/STM32CubeProgrammer#Preparing_the_USB_serial_link_for_flashing
#Install libusb
sudo apt-get install libusb-1.0-0 #For debian distributions
#Get udev rules from the STMCube
cd <your STM32CubeProgrammer install directory>/Drivers/rules
sudo cp *.* /etc/udev/rules.d/
#reload udev rules
sudo udevadm control --reload-rules
This worked for me on STM32CubeProgrammer 2.8.0 under Ubuntu 20.04, I hope it helps someone.
Second Possible Solution:
STM32 & ST-LINK - Cannot connect to MCU after successful programming - Electrical Engineering Stack Exchange
I managed to solve that problem. If anybody encounters similar problem, here's what I've done:
I used ST-Link v2 and ST-Link Utility. In setting, I set "Connect under reset" and SWD interface (I'm not sure about frequency).
Then I press the reset button on my board and clicked "Target" -> "Erase chip" and just after clicking I released the button - It erased the chip so I can now reprogram my MCU.
Anyway, if you need to use SWD pins as output, then add some delay at the beginning of the program or use some jumper to disable/enable setting these pins as outputs.
Community solution in related threads:
Solved: Can't connect to the MCU via STLinkV2 [ST-LINK err... - STMicroelectronics Community
Solved: Error connecting with ST-LINK in Linux - STMicroelectronics Community
Let me know if any of this helped you.
Have a good day,
Julian
In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.