Flashing STM32 using J-Flash ARM

Last time, we covered the topic of 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.

STM32 with J-link

J-Link software

You can download the latest J-Link software from the Segger Download page. You will be asked for an adapter serial number which can be found on the backside of the 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.

 J-Flash ARM

You can see project details along with Flash contents to be uploaded and LOG messages in the main window. If you have already connected your J-Link adapter to the ARM board, you can load compiled binary in an accessible format like .hex, bin, etc.

J-Arm load compiled binary

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 be accessed through the Target menu:

J-Flash ARM target menu

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

You can also 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:

Project settings of J-Flash

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 to the 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 the 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 on 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