cancel
Showing results for 
Search instead for 
Did you mean: 

Host application for interacting with STM32 Natvie SystemROM bootloader

subu.rama
Associate II

I am trying to verify the various commands described in AN3155, ST's app note for USART protocol used in the STM32 bootloader.

Per Section 1, when the bootloader receives 0x7F data frame, the code initializes the serial interface and then is ready to receive commands such as Get etc.

Question: Is there an ST host application already available to try out these commands or do I need to develop one?  (That is for sending the data frame to get the boot loader ready, to send the various commands described in AN3155 etc.)

Can I use an available terminal emulator to send these commands? If so, which one and what is the procedure to do so?

Thank you

Subu

4 REPLIES 4

You can use RealTerm in HEX mode to send/receive bytes/commands. Connect with EVEN parity, try 9600 8E1 to interact. The boot loader doesn't receive the 0x7F pattern, but times the waveform to determine the baud rate.

The "Flash Loader Demonstrator" is the original application ST provided, the new STM32 Cube Programmer also now implements a COM/USART connectivity option.

Various open source examples exist. The protocol isn't particularly complicated.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
subu.rama
Associate II

Thank you, Clive. I have a Nucleo-F446RE board. I have set BOOT0 to 1 by connecting pins 5 and 7 of CN7 as mentioned in the Nucleo user manual and app note AN2606.

I am using the UART3 bootloader on PC10 (TX) and PB11 (RX) connected to a USB-to-serial adapter.

I downloaded the ST Cube programmer and on connecting to UART3 as 9600 8E1, I get:

14:27:30 : Serial Port COM16 is successfully opened.

14:27:30 : Port configuration: parity = even, baudrate = 9600, data-bit = 8, stop-bit = 1.0, flow-control = off

14:27:30 : Activating device: OK

14:27:30 : Chip ID: 0x421 

14:27:30 : BootLoader protocol version: 3.1

14:27:32 : UPLOADING OPTION BYTES DATA ...

14:27:32 : Bank : 0x00

14:27:32 : Address : 0x1fffc000

14:27:32 : Size : 16 Bytes

14:27:33 : UPLOADING ...

14:27:33 : Size : 1024 Bytes

14:27:33 : Address : 0x8000000

14:27:33 : Read progress:

14:27:36 : Data read successfully

14:27:36 : Time elapsed during the read operation is: 00:00:02.607

There is really no UI in Cube MX programmer for sending various commands to the bootloader and seeing the responses. I understand the protocol is not complicated and I could perhaps use PySerial etc. to do this.

May be I not using the right keywords to search but I am unable to find any open source examples for this. I wanted to see if someone had already developed such an interface to the native bootloader.

Also, given what you say about the "0x7F" pattern, what does the following mean?

From AN3155, I quote:

Once the system memory boot mode is entered and the STM32 microcontroller (based on on Arm®(a) cores) has been configured (for more details refer to AN2606) the bootloader 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.

The duration of this data frame is measured using the Systick timer. The count value of the timer is then used to calculate the corresponding baud rate factor with respect to the current system clock.

Next, the code initializes the serial interface accordingly. Using this calculated baud rate, an acknowledge byte (0x79) is returned to the host, which signals that the STM32 is ready to receive commands.

I also downloaded realterm. I set up the Port and Display tabs. The status is "Port: 16 9600 8E1 None".

Now when I send 0x00 as "Send Numbers", I don't see anything on the display. (The black window on the top). So I went back to AN3155 where it says in Note 2:

For each command the host sends a byte and its complement (XOR = 0x00)

So I tried sending 0x00 0xFF (for the get version command). Nothing still.

Should I at least not see either ACK (0x79) or NACK (0x1F) being sent from the device?

What am I not getting?

Thank you very much for your help.

Subu

The "Flash Loader Demonstrator" comes with source, as I recall, and their are command line versions for it and the cube programmer, but probably not to micro-manage the connection. There are also several open source apps available. Google a bit..

In RealTerm, you must first send the 0x7F pattern for the STM32 to learn the speed. You get a single chance at this, then you must reset and try again. There should be an 0x79 response to the 0x7F pattern, then you can continue.

You want to "Send Numbers", but not CR/LF

Tx: 0x7F

Rx: 0x79

Tx: 0x00,0xFF

Rx: ...

Tx: 0x01,0xFE

Rx: ...

>>What am I not getting?

I don't know, this isn't terribly complicated.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Yes, after sending the "one chance" 0x7F a few times after resetting the board each time, I was finally able to establish a connection to the bootloader and could verify the commands and responses from AN3155.

The key sentence in your answer is:

"You get a single chance at this, then you must reset and try again. There should be an 0x79 response to the 0x7F pattern, then you can continue." :-)

I am not attempting to "micromanage" the connection!

I am just trying to understand the protocol.

Thank you again for your help.

Subu