cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F103RBT6 migration from standalone application to one that integrate a bootloader

FF1
Associate III

Dear all,

I've finished my board and application around the L6480H stepper driver and cSPIN library, all is fine, but now I have to add at my application the boot loader feature in order to achieve the in-field firmware update possibility (attached a photo of my finished 4-layers board).

The question is rather long, I'm also new to the boot loader usage with the STM32 micro controller family, so I kindly ask you to have some patience in reading this.

Briefly, inside my board, I've a JTAG connector for the ST-Link/V2 debugger/programmer, a RS232 interface connected to the RX/TX pin of the micro controller and also the choice to use a local jumper to set the boot0 input to 0 (as actually) or to 1 to perform the boot from the embedded boot loader that, if I'm right, should work through the USART1 interface that on this micro controller is on the PA9 and PA10 pins. Also I've an incremental quadrature encoder interface, some opto-isolated input for proximity sensors and a EEPROM used to save some parameters at the board power off.

From the STM32F103RBT6 data sheet (DoclD13587 Rev 17) page 15/117, §2.3.8, is written:

"The boot loader is located in System Memory. It is used to reprogram the Flash memory by using USART1. For further details please refer to AN2606."

From AN2606 (August 2018 Rev 33), page 1/292 at the page bottom the note refers to the chapter 2 and from this the AN3155 was related to the USART protocol.

Inside the AN3155 (Rev 9), page 5/38, is written the starting sequence for the boot loader then:

"Once the system memory boot mode is entered and the STM32 micro controller (based on on Arm®(a) cores) has been configured (for more details refer to AN2606) the boot loader code begins to scan the USARTx_RX line pin, waiting to receive the 0x7F data frame: a start bit, 0x7F data bits, even parity bit and a stop bit."

So the USART interface has to be configured with even parity and 1 stop bit, baud rate doesn't matter because the boot loader should implement the auto baud search feature, I'm right?

At now my application use the USAR with 57600,8,N,1 settings, so without parity hence I think to have only to change the parity and set it to even to match the request, because I'm using a LAN to RS232 converter I've to set these parameters to the RS232 section of the converter and I think to be fine with the USART parameters.

After this point I've to use some application able to send the data bytes of the .hex firmware file to the boot loader, this application of course must implement the protocol reported into the AN3155 specification.

From this point my questions begin.

All my equipment, inside which is the motor control board that can be reached on the LAN port through a LAN-RS232 adapter, is controlled by a Python script, my goal is perform the firmware update from a web page (to manage remotely the equipment I've a local web site so I've only to do a dedicated web page to perform the .hex file update).

Question #1

The first question is about the availability or if someone know where to found it an open source available code that perform the Python implementation for the USART protocol or if I've to write it as a new class from scratch, of course freely available code will save to me some time, so I'll say thank from now every people that can give me some info on this matter. EDITED: after a search I've found this reference https://pypi.org/project/stm32loader/ someone have already used it?

Question #2

Another question is how to enter into the boot mode without have to set the boot0 jumper on the board. The firmware update feature should be done from remote because for most of time the equipment is not physically accessible. For this reason the hypotetical sequence of operations could be to provide to send a dedicated command to my application through the USART interface which have the purpose to instruct that is time to do a firmware update (this of course is easy to do :)), after that make a jump to the USART embedded boot loader and perform the firmware update without the need to operate on the external boot0 line or perform an hardware reset of the board. Can be feasible from your perspective?

This is my first time with the STM32 boot loader so I'm to be sure about the steps that I've to do.

If all is feasible I kindly ask if there are some demo code/application note/technical note or info how to perform this jump from the C code perspective.

Question #3

When the updating process ends, from the embedded boot loader code, I suppose that the execution will jump to the main application starting point (entry point of the my application code) hence the new application code will be executed without the need to perform a hardware reset of the board. I'm right?

As a side note actually I'm working with the IAR Embedded Workbench IDE (version 8.32.1.18631) environment.

I say thank for any help available.

Best regards!

0 REPLIES 0