Setup PIL simulation using MBD for Kinetis V series

cancel
Showing results for 
Search instead for 
Did you mean: 

Setup PIL simulation using MBD for Kinetis V series

1,970 Views
diogocacador
Contributor III

Thanks for the extremely quickly reply Daniel.

My interest is in the KV31F series for BLDC/PMSM motor control.

I've noticed the Motor Control Toolbox for the K V series. I was just wondering if NXP plans to update it to  v2, i.e. the Model Based Design Toolbox, which seems to be the most up to date toolbox. The reason I ask is because I'm not being able to setup PIL simulation using that toolbox, nor use the FreeMaster tool, while building any of the provided examples.

I'm using the GCC toolchain and the default linker script was not set properly, which I had to manually edit in the template makefile in order to get it to link properly. Once that was done, if I enabled either PIL or FreeMaster, which uses the UART peripheral to communicate, Matlab was not able to generate the code from the provided examples as it fails to build. I'll attach a screenshot of the errors reported below.

 error.png

Could you provide some help?

Kind regards,

Diogo

13 Replies

931 Views
diogocacador
Contributor III

Where can I find this "intrinsic_cw.h" file?

Is this related to CodeWarrior toolchain in any way?

There's two files that include this file depending on the toolchain selected: 

"MLIB_AddSat.h" and "MLIB_SubSat.h"

These files are included using the following statements:

#if defined(__GNUC__)
#include "intrinsic_cw.h"
#undef __STATIC_INLINE
#define __STATIC_INLINE static inline
#elif defined(__IAR_SYSTEMS_ICC__)
#include <intrinsics.h>
#undef __STATIC_INLINE
#define __STATIC_INLINE static inline
#elif defined(__CC_ARM)
#include "MK40N512MD100.h"
#endif

Also worth noting is that my target model looks like the following:

kv3xf_sim_pil_target.png

And if I remove the bottom "BAM" block the error related to the "intrinsic_cw.h" file goes away, therefore it must be including the header files mentioned above. However a new error occur. This new error is actually during the simulation itself as shown below:

simulation error.png

Any thoughts on solving this one?

Regards,

Diogo

0 Kudos

931 Views
PedroCastro
Contributor III

Hi Diogo,

did you managed to fix this issue? I have the same problem regarding the intrinsic_cw.h file

0 Kudos

931 Views
dumitru-daniel_
NXP Employee
NXP Employee

Hi Pedro, 

Originally the toolbox for Kinetis was not released with the support for GCC. We have made an patch just to enable preliminary support for code generation with GCC but we have not retested the entire toolbox. It seems that some of the blocks from MCLIB are using this intrinsic_cw.h which does not seems to exist.

My advice - if you wish to use the toolbox is to stick with IAR compiler since that was tested by the time of the release.

Hope this helps! The IAR comes with a 32KB limited free edition: IAR Embedded Workbench 

Daniel

0 Kudos

931 Views
dumitru-daniel_
NXP Employee
NXP Employee

diogocacador‌ and Maciek‌,

Can you tell us the exact Kinetis parts you are using and wish to have GCC toolchain support enabled?

We are in the process of testing a potential hotfix and we want to make sure we test both of your use-cases to ensure it works before making it available.

Thank you and looking forward for your reply.

Best regards,
Daniel

0 Kudos

931 Views
Maciek
Contributor V

Hi Daniel,

we have been trying to use/evaluate MBD toolbox with Tower kits:

TWR-KV10Z32 and TWR-KV31F120M 

Currently we don't have any particular Kinetis parts selected (for motor control and power electronics projects). We will take what is available and supported.

In a few non-power electronics projects we are currently using K60F120M - but those are PLC-like industrial controllers.

Best regards

Maciek

0 Kudos

931 Views
dumitru-daniel_
NXP Employee
NXP Employee

Maciek‌, diogocacador‌ and all the others interested in Kinetis GCC support,

We have now a solution to this problem (GCC is not supported for Kinetis devices) and could be deployed as hotfix (will become available after we finalize all tests)

For the moment if you want to try it and helps us with testing and feedback here is what you need to update:

#1: Toolbox related files to add and enable the support for GCC

1.1. Go to {Kinetis Toolbox Install dir}\mctbx_Kinetis\mctbx_kv\mscripts\ folder and replace the mcd_kv_compiler_callback.p with the one attached

