Using Linux Shell Commands on Windows with MCUXpresso Pre-/Post-Build Steps

In “Touch & Build: Auto-Update of Firmware Date and Time” I’m using commands as ‘touch’ in a pre-build script with the NXP Eclipse based MCUXpresso IDE. That ‘touch’ command is not a Windows shell command, but common on Linux: it updates the time/date of a file.

Build Step Dialog in MCUXpresso IDE

Build Step Dialog in MCUXpresso IDE

As a Windows user you might wonder what is about this ‘Linux compatible shell’?

It is actually the ‘sh.exe’ located in

<IDE Installation>\ide\buildtools\bin
sh executable

sh executable

The files are actually from the Eclipse Embedded CDT (GNU MCU Eclipse Windows Build Tools). It comes with a bunch of utilities to make cross platform development easier on Windows as many scripts depend on Linux tools, and for this they are provided in this package.

So what commands and tools can I use? A simple way to find out is to run the sh.exe in a Windows cmd shell and type the command ‘help’:

sh in Windows cmd

sh in Windows cmd

To find out more about the commands:

  • type the command
  • or type the command with the option -h
  • use the Linux man pages 🙂
help

help

That’s it 🙂 With this I can do powerful things in the including doin hexdumps, moving files or creating new ones, calculating checksums or doing a ftp or scp (secure copy) to transfer the binary file to a remote host:

post build step with scp in MCUXpresso IDE

Happy Shelling 🙂

Links

2 thoughts on “Using Linux Shell Commands on Windows with MCUXpresso Pre-/Post-Build Steps

  1. I use MCUXpresso post-build scripting to create downloadable firmware package with a SHA256 digest added, and for making factory firmware by calling a PEMicro script that uses a .dll file to create and name the .sap file for a Cyclone programmer, as well as to get the CRC for that file. I could even copy those build artifacts to where they’re needed, if I wanted to.

    The Linux utilities appear to be provided by busybox, so commands may not have all the options available that you want. I haven’t tried this, but I imagine you could build your own version of busybox with the options you want to use, if they’re not already availabole.

    Liked by 1 person

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.