STM32401CC Blackpill Stuck after code upload

Really hoping someone can help me with this. After messing around for a very long time with the black pill I managed to get it upload and work with the stlink in both the cube ide and Arduino to blink the led and print some things over serial after connecting the usb.

The problem when uploading with the DFU bootloader whilst it seemingly works going into bootloader mode and uploading code. When it's finished it gets stuck not sure if in bootloader mode or what. Even if hitting reset. It won't blink or be recognised again over the com port unless I reflash it with the stlink over SWD. I searched a lot and the only people it seems that had a similar issue didnt have the right mode for CDC selected which I'm sure I have. Any ideas? I feel like it must be something very simple and obvious I've missed a long the way or at least I'm hoping so.

I actively use Blackpill in Arduino, but I’ve come to the conclusion that all these dances with boot buttons are inconvenient, so now I only use the st-link to download the code

Are you properly building your sketches to take into account the DFU bootloader?
Unlike an ATmega328, any user bootloader on an STM will be located at the start of flash, which is also where the compiler would put any sketch, unless you use the special linker script or link command to force it to be loaded at higher locations.

What do you use to monitor serial data? As far as I know the stlink V2* (should have mentioned before) doesn't have any VCP. As annoying as the dance is it's still better than doing a dongle cable dance. I think I won't have this problem on an the nucelo boards with the integrated stlink however would be great to get it to work this way for now.

How would I check how the sketches are being built? I thought it was all handled in the STMduino core support. I'm very new to this bootloader business but would like to understand more. Is there anything I can share for you to see what's going on?

What bootloader has to do with serial data? You don't need a bootloder to use a Serial.

To be honest, I not use a USB-Serial for debug. I mostly work with high frequency signals and serial debug couldn't be a much help for me. I used an oscilloscope and logic analysers to see how my code works.

It should be handled by the core support, but you'd have to have all of the options set correctly. I don't have any actual experience with Black Pill Boards, so I'm not sure I can help much. In my install, I don't even see an option for uploading using the DFU bootloader (only for using an STMCube Programmer using DFU.)

The option I'm talking about should show up in the "verbose" compilation output as part of the "Linking" command. If I compile for a Black Pill using the STMCube DFU upload method, I see:

   -Wl,--defsym=LD_FLASH_OFFSET=0

in the link command, which seems a likely candidate. That it's 0 is a bad sign - it indicates that it not expecting a bootloader in the ST chip itself.
There is one Bootloader upload option "HID Bootloader 2.2", and the Link command for THAT has:

  -Wl,--defsym=LD_FLASH_OFFSET=0x400

Which is more like what I'd expect for talking to a bootloader om the chip.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.