1.2. Go to {Kinetis Toolbox Install dir}\mctbx_Kinetis\mctbx_kv3xf\mctbx_kv3xf\ folder and replace mcd_kv3xf.tmf and mcd_kv3xf.tlc files with the ones attached

#2: GCC support files

2.1: Copy and replace the startup_MK22F51212.S file attached to both {Kinetis Toolbox Install dir}\mctbx_Kinetis\Kinetis_Platform_SDK\platform\startup\MK22F51212\gcc\ and {Kinetis Toolbox Install dir}\mctbx_Kinetis\mctbx_kv3xf\src\gcc_specific_files\ folders

#3: Define the GCC_ARM_TOOL system variable to point to GCC compiler toolchain.

For verification we used the compiler delivered with Model Based Design Toolbox for S32K rev 2.0.0 but you could use the one shipped with S32DS IDE as well.

e.g. GCC_ARM_TOOL = C:\MBDToolbox\mbdtbx_S32K\tools\gcc-arm-none-eabi-4_9

Notes: 

#1: The GCC options should be:

GCC Compile: -c -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -g -gstrict-dwarf

GCC Assemble: -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -g

GCC Link: -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16

1.JPG

#2: For the moment we have validated only for KV31F family

#3: If you need to use the Automotive Motor Control library you need to get the latest version that support Kinetis families with GCC.

#4: PIL is now functional

2.JPG

 

Please let us know your results!

Thank you!

MBDT team.

0 Kudos

931 Views
Maciek
Contributor V

Hi Daniel,

after Your hotfix I'm able to build the examples that are using only peripheral blocks from KV3x. I'm building on R2016b with GCC from S32K MBD Toolbox v3.0.0.

I'm getting errors for models that are using Math and Motor Control Library blocks!

You have said:

"#3: If you need to use the Automotive Motor Control library you need to get the latest version that support Kinetis families with GCC."

I assume this is my problem.

How to get/update this library to be able to compile models correctly ?

Thanks

Maciek

0 Kudos

931 Views
dumitru-daniel_
NXP Employee
NXP Employee

Hi diogocacador‌,

Any chance for you to test this fix ?

Thank you!

Daniel

0 Kudos

931 Views
diogo_cacador
Contributor I

Hello Daniel,

Apologies for very late reply, but I haven't been on this project at all for a while, but I'm back and full time on this.

Just took a quick stab at this again making a fresh install of the toolbox and also including the proposed fix above.

When compiling I get an error related to the file "intrinsic_cw.h", which cannot be found. (See attached screen grab)compile error.png

I'm using the GCC toolchain provided with the S32DS IDE for ARM v1.3. 

Hardware in use is the FRDM-KV31F with the motor control shield FRDM-MC-LVPMSM.

Any ideas?

Best regards,

Diogo

0 Kudos

931 Views
dumitru-daniel_
NXP Employee
NXP Employee

Diogo,

Can you send me the linker script you are using, the compiler version used and the modifications you have done to the toolbox ?

We want to put together all these files with some other needed from our side in order to create hot-fix to benefit for the entire community.

Best regards

Daniel

0 Kudos

931 Views
dumitru-daniel_
NXP Employee
NXP Employee

Hi Diogo, 

For the moment we would like to address the existing issues and if needed, depending on the feedback we got from community we'll consider such upgrade.

In this case, i branched your topic into a new thread since this one seems as a configuration issue.

We'll have a look into this problem you are reporting and will search for a workaround.

Stay tuned and thanks for your understanding.

Best regards,

Daniel

931 Views
dumitru-daniel_
NXP Employee
NXP Employee

Hi Diogo, 

So far i tested the PIL with IAR compiler  and it works fine.

The problem is the GCC toolchain. This is not supported in the toolbox even if the Release notes says it should. I need further investigations on that topic.

By any chance - can you switch to IAR? It is for free but limited to 32k code size: IAR Embedded Workbench 

In the mean time we are working to research an workaround/hotfix to allow you to continue the work with GCC. I logged the AST-605 in our internal database to track the issue.

Best regards,
Daniel

0 Kudos

931 Views
Maciek
Contributor V

Hi,

we are also very interested in GCC support for Kinetis. When we have tested MBD toolbox few months ago - we stopped at failed attempts with hand-made modifications. The response from NXP team was (as I remember) that GCC is not supported. Only IAR compiler. We gave up. We have invested in NXP tools and don't want to switch to another toolchain...

Best regards,

Maciek

0 Kudos