What is the role of Build tool object in toolchain?

6 visualizaciones (últimos 30 días)
Toshifumi Sone
Toshifumi Sone el 20 de Feb. de 2021
Comentada: Toshifumi Sone el 7 de Mzo. de 2021
Dear All,
Could you tell me the purpose of the code below??
I'm trying to make toolchain for RX64 micro-controller form Renesas Electronics. I have to make .hex file and ASAP2 file from Simulink bolck with Embedded Corder.
But I couldn't understand clear what the role of code below from link below .
% ------------------------------
% C Compiler
% ------------------------------
tool = tc.getBuildTool('C Compiler');
tool.setName('Intel C Compiler');
tool.setCommand('icl');
tool.setPath('');
tool.setDirective('IncludeSearchPath','-I'); <- What does this code mean? What is the purpose of this code?
tool.setDirective('PreprocessorDefine','-D');<- What does this code mean? What is the purpose of this code?
tool.setDirective('OutputFlag','-Fo');<- What does this code mean? What is the purpose of this code?
tool.setDirective('Debug','-Zi');<- What does this code mean? What is the purpose of this code?
tool.setFileExtension('Source','.c');<- What does this code mean? What is the purpose of this code?
tool.setFileExtension('Header','.h');<- What does this code mean? What is the purpose of this code?
tool.setFileExtension('Object','.obj');<- What does this code mean? What is the purpose of this code?
tool.setCommandPattern('|>TOOL<| |>TOOL_OPTIONS<| |>OUTPUT_FLAG<||>OUTPUT<|');<- What does this code mean? What is the purpose of this code?
Regards,

Respuesta aceptada

Yuxuan Hao
Yuxuan Hao el 24 de Feb. de 2021
Hi Toshifumi,
Simulink will use these options to generate the MSVC compiler option/makefile/cmakes.
For example, IncludeSearchPath means which directory you want to add to the search path. PreprocessorDefine means to defines a preprocessing symbol for a source file.
You should be able to find what do all these configurations mean in that web page.
Best Regards,
Yuxuan

Más respuestas (2)

Toshifumi Sone
Toshifumi Sone el 25 de Feb. de 2021
Dear Yuxuan,
Thank you for comment. Could you tell me some more?
  • Does the embedded corder use only MSVC compiler to make .c file or .h file? Is it impossible to use compiler for Renesas microcontroller ?
  • I tried to use cc-rx compiler within the make file. But the cc-rx compiler could not understand the -D option because it doesn't have the option. In this case how could I use cc-rx compiler ? Is it impossible to make executable file with embedded corder ? I would like to build with Embedded corder and get .hex file as executable file.
Kind regards,
Toshifumi
  2 comentarios
Ondrej Mikulas
Ondrej Mikulas el 25 de Feb. de 2021
Hello Toshifumi,
To use the cc-rx compiler, you need to modify the ToolchainInfo definition file. The code in the original question comes from the demo example file intel_tc from https://uk.mathworks.com/help/rtw/ug/register-custom-toolchain-and-build-executable.html#d122e99958.
Based on my experience, the documentation of this topic in Matlab Coder / Simulink Coder / Embedded Coder is quite too brief and fails to explain the complete workflow.
You need to modify the ToolchainInfo definition file in order to pass correct compiler and linker commands.
The PreprocessorDefine directive specifies the flag used to define macros for your compiler. The '-D' is specific to the Intel compiler from the demo example. You need to find an equivalent compiler flag that is valid for the Renesas compiler. Quickly skimming throught the documentation, I think the flag should be '-define='.
Similarly, the IncludeSearchPath specifies the compiler flag to select include directories. Intel compiler uses '-I' to select the include directories. Renesas CC-RX should use '-include='.
The other commands need to be customized in a similar way depending on the commands that Renesas compiler expects. You will need to set the name of the compiler commands:
% From Renesas ccrx documentation:
% ccrx -isa=rxv1 -output=obj=tp.obj tp1.c tp2.c
tool = tc.getBuildTool('C Compiler');
tool.setName( 'Renesas C Compiler'); % Descriptive name for you own identification
tool.setCommand( 'ccrx'); % Compiler command name
tool.setPath( ''); % Assumes the ccrx is defined on system path. Otherwise provide aboslute path to compiler installed folder
tool.setDirective( 'IncludeSearchPath', '-include');
tool.setDirective( 'PreprocessorDefine', '-define');
tool.setDirective( 'OutputFlag', '-output=obj=');
After registering the customized toolchain, you can experiment with it. It takes some trial and error to make things work, so prepare for that. Note that you can use tc.validate method of the ToolchainInfo object to check that it is formally correct (from Matlab point of view).
You can check that by setting GenerateCodeOnly parameter to on in Simulink model. Then you can inspect the generated makefile in the <model>_ert_rtw directory.
When you set the GenerateCodeOnly to off, Simulink will try to call the compiler and returns the commandline output to the Diagnostic Viewer window. You can check the messages there.
Toshifumi Sone
Toshifumi Sone el 7 de Mzo. de 2021
If you have succeeded to make executable file could you tell me about toolchain some more?
-Do you succeed to make executable file with the way you show avobe?
-How do you custom for Linker?
Regards,
Toshifumi

