S32k144EVB Simulink compile errors/missing libwinpthread-1.dll

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

S32k144EVB Simulink compile errors/missing libwinpthread-1.dll

2,741 Views
stefan130293
Contributor I

I am trying to program the S32K144EVB through Simulink using the NXP Model-Based Design Toolbox for S32K MCUs. I am on Matlab 2017b. 

The installation seemed to be correct and the env variable has been set. When I created the simple model with the button and the LED it started to compile code and I got a Code generation report. But when it than tried to compile with the GCC compiler it gave me the following error:

C:\MATLAB\Add-Ons\Toolboxes\NXP_MBDToolbox_S32K1xx(2)\code\NXP_S32_Model_mbd_rtw>"C:\Program Files\MATLAB\R2017b\bin\win64\gmake" -f NXP_S32_Model.mk COPY_MDLREF_INCLUDES=0 ISPROTECTINGMODEL=NOTPROTECTING GENERATE_ERT_S_FUNCTION=0 INCLUDE_MDL_TERMINATE_FCN=1 COMBINE_OUTPUT_UPDATE_FCNS=1 MULTI_INSTANCE_CODE=0 INTEGER_CODE=0
Cleaning...
RELATIVE_PATH_TO_ANCHOR is ..
==== Removing object files from build directory ====
Copying necessary files to build directory...
Compiler details : "C:\MATLAB\Add-Ons\Toolboxes\NXP_MBDToolbox_S32K1xx(2)\code\tools\gcc-6.3-arm32-eabi/bin/arm-none-eabi-gcc" -c -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -O1 -g -gstrict-dwarf -DARM_MATH_CM4 -D__FPU_PRESENT=1 -D__FPU_USED=1 -D__NVIC_PRIO_BITS=FEATURE_NVIC_PRIO_BITS -o SetupFiles -DCPU_S32K144HFT0VLLT -I. -I.. -I.. -I"C:\Program Files\MATLAB\R2017b\simulink\include" -I"C:\Program Files\MATLAB\R2017b\extern\include" -I"C:\Program Files\MATLAB\R2017b\rtw\c\src" -I"C:\Program Files\MATLAB\R2017b\rtw\c\libsrc" -I"C:\Program Files\MATLAB\R2017b\rtw\c\src\ext_mode\common" -I"C:\Program Files\MATLAB\R2017b\rtw\c\src\ext_mode\tcpip" -I"C:\Program Files\MATLAB\R2017b\rtw\c\src\ext_mode\serial" -I"C:\Program Files\MATLAB\R2017b\rtw\c\src\ext_mode\custom" -IC:\MATLAB\Add-Ons\Toolboxes\NXP_MBDToolbox_S32K1xx(2)\code -IC:\PROGRA~1\MATLAB\R2017b\simulink\include\sf_runtime -IC:\MATLAB\Add-Ons\Toolboxes\NXP_MBDToolbox_S32K1xx(2)\code\NXP_S32_Model_mbd_rtw -IC:\MBCD\OSCAT_projects\NXP_S32\Model -I"C:\MATLAB\Add-Ons\Toolboxes\NXP_MBDToolbox_S32K1xx(2)\code\tools\gcc-6.3-arm32-eabi/arm-none-eabi/include" -I"./common" -I"./inc" -I"./src/clock/S32K1xx" -I"./src/sim/S32K144" -I"./src/power/S32K1xx" -I"./S32K144/include" -I"../common" -I"../inc" -I"../src/clock/S32K1xx" -I"../src/sim/S32K144" -I"../src/power/S32K1xx" -I"../S32K144/include"
Assembler details : "C:\MATLAB\Add-Ons\Toolboxes\NXP_MBDToolbox_S32K1xx(2)\code\tools\gcc-6.3-arm32-eabi/bin/arm-none-eabi-gcc" -c -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -g -x assembler-with-cpp -o SetupFiles
Product: NXP_S32_Model.mot
Build product type: executable
Building file startup_S32K144.o...
"C:\MATLAB\Add-Ons\Toolboxes\NXP_MBDToolbox_S32K1xx(2)\code\tools\gcc-6.3-arm32-eabi/bin/arm-none-eabi-gcc" -c -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -g -x assembler-with-cpp -o startup_S32K144.o startup_S32K144.s
gmake: *** [startup_S32K144.o] Error 1
### Build procedure for model: 'NXP_S32_Model' aborted due to an error.
Error(s) encountered while building "NXP_S32_Model"

