Stuck somewhere at startup of application code, SWD not working
Hello everyone,
I created a new project with STM32Cube Version: 1.13.2 on Linux, selected my microcontroller (STM32WB35CCU6A), enabled all peripherals necessary (including USB and SWD, haven’t enabled anything RF related (yet)), and tried to upload my code on a brand new IC on a custom PCB. For the PCB, I followed the schematic without SMPS in AN5290 as shown on this screenshot.

I should also mention that I added a 100nF capacitor on nRST, as well as a pulldown on BOOT0 and two push buttons to pull nRST low or to pull BOOT0 high, and I didn’t try to use these pins for my application. Didn’t forget to supply Vbat. For the crystals I made sure to use compatible ones and used appropriate values for the capacitors that go with them. When entering application mode, the board (which contains other devices) draws ~20mA and ~30-40mA when I enter the bootloader with BOOT0. I use a cheap unofficial st-link v2, after connecting to the pc STM32Cube proposed to update the firmware on the st-link, It worked and after this I’m still able to program blue pill board with it (via SWD).
I have two problems, wich I have no idea how to solve:
- I can’t upload / debug code with SWD. Doesn’t matter if I’m in application mode or bootloader mode. Everytime it says "No device found on target". However, I’m successfuly able to program it with DFU (trough USB), only in bootloader which I think is normal. I tried using dfu-utils but had problem reading back the flash, so now I’m using STM32CubeProgrammer, which tells me that the code I uploaded and the code I read from the flash with it is identical.
- However, it seems that there is a problem entering the while(1) of the main generated by STM32Cube. The only code I added is one to blink an output which is tied to an external 100k pull-down and the enable input of some IC, that’s in the while(1), and I also added a write 1 (with HAL_GPIO_WritePin (thing_GPIO_Port, thing_Pin, 1);) in the Error_Handler() to try and see if something was going wrong. However, I never saw this ouput GPIO going to Vddd.
I looked at SWDIO and SWCLK, I see a lot of toggling when I try to upload/debug with SWD. I checked every voltage of the decoupling capacitors, I can see a solid 3.3V and I never saw it dropping by even a mV when I reset the chip to re-enter application mode. nRST stays at 3.3V and BOOT0 stays at 0V when I try to enter application mode. I resoldered the chip 3 times, it looks good, and I tried to replace the chip by another one one time, but to no avail. I tried to check for shorts, disabled the use of LSE and HSE to replace it with LSI and HSI, replaced all input interrupt pins with inputs, re-uploaded dozens of time with DFU using STM32CubeProgrammer and checked what had been wri, still can’t see this pin going toggling or going high. I also tried to use another pin which is also connected to a 100k pull-down and some chip enable input. At this point I have no idea what to try, and would greatly appreciate any advice.