2025-05-18 3:24 AM
Hello, first of all I'm completely new with microcontrollers and I really don't know anything. This is my first experience trying out one. I'm a total noob.
I'm using STM32F103C8T6 with STLink V2. I have 4 units of STM32 and 3 of STLink. I upgraded the firmware of all my STLinks in CubeProgrammer succesfully with no errors.
I succesfully programmed a USB that simulates a keyboard that periodically sends the letter "r" to the PC. I also programmed two versions of a 16 button gamepad; one that uses polling and another that uses interrupts to detect button presses. I have the keyboard and one of the gamepad programs actually flashed into 2 of my STM32 right now. I also have a version of the 16 button gamepad in a ".bin" file that I copied with CubeProgrammer.
So, everything was working properly; I flashed and tested 2 of my 4 STM32 multiple times with one STLink, as well as mass erased their memory also multiple times. But today I was rewriting the "interrupt gamepad program", and after flashing it into the STM32 everything stopped working. Now I am getting a "No STM32 target found!" with all the boards and STLinks... none of them work.
I am getting this error:
11:15:28 : UR connection mode is defined with the HWrst reset mode
11:15:28 : ST-LINK SN : 16004A002933353739303541
11:15:28 : ST-LINK FW : V2J45S7
11:15:28 : Board : --
11:15:28 : Voltage : 3.14V
11:15:28 : Error: Unable to get core ID
11:15:28 : Error: No STM32 target found! If your product embeds Debug Authentication, please perform a discovery using Debug Authentication
I tried:
- Using all of my 3 pc USB ports.
- Checking with all my boards and all my STLinks (2 of the boards and 2 of the STLinks were virgin. Still same fail for all 4 boards and 3 STLinks).
- Checking the wiring was done properly.
- Connecting via CubeProgrammer with many different combinations of modes (Under reset, normal) reset modes (Hardware, Software, Core) and frequencies(4000, 1800, 950...)
- Connecting via the (to my knowledge) outdated STM32 ST-LINK Utility also with different config options (still same No STM32 target found! error).
- Reinstalling dpinst_amd64.exe driver from en.stsw-link009.zip download.
I don't get it... I was happily coding a couple hours ago and now suddenly I get this No STM32 target found! with all my boards (even the unused virgin ones).
Any solutions? If more info is needed, tell me and I will try to provide it.
Thanks.
2025-05-18 3:55 AM
Ok so I kept trying and somehow it was able to connect. The problem with the virgin STLinks was that their pin labels were improperly printed into the case. I removed the case and followed the labels that were on the PCB itself.
Now I have a problem with the STM32 that has my program flashed. I'm getting this error:
12:37:27 : UR connection mode is defined with the HWrst reset mode
12:37:27 : ST-LINK SN : 16004A002933353739303541
12:37:27 : ST-LINK FW : V2J45S7
12:37:27 : Board : --
12:37:27 : Voltage : 3.13V
12:37:27 : Error: Unable to get core ID
12:37:27 : Error: Cannot connect to access port 0! If you are trying to connect to a device with TrustZone enabled please try to connect with HotPlug mode. If you are trying to connect to a device which supports Debug Authentication with certificate or password, please open your device using it.
I can't directly program it from the IDE, and I have to press the board's RESRT button every time I want to connect to the CubeProgrammer, which is inconvenient. After I do a mass erase, the MCU connects with no problem and is able to be programmed from IDE again.
In which way may I be messing things up in my code to cause this Cannot connect to acces port 0! error? Like, what causes it?
2025-05-18 3:56 AM
Your code is probably quickly jamming up the MCU, before the debugger can connect.
Try "Connect Under Reset" if you connected NRST pin to ST-LINK.
Set the BOOTx pins so it uses the ROM System Loader at Reset instead of your code.
2025-05-18 4:05 AM
Hey, thanks for the answer! I forgot to mention I also tried to change jumpers of BOOT0 to 1. But It looks like my problem with the virgin STLinks was that the pinout labels were incorrectly printed, but now they connect.
I now have a new problem with the 16button gamepad program. After flashing it I have connect problems described in a post I just did 1 min before you posted this reply.
Thanks again for your time!
2025-05-18 4:12 AM - edited 2025-05-18 4:15 AM
Hi,
so it was working - but "suddenly" no more.
Maybe you wrote in your last program something, using the swd/swc debug pins - then connection is lost.
To get connect to boards, try connecting in dfu mode (= start bootloader), then full erase chip.
Problem: the F103 has no DFU/USB bootloader, so you have to use a USB-serial adapter, to connect to USART1 .
If you dont have USB-to-serial adapter, you could try :
- use CubeProgrammer , hardware reset mode.
- set/press reset on your bluePill
- then connect ...try to full erase chip.
ed
Tesla was faster...
So now, in IDE try connection mode : software system reset.
2025-05-18 5:05 AM
I think some problems are coming from this line in my code:
#define MASK_BUTTON5_IRQ() __set_BASEPRI(1 << 4)
Every time my code reach the MASK_BUTTON5_IRQ() macro, the "gamepad" stops working. Also it seems like when that macro is present in the code, I get connection problems.
I was playing around with interrupt masking, setting some EXTI lines to 0, others to 1 and others to 2 to see how changing BASEPRI value affected things; but every time I use it in my code, it just break the whole thing.
I wanted to try stopping the SysTick_IRQn by using
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
or
NVIC_DisableIRQ(SysTick_IRQn); (I don't know if NVIC is able to disable SysTick or not)
But now I'm wondering how safe it is and if I'm going to brick my STM32