Skip to main content
Visitor II
September 21, 2020
Question

Why do I have to send a UART bootloader command twice to get an answer ?

  • September 21, 2020
  • 5 replies
  • 1598 views

Hello,

I am using a STM32L432KC to control the UART bootloader of a STM32F446RE.

First, I am sending Get and Get ID command to check if I get the recquired answer. It works, but not as I wish.

To begin I Initialize the bootloader sending 0x7F and that works too.

What I don't understand is why do I have to send the command twice to get an answer. It's the case for the 0x7F as well as for the get and Get ID. The first request never works, but all the following does.

Example :

Me : 0x7F

Res : Anything.. (not specially 1F)

Me : 0x7F

Res : 0x79

Me : 0xFD & 0x02

Res : 1F

Me : 0xFD & 0x02

Res : 79 01 04 21 79

Me : 0xFD & 0x02

Res : 79 01 04 21 79

Me : 0xFD & 0x02

Res : 79 01 04 21 79

...

It's exactly the same for the Get command...

I don't know if it's a normal situation or not, but I don't think it is really ergonomic..

Maybe someone could explain me, thus I could improve my program to overcome that.

Thanks in advance for your answer.

Regards

    This topic has been closed for replies.

    5 replies

    Graduate II
    September 21, 2020

    Shouldn't you send  0x00+0xFF? until you see ack as start. Have a look ar AN3155.

    Zephyr SAuthor
    Visitor II
    September 21, 2020

    That's what I should send concerning Get command.

    Then I don't understand why neither,but if I send 0x00+0xFF it doesn't work, I have to send 0xFF+0x00... Exactly the same thing for the GetID command, I have to send 0xFD+0x02 (not 0x02+0xFD).

    As it works this way, I d'ont think that's a pretty big deal.

    Super User
    September 21, 2020

    Looks to be an error in your reception. The bootloader is responding correctly to what you're sending, but you're not interpreting the response until a byte late. It's using the second byte of 02 FD and the first byte of the next 02 FD to respond to. Use a different command back to back and it will no longer work.

    --> 0x7F

    0x79

    --> 0x7F 0xFD

    0x1F

    --> 0x02 0xFD

    79 01 04 21 79

    etc...

    Put a logic analyzer on the line to see exactly what's happening.

    Zephyr SAuthor
    Visitor II
    September 23, 2020

    I don't think so because as I told you, I have to send twice the init command (0x7F) too which is built by only one byte.

    The system can't take one byte from the first request and one from the second as it's the same byte in both and the system only need one of them, not both.

    Super User
    September 23, 2020

    Look at the Rx/Tx lines using oscilloscope.

    Do you have a pullup on mcu's Tx?

    JW