The MCU-Link is a $10 CMSIS-DAP capable debug probe which works out-of-the box with the MCUXpresso Eclipse based IDE. This is great for development, but how can I programming with the push of a button or a script? The answer is no: there is an easy way to use the debug probe outside Eclipse from a shell script, and you can use that MCU-Link probe to do the job. This is especially useful as with the example below where I have to program 60 boards this week-end :-).
The idea is to use the existing infrastructure: no need to install extra plugins, no need to mess up with installing other frameworks or programming languages. Simply use what I already have installed.
Double-click on .launch file to edit it. This opens the settings. Go the ‘GUI Flash Tool’ and turn on ‘Preview command’:
This will trigger a dialog with the command line used for the flash tool. Apply the settings and close the dialog.
With the project selected, use the desired operation, for example programming the flash:
Another way is to get the command/script from the GUI Flash Tool:
This is useful for example to program a binary file (see Using Eclipse to Program Binary Files to an Embedded Target ):
This now opens a preview dialog:
The beauty of this is that I don’t have to find the correct parameters, the settings of the device or other complicated steps to get the job done: It is basically using what I have used to program the board during development, but as command line script :-).
Select the shell script to be used:
Then copy the script to the clipboard:
Store the content to a script/batch file:
I noticed a problem if the workspace folder has spaces. Because the path variable is double-quoted and the string combination is double-quoted too, it leads to a wrong path:
What I did was removing the double-quotes from the variables in my script.
Finally run the script from the command line shell:
That way I can easily program a larger batch of my boards without the need to run Eclipse or a GUI.
The MCUXpresso IDE already has everything built-in to provide standalone programming from the command line shell. I get the script files from the IDE and then can use and tweak them in my scripting environment. This does not only work for the MCU-Link, but any supported debug probe such as the P&E Multilink and the SEGGER J-Link. So that way I can easily do a batch programming of many boards. If tapping more into a production environment, I recommend that you have a look at the Cyclone solutions from PEMicro or the SEGGER Flasher, as that way you even don’t need a host PC.
Happy flashing 🙂
- MCU-Link Debug Probe: New MCU-Link Debug Probe from NXP
- Community discussion: https://community.nxp.com/t5/Kinetis-Microcontrollers/Flash-tool-SWD-JTAG/m-p/1183765
- Debugging LPC in command line mode: https://community.nxp.com/t5/MCUXpresso-General/Debug-LPC54628-in-command-line-using-linkserver-and-gdb-without/m-p/846003
- Using command line tool: https://community.nxp.com/t5/LPCXpresso-IDE-FAQs/Using-the-command-line-flash-programming-tool/m-p/474743
- Using Eclipse to program binaries: https://mcuoneclipse.com/2017/05/06/using-eclipse-to-program-binary-files-to-an-embedded-target/