Flashing STM32 using J-Flash ARM

Last time we have covered topic about flashing STM32 microcontrollers using bootlaoder. This is easiest and cheapest way of loading programs to MCU memory. But this isn’t the only way of doing this. Software can also be downloaded to using JTAG adapter which is used for debugging. This time we are not digging into debugging but staying only with programming.

You can download latest J-Link software from Segger Download page. You will be asked for adapter serial number which can be found on back side of J-Link adapter. Once installed you will get a bunch of programs used for various purposes. We are going to use J-Flash ARM which is used for programming microcontrollers using J-Link Adapter. J-Flash ARM is a GUI interface that allows easy work with ARM microcontrollers. It supports most of ARM microcontrollers including ARM7/9/11 and Cortex-M0/M3. Programming speed reaches up to 150kB/s.

Lets start J-Flash ARM to give it a try.

This is main window where you can see project details, Flash contents to be uploaded and LOG messages. If you have already connected your J-Link adapter to ARM board you can load compiled binary in any popular format like .hex, bin, etc.

Once loaded you will see its contents in a window. Next you can go directly to menu Target->Program&Verify. Adapter will automatically connect to target and initiate programming. If programmed memory area isn’t empty you will be asked if you need to erase overwritten area:

Usually you would go with Yes.

After couple of seconds its done:

To start your program without hitting reset button you can go to menu Target->Start Application or hit F9 keyboard key. This is it for basic programming. Lets go quickly through what else we can do with J-Flash ARM. Almost all fun can be reached within Target menu:

Here you can see a Test function where you can test programming and reading speed. Here is my test results:

Also you can secure or un-secure chip, check blank, fill flash memory with zeros, erase chip, verify and so on. These are basic functions that you would expect from programmer.

If you want more control on you programming then you can change project settings. To enter settings menu you should go to Options-Project Settings. Here you will find several settings tabs. General, Target interface, CPU, Flash and Production:

For instance in Target Interface you will be able to select JTAG or SWD and speeds before initialization and after initialization. Normally leave them to Auto to be safe. In CPU settings you can select your device manually. Also you can add some actions in to init sequence. Bu default there is a reset signal sent. But you for some reason may do other stuff like adding delay. Production settings allow to select some robust tasks when programming chips for production. Here you can even program device serial number in to selected memory location.

Normally for prototyping you don’t need to change any settings. It works fine out of the box. As you know normally JTAG adapters are meant to be more than just programmers. Their main purpose is debugging software. But if you have one it can serve both purposes.

Couple more flashing methods: Embedded Bootloader and Using ST-Link Utility

Leave a Reply

Your email address will not be published. Required fields are marked *