Using Eclipse to Program Binary Files to an Embedded Target

I’m using Eclipse based IDE’s to develop and debug my embedded applications. This works great, as Eclipse has all the necessary tools to edit, build and debug it. But when it comes just to download/flash a binary to the board, then things are pretty much specific to the tools used. With the advent of the new MCUXpresso IDE, here is how that Eclipse IDE can be used for this.

LinkServer GUI Flash Programmer

LinkServer GUI Flash Programmer

Outline

The normal way in Eclipse to download a binary to the target is to use the debugger with a so called launch (or debug) configuration. That launch configuration needs a ‘project’, so programming a board without a project is not the usual thing. But there are ways how to download and program an application without a project. I show this here with using the NXP MCUXpresso IDE (V10.0.0), but some ways are applicable say using the Kinetis Design Studio (V3.2.0) or if using the GNU ARM Eclipse plugins.

Binaries

There are different file formats which can be used to program a microcontroller:

  • ELF/Dwarf: This is the normal output format of the linker. Typical extensions are .elf, .abs or .axf (ARM eXecutable File). This file format has the code and data, plus the debug information (which is *not* downloaded to the target and only used for debugging).

That ELF/Dwarf file usually gets converted into different binary formats more suitable for programmers or boot loaders, and they do not include the debug information:

  • S19/S-Record: textual file format (type, address, size, code, checksum). Typical extensions are .s19, .srec or .sx
  • Intel Hex: textual file format (similar representation as S19). Typical extension is .hex
  • Binary: In this format, the data is written in binary form, without address information. It is basically a ‘memory dump’.

Each format has its own pros and cons, see “S-Record, Intel Hex and Binary Files” for a more detailed overview.

To generate the different formats:

Using LinkServer GUI Flash Programmer

With using the MCUXpresso IDE, there is a LinkServer GUI Flash Programmer (see “Using the LPCXpresso V2/V3 Boards to Debug an external Board“):

LinkServer GUI Flash Programmer

LinkServer GUI Flash Programmer

In that dialog I simply can specify the binary I want to download. But there are the following restrictions:

  • Only ELF/Dwarf and binary files supported (e.g. no S19 or Intel Hex files)
  • Only works with the NXP LinkServer debug connection (LPC-Link, LPC-Link2, CMSIS-DAP) (e.g. no support for Segger J-Link or P&E Multilink)

Using Launch Configuration

The other approach is to use a launch configuration. This actually would be the same as using a normal debug session.

💡 In Kinetis Design Studio V3.2.0 there is a ‘Flash from file’ toolbar button. It is basically the same as using a special launch configuration. As it might interfere with the normal Eclipse launch configuration, I’m not using that way any more.

To create a new launch/debug configuration, I can duplicate an existing one (matching my device):

Duplicate Launch Configuration

Duplicate Launch Configuration

P&E

For a P&E debug connection (MCUXpresso IDE or e.g. Kinetis Design Studio), specify a dummy project and the binary to download (use the ‘Browse’ button:

PnE Binary to Download

PnE Binary to Download

All types of files (ELF/Dwarf, S19, Binary and Intel Hex) are supported by the P&E launch configuration.

In the startup options I have to disable the debug (symbols) usage. Alternatively I could specify the binary file here too:

PnE Startup Options

PnE Startup Options

Then I can use the normal ‘debug’ which will use that binary file specified to be programmed. If I want only to download and skip the ‘debug’ step, then I can use the approach described in “Emulating Eclipse ‘Run’ with ‘Debug’ Configuration“.

Segger (GNU ARM Eclipse)

The same approach is used for the Segger J-Link debug connection (Kinetis Design Studio, or with the GNU ARM Eclipse plugins installed in MCUXpresso IDE, see “MCUXpresso IDE: Importing Kinetis Design Studio Projects“).

Specify the binary file in the Main tab:

Binary File in Segger Launch Configuration

Binary File in Segger Launch Configuration

The following files are supported: ELF/Dwarf, S19 and Intel Hex.

In the ‘Startup’ settings disable loading the symbols:

Segger Startup Tab

Segger Startup Tab

Using the same approach for Binary files will produce an error. Alex from Segger (thanks!) provided me a way how to load binary files:

Specify a dummy (valid) ELF/Dwarf file:

Dummy ELFDwarf File

Dummy ELF/Dwarf File

In the Startup tab, disable ‘Load Symbols’ and ‘Load Executable’. Use the

monitor loadbin <file name>

to load the file.

💡 I tried using Eclipse variables as ${project_loc} instead of using an absolute path to the binary, but this somehow can lock the debug session (not sure why). Using an absolute path worked for me.

Have ‘Set Program counter’, ‘Set Breakpoint’ and ‘Continue’ disabled:

Loading Binary

Loading Binary

Summary

Currently users of the GNU ARM Eclipse plugins (e.g. Kinetis Design Studio, or if you install them into MCUXpresso IDE) have the most flexible options to download binaries to the target. For the GNU ARM Eclipse plugins and the P&E plugin all what I need is to specify the binary file.

If using the standard MCUXpresso IDE V10.0.0, then there is the LinkServer dialog which supports the LPC-Link2/Link connections. For P&E the support is the same as with the GNU ARM Eclipse Plugins. For Segger I can install the GNU ARM Eclipse plugins or to use the Segger external tools to download binaries.

Because ‘programming binary files’ is not a standard feature of Eclipse, every vendor comes up with its own ways. If such an option or extension is not present, you still can try using a normal launch configuration, but the debug plugin has to accept a binary without debug information. Or use an external tool outside Eclipse.

Happy Binaring 🙂

Links

Advertisements

4 thoughts on “Using Eclipse to Program Binary Files to an Embedded Target

  1. Thanks. A good pointer. I sometimes want to program a newly built test image. The scenario is that as part of my workflow when submitting a Git PullRequest, I build a new project/directory instance from the baseline Git. And then merge the changes I want to a PR branch and build test. At the end I have an image which I need to do some integration testing with – but its difficult to program through KDS/JTAG without a new project.
    BTW there is a new BlackMagicProbe/JTAG (BMP) completed from KickStarter – I received one this week, but haven’t tried it yet

    https://gitter.im/1bitsy/Lobby?source=orgpage
    https://1bitsy-and-black-magic-probe.backerkit.com/

    Like

    • Yes, I had looked at that Black Magic probe, and my thinking was ‘oh, yet another debug probe without the required software/debugger’. Maybe it will be different for that one, but my experience with that kind of things was not good. Doing a SWD/JTAG probe is not hard. Supporting all the different microcontrollers is the hard thing: flash programming, memory map, exception handling, hardware breakpoints, security and flash protection settings, etc.
      Let us know how it works!

      Like

  2. I am trying to recover FRDM-K22F OpenSDA firmware using Kinetis studio and Multilink FX, however J12 on board is set for JTAG programmer. Can I program chip without using SDA_JTAG_TDO and SDA_JTAG_TDI pins. Before I dropped to Bootloader in Windows 10: from ARMmbed: 0221_k20dx128_k22f_0x8000.bin
    from Pemicro: MSD-DEBUG-FRDM-K22F_Pemicro_v114.SDA
    from NXP: mbedWinSerial_16466.exe
    Which one to use?

    Like

What do you think?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s