Flashing STM32 using J-Flash ARM

Last time we have covered the topic about flashing STM32 microcontrollers using bootlaoder. This is the most comfortable and cheapest way of loading programs to MCU memory. But this isn’t the only way of doing this. The 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 the 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 the 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. The adapter will automatically connect to target and initiate programming. If the programmed memory area isn’t empty you will be asked if you need to erase overwritten area:

Usually, you would go with Yes.

After a couple of seconds its done:

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

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

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

If you want more control of your programming, then you can change project settings. To enter the 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. Usually, leave them to Auto to be safe. In CPU settings you can pick your device manually. Also, you can add some actions in to init sequence. By default, there is a reset signal sent. But you for some reason may do other stuff like adding delay. Production settings allow selecting some robust tasks when programming chips for production. Here you can even program device serial number into the selected memory location.

Usually, for prototyping, you don’t need to change any settings. It works fine out of the box. As you know, JTAG adapters are meant to be more than just programmers. Their primary 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