AnsweredAssumed Answered

Trouble getting the acknowledge byte (0x79) back from from bootloader STM32F417

Question asked by Gordon Madden on Mar 16, 2017

I have my jump function that successfully jumps to the bootloader memory from the running code.

Now the processor is supposed to (according to AN3155 - USART protocol used in the STM32 bootloader):

Once the system memory boot mode is entered and the STM32 microcontroller 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: one start bit, 0x7F data bits, even parity bit and one 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 send the expected byte (0x7F) and I get an 8-bit number back, but it is not 0x79 (decimal 121) as expected.

I'm wondering if the ports (host program to USART on the 417) are not running at the same speed? The manual doesn't really address this. It is supposed to receive the 0x7F byte and recalculate the baud rate of the USART. It does not say anything about changing the speed of the serial connection on the host computer. I am running a program in C# in the terminal on a Windows machine, but the serial port is still set to 115,200 per the instructions in the manual. If there is a baud rate discrepancy, isn't that going to mess with received signal? Or the sent one for that matter.

I have looked at the input (0x7F) on an oscope and verified that it is receiving that byte.

The numbers I get back (from sending 0x7F) are 254, 253, 63 191, 126, and not in the same order each time.

How do I get the serial ports to be the same speed or is there another problem?


Here is my C# code:

namespace SerialPortTest
    class Program
        static bool _continue;
        static SerialPort _serialPort;


        static void Main(string[] args)
            _continue = true;


            // Create a new SerialPort object.
            _serialPort = new SerialPort("COM10", 115200, Parity.Even, 8, StopBits.One);




            while (_continue)
                // Read character typed into the terminal
                int charOut = Console.Read();


                // Convert character to char
                char charOuter = (char)charOut;


                // If it's 'F' or 'S', write that character out to the board
                if( charOuter == 'F' || charOuter == 'S' )


                // If it's 'B', we want to jump to Bootloader
                if( charOuter == 'B' )


                if( charOuter == 'Y' )
                    // Write "7F" to start communicating with Bootloader


                    int byte_read = _serialPort.ReadByte();

I am using 'F' and 'S' to make the flashing LEDs in my STM32F417 code run faster and slower.

When I send 'B', the jump to bootloader is initiated.

After getting to bootloader, I can press 'Y' and send 0x7F to the USART and read the result back in the host program.


Thanks again!