2018-11-29 10:10 PM
I have a requirement for implementing firmware upgrade feature for one of our products which is based on STM32F412ZG microcontroller. I know that ST provides a system memory bootloader which already supports firmware upgrade using USB DFU class.
But the requirement is to add additional user interactions(Blink LED, buzzer, etc) during the upgrade process, or to indicate that the device is in bootloader mode. Since I cannot change the on-chip bootloader I'm trying to develop a custom bootloader which is based on the USB DFU device application (generated from STMCubeMX). After flashing this sample project on STM32F412g-discovery and plugging the device into PC using, I get the following error in Device Manager
STM Device in DFU mode (with an exclamation mark) and under details it says, This device cannot start. (Code 10)
However if I jump to system memory bootloader, the PC is able to load the correct driver and it gets detected as STM Device in DFU mode correctly and I'm also able to successfully upgrade the firmware using DfuseDemo.exe
I have installed DfuseDemo package from ST along with the corresponding drivers provided in the same package.
I'm failing to understand why the project created using STMCubeMX is not working and I'm also not able to find an example project for UDB DFU device for STM32F412g-discovery.
Please help me in understanding what could be wrong or direct me to where I can find a working sample project.
PS: PC is running windows 10. I'm also not sure if it's completely windows 10 problem whatever I'm facing.
2018-11-30 12:58 AM
you have to change
#define CDC_DATA_HS_MAX_PACKET_SIZE 512 /* Endpoint IN & OUT Packet size */
#define CDC_DATA_HS_MAX_PACKET_SIZE 64/* Endpoint IN & OUT Packet size */
in usbd_cdc.h
2018-11-30 01:11 AM
But I'm using DFU class, not CDC.
2018-11-30 01:19 AM
i never used DFU. but code 10 error occurs cuz of wrong packet size. SO i think it must smh simillar to this
2018-11-30 01:28 AM
Okay, I'll look into it. Thanks a lot for your support.
2018-11-30 12:52 PM
Take a look at https://github.com/IntergatedCircuits/DfuBootloader
There is no direct support for STM32F412ZG, but you can just use stm32f405 target for the purposes of USB, GPIOs and timers, the basic peripherals are all mapped to the same address and interrupt lines. (Remember to increase the flash size to 16k in the linker script.) Or just start off with the USBDevice library.
The nice feature of the library and the DFU class implementation, that the interface implements both bootloader and application side operation, and it can be mounted on the USB device of the application. Therefore the DFU interface can be used to manage the transition from application mode to bootloader, as it is defined by the DFU class specification.
2018-11-30 01:04 PM
Watch also stack size on Keil builds