DZone
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
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
The Latest "Software Integration: The Intersection of APIs, Microservices, and Cloud-Based Systems" Trend Report
Get the report
  1. DZone
  2. Software Design and Architecture
  3. Integration
  4. MCUXpresso IDE: S-Record, Intel Hex, and Binary Files

MCUXpresso IDE: S-Record, Intel Hex, and Binary Files

Post build steps let you customize actions after the build phase. The MCUXpresso IDE offers a versatile way to generate binary, S19, or Intel Hex files using those steps.

Erich Styger user avatar by
Erich Styger
·
Apr. 24, 17 · Tutorial
Like (0)
Save
Tweet
Share
7.54K Views

Join the DZone community and get the full member experience.

Join For Free

This is another article about the NXP MCUXpresso IDE (see MCUXPresso IDE: Unified Eclipse IDE for NXPs ARM Cortex-M Microcontrollers), this time it is about Post-build steps. Post-build steps are custom actions that can be executed after the build (or link phase), and are typically used to generate S-Record, Binary or Intel Hex files (see S-Record, Intel Hex, and Binary Files).

Post Build Steps Details

Post Build Steps Details

This article is part of a series to get up to speed using the new NXP MCUXpresso IDE. Published so far are:

  • MCUXpresso IDE: Unified Eclipse IDE for NXPs ARM Cortex-M Microcontrollers
  • MCUXpresso IDE: Adding the Eclipse Marketplace Client
  • MCUXpresso IDE: Importing Kinetis Design Studio Projects
  • MCUXpresso IDE: Installing Processor Expert into Eclipse Neon

Outline

Post build steps are part of the Eclipse CDT build tool's integration. If using the GNU ARM Eclipse plugins as in Kinetis Design Studio, then it offers check boxes to run pre-configured post build steps, e.g. for creating flash image files or printing the code size.

This post shows how to do the same in the MCUXpresso IDE, either using post build steps or using a context menu on the executable file.

The post build steps can be found under the C/C++ Build project settings, under the ‘Build Steps’ tab.

Post Build Steps

Post build steps

Pressing the ‘Edit’ button opens a dialog where I can edit the actions:

Post Build Steps Details

Post Build Steps Details

The default probably shows the following:

arm-none-eabi-size "${BuildArtifactFileName}"
# arm-none-eabi-objcopy -v -O binary "${BuildArtifactFileName}" "${BuildArtifactFileBaseName}.bin"
# checksum -p ${TargetChip} -d "${BuildArtifactFileBaseName}.bin"


The first command (arm-none-eabi-size) prints code size information (see text, data, and bss: Code and Data Size Explained), with an output something like this in the console view:

   text       data        bss        dec        hex    filename
 540764        344      37032     578140      8d25c    MK64FN1M0xxx12_Project_Demo.axf


If there is a line starting with ‘#’, then everything following that will be ignored: That line plus all the lines which follow. Remove the ‘#’ to have the command executed.

To generate a binary file, use

arm-none-eabi-objcopy -v -O binary "${BuildArtifactFileName}" "${BuildArtifactFileBaseName}.bin"


To generate a S19/Motorola S-Record (see “xxx”), use the following:

arm-none-eabi-objcopy -v -O srec "${BuildArtifactFileName}" "${BuildArtifactFileBaseName}.s19"


To generate Intel Hex, use the following:

arm-none-eabi-objcopy -v -O ihex "${BuildArtifactFileName}" "${BuildArtifactFileBaseName}.hex"


A description of all options for the GNU objcopy program can be found in https://sourceware.org/binutils/docs/binutils/objcopy.html

To change the length of S19 lines, the option...

--srec-len <length>


... is useful, e.g. –srec-len 128. See S-Record Manipulation with GNU objcopy and Burner Utility.

I can use multiple commands, such as the example below, which will produce S19, Intel Hex, and Binary files:

Generating binary, s-record and intel hex files

Generating binary, s-record and Intel hex files

The command execution can be checked in the console view:

Output to Console

Output to Console

The files get generated into the build output folder:

Output Folder

Output Folder

Other than that, have a look at the (excellent) electronic documentation, using the menu Help > MCUXpresso IDE User Guide:

MCUXpresso User Guide

MCUXpresso User Guide

Then you search for what you are looking for:

Help about post build steps

Help about post build steps

Binary Utilities

If I only need a binary or Intel Hex file right away without using a post build step, I can use the ‘Binary Utilities’ menu. It does not have the ability to generate S19 files, but is otherwise very useful:

Binary Utilities

Binary Utilities

 Make sure you select a binary (ELF/Dwarf .afx) file, otherwise the menu does not show up.

The interesting thing is that these menus are configurable, under the menu Window > Preferences > MCUXpresso IDE > Utilities:

Utility Menu Settings

Utility Menu Settings

I cannot add more menu entries, and I cannot change the menu name. But I can change the menu action. So if I would like to create the S19 file instead of the intel hex, I can change that entry. Or I can execute multiple commands separated by a semicolon:

arm-none-eabi-objcopy -O ihex "${FileName}" "${FileBaseName}.hex"; arm-none-eabi-objcopy -v -O srec "${BuildArtifactFileName}" "${BuildArtifactFileBaseName}.s19"


 Make sure to use a semicolon *plus a space* as separator. A semicolon alone will give an error message.

Creating both Hex and S19 Files

Creating both Hex and S19 Files

 The settings are part of the workspace settings, so if you want this for multiple workspaces, you have to export/import the settings or do it in each workspace.

The MCUXpresso IDE has a versatile way to generate binary, S19, or Intel Hex files using post-build steps. For creating hex and binary files ‘ad-hoc’, I can use the Binary context menu on the ELF/Dwarf executable file. As a bonus feature, I can change the Binary Utilities commands.

And if you want to generate more advanced files or generating complex checksums, have a look at the ‘SRecord’ tool described in my other article: CRC Checksum Generation with ‘SRecord’ Tools for GNU and Eclipse.

Happy Hexing!

Links

  • MCUXpresso IDE web page: http://www.nxp.com/mcuxpresso/ide
  • MCUXpresso IDE community: http://www.nxp.com/mcuxpresso/ide/forum
  • MCUXpresso Config tools and SDK: https://mcuxpresso.nxp.com/
  • GNU Objcopy: https://sourceware.org/binutils/docs/binutils/objcopy.html
Integrated development environment Build (game engine) POST (HTTP)

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

  • Data Stream Using Apache Kafka and Camel Application
  • Master Spring Boot 3 With GraalVM Native Image
  • Kubernetes-Native Development With Quarkus and Eclipse JKube
  • 10 Most Popular Frameworks for Building RESTful APIs

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • 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: