Develop and Deploy Embedded Software Components to Platform Services by Using Embedded Coder - MATLAB & Simulink (original) (raw)
Main Content
Embedded Coder® enables you to generate readable, compact, and fast C and C++ code for embedded processors used in mass production. This set of examples shows how you can use Embedded Coder to generate, optimize, verify, and deploy code in a scalable workflow. For background information about Embedded Coder and a basic code generation workflow, see Get Started with Embedded Coder.
The major steps of the workflow depend on your requirements and goals for deploying the generated code, including:
- The target hardware and middleware on which you deploy the generated code.
- Your deployment objective—whether you want to generate application, component, subcomponent, or utility code.
These examples show how to generate and deploy component C code by using CMake, but Embedded Coder supports many other deployment workflows. Each example includes information about how you can modify the workflow for other deployment goals.
Target Hardware
Your target hardware determines many of the options that are available for your generated code, including many code optimization options. For some hardware targets, Embedded Coder provides support packages that help to automate the integration, execution, and verification of generated code. Some common targets include:
- AUTOSAR Standard — See AUTOSAR Blockset.
- ARM® processors, including ARM Cortex-A Processors, ARM Cortex-M Processors, and ARM Cortex-R Processors
- AMD SoC Devices
- Intel SoC Devices
- STMicroelectronics STM32 Processors
- Texas Instruments® C2000 Processors — See C2000 Microcontroller Blockset (C2000 Microcontroller Blockset).
For more hardware support packages, see Embedded Coder Supported Hardware.
For this example, you use the MATLAB® development computer as the target execution environment and you do not use a hardware support package.
Deployment Objectives
Deployment objectives define the type of code you want to generate and how you plan to deploy it in the target execution environment. The typical deployment objectives are:
- Application — Unit of code generated from a top model that can run in a single-process or multiprocess target environment.
- Component — Unit of code generated from a top model that can run in a single-process target environment.
- Subcomponent — Code generated from a model that is referenced by an application or component model. A subcomponent is produced and tested independently but deployed within an application or component.
- Utility — Code generated from a linked subsystem that adheres to specific modeling constraints. The generated code is part of a shared library and can be called from anywhere.
For this example, you generate component code from a top model and subcomponent code from a referenced model. For more information, seeSoftware Deployment Objectives and Deployment Types.
Code Generation Workflow
The workflow follows these steps:
- Prepare Models for Code Generation — Set up your models using model-based design practices that support your code generation goals and the scalability of your project.
- Configure Basic Code Generation Settings — Choose the basic settings for code generation based on your objectives, including target deployment hardware. In this example, you save these settings so that you can reuse them for other models that generate code for the same platform.
- Define the Interfaces Between the Generated Code and Your Deployment Platform — Specify how generated code interacts with your deployment platform. In this example, you define these interfaces so that you can reuse them for other models that generate code for the same platform.
- Apply Code and Deployment Configurations to Models — Configure your model to use the configurations that you defined in the two previous steps. By defining the configurations separately from the models, you can easily re-use them for other models that generate code for the same platform. You can also define different configurations for other platforms so that you can reuse the same models to generate code for other platforms.
- Call Existing Code from a Model and Generated Code — This optional but common step shows how to integrate existing C code into the model and generated code.
- Optimize the Generated Code — Generate and examine the code that includes standard optimizations for your target. Depending on your goals, you can use more advanced techniques to further optimize the code.
- Test the Generated Code — Test the generated code by running a software-in-the-loop (SIL) simulation, which compares results from running the generated code to results from model simulation.
- Deploy the Generated Code — Build and deploy an executable from the generated code. For this example, use CMake.
To start the workflow, see Prepare Models for Code Generation.