Compilation Error for MBD Toolbox S32K3 [using .mex file]

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

Compilation Error for MBD Toolbox S32K3 [using .mex file]

Jump to solution
260 Views
abhishekkumarbwi
Contributor I

Dear All, 

I am using a .mex (as attached) file (Configuration Template) from an existing project. 

I am trying to get a simple ADC GroupRead [following the example]. 

When I try to build. I get an error. 

Several Files are missing [or not generated]. 

Also, in the example of ADC stream read.

A function is used "GetStreamLastPointer". 

I do not understand the usage for it. As we setup the buffer already. 

When we recieve an inturrupt of Group Notification. The buffer should have been filled.

So ideally we should just read the buffer (in IRQ handler) and no additional function shall be needed. 

Can you please guide for the correct process? 

Tool Details

Matlab: 2022b

NxP Toolbox: NXP Model-Based Design Toolbox for S32K3xx Series

GCC Compiler

0 Kudos
1 Solution
221 Views
Irina_Costachescu
NXP Employee
NXP Employee

Hi @abhishekkumarbwi 

Thank you for sharing your project with us. While testing the attached model, together with its associated .mex file, I have encountered multiple issues, for which I would like to provide the following information and guidance:

1. The first error encountered while building the model was related to a failure in the compilation process, due to the fact that multiple files with the same name are present in the sources list. The cause of this issue is represented by the usage of the Port component together with the Pins Tool inside your .mex (they both generate configuration files with the same names). MBDT integrates the RTD (Real-Time Drivers) package for enabling the on-board configuration inside S32 Configuration Tools. The Port component and the Pins Tool can't be used simultaneously inside a .mex file, due to the drivers limitations with respect to these components compatibility.

The feature of using the Port component together with the Pins Tool will be available in our next release, which will include a new RTD package version, where this issue was addressed.

Proposed Solution: Delete the Port component configuration by right clicking on it and selecting Remove, and add the Siul2_Port component from the Drivers categories. No other settings must be made inside the Siul2_Port component, as it will be used only for initializing the pins as configured in Pins Tool

Irina_Costachescu_0-1709662148543.png

2. The .mex file is configured for the S32K312_100MQFP processor, while your model is set for an application targeting S32K344-Q172. There must be a match in the project configuration and the processor targeted by the Simulink model, otherwise errors will be thrown during the build process.

Now depending on which processor you are targeting, please choose the suitable approach for your use case from the ones mentioned below.

Proposed Solution 1: Change the S32K344-Q172 to S32K312-Q172 from the model's Hardware Settings - Hardware Implementation - Target Hardware Resources group - Hardware - Hardware Part widget. This step will reset your configuration template to the default S32K312-Q172 project the toolbox provides, so you would need to reselect your own Configuration Template by pressing the Browse button. Check also the selection of the blocks in the Simulink model after this process.

Irina_Costachescu_1-1709662296449.png

Irina_Costachescu_2-1709662360793.png

Proposed Solution 2: Change the processor used in the configuration by accessing File - Switch Processor from the S32 Configuration Tools menu. In the opened window choose the S32K344-Q172, as target by your model and perform your configuration updates.

Irina_Costachescu_3-1709662422928.png

Note: S32K312_100MQFP is not a package that MBDT provides support for, the only available selection being S32K312-Q172. If you would like to use S32K312-Q100 with MBDT, please check the following thread (link).

3. The MBDT models execute on target periodically, and this is implemented with the help of a timer. If you go to the Timers tab in the model's Configuration Parameters, you will see that the Step Timer used by the model is GPT. This timer is loaded with a configurable period and triggers an interrupt whenever the timeout is reached - inside its Interrupt Service Routine the application code is executed. However, in your associated .mex file the Gpt component is not configured, therefore, using this selection will cause the build to fail.

Irina_Costachescu_4-1709662617674.png

Proposed Solution 1: Change the model's Step Timer to SysTick (generic Arm timer which does need a .mex configuration).
Proposed Solution 2: Add Gpt component inside your .mex file and configure it appropriately - for reference you can check the S32K312-Q172 default project existent in <toolbox_root>/mbdtbx_s32k3/devices/S32K312-Q172/s32ds_default_project_config/s32k312-q172.mex.

4. Get Clock Frequency API must be enabled inside the Clocks Tool for model's timing computation we perform in our toolbox.

Irina_Costachescu_5-1709662724796.png

5. MBDT currently offers support only for FunctionalGroups as the ComponentGenerationMethod.

Irina_Costachescu_7-1709663148998.png

6. Os component needs to be enabled - no specific configuration needed - files from other components are requiring Os drivers. 

Irina_Costachescu_6-1709662760690.png

7. There are some known issues with the Adc functionalities for reading channels groups, fixed in the attached .zip file. Please download the attached archive and copy the contents from the adc_patch folder to their right locations inside the toolbox, as it follows:

adc.tlc and adc.c       to <toolbox_root>/mbdtbx_s32k3/+mbd_s32k3/+common/blocks/adc
s32k3_adc.mexw64  to <toolbox_root>/mbdtbx_s32k3/blocks/adc

Also, inside the archive you could also find an updated version of the files that you have sent, containing modifications for the steps 1-6, with the following mentions:

  • PIL_RoPPConfig.mex:
    - used Siul2_Port instead of Port
    - enabled the Get Clock Frequency API
    - changed ComponentGenerationMethod selection to Functional Groups
    - added Os component
  • PIL_RoPP.slx:
    - changed the model for the S32K312-Q172 Hardware Part
    - changed the model to use SysTick instead of GPT as the Step Timer

The model builds successfully with these updates on its settings and inside its associated .mex, however please consider it only as a reference of how to obtain a working setup, and feel free to perform your own changes, as needed by your project, based on the above explanations.

