S32K144 Simulink External Mode

cancel
Showing results for 
Search instead for 
Did you mean: 

S32K144 Simulink External Mode

Jump to solution
1,331 Views
b622402
Contributor I

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:

model.png

Settings used for External Mode (COM3 port, 56700 baud rate):

config.png

The error encountered during build:

error.png

Corresponding line in the makefile, I believe:

makefile.png

Does anybody have an idea what goes wrong here? Or any pointers how to get External Mode working?

Thanks,

John

Labels (1)
1 Solution
937 Views
paulvlase
NXP Employee
NXP Employee

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.

View solution in original post

5 Replies
938 Views
paulvlase
NXP Employee
NXP Employee

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.

View solution in original post

848 Views
rsating
Contributor III

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?

0 Kudos
835 Views
rsating
Contributor III

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:

NXP_MBDT_S23K1xx_Target_Connection.png

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.

0 Kudos
776 Views
rsating
Contributor III

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.

0 Kudos
766 Views
mariuslucianand
NXP Employee
NXP Employee

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

0 Kudos