aa4cc / ert_linux

Simulink Embedded Coder target for Linux
Other
25 stars 12 forks source link

cannot generate code in matlab2023b #4

Open muler415 opened 3 months ago

muler415 commented 3 months ago

when I opened model_sample.slx, used embeded coder in simulink which used ert_linux.tlc, after clicking generate code, there is error as following. please let me know anything I missed.

Thanks/Forrest

=== 编译 (已用时间: 0.317 秒) === 错误:None of the toolchains, "Clang v3.1 | gmake (64-bit Mac), GNU gcc/g++ | gmake (64-bit Linux)", specified in D:\repo2\ert_linux\ert_linux\ert_linux.tmf in are in the current list of registered toolchains, "Arduino ARM, Arduino ARM MBED, Arduino AVR, AUTOSAR Adaptive Linux Executable, AUTOSAR Adaptive | CMake, Cadence Xcelium (64-bit Linux), Catkin, CMake, Colcon Tools, eProsima 2.x Project, ESP32, GNU Tools for VEX ARM Cortex, IBIS-AMI Microsoft Visual C++ 2017 v15.0 | nmake (64-bit Windows), IBIS-AMI Microsoft Visual C++ 2019 v16.0 | nmake (64-bit Windows), IBIS-AMI Microsoft Visual C++ 2022 v17.0 | nmake (64-bit Windows), IBIS-AMI MinGW64 | gmake (64-bit Windows), Intel oneAPI 2021 (w/Microsoft Visual Studio 2017) | nmake (64-bit Windows), Intel oneAPI 2021 (w/Microsoft Visual Studio 2019) | nmake (64-bit Windows), Intel oneAPI 2022 (w/Microsoft Visual Studio 2017) | nmake (64-bit Windows), Intel oneAPI 2022 (w/Microsoft Visual Studio 2019) | nmake (64-bit Windows), Intel oneAPI 2022 (w/Microsoft Visual Studio 2022) | nmake (64-bit Windows), Intel oneAPI 2023 (w/Microsoft Visual Studio 2019) | nmake (64-bit Windows), Intel oneAPI 2023 (w/Microsoft Visual Studio 2022) | nmake (64-bit Windows), Intel Parallel Studio XE 2020 (w/Microsoft Visual Studio 2017) | nmake (64-bit Windows), Intel Parallel Studio XE 2020 (w/Microsoft Visual Studio 2019) | nmake (64-bit Windows), LCC-win64 v2.4.1 | gmake (64-bit Windows), Mentor Graphics QuestaSim/Modelsim (32-bit Windows), Mentor Graphics QuestaSim/Modelsim (64-bit Linux), Mentor Graphics QuestaSim/Modelsim (64-bit Windows), Microsoft Visual C++ 2017 v15.0 | CMake/Ninja (32-bit Windows), Microsoft Visual C++ 2017 v15.0 | CMake/Ninja (64-bit Windows), Microsoft Visual C++ 2017 v15.0 | CMake/nmake (32-bit Windows), Microsoft Visual C++ 2017 v15.0 | CMake/nmake (64-bit Windows), Microsoft Visual C++ 2017 v15.0 | nmake (64-bit Windows), Microsoft Visual C++ 2019 v16.0 | CMake/Ninja (32-bit Windows), Microsoft Visual C++ 2019 v16.0 | CMake/Ninja (64-bit Windows), Microsoft Visual C++ 2019 v16.0 | CMake/nmake (32-bit Windows), Microsoft Visual C++ 2019 v16.0 | CMake/nmake (64-bit Windows), Microsoft Visual C++ 2019 v16.0 | nmake (64-bit Windows), Microsoft Visual C++ 2022 v17.0 | CMake/Ninja (32-bit Windows), Microsoft Visual C++ 2022 v17.0 | CMake/Ninja (64-bit Windows), Microsoft Visual C++ 2022 v17.0 | CMake/nmake (32-bit Windows), Microsoft Visual C++ 2022 v17.0 | CMake/nmake (64-bit Windows), Microsoft Visual C++ 2022 v17.0 | nmake (64-bit Windows), Microsoft Visual Studio Project 2017 | CMake (32-bit Windows), Microsoft Visual Studio Project 2017 | CMake (64-bit Windows), Microsoft Visual Studio Project 2019 | CMake (32-bit Windows), Microsoft Visual Studio Project 2019 | CMake (64-bit Windows), Microsoft Visual Studio Project 2022 | CMake (32-bit Windows), Microsoft Visual Studio Project 2022 | CMake (64-bit Windows), MinGW64 | CMake/gmake (64-bit Windows), MinGW64 | CMake/Ninja (64-bit Windows), MinGW64 | gmake (64-bit Windows), NVIDIA CUDA (w/Microsoft Visual C++ 2017) | nmake (64-bit Windows), NVIDIA CUDA (w/Microsoft Visual C++ 2019) | nmake (64-bit Windows), NVIDIA CUDA (w/Microsoft Visual C++ 2022) | nmake (64-bit Windows), RTI Connext 6.x Project, RTI Connext Micro 2.4 Project, Simulink Real-Time Linux arm64 Remote Build Toolchain, Simulink Real-Time Linux x64 Remote Build Toolchain, Simulink Real-Time Toolchain, Synopsys VCS (64-bit Linux), Texas Instruments Code Composer Studio (ARM), Texas Instruments Code Composer Studio (C2000), Texas Instruments Code Composer Studio - EABI (C2000), Xilinx Vivado Simulator (64-bit Linux), Xilinx Vivado Simulator (64-bit Windows)".