Also, please consider performing a backup of the .mex I have attached in a location different than the one where the model is placed, to avoid its overwriting during various tests you may perform with your model.

As for the usage of the Adc_GetStreamLastPointer I would like to point you to the AUTOSAR documentation which I find to be explained very well (Chapter 7.1.3 ADC Buffer Access Mode Example).

Please let us know if further information is needed.

Hope this helps,

Irina

View solution in original post

0 Kudos
1 Reply
222 Views
Irina_Costachescu
NXP Employee
NXP Employee

Hi @abhishekkumarbwi 

Thank you for sharing your project with us. While testing the attached model, together with its associated .mex file, I have encountered multiple issues, for which I would like to provide the following information and guidance:

1. The first error encountered while building the model was related to a failure in the compilation process, due to the fact that multiple files with the same name are present in the sources list. The cause of this issue is represented by the usage of the Port component together with the Pins Tool inside your .mex (they both generate configuration files with the same names). MBDT integrates the RTD (Real-Time Drivers) package for enabling the on-board configuration inside S32 Configuration Tools. The Port component and the Pins Tool can't be used simultaneously inside a .mex file, due to the drivers limitations with respect to these components compatibility.

The feature of using the Port component together with the Pins Tool will be available in our next release, which will include a new RTD package version, where this issue was addressed.

Proposed Solution: Delete the Port component configuration by right clicking on it and selecting Remove, and add the Siul2_Port component from the Drivers categories. No other settings must be made inside the Siul2_Port component, as it will be used only for initializing the pins as configured in Pins Tool

Irina_Costachescu_0-1709662148543.png

2. The .mex file is configured for the S32K312_100MQFP processor, while your model is set for an application targeting S32K344-Q172. There must be a match in the project configuration and the processor targeted by the Simulink model, otherwise errors will be thrown during the build process.

Now depending on which processor you are targeting, please choose the suitable approach for your use case from the ones mentioned below.

Proposed Solution 1: Change the S32K344-Q172 to S32K312-Q172 from the model's Hardware Settings - Hardware Implementation - Target Hardware Resources group - Hardware - Hardware Part widget. This step will reset your configuration template to the default S32K312-Q172 project the toolbox provides, so you would need to reselect your own Configuration Template by pressing the Browse button. Check also the selection of the blocks in the Simulink model after this process.

Irina_Costachescu_1-1709662296449.png

Irina_Costachescu_2-1709662360793.png

Proposed Solution 2: Change the processor used in the configuration by accessing File - Switch Processor from the S32 Configuration Tools menu. In the opened window choose the S32K344-Q172, as target by your model and perform your configuration updates.

Irina_Costachescu_3-1709662422928.png

Note: S32K312_100MQFP is not a package that MBDT provides support for, the only available selection being S32K312-Q172. If you would like to use S32K312-Q100 with MBDT, please check the following thread (link).

3. The MBDT models execute on target periodically, and this is implemented with the help of a timer. If you go to the Timers tab in the model's Configuration Parameters, you will see that the Step Timer used by the model is GPT. This timer is loaded with a configurable period and triggers an interrupt whenever the timeout is reached - inside its Interrupt Service Routine the application code is executed. However, in your associated .mex file the Gpt component is not configured, therefore, using this selection will cause the build to fail.

Irina_Costachescu_4-1709662617674.png

Proposed Solution 1: Change the model's Step Timer to SysTick (generic Arm timer which does need a .mex configuration).
Proposed Solution 2: Add Gpt component inside your .mex file and configure it appropriately - for reference you can check the S32K312-Q172 default project existent in <toolbox_root>/mbdtbx_s32k3/devices/S32K312-Q172/s32ds_default_project_config/s32k312-q172.mex.

4. Get Clock Frequency API must be enabled inside the Clocks Tool for model's timing computation we perform in our toolbox.

Irina_Costachescu_5-1709662724796.png

5. MBDT currently offers support only for FunctionalGroups as the ComponentGenerationMethod.

Irina_Costachescu_7-1709663148998.png

6. Os component needs to be enabled - no specific configuration needed - files from other components are requiring Os drivers. 

Irina_Costachescu_6-1709662760690.png

7. There are some known issues with the Adc functionalities for reading channels groups, fixed in the attached .zip file. Please download the attached archive and copy the contents from the adc_patch folder to their right locations inside the toolbox, as it follows:

adc.tlc and adc.c       to <toolbox_root>/mbdtbx_s32k3/+mbd_s32k3/+common/blocks/adc
s32k3_adc.mexw64  to <toolbox_root>/mbdtbx_s32k3/blocks/adc

Also, inside the archive you could also find an updated version of the files that you have sent, containing modifications for the steps 1-6, with the following mentions:

  • PIL_RoPPConfig.mex:
    - used Siul2_Port instead of Port
    - enabled the Get Clock Frequency API
    - changed ComponentGenerationMethod selection to Functional Groups
    - added Os component
  • PIL_RoPP.slx:
    - changed the model for the S32K312-Q172 Hardware Part
    - changed the model to use SysTick instead of GPT as the Step Timer

The model builds successfully with these updates on its settings and inside its associated .mex, however please consider it only as a reference of how to obtain a working setup, and feel free to perform your own changes, as needed by your project, based on the above explanations.

Also, please consider performing a backup of the .mex I have attached in a location different than the one where the model is placed, to avoid its overwriting during various tests you may perform with your model.

As for the usage of the Adc_GetStreamLastPointer I would like to point you to the AUTOSAR documentation which I find to be explained very well (Chapter 7.1.3 ADC Buffer Access Mode Example).

Please let us know if further information is needed.

Hope this helps,

Irina

0 Kudos