cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 Flash Tool

wojtusch
Associate II
Posted on August 04, 2010 at 18:58

STM32 Flash Tool

#flash-erasing-programming
9 REPLIES 9
swhite2
Associate III
Posted on May 17, 2011 at 14:00

Not sure why you want to write your own but there's a number of free solutions already out there.

ST has their

http://www.st.com/stonline/products/support/micro/files/um0462.zip

package but it is just that. It may, or may not, work in a production environment.

There's also

http://www.er-forum.de/obd-diag-dl/index.php?action=downloadfile&filename=STM-Progger.zip&directory=Soft f%FCr Programmiertools Controller etc.&

which works well but doesn't do any advanced stuff (option bytes etc).

At the very least you could use these and sniff the serial lines to see how they work.

wojtusch
Associate II
Posted on May 17, 2011 at 14:00

Hello Stuart,

thank you for the links. There is also a Python flash tool: http://tuxotronic.org/wiki/projects/stm32loader

It's open source, so no sniffing necessary 🙂

Anyway my problem is, that I can't receive any ACKs and NACKs, because I just have a half-duplex connection. So I have to write my own flash tool. Additionally I want to write to my device without erasing the flash memory completely.

wojtusch
Associate II
Posted on May 17, 2011 at 14:00

Hi everyone.

Is it maybe possible to get an answer from a ST representative:

Is there a possibility to write to the flash memory of a STM32 device with using the internal bootloader and with erasing just the flash memory that is needed for the new program (no mass erase) before? No write or read protection is applied to the flash memory.

Also I would like to know, if I always have to do a manual hardware reset after writing to the flash memory with the bootloader in order to leave the bootloader mode. I thought the GO command with address 0x08000000 could do that, but it doesn't work for me.

Best regards

Janis
chikos332
Associate II
Posted on May 17, 2011 at 14:00

Hi,

If you want an ST representative answer then check with your local providers/ST support division...

But anyway:

Yes, It is possible to erase only some sectors of the flash when it is not write protected, but you have to know that it takes much more time than the mass erase command.

So may be you can try with increasing your delay (I have no idea if 0.2s is enough, check the datasheet for precise timing values).

But mainly check that you have the right checksum and number of data (it is usually where we have something wrong).

If the GO command doesn't work, then it may mean that:

  - The program written in the 0x08000000 address is not correct.

  - The Go command was launched with wrong parameters (checksum, address...)

  - The IWDG is enabled and prevent the code from being run correctly.

  - The program is running but you cannot see it.

--> so start by checking if the GO command received the correct parameters and returned two ACKs (if you have oscillo, or sniffer) you can even use the Hyperterminal for that.

    then verify that your program, in 0x08000000 is running in standalone mode.

    You can also disable the IWDG option to be sure that it is not the root cause.

    then check if you are really sure that it is not running (led blinking, IO toggling, send uart message....).

Cheers.

wojtusch
Associate II
Posted on May 17, 2011 at 14:00

Hello Chikos,

thank you for your replay. I thought it's a ST forum and my ST distributor refered me to the ST website with that problem. That's why I asked for a representative...

Anyway, your answer helped me a lot. I totally underestimated the time that is needed to erase single pages. According to the datasheet it takes max. 40ms per page. With erasing 124 pages that results in almost 5 seconds (!). Increasing my delay solved the erase and go command problems.

So, thanks a lot for your advice 🙂

Best regards

Janis
josembarros
Associate
Posted on May 17, 2011 at 14:00

 Hello, 

Is flash erasing necessary before programming?

I have been coding a USB HID bootloader for a high density device, it appears to be working, but I just call FLASH_WRITE without erasing!?!

Posted on May 17, 2011 at 14:00

>>Is flash erasing necessary before programming?

It is certainly required for the original serial port version, as both the read and write byte functions permit random access to the memory. And you should probably also only write even numbers of bytes, at even addresses.

One would imagine the USB versions would need to perform mass or selective erases, as there are many situations where you'd only want to write specific portions of the memory and not have it erase everything all the time.

If you, or the OP don't like how the standard boot loader function it is relatively easy to upload and execute a custom loader in RAM provided the device hasn't been locked down.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
davidmodulartech
Associate III
Posted on July 06, 2016 at 22:09

I have been programming an STM32f103, to get used to it and begin development. I was advancing pretty well, had the GPIO working, SysTick interrupting and a basic time-banding system working.

 

Then for some reason I was presented with the page (on the bootloader demonstrator) asking me to bulk erase memory. Not sure how I got there, (Pressed buttons too fast?? Not sure).

So with no other option (resetting, unplugging etc. didn't help) I bulk erased. Reset the board and proceeded to download my program.

Downloaded fine. I even uploaded to make sure it was actually writing and the code seems fine. But....

The program doesn't work now...

The board I'm using came with some other software on it, undocumented. Did it have some other functionality enabled that I hadn't (needed) to load??

Anyone have any ideas?

Posted on July 06, 2016 at 22:53

As a general rule I'd like to avoid reopening dormant threads from 2010, please open a new thread even if it is on-point, and cite the old thread where/if relevant.

The F103 is a chip, I have no idea what board you are using, or what additional firmware might be on it. If your code is not built to reside at 0x08000000 then assume there is other code on the chip. Make sure you pull BOOT0 Low so it runs your code, and not that of the ROM based System Loader.

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