Flashing STM32 using J-Flash ARM

Last time we have covered the topic about flashing STM32 microcontrollers using the bootloader, which is the most comfortable and cheapest way of loading programs into MCU memory. But this isn’t the only way of doing this.

The firmware can also be downloaded using the JTAG adapter, which is also used for debugging. This time we are not digging into debugging but staying only with programming.

J-Link software

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 that are used for various purposes. We are going to use J-Flash ARM for flashing microcontrollers using J-Link Adapter.

J-Flash ARM is a GUI interface that allows easy connection to ARM microcontrollers. It supports most of the ARM microcontrollers including ARM7/9/11 and Cortex-M0/M3. Programming speed reaches up to 150kB/s.

Let us start J-Flash ARM to give it a try.

In the main window, you can see project details along with 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 accessible format like .hex, bin, etc.

Programming ARM via JTAG

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 it is done:

To start your program without hitting the reset button, you can go to menu Target->Start Application or hit an F9 keyboard key.

Other features of J-Flash

Let us go quickly through other things you can do with J-Flash ARM. Almost all fun can accessed through 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 adapter.

Project settings of J-Flash

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 by running it in the target board. But if you have one, it can serve both purposes.

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

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.