In last post we know that System Memory is a flash area, which can be booted up after Power on Reset. This post I will show you a applicability of it to update firmware through USB port.
1. What is DFU?
DFU stands for Device Firmware Update, which is an incredibly useful feature on modern microcontroller, allows for quick and easy update to a device’s firmware without the need of extra piece of hardware.
2. How can we update firmware in STM32F411E Discovery?
In the post about Arm Cortex-M4 booting sequence, I showed you how to access the System Memory inside Code area by config the BOOT pins.
To refresh you memory, BOOT1 pin is set to low and BOOT0 pin is set to high then System Memory will be mapped to Alias area of flash.
Then after Power On Reset, the System Memory with a boot loader inside will be booted up. And with the implemented code, it allows you to update firmware through USB port.
Now I will show you how to make it works.
2.1. Setup BOOT pins to access System Memory
We already know BOOT1 pin should be set to low and BOOT0 pin should be set to high for System Memory access purpose.
Lets take a look at schematic to find these pins location
Because PIN B2 is same as BOOT 1 pin, then you should connect BOOT1 pin to GND and BOOT0 pin to VDD as I marked in yellow.
If your application is running then you set up the pins as above then reboot, you will se nothing happen now because the boot loader in System Memory is running.
2.2. Connect board to PC
Now we don’t use ST Link anymore, however we still need to connect it to get the power.
The micro USB port should be connect to PC for firmware update purpose.
2.3. Download and install DFUSE Demo
You can download the installation files in bellow link:
After downloading, run DfuSe_Demo_V3.0.5_Setup.exe to install as normally Window application.
After finish you will have the tool to convert hex file to dfu file (Dfu file manager) and the application to flash DFU file into memory(DfuSeDemo).
2.4. Create DFU file
Open whatever project (GPIO_HAL for example), choose Option for Target -> Output -> tick on Create HEX file box
Now rebuild project you will get GPIO_HAL.hex file in GPIO_HAL\Objects folder
Now open Dfu file manager, choose option to create dfu file
Click OK to jump to generate tool
Click S19 or HEX and choose created GPIO_HAL.hex file
Click Generate to create DFU file, save it as GPIO_HAL.dfu
2.5. Update Firmware
Run DfuSeDemo, reset the box and you will see the board is detected as STM Device in DFU mode
In Upgrade or Verify Action, click Choose and add your GPIO_HAL.dfu file
Click Upgrade to start download firmware to the flash memory.
Now data is written successfully into Flash memory.
Disconnect BOOT pins into GND and VDD and reboot the box, you will see GPIO_HAL application is working as normal.
Update firmware by using System Memory accessing and DFU Demo help us to understand the boot configuration with real device. We also get a new method to flash image without ST Link.
In other post I will so you how to create a custom bootloader from scratch.
Hope you enjoy it.
2 thoughts on “Firmware Update by accessing System Memory”
This title is the sweetest. Twinkle Falls sounds like a place I want to be :p Catlin North Purvis
I like it when individuals come together and share thoughts. Great blog, continue the good work! Daphene Herb Price