-
Notifications
You must be signed in to change notification settings - Fork 1
Generating Autocode for Flight
The instructions are what I use to generating autocode for SOC-i flight software. There are some specific code generation and simulation settings that are important to set properly. Make sure that you've configured the main Simulink build options from this link before starting these instructions.
In Simulink's navigation bar, click on Code -> C/C++ Code -> Code Generation Options... to open up the configuration parameters for the autocode. The following subsections each correspond to one of the tabs on the left-hand pane. I'll include as many screenshots as I can.
- Make sure the
Languageis set to C. - Check the
Package code and artifactsbox. Set theZip file name:to soci_fsw_build

- Check the following boxes:
Create code generation report,Open report automatically,Generate model Web view, andStatic code metrics.
You will need to include some custom header and source files to build the autocode with the SOAR payload. You will need to use absolute paths here that are specific to your machine.
Under Additional build information -> Include directories put the following folder reference
<absolute_path_to_repo>/soci-gnc/Lib/FSW/soar/include/ecos/include

Under Additional build information -> Source files put the following lines
<absolute_path_to_repo>/soci-gnc/Lib/FSW/soar/include/ecos/src/amd_1.c
<absolute_path_to_repo>/soci-gnc/Lib/FSW/soar/include/ecos/src/amd_2.c
<absolute_path_to_repo>/soci-gnc/Lib/FSW/soar/include/ecos/src/amd_aat.c
<absolute_path_to_repo>/soci-gnc/Lib/FSW/soar/include/ecos/src/amd_control.c
<absolute_path_to_repo>/soci-gnc/Lib/FSW/soar/include/ecos/src/amd_defaults.c
<absolute_path_to_repo>/soci-gnc/Lib/FSW/soar/include/ecos/src/amd_dump.c
<absolute_path_to_repo>/soci-gnc/Lib/FSW/soar/include/ecos/src/amd_global.c
<absolute_path_to_repo>/soci-gnc/Lib/FSW/soar/include/ecos/src/amd_info.c
<absolute_path_to_repo>/soci-gnc/Lib/FSW/soar/include/ecos/src/amd_order.c
<absolute_path_to_repo>/soci-gnc/Lib/FSW/soar/include/ecos/src/amd_post_tree.c
<absolute_path_to_repo>/soci-gnc/Lib/FSW/soar/include/ecos/src/amd_postorder.c
<absolute_path_to_repo>/soci-gnc/Lib/FSW/soar/include/ecos/src/amd_preprocess.c
<absolute_path_to_repo>/soci-gnc/Lib/FSW/soar/include/ecos/src/amd_valid.c
<absolute_path_to_repo>/soci-gnc/Lib/FSW/soar/include/ecos/src/cone.c
<absolute_path_to_repo>/soci-gnc/Lib/FSW/soar/include/ecos/src/ctrlc.c
<absolute_path_to_repo>/soci-gnc/Lib/FSW/soar/include/ecos/src/ecos.c
<absolute_path_to_repo>/soci-gnc/Lib/FSW/soar/include/ecos/src/equil.c
<absolute_path_to_repo>/soci-gnc/Lib/FSW/soar/include/ecos/src/kkt.c
<absolute_path_to_repo>/soci-gnc/Lib/FSW/soar/include/ecos/src/ldl.c
<absolute_path_to_repo>/soci-gnc/Lib/FSW/soar/include/ecos/src/matlab_main.c
<absolute_path_to_repo>/soci-gnc/Lib/FSW/soar/include/ecos/src/preproc.c
<absolute_path_to_repo>/soci-gnc/Lib/FSW/soar/include/ecos/src/runecos.c
<absolute_path_to_repo>/soci-gnc/Lib/FSW/soar/include/ecos/src/spla.c
<absolute_path_to_repo>/soci-gnc/Lib/FSW/soar/include/ecos/src/splamm.c
<absolute_path_to_repo>/soci-gnc/Lib/FSW/soar/include/ecos/src/timer.c
<absolute_path_to_repo>/soci-gnc/Lib/FSW/soar/include/ecos/src/wright_omega.c

- Set the
Data definitionto beData defined in a single separate source file - Set the
Data definition filenameto besoci_global.c - Set the
Data declarationto beData declared in a single separate header file - Set the
Data declaration filenameto besoci_global.h

Here are the steps that I take to generate autocode.
Make sure your current Matlab path is the Src folder in the repository.
- Run the
Sim_init.mscript. - Click on the
FSW_Libin the main Simulink file that opens up. - In the lower-left corner, click on the grey lock icon. When the yellow bar pops up, click on
Disable this link.

- Click on
Code -> C/C++ Code -> Embedded Coder Quick Start. When the popup opens, clickNext - Choose
Subsystem, and then click onFSW_Liband clickNext. - Make sure things are set to
C codeandSingle instance. ClickNext. - Click
Nextand let Simulink figure out the number of sample times. This may take a minute, but you should see it come back with the following image:

- On the next screen, set
Device Vendorto beNXPandDevice TypetoCortex-M4. - Choose
Execution efficiencyas the priority. ClickNext. - You should see no suggested parameter changes on the next screen. If you do see a suggested change, you may not have configured Simulink properly -- or I may have forgotten to include something here. You will need to accept any suggested parameter changes to move ahead. Click
Next. - This will run the code generation tool, and will take some time. When it's done, you'll see a report open up automatically.
The generated code will be placed into the Build/soci_fsw_build folder, and will also generate a soci_fsw_build.zip folder.
If you get some build failures, try these steps:
- Delete the
Build/slprjfolder and try again. - Reach out to Taylor with screen shots of the error messages that you're seeing.