ppisa commented 3 months ago

The ert_linux is intended for GNU/Linux targets, native and cross compiled and can be used even as experimental base for some other POSIX compliant RTOSes, tested with NuttX. You can see that the message specifies that "Clang v3.1" or "gmake (64-bit Mac), GNU gcc/g++" or "gmake (64-bit Linux)" toolchain is missing. You seems to have some Linux targets registered but they are some CMake specific ones.

The primary information which you should report is what you want achieve. i.e. build my model for Raspberry Pi 3 RT Linux target on Windows host. Or I want to build for x86 64-bit Ubuntu PC target with COMEDI cards inserted.

Even in this case, I have probably bad news for you, I have newer tested Matlab on some Windows based host from end of nineties and ert_linux has not been tested and tuned (and hacked, Windows are non-standard, non-POSIX environment) for such use. ert_linux has been successfully used on x86_64 Debian system running Preemp RT kernels, graphics etc to generate models run on same computer with up to 30 kHz applications, it has been used to build and croscompile models for Raspberry Pi, AMD/Xilinx Zynq systems, 64-bit Raspberry Pi targets, Nvidia Jetson and many more targets. But for all these tasks we have used GNU/Linux based host systems for development.

Clean fixes to run it even on Windows are welcomed but dirty hacks not.

muler415 commented 3 months ago

Thanks for supporting. do you have detail how to install these toolchains("Clang v3.1" or "gmake (64-bit Mac), GNU gcc/g++" or "gmake (64-bit Linux)") on windows? how to register these toolchains on matlab? I cannot find it in readme. please help.

Thanks/Forrest

ppisa commented 3 months ago

I cannot help without extraordinary time spent and installing Windows somewhere etc... There is not necessary readme to install standard toolchain on any of GNU/Linux distribution. It is there when you have environment to compile arbitrarily C program. You get superset of these tools by installing package build-essential on Debian, Ubuntu, you use zypper info -t pattern devel_basis on Suse, basically when Matlab supports and is setup for Simulink acceleration and S-functions builds you have all required tools. For cross compile for ARM AArch64 you add crossbuild-essential-arm64 and ert_linux works. On windows, there is problem to install even GNU/make, system is incapable to provide basic services so you need to install whole environment like https://en.wikipedia.org/wiki/MinGW, https://en.wikipedia.org/wiki/Cygwin but the the paths in that environment do not match paths in native Wndows programs so you need to use paths mapping etc. It is horror and I have no time to even glimpse at it till summer. And I expect that there would be more problems in ert_linux generated Makefiles caused by this MS Windows system mess. If you want to try ert_linux now setup some Linux system and start Matlab on it. Even Microsoft cannot run they latest AI tools without GNU/Linux installed in WSL as I have read in the news and we have much less resources and motivation to spent weeks on their broken system.

