Integrate SAF with Simulink generated application

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

Integrate SAF with Simulink generated application

304 Views
mweiss
Contributor II

Hi,

we generate our application with Simulink and MBDT. I'm currently looking into SAF and its module APIs. I wonder what is the best practice to integrate SAF and Simulink.

I can think of at least 2 ways:

  1. somehow import the configured (via S32DS) SAF modules into Simulink and call the respective SAF API functions as recommended by the SAF safety manual and SAF module documentation from within Simulink
  2. have a complete (configured) S32DS SAF project and call from there into the Simulink generated code that implements the application software

Personally I would prefer option 1, but any type of import or call into C method we already tried also had issues with Simulinks Model Advisor.

Are there any examples, we could look into?

SAF

MBDT

0 Kudos
5 Replies

224 Views
embedded_dan73
Contributor I

Hi to both @mweiss and @antoinedubois , and hello to all the community.

Thanks Markus for opening this thread, you anticipated me, because I'm also facing this quest, even if in my case I'm still in a phase of initial research and evaluation of what it is possible do.

Our scope is to develop a new electronic unit based on S32K358 MCU, and the challenge from our side is to create the whole application (and bsp layer also) using Simulink, and so interfacing with MBD Toolbox.

For the moment I made some prototyping app with S32K3X4EVB-172 evaboard (it's not the same MCU but the intention was to take familiarity with the tool), and the community (special thanks to @Irina_Costachescu ) already helped me a lot in solving some issues.

Now we are considering to retreive a license for SAF, but before doing this we are trying to have some information on its possibile integration with Simulink.

If there isn't a native support in MBD Toolbox, the option 1 mentioned by Markus seems also to me the best approach, but I'm wondering if the framework could maintain the same timing, operating conditions and so on...

If someone have some more information it would be much appreciated.

Thanks to all in advance.

0 Kudos

188 Views
mweiss
Contributor II

Hi @embedded_dan73 and others,

 

I made some good progress using https://de.mathworks.com/help/simulink/ug/import-custom-code-using-the-simulink-code-importer-wizard.... This option was mentioned by the trainer in a MathWorks ISO26262 training. Actually, he mentioned to start the import wizard from Simulink Test.

Personally, I prefer to use a script instead of the graphical wizzard. Seems to be easier with a large set of source and include files.

It generates a Simulink library, with blocks for the respective C functions specified before.

I also had to specify a define choosing from SAF #ifdefs and add some file with empty functions to successfully pass the compile step during the import. Probably, the define and those functions will not be used later in actual binary build steps. At least, this is how I understand it right now.

Hope this helps and good luck with your projects,

Markus

0 Kudos

176 Views
embedded_dan73
Contributor I

Hi Markus,

thanks a lot for your feedback, it's really interesting and helpful.

I also made, in the past, some custom code porting inside Simulink but using the "C-Call" function block (for some low level bsp calls), I didn't knew the approach you show here and it looks very useful.

Interesting also the approach with scripts (other method I used but not for code porting).

We are still evaluating if get or not the SAF, but in the meanwhile your informations are really important.

Thanks again, I'll let you and community updated for any progress by my side also.

 

With kind regards,

Daniel

0 Kudos

279 Views
antoinedubois
NXP Employee
NXP Employee

Hi Markus,

this are great ideas unfortunately not yet supported in our current SAF or MBDT products yet. I think your option 1 would work.

 

0 Kudos

263 Views
mweiss
Contributor II

Hi Antoine,

thank you for your reply.

I will try to follow option 1 then.

But still wondering how others do it? They must be facing the same challenge.

0 Kudos