I than went to the working directory and started the (**model.bat) batch file located in it. After i run that it gave me an error that libwinpthread-1.dll was missing and that reinstalling the software should fix this.

So i went to find the .dll located in:

C:\MATLAB\Add-Ons\Toolboxes\NXP_MBDToolbox_S32K1xx(2)\code\tools\gcc-6.3-arm32-eabi\bin

and copied it to the same location as were the batch file was located. So I rebuild the model (through Simulink) and it successfully downloaded the code to the board. 

I know this is not how it is supposed to work. But for some reason it cannot find the .dll even when the env variable is set correctly. Any solution?

Tags (1)
0 Kudos
14 Replies

2,080 Views
constantinrazva
NXP Employee
NXP Employee

Hello stefan130293‌,

From what I've seen on this post, adding the gcc6.3 directory to the PATH variable (in your system environmental variables) can fix this issue. Can you test that out an confirm it works?

Thank you,

Razvan.

0 Kudos

2,080 Views
stefan130293
Contributor I

I just tried that. adding all subfolders and only adding the bin folder both options don't work.

0 Kudos

2,080 Views
constantinrazva
NXP Employee
NXP Employee

Hello stefan130293,

So did you add to the system environmental variable PATH the following  

C:\MATLAB\Add-Ons\Toolboxes\NXP_MBDToolbox_S32K1xx(2)\code\tools\gcc-6.3-arm32-eabi\bin

and it did not work?

Kind regards,

Razvan.

0 Kudos

2,080 Views
constantinrazva
NXP Employee
NXP Employee

I must add a note here: after you've edited the PATH system variable from Windows, you'll have to restart MATLAB, so that the changes could be made. The other option is to edit the MATLAB variable where the PATH is saved, by using getenv() and setenv() MATLAB functions.

0 Kudos

2,080 Views
constantinrazva
NXP Employee
NXP Employee

getenv(var_name) -> returns a string with the value of var_name (environmental variable name)

setenv(var_name, value) -> set value to var_name

You can use these two like this:

setenv('PATH', [getenv('PATH'), ';C:\MATLAB\Add-Ons\Toolboxes\NXP_MBDToolbox_S32K1xx(2)\code\tools\gcc-6.3-arm32-eabi\bin']);

if you want to edit the MATLAB value for PATH so you don't have to restart. But keep in mind that it's only available for the running instance of MATLAB; the next time you'll open it, it will read the system variable again, so if you've not made the changes there, they'll be lost.

Hope this helps,

Razvan.

0 Kudos

2,080 Views
stefan130293
Contributor I

If i run: 

getenv('GCC_S32K_TOOL') 

it returns:

'C:\MATLAB\Add-Ons\Toolboxes\NXP_MBDToolbox_S32K1xx(2)\code\tools\gcc-6.3-arm32-eabi\bin'

Than I stil receive the build error. When I run your command it is working for as long as I keep matlab open. Did I do something wrong with the enviorment path?

0 Kudos

2,080 Views
constantinrazva
NXP Employee
NXP Employee

Hello stefan130293‌,

The problem is that in GCC_S32K_TOOL variable it looks for executable files like arm-none-eabi-gcc-6.3.1.exe, used for compiling/linking. 

When it is looking for the .dll, it first looks in the current working directory, then it searches the PATH variable, looking at each directory, from left to right. This is why you'll need to append it to the system environmental variable named PATH, so you don't need to call those functions every time you open MATLAB. 

To append this to PATH, you can follow the steps described here, depending on what Windows you have.

After you've added it and restart MATLAB, you'll not get the error anymore.

Hope this helps,

Razvan.

0 Kudos

2,080 Views
stefan130293
Contributor I

Hello Constantin Razvan Chivu,

I appended it to the Path variable (restarted matlab + PC). I checked with getenv('PATH') if it was indeed appended and it was. If I than try to download to the board i still receive the same error. 

After running:

setenv('PATH', [getenv('PATH'), ';C:\MATLAB\Add-Ons\Toolboxes\NXP_MBDToolbox_S32K1xx(2)\code\tools\gcc-6.3-arm32-eabi\bin']);

It is avaible twice in te Path variable. But only now it is able to find it.

I do have to execute the envoirment variable window as administrator, maybe this is the problem?

0 Kudos

2,080 Views
constantinrazva
NXP Employee
NXP Employee

Hello stefan130293‌,

When you appended it to PATH, did you put a semicolon before it? You must use that to separate the various paths from there. That might be a problem.

Can you post here the output of getenv('PATH') before running any setenv() command?

Thank you,

Razvan.

0 Kudos

2,080 Views
stefan130293
Contributor I

I run it on windows 10, I think they changed the env varibale interface. See screenshot.

pastedImage_1.png

Result of getenv('PATH'):

ans =

'C:\Program Files (x86)\Common Files\Oracle\Java\javapath;U:\cr5_data\cr5_resource\zeao\bin;U:\cr5_data\cr5_resource\bin;U:\cr5_data\cr5_resource\zds\bin;c:\Zuken\cr5000_R13\local\zsys\bin;c:\Zuken\cr5000_R13\bin;C:\Zuken\cr5000_R13\zpms\bin\Win32OODB;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files\Microsoft Windows Performance Toolkit\;C:\Program Files\MATLAB\R2017b\runtime\win64;C:\Program Files\MATLAB\R2017b\bin;C:\Program Files\MATLAB\R2016b\runtime\win64;C:\Program Files\MATLAB\R2016b\bin;C:\Program Files\MATLAB\R2016b\polyspace\bin;C:\Program Files (x86)\Seapine\TestTrack\;C:\Program Files\gs\gs9.05\bin\;C:\Program Files\gs\gs9.05\lib\;C:\Zuken\CR5000_R13\Lightning\programs;C:\Program Files\MATLAB\MATLAB Runtime\v91\runtime\win64;C:\Program Files\MATLAB\R2015b\runtime\win64;C:\Program Files\MATLAB\R2015b\bin;C:\Program Files\MATLAB\R2015b\polyspace\bin;C:\MATLAB\Add-Ons\Toolboxes\NXP_MBDToolbox_S32K1xx(2)\code\tools\gcc-6.3-arm32-eabi\bin;C:\Users\SBRU\AppData\Local\Microsoft\WindowsApps;C:\Users\SBRU\AppData\Local\Programs\Git\cmd'

0 Kudos

2,080 Views
constantinrazva
NXP Employee
NXP Employee

Hello stefan130293‌,

Indeed, in Windows 10 they changed how the environmental variables are displayed (made it more user-friendly in my opinion); getting back to the point -  the PATH variable seems to be good. I compared it with the one that I put in the call for setenv() [the one that works], and it matched it. I don't understand how it can not find it the first time, and only works if it's put from MATLAB directly. I'll try to force this issue on my computer to see what's the problem.

In the meanwhile, if you run that command when you start MATLAB, you'll manage to build the ELF file with no errors.

Kind regards,

Razvan.

0 Kudos

2,080 Views
stefan130293
Contributor I

Seems it is not wokring with simulink projects. If i open the model standalone and copy/paste the .dll it is working agian.

0 Kudos

2,080 Views
stefan130293
Contributor I

Sorry Constantin Razvan Chivu. It seems that i did something wrong. I have uploaded the project folder and reset the paths. Unfortunaly it is now broken again.

0 Kudos

2,079 Views
constantinrazva
NXP Employee
NXP Employee

Hello stefan130293‌,

I have not seen this issue before. Can you try and reset the MATLAB path? For that you should go to MATLAB Home tab -> Set Path -> Default -> Save.

Capture.JPG

 

Untitled.png

and then run the mbd_s32k_path script again, so you install the path for the toolbox over a fresh, default MATLAB path. 

 

Note: this will remove additional toolboxes path, so you'll have to add them back later.

And can you attach the project folder here, as a .zip? Just as the toolbox generates it, before copying by hand anything else.

Thank you,

Razvan.

0 Kudos