Main Content

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.

CMSIS and third-party component installation in Hardware Setup

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')
Code Replacement Viewer for Arm Cortex A

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.

  1. In the Simulink model, open the Configuration Parameters dialog box.

  2. From the left navigation pane, select Hardware Implementation. Select Hardware board to Raspberry Pi. Ensure that the Device vendor is set to ARM 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 to ARM Cortex-A (64-bit).

    Confirm Device vendor and device type details for Raspberry Pi hardware

  3. In the left navigation pane of the Configuration Parameters dialog box, select Code Generation > Interface.

  4. In the Software environment section, click Select of the Code replacement library parameter.

  5. 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.

    ARM Cortex-A CMSIS selection

  6. 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.

  7. In the Advanced parameters section, select Summarize which blocks triggered code replacement. For more information, see Summarize which blocks triggered code replacements (Embedded Coder).

    Generate Code Genration Report

  8. 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

(MATLAB Coder) | (MATLAB Coder) | | (Embedded Coder) | (Embedded Coder) | (Embedded Coder)