Skip to main content
FStra.9
Associate III
January 18, 2024
Solved

rs485 half-duplex bootloader

  • January 18, 2024
  • 5 replies
  • 4836 views

I have an RS585 1/2 duplex transceiver hooked to USART2 configured for hardware flow control (RS485) on an STM32L412 micro.

Is it possible to program a virgin part using the STM32CubeProgrammer, and to later do a firmware update over this comm channel?

I searched the forums but did not find a definitive answer.

This topic has been closed for replies.
Best answer by FStra.9

Very nice thought, that would preserve the STM32Programmer capability.

 

5 replies

Tesla DeLorean
Guru
January 18, 2024

>>I searched the forums but did not find a definitive answer.

Probably because its one of those "depends" situations. The protocol is admittedly half-duplex, but there is no consideration of any turn-around time, or reflection / echo-back of the data sent in response.

Also the protocol's method of auto-bauding is hair-triggered. It's not receiving the "0x7F" data pattern as much as it is timing the edges. If the wiring/transceivers are noisy it is apt to incorrectly determine the baud rate, and you need to reset and start-over.

What is perhaps more practical is your own small loader which has awareness of your hardware, and you can control expectations.

 

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
AScha.3
Super User
January 18, 2024

Just look in ds , boot modes :

AScha3_0-1705610836332.png

So no "automatic" boot by the built in bootloader on rs485 here.

-> refer to AN2606 for bootmodes.

But you can write your own bootloader, that uses anything, also ...rs485 .

So for your question: yes, is possible, but you have to write this special bootloader.

"If you feel a post has answered your question, please click ""Accept as Solution""."
FStra.9
FStra.9Author
Associate III
January 18, 2024

How do you go about writing your own bootloader for a virgin part to be programmed over the RS485 half-duplex comm port?

How do you go about writing you own bootloader in general?

How do you get into into FLASH?

etc, etc, etc

AScha.3
Super User
January 18, 2024

>Is it possible to program a virgin part using the STM32CubeProgrammer, and to later do a firmware update over this comm channel?

You wrote it yourself - first time you program it by SWD / debug or boot connection, with STM32CubeProgrammer or CubeIDE.

Then , if you have your program and own bootloader on chip, it can start your bootloader , on rs485 or elsewhere.

And "how to ..." , look what others did, maybe here:

https://github.com/viktorvano/STM32-Bootloader

 

"If you feel a post has answered your question, please click ""Accept as Solution""."
Pavel A.
Super User
January 18, 2024

Put another STM32 board or a similar device in the middle. Wire out two UARTs, one in normal full duplex mode to the PC with CubeProgrammer, another to RS-485 adapter to your target board. Write a program to forward all received data from both UARTs to the other UART. Buffer the data as needed to ensure the delay to switch the RS-485 direction. Start it from listening for the 7F bytes from the target.

FStra.9
FStra.9AuthorBest answer
Associate III
January 18, 2024

Very nice thought, that would preserve the STM32Programmer capability.

 

FStra.9
FStra.9Author
Associate III
January 18, 2024

Oops, I'm wondering about how the 1/2 duplex side bootloader would manage the DE, and RE lines?

FStra.9
FStra.9Author
Associate III
January 18, 2024

I think there’s still a problem w/ this notion in that the bootloader is not made to drive the ½ duplex transceiver,

So a custom bootloader would still be needed, right?

 

Pavel A.
Super User
January 18, 2024

IIRC there are RS-485 adapters that automatically switch the direction. Something like, it sets the adapter to receive and lets its host receive, until the host starts sending, then it switches to the TX mode. But yes this is a problem.