Customized hardware implementation causes a simulink error: Invalid index with 2018b.

조회 수: 10 (최근 30일)
I am customizing my own hardware implementation according to the tutorial: https://www.mathworks.com/help/rtw/ug/hardware-targets.html using ert.tlc with matlab 2018b.
When I select my customized hardware implementation and ert.tlc(Embedded Coder) as system target file, the simulink 'Build Model' command reports a 'Component:Simulink | Category:Block diagram error: Invalid index' error as shown in the following picture,
When I run the sl_build(gcs) command independently, the detailed error is displayed as,
Error using mf.zero.PrimitiveSequence/at
Invalid index.
Error in Simulink.filegen.internal.FolderSpecificationTokens/resolveTargetEnvironemntToken
Error in Simulink.filegen.internal.FolderSpecificationTokens
Error in Simulink.filegen.internal.FolderConfiguration
Error in slbuild_private
Error in sl (line 15)
[varargout{1:nargout}]=feval(varargin{:});
Error in slbuild (line 83)
sl('slbuild_private', mdl, target, varargin{2:end});
My customized script is just as follows without any modifications from the above URL,
function sl_customization(cm)
cm.registerTargetInfo(@loc_register_device);
end
function thisDev = loc_register_device
thisDev = RTW.HWDeviceRegistry;
thisDev.Vendor = 'MyDevVendor';
thisDev.Type = 'MyDevType';
thisDev.Alias = {};
thisDev.Platform = {'Prod', 'Target'};
thisDev.setWordSizes([8 16 32 32 32]);
thisDev.LargestAtomicInteger = 'Char';
thisDev.LargestAtomicFloat = 'None';
thisDev.Endianess = 'Unspecified';
thisDev.IntDivRoundTo = 'Undefined';
thisDev.ShiftRightIntArith = true;
thisDev.setEnabled({'IntDivRoundTo'});
end
The Hardware Implementation pane is shown as follows:
By the way, it works correctly in the MATLAB 2017b environment and my computer system version is Windows 10 1809.
How can I customize my own hardware implementation correctly for scientific purposes in 2018b?
Thanks in advance for your answers.

채택된 답변

Lars Rosqvist
Lars Rosqvist 2018년 11월 29일
편집: Lars Rosqvist 2018년 11월 30일
The problem is this line:
thisDev.Alias = {};
Set this to something else than empty.
thisDev.Alias = {'MyDev'};
/Lars
  댓글 수: 2
Hankun Jiang
Hankun Jiang 2019년 2월 15일
You said the problem is in that line and your answer is accepted. However, how can I open the "customized script" and modify the code. Thank you.
Snipaste_2019-02-15_10-43-48.png
Lars Rosqvist
Lars Rosqvist 2019년 2월 15일
Hi Hankun,
No, in many cases these files are protected by the developer so you cannot access them.
In this case the solution is simple. In the new update of MATLAB R2018b the need of having Alias specified has been fixed, so you do not need to update this file. Just update MATLAB.
I have verified this in update 3 of R2018b and it works.
MATLABUpdates.jpg
Thanks,
Lars

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Andrei Vlad
Andrei Vlad 2018년 11월 30일
Hello,
I am trying to generate code for an STM32 discovery board (STM32L476G) for academic purposes.
I am using matlab 2018 and embedded coder together with the STM32 Mat/Target support package and STM32CubeMx.
I have selecte in Hardware Implementation STM32 as the vendor and device type.
I have generated a .ioc (cubemx config) file which I have then imported and specified the correct cubemx path in matlab.
I have built a simple example to control the LEDs based on the joystick (see attachment).
When trying to generate code I get the following issue: Invalid index.
Current observation: The model itsself is not a problem as i can remove all stm32 specific blocks and leave a very simple logic without solving the issue.
Assumption: The STM32 library which is imported when selecting stm32 in hardware implementation is not imported with a correct index.
Please help me solve this issue!
Many thanks,
Andrei
  댓글 수: 1
Jonathan Mott
Jonathan Mott 2018년 12월 25일
From your Simulink model, select Model Configuration Parameters. Under the Hardware Implementation menu, select Custom Processor from the Device vendor drop down list. Make sure you configure it so it has the same device details as the STM32 32-bit Cortex-M Device type.

댓글을 달려면 로그인하십시오.


Lars Rosqvist
Lars Rosqvist 2018년 11월 30일
Hi,
Try to search for a function called loc_createDevice in your STM installation.
If you find it, check if the Alias is empty.
/Lars
  댓글 수: 5
Andrei Vlad
Andrei Vlad 2018년 12월 27일
Hello,
Sorry for the late reply. Indeed, I have used the same fix (production hardware different from target hardware). I have also contacted STMicroelectronics directly, but they did not offer an answer.
In the meantime I have seen there are many other bugs in the tools STM provides (MAT Target, CubeMx, SW4STM32). Hopefully they will be fixed soon.
Best regards,
Andrei

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by