2021-07-19 03:39 AM
I'm working on an project with an L476 using SWD. Main project is basically up and running, but I'm having problems with the bootloader.
The bootloader needs to be small as possible, so am avoiding the bloaty HAL and have set up the PLL. Seems OK in that the debug UART is kicking out exactly the right baud rate, but if I just run in a loop sending out 0x55 the unit locks up and loses the debugger connection.
The only way I can reconnect is by powering the unit up and hitting go on the debugger at exactly the right time. It can take scores of goes before I can reconnect. It keeps telling me that there is no part found.
So, some questions:
Many thanks.
2021-07-19 04:21 AM
Minimize, then add back features till see what is stopping it.
Possibilities:
Paul
2021-07-19 04:37 AM
Hi Paul,
Thanks the the reply.
The code is already minimised, I'm doing nothing but initialise the PLL and UART then send out 0x55 over the UART in an infinite loop (with a short delay between sending the 0x55 out).
There are no interrupts enabled, the watchdog is not enabled. Even if there was an interrupt enabled, it wouldn't explain why the debugger gets locked out. Suggests to me that something non volatile is getting corrupted. I did try doing it by not initialising the PLL and that was OK, so it's surely something to do with that, but the frequency seems fine as the UART is at the right frequency. That's wht I wondered whether it might be a flash thing, but the latency seems right.
I also don't understand why connecting the debugger just doesn't allow me to reprogram because, as I asked abive, why doesn't the debugger hold the unit in reset and allow an easy reconnect. I've never come across this before in 15 ish years of using an STM32.
2021-07-19 05:34 AM
LOL - You are the STM expert and I'm the beginner (30years MCUs, but relative beginner in STM).
I'll work on the principle of "no such thing as a stupid question", hoping my points inspire a thought that resolves this.
1. Did you try running your exact minimal project on the curiosity hardware?
If diff behavior that suggests a hardware difference.
Maybe a bad via? Good old meter work to probe out each pin-to-pin connection to verify connected.
Maybe a miss populated component (wrong value, orientation...)?
2. There is a debugger option in IDE for "Connect under reset"
Actually there are a mess of settings there that could wreak havoc.
Project >RightClick >DebugAs > DebugCfgs > Tab:Debugger > Reset Behaviour
Maybe the defaults have changed in IDE versions from what you were used to.
Paul
2021-07-19 06:12 AM
Perhaps some issue electrically? Solid grounds? No floating islands or disconnected nets? Double check netlists for net names for misnaming and connectivity, especially power nets.
Is NRST connected via your debugger interface?
Does HAL equivalent code fail similarly?
Debugger can have difficulty if low power modes used, pin latch-up or the chip simply non-functional.
Does complete power cycle of board, or turning off for a while alter behaviour/connectivity?
State of BOOT0 pin
2021-07-19 06:33 AM
I think we can rule out any sort of hardware issue. It's been working for two months just fine with the non-bootloader program. There's clearly something locking it up and it must be to do with the PLL and/or flash setup.
NRST *is* connected to the debugger, yes.
Paul, I checked the reset behaviour and at first I thought it must be because it was not selected as #connect under reset, but even changing to that does not help.
It seems easier to connect if I use the cube programmer. I can then erase the chip and all is well.