cancel
Showing results for 
Search instead for 
Did you mean: 

Using the Flash Loader Demonstrator to Load Initial Code

jwormsley2
Associate II
Posted on August 24, 2009 at 11:20

Using the Flash Loader Demonstrator to Load Initial Code

6 REPLIES 6
jwormsley2
Associate II
Posted on May 17, 2011 at 13:19

I'm using an STM32F101C8 with IAR. My code is divided into two pieces, a bootloader that is never changed and an application that can be. My bootloader looks for a new image in an external flash device, and if present flashes the cpu with that code, and if not, just jumps to the application code already present. The bootloader resides at 0x8000000 and the application at 0x8002000. The application can download new code to the external flash and a reset will program the new code via my bootloader. All this works fine and has been for months.

So far, I've been programming the initial code with the jtag port via IAR. First I load my bootloader, then the application, and I'm ready to go. But now that we're leaving low quantity beta phase and entering a production phase, I need a different way to program these devices that doesn't require IAR, or more importantly, myself to program thousands of boards. Enter the serial bootloader.

I have build a serial cable that can connect to our device, and I have a jumper to pull up the BOOT0 pin to enter the built in bootloader mode. I can use both version 1.0 and version 2.0 of the Flash Loader Demonstrator program to connect to the device. I configured IAR to output a Binary file for both the bootloader and the application (the application binary being the same one I put into my external flash so I'd like to keep that binary, but I could change my bootloader to S-Record or Hex). I tell the Flash Loader Demonstrator to erase the whole part, then load the bootloader at 0x8000000, then reset the device, then set erase only as needed and load the application at 0x8002000. Everything looks like it works fine, no errors are generated. However, the application does not start up.

Version 1.0 shows this when I connect:

Target: STM32F101xx

PID: 0410

Version: 2.1

Version 2.0 shows this when I connect:

Target: STM32_Med-density_64K

PID: 0410

Version: 2.1

I've also tried the command line version from version 2.0 and it again looks like it is working, but the application does not run. The command line I used was:

STMFlashLoader.exe -c --pn 2 --br 115200 -i STM32_Med-density_64K -e --all -d --a 8000000 --fn Bootloader.bin -d --a 8002000 --fn Application.bin

The output was this (edited for space, but all blocks have [OK]):

Connecting [OK]

Configuring [OK]

ERASING ...

erasing all pages [OK]

DOWNLOADING ...

downloading page 0 @0x 8000000 size 1.00(Kb) [OK]

...

downloading page 7 @0x 8001C00 size 1.00(Kb) [OK]

DOWNLOADING ...

downloading page 0 @0x 8002000 size 1.00(Kb) [OK]

...

downloading page 55 @0x 800FC00 size 1.00(Kb) [OK]

I loaded the option bytes from the device after flashing with IAR and they are not changed from the defaults, so I don't think that's the problem. I'm not (currently) protecting any blocks from reading or writing, and a verify operation succeeds.

As a test, I even tried combining my bootloader and application into one binary file (with the application offset 0x2000 beyond the bootloader) and that does not work, either.

Does anyone know what I'm missing?

Thanks in advance.

Jeff.

16-32micros
Associate III
Posted on May 17, 2011 at 13:19

Hi jeff,

Could you split the whole process to two Operations with the STMFlashLoader.exe batch file :

1) Erase all + Program your bootloader

2) program only your application without erase

and see if it works?

Cheers,

STone-32.

[ This message was edited by: STOne-32 on 05-08-2009 23:00 ]

jwormsley2
Associate II
Posted on May 17, 2011 at 13:19

Erase, reset the board, then load the binary data is still not working.

I'm using this batch file:

@ECHO OFF

echo Connect first board

pause

:START

STMFlashLoader.exe -c --pn 2 --br 115200 -i STM32_Med-density_64K -e --all

echo Reset board

pause

STMFlashLoader.exe -c --pn 2 --br 115200 -i STM32_Med-density_64K -d --a 8000000 --fn Bootloader.bin -d --a 8002000 --fn MDC_RTOS_1032.bin

echo Connect next board

pause

goto START

C:\PROGRA~1\STMICR~1\Software\FLASHL~1>FlashReader.bat

Connect first board

Press any key to continue . . .

Connecting [OK]

Configuring [OK]

ERASING ...

erasing all pages [OK]

Reset board

Press any key to continue . . .

Connecting [OK]

Configuring [OK]

DOWNLOADING ...

downloading page 0 @0x 8000000 size 1.00(Kb) [OK]

...

downloading page 7 @0x 8001C00 size 1.00(Kb) [OK]

DOWNLOADING ...

downloading page 0 @0x 8002000 size 1.00(Kb) [OK]

...

downloading page 55 @0x 800FC00 size 1.00(Kb) [OK]

Press any key to continue ...

Connect next board

Press any key to continue . . .

[CTRL-C]

Terminate batch job (Y/N)? y

I have found out that I can use version 1.0 with binary files now. I am not sure what changed, but I can erase, then reset and reload the app and load my bootloader, then reset and reload the app and load my application and it works. I was also able to merge my bootloader and application into a single binary and program with version 1.0. Unfortunately, I don't think I can run version 1.0 from a batch file. I don't care much which version works, as long as one does. But I have to be able to automate it so our production house can do it.

I know version 2.0 came with source code. Does version 1.0 source exist? I'd like to be able to compare the differences, and possibly write my own (eventually).

andreas2
Associate II
Posted on May 17, 2011 at 13:19

I remember reading something about a bug in the flash loader demonstrator. I don't remember the details, and I don't use it myself. Something about a ''remove all FFs'' option. Can you flash your bootloader with version 2.0 and do a verify without errors? Flash with 2.0 and verify with another method (1.0, JTAG, ...)?

For our production programming we've so far used OpenOCD with great success. That might be an option for you if you can access the JTAG pins.

mcuisp
Associate II
Posted on May 17, 2011 at 13:19

Hi jwormsley:

First, the HEX files can combine by notepad, use copy and paste, only the first '':00000001FF'' should be remove.

For anaother choice of Flash Loader Demo 2.00, my program mcuisp.exe also can used to do ISP for STM32.

For production phase, my EP868 HandHeld Flash Loader is a good tool for ISP download. It can work without connnect to PC, download more speed, with BPS up to 921600. Product SerialNo is also supported. It also support STM8S, anaother product line of ST.

James Peng

www.mcuisp.com

MSN: mcuisp@hotmail.com

[ This message was edited by: mcuisp on 22-08-2009 09:04 ]

jwormsley2
Associate II
Posted on May 17, 2011 at 13:19

James,

Thanks for the reply. I was able to use a hex editor to merge the binary images and use version 1.0 to download the resulting image properly. I haven't yet been able to get 2.0 to do so. It all looks like it works, no error messages, but the device doesn't boot. I haven't had time to do a dump and compare with JTAG yet. I'll have a look at your product and see if it might meet our needs as well.

Jeff.