Eclipse based IDE’s have typically one limitation: the IDE has not much scripting capabilities. Yes, I can use things like JUnit for testing, but if it comes to build and debug C/C++ applications, then support gets really rare. An exception to this is CodeWarrior for MCU which features a command line version of the IDE which can be used for test automation as I used it in one of my tutorials. What I missed so far is to have a command line interface for Processor Expert to generate code. This is now possible with CodeWarrior for MCU10.5 :-).
Eclipse Command Line Options
Inside the CodeWarrior Eclipse folder, there three executables I can use for Eclipse as a command line version:
- cwide.exe: this is what I typically launch from a shortcut. It can be used with command arguments too.
- cwidec.exe: similar to cwide.exe, but it waits until the IDE closes. Useful for batch processing, see CodeWarrior Flash Programming from a DOS Shell
- ecd.exe: this is used to build projects from the command line.
ecd.exe
ecd.exe is used to generate make files and build projects. The command is described in the online help under
CodeWarrior for Microcontrollers V10.x > Common Manuals > CodeWarrior Common Features Guide > IDE Extensions
cwide.exe and cwidec.exe
The cwide.exe and cwidec.exe can be started to execute a debugger shell script (CodeWarrior Flash Programming from a DOS Shell), e.g.
cwide.exe -vmargsplus -Dcw.script=D:\my_script.tcl
The cwidec.exe and cwide.exe (or any Eclipse) have an -application option which let me execute Processor Expert from the command line:
- -application <plugin>: executes a plugin. For Processor Expert com.freescale.processorexpert.core.PExApplication has to be used.
-application is one of the Eclipse platform runtime/command line options described here.
The Processor Expert plugin accpets two options:
- -generateAll: generates Processor Expert code for all projects in the workspace.
- -generate <projectName>: only generates for the given project.
The command line accepts any other Eclipse standard command line arguments. Common ones are:
- -noSplash: do not show splash screen
- -data: workspace to be used
- -showlocation: show workspace in title bar
Generating Processor Expert Code from Command Line
To generate Processor Expert code for my project ‘Frdm’ present in my workspace located in c:\tmp\wsp_10.5, I use the following command line
cwidec.exe -noSplash -data c:\tmp\wsp_10.5 -application com.freescale.processorexpert.core.PExApplication -generate Frdm
This will give something like this:
💡 There are several warnings I can ignore, as my code is properly generated 😉
With this, I can automate Processor Expert code generation :-).
Summary
With the -application Option I can now automatically generate and build Processor Expert projects from batch files. This is very useful for testing and automated building: I can check out my projects from a version control system, generate code, build it, download it, and debug it, all automated 🙂
Happy Generating 🙂
Hi Erich, I am having a problem with generating the PEx components from a command line when my project uses the Segger_RTT component. The errors I receive are:
com.freescale.processorexpert.core: Loading KDS3 project components – component “My Components/SeggerRTT UUID: version:01.022” was not found/selected from any repository!
com.freescale.processorexpert.core: Loading KDS3 project components – component “My Components/Wait UUID: version:01.067” was not found/selected from any repository!
com.freescale.processorexpert.core: Loading KDS3 project components – component “My Components/KinetisSDK UUID: version:01.001” was not found/selected from any repository!
Can you recommend any changes to the command line that would allow this to work? If I launch KDS and build there, everything is fine. The only clue I have been able to find is that the .PE file refers to a variable called “home_ProcessorExpert_loc”. I have been unable to find this anywhere on my system. I have grep’d and checked system setttings, as well as KDS properties, and don’t see it.
Thank you!
LikeLike
Hi Dave,
are you already using the –launcher.ini option (see https://mcuoneclipse.com/2014/09/12/building-projects-with-eclipse-from-the-command-line/)?
LikeLike
No, thank you, I missed that! I will have a look.
LikeLike
I used –launcher.ini and passed it my KDS ini path, but I still get the error indicating that it cannot find the RTT component. Is there a way to see what repositories eclipse knows about from the command line?
LikeLike
The Processor Expert repositories are listed in the workspace settings afaik, see https://mcuoneclipse.com/2015/07/06/processor-expert-component-repositories/. But it always should find the ‘legacy’ one as this was used before the time of the new repositories.
LikeLiked by 1 person
Does this work with newer KDS like 3.2.0?
For me the code generation just hangs and process never exits:
C:\Program Files (x86)\Jenkins\workspace\Tatra\FracView-PS>”c:\Freescale\KDS_
v3\eclipse\eclipsec.exe” –launcher.suppressErrors -nosplash –launcher.ini “c:\
Freescale\KDS_v3\eclipse\kinetis-design-studio.ini” -data “C:\Program Files (x86
)\Jenkins\workspace\KDS” -application com.freescale.processorexpert.core.PExAppl
ication -generateAll
Opening project Tatra …
generating
Does anyone know the solution?
LikeLike
Yes, it should work the same way with KDS. I have not used it recenlty, but I have used it with KDS too.
LikeLike
Unfortunately, I cannot get it working with KDS 3.2.0. Tried on few computers, same result. It just hangs after “generating”. This is frustrating, as I wanted my projects to be build by Jenkins.
LikeLike
Hi Matt,
ok, I’ll give it a try tomorrow and report back.
LikeLike
Hi Matt,
I gave it a quick try, and it works fine on my side:
C:\nxp\KDS_3.2.0\eclipse>eclipsec.exe -noSplash -data c:\tmp\wsp_kds_3.2.0 -application com.freescale.processorexpert.core.PExApplication -generate MyProject
Opening project MyProject ...
generating
generation finished
project closed
C:\nxp\KDS_3.2.0\eclipse>
LikeLike
Well, I also tried to create few small projects and they generate without problems. Something is wrong with my projects, they hang during generation. Maybe I will try to recreate them from scratch and see if it helps. Thank you for your help.
LikeLike
OK, I think I found what is wrong. I don’t keep static_code directory in my repository. It seems that this is the problem. When I have static_code directory I have no problems with generating code from console. Maybe it tries to show dialog window like it does when using GUI(it shows a windows “do you want to synchronize static code” or something like that, after PE code generation)?
LikeLike
Hi Matt,
yes, you have to have the Static_Code directory present in your repository. That directory and its files get created at project creation time, but not re-recrated if you delete it. Not sure why, but that’s why I have it always (I hope) present in the repo.
LikeLike
Erich,
It seams that the command you use assumes that there is a workspace with the project imported into it. I am attempting to automate my builds on a server, but I do not check my workspace into Git. I am assuming I would have to create a workspace before generating the Processor Expert code. Do you know how to generate the workspace from the command line?
Thanks for your great site!
Frank
LikeLike
Hi Frank,
The workspace (.metadata) never should be pushed to git! And this is not necessary, as if you specify a workspace path, if it does not exist, Eclipse will create it. And you can import project from the command line, see https://mcuoneclipse.com/2017/08/03/building-eclipse-and-mcuxpresso-ide-projects-from-the-command-line/
LikeLike
Do you know of a way to define a C/C++ symbol (i.e. -DMY_DEFINE=123) when using ecd.exe?
LikeLike
Hi Frank,
not to my knowledge. But you could define a symbol on the host system level (environment variable) and then use it. Not ideal, but should work.
LikeLike