Support Embedded Linux Board in SoC Blockset
This example shows how to set up embedded Linux® board to support the SoC Blockset™ features.
SoC Blockset supports a variety of stock boards. The SoC Blockset for Embedded Linux Devices provides a board selection option, Embedded Linux Board, to set up your board so that it supports SoC Blockset features. To support your board you must follow these steps.
Customize a Linux image to use SoC Blockset features.
Create or use a board configuration in SoC Blockset.
Select a toolchain and set the build options.
After you complete these steps, you can use SoC Blockset features to simulate, deploy, and monitor applications on your board.
This example we will show how to support SoC Blockset features on Raspberry Pi® as a typical embedded Linux board.
Run Hardware Board Setup
During the support package installation, you are instructed to perform the hardware board setup process that guides you through configuring, and connecting your hardware board. If the support package is already installed, you can start the hardware setup by using the Add-On Manager.
The hardware setup provides instructions for configuring the support package to work with your hardware. One step of the hardware board setup is to run the OS Customizer tool to update the embedded operating system (OS) image on your board. The tool detects the missing packages in the OS image that are required to use SoC Blockset features. Then, the tool provides instructions on how to add those packages to generate an updated OS image for your board. When the hardware setup process completes, you can continue with the other steps in this example.
Create Configuration for Your Board
Using Embedded Linux Board
option, you can support multiple boards. To enable SoC Blockset to correctly use your board for simulating and deploying Simulink® models, you must configure Embedded Linux Board selection for your board. Follow the steps below.
1. Create a new model in Simulink.
2. On the Apps tab, under Setup to Run on Hardware, click System on Chip (SoC). In the SYSTEM ON CHIP (SOC) window, select Embedded Linux Board
.
3. On the System on Chip tab, click Hardware Settings to open the Configuration Parameters dialog box.
4. On the Hardware Implementation pane, expand the Hardware board settings > Target Hardware resources > Board Configuration group.
5. For the Name parameter, select <Add new Board Configuration>
and replace that text with a new board name, such as My Raspberry PI board
.
6. Set the required properties for the specified board. For example, set Number of cores to 4
and set Processor family to cortex-a72
.
7. To save the new board configuration to SoC Blockset, click Save. If you later change the board settings, click OK to save the updated settings. Now, you can use this board configuration for the current and other models using Embedded Linux Board
as the Hardware board and selecting your board configuration.
Select a Toolchain and Set the Build Options
Before you can deploy a model to an embedded Linux board, you must select an applicable toolchain and set the corresponding build options by following these steps.
1. Click Hardware Settings in the System On Chip tab to configure the model to run on hardware.
2. Select Code Generation pane in the Configuration Parameters dialog box.
3. Set the Toolchain parameter to the applicable toolchain for your board.
The default value for the Toolchain parameter is GGC Linaro for Embedded Linux (AArch64)
. Change the toolchain if that selection is not correct for your board. If no toolchain matches your board, you may follow the steps in Register Custom Toolchain and Build Executable (Embedded Coder) to register a new toolchain.
4. A toolchain can have multiple build configurations. For example, GGC Linaro for Embedded Linux (AArch64)
has four build configurations and the one for the fastest build is selected. To see the available build configurations, expand the Toolchain details pane
5. If the toolchain build configuration details do not match your hardware board, you can change them if you select Specify
for the Build configuration parameter.
6. If you change the toolchain or the build configuration, click OK to save the new settings.
Deploy and Run Model on Your Board
After the board OS image is ready and the board and toolchain are configured, you can deploy your model to your embedded Linux board by following these steps.
1. Open the example model soc_task_execution_step3
from the Task Execution example.
open_system('soc_task_execution_step3') set_param('soc_task_execution_step3','SimulationCommand','Update')
2. Set the hardware board, select the board configuration, and select the toolchain by following the steps in Select a Toolchain and Set the Build Options.
3. Follow the steps previously described in this example for the reference model soc_task_execution_step3_ref
used in this example.
4. Use the SoC Builder tool to deploy and run the model in external mode on your hardware board.
5. To view the execution results, click Data Inspector in the Review Results tab in Simulink. The Simulink Data Inspector window displays these graphs.
Further Exploration
Use your embedded Linux board to explore the Task Execution in its entirety.