2016-02-09 04:22 PM
I've got an STM32L15x whose application sets a ram flag then does a soft reset, after which the startup code jumps to the DFU bootloader. So far so good, the DFU kicks in and the host PC is successfully talking to it and pushing new firmware (validated by reading back using ST/Link.)
However, it's very inconsistent from run to run, or PC to PC, or firmware to firmware (no patterns) but the newly flashed application often fails to start following a DFU leave/exit and we can't recover it until the battery drains. This is a major issue since the unit is sealed and we can hard reset.Anyone any idea ? #stm32 #dfu #bootloader2016-02-09 07:47 PM
The first step I think would be to understand what is happening, and how it is failing. I'd probably start with some USART output initialized as soon as it gets into the Reset Handler code, and get some telemetry from there.
If the device has to reconnect via USB, you might want to look at what's going on with the interface's pins, and if there are any timing issues, or issues with clocks or PLLs coming up, and any expectations the device has for being in a truly reset state, vs hot starting out of the DFU loader.2016-02-10 04:53 PM
As a workaround, we've added a soft-reset in the startup code and it seems to do the trick.
We haven't yet found what is exactly causing the issue...2016-02-18 03:41 PM
For anyone else having similar issue...
We've been working with STM to figure out what was happening. In short, this is a side-effect of the application using USB and not resetting the usb core on start. Here is an excerpt from the AN3156: ''When performing a jump from the bootloader to a loaded application code which uses the USB IP, the user application has to disable all pending USB interrupts and reset the core before enabling interrupts. Otherwise, a pending interrupt (issued from the bootloader code) may interfere with the user code and cause a functional failure.
''STM provided us with the following snippet to add to the beginning of code:SystemClock_Config();
HAL_NVIC_DisableIRQ(USB_LP_IRQn);
__HAL_RCC_USB_FORCE_RESET();
__HAL_RCC_USB_RELEASE_RESET();
/* Init Device Library */
USBD_Init(&USBD_Device, &VCP_Desc, 0);
Thanks to Joe@STM :)2016-02-20 08:34 AM
2016-02-20 12:02 PM
That's probably less of an issue with USB/CAN where the use of HSI is generally frowned upon.
It might make sense to get the trim handled in the SystemInit() call tree, as being pulled off to 7.2 MHz might come as rather a surprise, at the very least check if it has been zero'd and apply the default.2016-02-21 06:04 AM