cancel
Showing results for 
Search instead for 
Did you mean: 

rs485 half-duplex bootloader

FStra.9
Associate III

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.

1 ACCEPTED SOLUTION

Accepted Solutions
FStra.9
Associate III

Very nice thought, that would preserve the STM32Programmer capability.

 

View solution in original post

10 REPLIES 10

>>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 Venmo
Up vote any posts that you find helpful, it shows what's working..
AScha.3
Chief II

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".

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

>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".

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

You'd design a board with final test programming, and debug in mind at the outset. Having a connector or pads to facilitate a SWD connection.

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

Presumably a topic for embedded software engineering courses these days. As I recall Elecia White's 'Making Embedded Systems' had some coverage of the topic. ST has assorted IAP examples using different interfaces. You could perhaps work it from the angle of the protocols defined documented by ST, and how you might implement those within your own code, or use things like X-MODEM, or other protocols that might be better suited to half-duplex radio links, etc.

>>How do you get into into FLASH?

Via SWD, other supported USART, SPI or I2C for the chip in question

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

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
Associate III

Very nice thought, that would preserve the STM32Programmer capability.

 

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

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?