ppisa commented 3 months ago

And you do not specify your target, motivation, project so I cannot have idea and response if the idea is feasible to be solved by ert_linux, it is minimalist and works well, in the fact in all tested version much better from real-time timing guarantees rules than Matworks original code, but they seem to not care for fundamental breaking basic RT Linux application design rules when we reported them to developers around their coders tools. But many Simulink tools do not work with our version on the other hand because they rely on some wrappers etc. which we have not resorces to implement yet.

muler415 commented 3 months ago

Thanks for explaination. I understood. I tried to make it work on my win11 Matlab, targeting machine is Ubuntu 22.04 with patch Linux Preempt-RT. I have installed mingw64 and cross-compiler aarch64-linux-gnu on my win11. here is what I tried: comments these toolchains line in ert_linux.tmf by workaround this issue. and now it can generate code.

Opt in to simplified format by specifying compatible Toolchain

TOOLCHAIN_NAME = ["Clang v3.1 | gmake (64-bit Mac)", \

"GNU gcc/g++ | gmake (64-bit Linux)"]

however when I tried to compile model_sample.slx in embeded coder by make command - 'make_rtw OPT_OPTS="-O2 -ggdb -Wall" CC=aarch64-linux-gnu-gcc CPP=aarch64-linux-gnu-gcc'. it will throw failure. anything should I change ert_linux.tmf to fix this failure.

=== 编译 (已用时间: 24 秒) ===

正在启动 model_sample 的编译过程

### 正在为 '模型特定' 文件夹结构生成代码和工件
### 正在将代码生成到编译文件夹中: D:\repo2\ert_linux\model_samples\model_sample_ert_linux
### Invoking Target Language Compiler on model_sample.rtw
### Using System Target File: D:\repo2\ert_linux\ert_linux\ert_linux.tlc
### Loading TLC function libraries
.......
### Generating TLC interface API for custom data
### Initial pass through model to cache user defined code
.
### Caching model source code
................................
### Writing header file model_sample_types.h
### Writing header file model_sample.h
### Writing header file rtwtypes.h
.
### Writing header file multiword_types.h
### Writing source file model_sample.c
### Writing header file model_sample_private.h
### Writing source file model_sample_data.c
### Writing header file rtmodel.h
.
### Writing source file ert_main.c
### TLC code generation complete (took 4.642s).
### Generating TLC interface API.
..
### Creating data type transition file model_sample_dt.h
### Creating HTML report file index.html
### 正在保存二进制信息缓存。
.
### 正在处理模板联编文件: D:\repo2\ert_linux\ert_linux\ert_linux.tmf
警告:警告: 在模板联编文件 D:\repo2\ert_linux\ert_linux\ert_linux.tmf 中发现旧版 make 变量 |>ISPROTECTINGMODEL<|。不再需要这些变量。您可以删除这些变量。
警告:警告: 在模板联编文件 D:\repo2\ert_linux\ert_linux\ert_linux.tmf 中发现旧版 make 变量 |>MASTER_ANCHOR_DIR<|。不再需要这些变量。您可以删除这些变量。
### 已创建联编文件 D:\repo2\ert_linux\model_samples\model_sample_ert_linux\model_sample.mk
### model_sample 的编译过程因错误而中止。
编译的顶层模型目标:

模型            操作  重新编译原因        
================================
model_sample  失败  代码生成信息文件不存在。  

编译了 0 个模型,共 1 个模型(0 个模型已经是最新的)
编译持续时间: 0h 0m 23.327s
错误:### Make will not be invoked - template makefile is for a different host
muler415 commented 3 months ago

I spent some time to check tmf file and found it host on Unix platform. but in my case I used Windows as matlab host. I changed HOST=PC in ert_linux.tmf. the issue is gone. It can compile generated code now.