Hi,
I'm trying to get the MBDT example for External Mode to work with a S32K144EVB. However, the example fails to compile when External Mode is enabled in config.
Model:
Settings used for External Mode (COM3 port, 56700 baud rate):
The error encountered during build:
Corresponding line in the makefile, I believe:
Does anybody have an idea what goes wrong here? Or any pointers how to get External Mode working?
Thanks,
John
解決済! 解決策の投稿を見る。
Hi b622402@urhen.com,
The error is caused by how Matlab generates the makefile to build the application in R2019a release. On line 651 in extmode_s32k14x.tmf it creates a rule with spaces in the prerequisites part, "C:\Programs Files\MATLAB\R2019a\...". That rule is generated automatically by Matlab to build a required Matlab C source file rtiostream_utils.c.
I am still investigating why Matlab generates this strange rules in R2019a.
For now, as a workaround you can move Matlab to C:\MATLAB\R2019a or some other path without spaces.
Hi b622402@urhen.com,
The error is caused by how Matlab generates the makefile to build the application in R2019a release. On line 651 in extmode_s32k14x.tmf it creates a rule with spaces in the prerequisites part, "C:\Programs Files\MATLAB\R2019a\...". That rule is generated automatically by Matlab to build a required Matlab C source file rtiostream_utils.c.
I am still investigating why Matlab generates this strange rules in R2019a.
For now, as a workaround you can move Matlab to C:\MATLAB\R2019a or some other path without spaces.
This problem is still happening in Matlab R2019b.
Has anyone reported this in a service request to Mathworks?
It is a miserable problem that will affect a big proportion of MBDT users.
Has anyone found a less painful fix besides a complete re-install of Matlab + MBDT + add-ons?
I reported the issue to Mathworks. It was confirmed a known problem in R2019a, R2019b, and R2020a.
"Yes this is an identified issue that the build fails when the file path contains spaces."
"I have checked internally that changes have been made in the recent MATLAB R2020b release. Now instead of expanding the path, the generated makefile will stay with tokenized path, and thus resolves this issue."
It is true that re-installing Matlab on a path without spaces in the directory names is a workaround.
However, a less disruptive workaround is described below.
The following describes how the build process can be customized:
https://www.mathworks.com/help/rtw/ug/customizing-the-target-build-process-with-the-stf-make-rtw-hoo...
Look for the m-file *_make_rtw_hook.m In my case I found two matches:
.\AppData\Roaming\MathWorks\MATLAB Add-Ons\Toolboxes\NXP_MBDToolbox_S32K1xx\mbdtbx_s32k_as\mbd_s32k_as_make_rtw_hook.m
.\AppData\Roaming\MathWorks\MATLAB Add-Ons\Toolboxes\NXP_MBDToolbox_S32K1xx\mbdtbx_s32k\mbd_s32k_make_rtw_hook.m
Setting a breakpoint showed only the second script was run in my case, but I applied the fix to both.
Look for the contents of the case statement: case 'before_make'
Mathworks suggested adding the following code [to the end] of the code block for that case option:
% --- Fix for External Mode Build Error ---
files = {buildInfo.Src.Files.FileName};
filesToRemove = {'rtiostream_utils.c'};
removeIdxs = cellfun(@(x) strcmp(files,x), filesToRemove,'UniformOutput',false);
removeIdx = any(cell2mat(removeIdxs'),1);
if (~isempty(files(removeIdx)))
buildInfo.Src.Files(removeIdx).Path = '';
end
The filename in bold (above) must match the filename on the troublesome code on Line 621 of the makefile.
With the this fix in place the build completed successfully, downloaded the executable to the board, and the application started running with the blue LED flashing.
Note the Target Connection configuration needs to be set properly for the code to be deployed and run successfully:
There is one remaining challenge, however, given the knob on the dashboard has no effect on the duty cycle of the flashing LED, and the scope does not show any activity from the board; it is as if the application runs on the board without any persistent connection to Simulink, as one would expect from External Mode. It is if the example is not running in External Mode. But I cannot see any options or settings to turn it on.
Any suggestions for overcoming this last challenge are welcome.
It turns out the broken makefile problem originally reported at the start of this thread returns, and the above fix does not help, with Processor-in-the-Loop (PIL) examples, and likely elsewhere. Only re-installing Matlab/Simulink on a path without spaces is a reliable fix.
Hello @rsating ,
Thank you for such a wonderful contribution to our community! Your suggestions will help others too!
Even if, as you mentioned in your last reply, reinstalling Matlab in a path with no spaces is the best solution so far, maybe for others, the lines of code you've provided will be enough.
It's been a while since we are facing this issue with the spaces in the path for PIL.
Thank you!
Marius