Optimize Code for Raspberry Pi Using Code Replacement Library
You can configure your Simulink® model to replace generic code with ARM® Cortex® microcontroller software interface standard (CMSIS) code that is optimized for Raspberry Pi® ARM Cortex-A processors. Enabling the ARM Cortex-A CMSIS CRL can improve the performance and efficiency of the code generated and deployed on your Raspberry Pi hardware. For more information on CRL, see What Is Code Replacement? (MATLAB Coder). To view the list of the supported Raspberry Pi hardware, see Supported ARM Cortex-A Processors for Raspberry Pi Hardware. For more information on the supported CMSIS library functions, see Supported CMSIS Library Functions for ARM Cortex-A Processors (Embedded Coder).
Note
To use code replacement library for Simulink Support Package for Raspberry Pi Hardware, you must have an Embedded Coder® license.
When you install Simulink Support Package for Raspberry Pi Hardware, the Hardware Setup automatically installs the ARM Cortex-A CMSIS CRL and the dependent third-party components.
After you successfully install the support package, execute this command on your MATLAB® Command Window to view the code replacement libraries.
crviewer('ARM Cortex-A CMSIS')
The Code Replacement Viewer dialog box opens and displays the code replacement libraries for ARM Cortex-A processors. For more information, see Code Replacement Viewer (MATLAB Coder).
Follow these steps to activate the code replacement libraries for Raspberry Pi hardware.
In the Simulink model, open the Configuration Parameters dialog box.
From the left navigation pane, select Hardware Implementation. Select Hardware board to
Raspberry Pi
. Ensure that the Device vendor is set toARM Compatible
.Note
For 32-bit Raspberry Pi hardware board, ensure Device type is set to
ARM Cortex-A (32-bit)
and for 64-bit Raspberry Pi hardware board, ensure Device type is set toARM Cortex-A (64-bit)
.In the left navigation pane of the Configuration Parameters dialog box, select Code Generation > Interface.
In the Software environment section, click Select of the Code replacement library parameter.
In the Choose one or multiple Code replacement libraries for code generation dialog box, select ARM Cortex-A CMSIS to the Selected code replacement libraries - prioritized section and click OK.
You can include a summary of replacement functions used and their associated blocks in the code generation report. In the left navigation pane of the Configuration Parameters dialog box, select Code GenerationReport, and then select Create code generation report.
In the Advanced parameters section, select Summarize which blocks triggered code replacement. For more information, see Summarize which blocks triggered code replacements (Embedded Coder).
Build your Simulink model. in the Code Generation Report, a Code Replacement Report section is automatically included in the HTML report. This section documents the CRL functions that were used for code replacements during code generation. For more information, see Analyze Code Replacements in Generated Code (Embedded Coder).
See Also
What Is Code Replacement? (MATLAB Coder) | Choose a Code Replacement Library (MATLAB Coder) | Supported ARM Cortex-A Processors for Raspberry Pi Hardware | Summarize which blocks triggered code replacements (Embedded Coder) | Analyze Code Replacements in Generated Code (Embedded Coder) | Supported CMSIS Library Functions for ARM Cortex-A Processors (Embedded Coder)