Skip to main content
erussell
Associate III
April 26, 2020
Question

Convert elf file into an srec file

  • April 26, 2020
  • 4 replies
  • 4466 views

I am using STM32CubeIDE, version 1.2.0.

 I want to convert the elf file into an srec file with a particular format.

I have tried editing the command line in the Post-build steps to read:

arm-none-eabi-objcopy.exe -O srec —srec-len=28 —srec-forceS3 “$(BuildArtifactBaseName).elf�? “$(BuildArtifactBaseName).s19�?

A file is generated with the .s19 extension but the file contents are in the Intel hex format.

I have also tried to select the box in Tool Settings/ MCU Post build outputs window labeled “Convert to Motorola S-record�? and I get the same result. The generated file has the .srec extension but the format of the file is Intel hex.

Has anyone figured out the correct way to do this?

Thanks

This topic has been closed for replies.

4 replies

waclawek.jan
Super User
April 26, 2020

@objcopy is part of the binutils project, so you perhaps might want to raise a complaint there... But I don't believe that is a viable path.

You might try some of the ARM-built GNU binaries.

Also, are you sure CubeIDE executes your command line? Also, do the double-dash options start with double-dash? Here I see something different, but that may be the idiotic salesforce autocorrecting editor, too: ( --test) Try to run that command normally in command line.

It may be better to simply convert intelhex to srec using srecord.

JW

Tesla DeLorean
Guru
April 26, 2020

Back when the Atollic demo didn't generate hex files properly I posted a tool called FIXELF that exported in Intel and Motorola forms

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
erussell
erussellAuthor
Associate III
April 27, 2020

Those really are double dashes.

Thank you both! I will try both suggestions.

erussell
erussellAuthor
Associate III
April 27, 2020

Again, thank you both for your suggestions. They reminded me that I have access to IAR's ielftool which I have been using for years for an NXP processor. So I used that and it worked as expected.

I do suspect something wrong with the way STM32CubeIDE is handling the post build command though. While it does parse the command line (and return an error when the syntax isn't correct) it is odd that it consistently converts the elf file to intelhex format no matter what the command line reads.