Iniciar sesión para comentar.


Toshifumi Sone
Toshifumi Sone el 26 de Feb. de 2021
Dear Ondrej,
Thank you for your advise. My embedded corder started to compile with cc-rx from Renesas.
But I found another error by compiler like below.
Have you ever expericnce this?
...### ツールチェーンの使用: Renesas | gmake makefile (RX64M)
### 'C:\Users\59692\Desktop\20210222_Simulink Share\Main\NassFCM_ert_rtw\NassFCM.mk' は最新の状態です。
### 'NassFCM' をビルドしています: "C:\PROGRA~1\MATLAB\R2017A~1\bin\win64\gmake" -f NassFCM.mk postbuild all
"C:\Program Files (x86)\Renesas Electronics\CS+\CC\CC-RX\V3.03.00\Bin/ccrx" -isa=rxv2 -fpu -endian=big -dbl_size=8 -signed_char -signed_bitfield -auto_enum -bit_order=left -pack -lang=c99 -output=obj -define=TERMFCN=1 -define=ONESTEPFCN=1 -define=MAT_FILE=0 -define=MULTI_INSTANCE_CODE=0 -define=INTEGER_CODE=0 -define=MT=0 -define=CLASSIC_INTERFACE=0 -define=ALLOCATIONFCN=0 -define=TID01EQ=0 -define=MODEL=NassFCM -define=NUMST=1 -define=NCSTATES=0 -define=HAVESTDIO -include=C:/Users/59692/Desktop/202102~1/Main -include=C:/Users/59692/Desktop/202102~1/Main/NassFCM_ert_rtw -include=C:/Users/59692/Desktop/HA11test/src/smc_gen -include=C:/Users/59692/Desktop/202102~1/Main/AppInterface/Nass -include=C:/Program -include=C:/Users/59692/Desktop/202102~1/Main/Files -include=C:/Users/59692/Desktop/202102~1/Main/(x86)/Renesas -include=C:/Users/59692/Desktop/202102~1/Main/Electronics/CS+/CC/CC-RX/V3.03.00/bin -include=C:/Users/59692/Desktop/202102~1/Main/AppInterface/Generic -include=C:/PROGRA~1/MATLAB/R2017A~1/extern/include -include=C:/PROGRA~1/MATLAB/R2017A~1/simulink/include -include=C:/PROGRA~1/MATLAB/R2017A~1/rtw/c/src -include=C:/PROGRA~1/MATLAB/R2017A~1/rtw/c/src/ext_mode/common -include=C:/PROGRA~1/MATLAB/R2017A~1/rtw/c/ert "AirByp.c"
RX Family C/C++ Compiler V3.03.00 [20 Nov 2020]
RX Family Assembler V3.03.00.02 [11 Nov 2020]
Renesas Optimizing Linker V3.03.00 [01 Oct 2020]
Copyright (C) 2011, 2020 Renesas Electronics Corporation
Copyright (C) 2003-2020 University of Illinois at Urbana-Champaign.
All rights reserved.
AirByp.c:
F0553200:Error occurred in executing 'macrx.exe'
Kind regards,
Sone

Categorías

Más información sobre Custom Toolchain Registration en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by