Simulink Code gen does not invoke makecfg.m for custom Matlab L2 S-function.

2 Ansichten (letzte 30 Tage)
Hi,
It seems that there is no invokation of makecfg.m for customizing the build directive in case of custom Matlab L2 S-functions.
It seems that the makecfg.m will only be called in case a .mex simulink block binary is present.
Can anyone confirm regarding this behavior?
Thanks!

Antworten (1)

Vandit
Vandit am 1 Jun. 2023
Hi,
Yes, the 'makecfg.m' function is only called if a '.mex' Simulink block binary is present. This is because the '.mex' file contains all the necessary information for compiling the S-function, including the build directive. If there is no '.mex' file, then 'makecfg.m 'is not called and the S-function will be compiled with the default build directive. The reason for this behavior is that the '.mex' file is a compiled binary file, and it is not possible to modify the build directive after the file has been compiled. If you need to customize the build directive for a custom Matlab L2 S-function, then you will need to create a '.mex' file.
To invoke 'makecgf.m' file for customizing the build directive in case of custom Matlab L2 S-functions, follow the steps given below:
  1. Create your custom MATLAB Level-2 S-function and save it in a directory on the MATLAB search path.
  2. Create a 'makecfg.m ' script in the same directory as your MATLAB Level-2 S-function file.
  3. In the "Code Generation" section present in the "Configuration Parameters" dialog box for your Simulink model, set the "System target file" parameter to the appropriate value for your platform.
  4. In the same section, set "Generate makefile" to "on" then select "Makefile" for the "Template makefile" parameter and finally set "Make command" to the command-line command that you want to use to invoke the make process.
  5. Generate C code for your Simulink model that uses your custom MATLAB Level-2 S-function. Simulink will generate a makefile for your model.
  6. Open the generated makefile and at the end of the makefile, add the following lines and then save the changes.
# Invoke makecfg to customize build settings
MATLAB_ROOT = $(MATLAB)
include $(MATLAB_ROOT)/extern/lib/$(TARGET_ARCH)/mwci/mwmakefile
7.Modify the 'makecfg' script to include the desired build options and commands and save the required changes.
8.Run make command to build your Simulink model and your custom MATLAB L2S-function using customized makefile.
By following these steps, you should be able to invoke makecfg.m for customizing the build directive in case of custom MATLAB Level-2 S-functions within Simulink.
To know more about how to use makecfg to Customize Generated Makefiles for S-Functions refer to the link below:
Hope this helps.
Thankyou
  1 Kommentar
Konstantinos
Konstantinos am 14 Jul. 2023
Bearbeitet: Konstantinos am 15 Jul. 2023
Hi Vandit,
Thank you for your answer! Please consider adding this info to the documentation.
I'm building a 3d party Toolbox that includes a Simulink Library with a L2 Matlab sFunction. The only build option I want to add is a couple of compiler link flags when this Simulink Block of mine is a added to a Simulink Model.
Any chance I could embedd these buildinfo properties in a clean and transparent to the customer/user way?
Best,
Konstantinos

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Simulink Coder finden Sie in Help Center und File Exchange

Produkte


Version

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by