For Newer Versions - MATLAB R2023a, R2022b (Update 2), R2022a (Update 6) and beyond:
To generate the A2L file for the Speedgoat workflow in recent MATLAB versions, do the following:
(1) On the REAL-TIME tab, select RUN ON TARGET > Build Application.
(2) On the C CODE tab, select Share > Generate Calibration Files. If you do not see the C Code tab, go to the APPS tab and open the Simulink Coder app.
(3) Use the Generate Calibration Files utility to generate the required version of ASAP2 file. To replace ECU addresses in the A2L file, in the Symbol file field, provide the 'ModelName' binary file located in the build folder ('ModelName_sg_rtw' or 'ModelName_slrealtime_rtw'). For more information about using the tool, see Generate ASAP2 and CDF Calibration Files. You can perform the same operations from steps (1)-(3) by using the slbuild and coder.asap2.export functions. Note that 'coder.asap2.export' requires the full build folder 'ModelName_slrealtime_rtw' as well as the model SLX file and all its dependencies.
>> slbuild('ModelName');
>> coder.asap2.export('ModelName',...
'MapFile', 'ModelName_sg_rtw/ModelName',...
'Comments', false);
Optionally, you can package the generated A2L file into the MLDATX file by using:
>> copyfile(fullfile(pwd,'/ModelName_slrealtime_rtw/ModelName.a2l'));
>> app_obj = slrealtime.Application('ModelName.mldatx');
>> updateASAP2(app_obj,'ModelName.a2l');
The A2L file will appear in the 'ModelName_slrealtime_rtw' build folder.
If you would like any of the above functions to be run automatically after every build, consider adding them as a post-code generation command ("PostCodeGenCommand") in the configuration parameters. The detailed procedure for this can be referenced here:
For Older Versions - MATLAB R2022b (Update 1 and earlier), R2022a (Update 5 and earlier), R2021b, R2021a, and R2020b:
In previous releases, the Simulink Real-Time model build will always generate an A2L file in the post-build step. The A2L file will appear in the 'ModelName_slrealtime_rtw' build folder.
In addition, the A2L file is packaged into the real-time application MLDATX file. You can extract the A2L file from the MLDATX file at a later point using the extractASAP2 method:
>> app_obj = slrealtime.Application('ModelName.mldatx');
>> extractASAP2(app_obj);
It is not possible to disable the automatic A2L file generation and packaging in these previous releases.