Skip to main content
Gordon Madden
Associate III
July 25, 2017
Question

USART bootloader, no ACK from GO command

  • July 25, 2017
  • 3 replies
  • 927 views
Posted on July 25, 2017 at 21:03

Hello!

I have used

the

bootloader in the stm32f417 for firmware updating, and the GO command always worked.

Now my program is hanging while waiting for an ACK from the bootloader. My C# code for the host:

Sending GO command:

                    

var go = new byte[] { 0x21 };

            var de = new byte[] { 0xDE };

            byte_read = 0;

            _serialPort.Write(go, 0, 1);

            _serialPort.Write(de, 0, 1);

            // Receive ACK byte

HANGS

-->   byte_read = _serialPort.ReadByte();

            if (byte_read == NACK)

            {

                //Console.WriteLine('NACK received for GO COMMAND start');

            }

           

I tried putting in delays and placing it inside a while loop to repeatedly send and then receive the ACK:

            var go = new byte[] { 0x21 };

            var de = new byte[] { 0xDE };

            byte_read = 0;

            while (byte_read != 0x79)

            {

                _serialPort.Write(go, 0, 1);

                Thread.Sleep(100);

                _serialPort.Write(de, 0, 1);

                Thread.Sleep(100);

                // Receive ACK byte

  

HANGS

-->      byte_read = _serialPort.ReadByte();

                Thread.Sleep(300);

                //Console.WriteLine('ACK = 0x{0} for GO command', byte_read.ToString('X'));

                //Console.WriteLine('');

                if (byte_read == NACK)

                {

                    //Console.WriteLine('NACK received for GO COMMAND start');

                    //Console.WriteLine('');

                }

            }

Why would sending the GO command cause the program to block on the ACK byte?

I have stepped through the code with Keil and Visual Studio in debug and can see the correct bytes being sent to the USART.

This is the tale end of the firmware update app and the update is completed. I can restart the board and the firmware is there.

Any suggestions?

Thanks!

    This topic has been closed for replies.

    3 replies

    Tesla DeLorean
    Guru
    July 25, 2017
    Posted on July 25, 2017 at 21:43

    Tried walking it through with RealTerm sending it hex bytes?

    I don't think adding delays between them will help at all, I send strings of multiple bytes.

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    Tesla DeLorean
    Guru
    July 25, 2017
    Posted on July 25, 2017 at 21:46

    { // Tx: 21 Go 0x08000000 SP=[0], PC=[4]

    BYTE data[7] = { 0x21, 0xDE, 0x08, 0x00, 0x00, 0x00, 0x08 };
    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    Gordon Madden
    Associate III
    July 26, 2017
    Posted on July 26, 2017 at 02:07

    I will do that. I'm not familiar with the syntax above. Downloaded RealTerm. Set baud, parity, data, stop, and flow control. Looks like bytes can be sent using the Send tab, but what was your test setup for sending the bytes?

    Thanks!