cancel
Showing results for 
Search instead for 
Did you mean: 

Reprogramming the firmware via USART2 and RS485

robertwood9
Associate III
Posted on December 15, 2009 at 19:30

Reprogramming the firmware via USART2 and RS485

6 REPLIES 6
robertwood9
Associate III
Posted on May 17, 2011 at 13:22

Folks,

I'm not clear on how to reprogram the memory when using RS485 and USART2 (as opposed to USART1). From what I understand there are bootloader functions built into the device and if you have an RS232 connection there's a program you can run on a computer (presumably only Windows?) to program a hex file with ease.

In out case however, we need the timer pins for driving a motor and these are shared with USART1. Not only that, we have an RS485 conne4ction to further complicate matters. Even worse, the RS485 comes in from a master module and is not accessible from the outside world.

Are the functions that are in the STM32's ROM available to call from a bit of user code that might be put in some protected part of flash? If not, how would we go about reprogramming in the field.

With the AVRs for example, you can enable bits of memory for a custom bootloader and have your own code for assembling messages that come in and rewriting the firmware. I assume this is what we need to do on our case, but am not at all clear how we would achieve this.

Many thanks!

Rob

[ This message was edited by: robert.wood on 07-09-2009 12:39 ]

st3
Associate II
Posted on May 17, 2011 at 13:22

Go to the Application Notes page,

http://www.st.com/mcu/familiesdocs-110.html

Look at Application Note AN2557 STM32F10x in-application programming using the USART,

http://www.st.com/stonline/products/literature/an/13588.pdf

Quote:

The STM32F10x microcontroller can run user-specific firmware to perform IAP of the microcontroller-embedded Flash memory. This feature allows the use of any type of communication protocol for the reprogramming process (such as CAN, USART, USB).

USART is the example used in this application note

robertwood9
Associate III
Posted on May 17, 2011 at 13:22

Thanks for the reply, ST7. This doesn't really give me the information I need though.

With the AVR bootloader I wrote, Atmel gave information about how to program pages at a time how to erase, how to set-up which page you were writing to, how big the page was etc etc. All this apps note really seems to do is say, use hyperterminal (which I can't for my systems) and then you can write your own if you want, but doesn't give the necessary details.

I've tried Google searches but there seems to be little information.

I have one system where I need to have an XMEGA take the identical image for three STM32s and then it needs to send that image down three UARTs to the STM32s to program them. Also, it's UART2, not UART1!

Cheers!

st3
Associate II
Posted on May 17, 2011 at 13:22

Quote:

Atmel gave information about how to program pages at a time how to erase, how to set-up which page you were writing to, how big the page was etc etc.

That information is all in the Data Sheet and/or User Manual, and support functions are available in the Firmware Library.

Quote:

All this apps note really seems to do is say, use hyperterminal

The App Note is a bit misleading in the way it suggests that this is somehow specific to Hyperterminal.

In fact, there is absolutely no dependence whatsoever on Hyperterminal; it is just a plain serial Link - it neither knows nor cares what application you use on the other end!

You can use a real terminal, or any other terminal emulator, or any application of your own devising.

The data is transferred using (IIRC) YMODEM - which is a standard protocol available on any decent terminal program, and easy to implement for yourself.

robertwood9
Associate III
Posted on May 17, 2011 at 13:22

Thanks, ST7.

I think I may have been under a misapprehension about the boot loader! I thought it was something that was part of ROM, but actually it looks like it's part of user flash that you have to program via JTAG first. Is that right?

With this assumption, do I then understand correctly that what ST have given is the boot loader firmware that works on UART1, but you can mod it relatively easily to other comms ports as suitable for your application?

Also, I assume the idea is that once you have programmed your boot loader via JTAG, you can then lock the sectors of flash the boot loader resides to prevent that being overwritten?

Sorry to be numb. Looks like I just misunderstood how this works!

If anyone else is interested, there's a little information about a Python program to run on Linux, Mac and Windows for programming your device.

http://www.micromouseonline.com/blog/2009/05/07/stm32-arm-cortex-bootloader

Cheers,

Rob

st3
Associate II
Posted on May 17, 2011 at 13:22

Quote:

I think I may have been under a misapprehension about the boot loader! I thought it was something that was part of ROM

There is a bootloader in ROM - but that one only works over UART1.

If you want a bootloader to work over any other interface then, yes, you do have to write & load that yourself.

Note that some of the newer STM32 lines do have a bootloader in ROM that works over other interfaces than just UART1.

Quote:

do I then understand correctly that what ST have given is the boot loader firmware that works on UART1, but you can mod it relatively easily to other comms ports as suitable for your application?

The application note illustrates that, with suitable software, you can make a bootloader to update your chip over any interface that you require.

Quote:

I assume the idea is that once you have programmed your boot loader via JTAG, you can then lock the sectors of flash the boot loader resides to prevent that being overwritten?

Yes, you could do that.