DZone
IoT Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > IoT Zone > Generating Intel Hex Files Based on a Given Length Using Srec_Cat

Generating Intel Hex Files Based on a Given Length Using Srec_Cat

Learn more about standard binary files and how you can control data based on length with Intel Hex.

Erich Styger user avatar by
Erich Styger
·
Jul. 03, 19 · IoT Zone · Tutorial
Like (3)
Save
Tweet
13.88K Views

Join the DZone community and get the full member experience.

Join For Free

The 'standard' binary files for many tools are S19, binary, or Intel Hex files. Especially for S19 and Intel Hex, it can be useful to control the amount of data per line. By default, the GNU objcopy creates files with a line length of 44 characters:

Image title

Default objcopy binary file line length

But it is possible to have Intel Hex files with a custom line length using the SRecord utility, and this is what this article is about.

First, use the GNU ' objcopy' to generate a Intel Hex file (or use the MCUXpresso IDE for this). The following line generates the Intel Hex file from an ELF/Dwarf (.axf) file:

arm-none-eabi-objcopy -v -O ihex app.axf app.hex


This generates a 'default' Intel Hex file with a line length of 44 characters:

Image title

Default objcopy binary file line length

Then, use the srec_cat tool from the SRecord package with the  -line-length option:

srec_cat app.hex -intel -output new.hex -Intel -line-length=64


With this, I have an Intel Hex file with a different line length — in this case, 64 characters:

Image title

Intel Hex File with longer lines

That's it!

The SRecord tools are very versatile to convert and manipulate binary files. To learn more, have a look at the links below.

Happy Inteling!

Links

  • SRecord Tool on SourceForge
  • GNU objcopy
  • MCUXpresso IDE: S-Record, Intel Hex, and Binary Files
  • Converting Binary Files to Intel Hex Format with the SRecord Tool
  • S-Record, Intel Hex, and Binary Files
  • Merging S19 Files wir srec_cat

Published at DZone with permission of Erich Styger, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Top 5 Programming Languages in AI: A Comparison
  • How To Use Open Source Cadence for Polling
  • Legacy Modernization and Hybrid Cloud with Kafka in Healthcare
  • Which JVM Version Is the Fastest?

Comments

IoT Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo