Sunday, December 16, 2012

Flashing programs to STM32. Embedded Bootloader

There has been several requests among users to explain more about loading programs in to flash memory of STM32 microcontrollers.
This of course is a wide topic but lets focus on how to achieve result – flash program in to MCU. Depending on what arsenal is on your desk you can do in several different ways. Let’s try to go through them in practical way.

Embedded bootloader

All STM32 microcontrollers comes with built-in bootloaders that are programmed during production. Depending on device type flash memory can be programmed using one of interfaces like USART1 or USART2, USB, CAN. Mostly we are dealing with low, medium and high density devices so they can access bootloader using USART1 interface. USART1 can be connected to computer using RS232 interface or USART to USB driver chip like FT232. In order to enter bootloader special MCU pins has to be set to proper logical values. These are called BOOT0 and BOOT1 pins on a microcontroller. Boot pins can have several cases:
As you can see there are three cases: first case is when BOOT0 pin is tied to ground and BOOT1 is open or at logical state 0 then after reset program is executed from Main Flash Memory. This is your normal configuration when executing programs. Second case (BOOT1=0; BOOT0=1) means that after reset execution starts at System memory where built int bootloader resides. This is the case when we need to upload binaries via USART1. And third case means that program execution is performed in SRAM. So lets focus on second case – System memory. In many development boards you will find jumper pins where you can select BOOT0 and BOOT1 configurations. For instance in STM32F103RBT6 board these looks like this:
In image you can see that jumper settings already selects to run internal bootloader. What we do next is download Flash Loader Demonstrator which is a tool to interact with bootloader. Install it and launch. You will see screen where you will be able to select USART parameters. Be sure to select correct COM port:
Read more at http://www.hqew.net/circuit-diagram/Flashing-programs-to-STM32$2e-Embedded-Bootloader_13458.html

No comments:

Post a Comment