cancel
Showing results for 
Search instead for 
Did you mean: 

Failed to connecting to the target through MATLAB simulink.

Abdulilah Alsulami
Associate II
Posted on October 26, 2017 at 08:07

How I can solve

Failed to connect to the target problem occurred during connecting simulink to STM32F4 board in External Mode?

 

I follow all procedure mentioned on MAT-Target PDF provided by ST, but when I begin connecting my model to the target this error message occurred:

'Error occurred while executing External Mode MEX-file 'ext_comm': Failed to connect to the target. Possible reasons for the failure: 

 

a) The target is not switched on. 

 

b)The target is not connected to your host machine. 

 

c) The application for the model is not running on the target. 

 

You might have clicked the Stop button. If the Run button is not dimmed, click it. Otherwise, click the Build button, which downloads and runs your application on the target.

Caused by: Expected 1xN string array for host name'.

 

I checked the three possible errors mentioned above but no result.

Also I attached a snapshot for the error window appearing during connecting process.

So, could any one help me for solving this issue.

I used 2016a MatLab version with STM32F4 nucleo board.

#simulink #stm32-mat/target-matlab
1 ACCEPTED SOLUTION

Accepted Solutions
Posted on February 09, 2018 at 11:17

Hi, everyone

External mode require VCP(Virtual Com Port) in the configuration but the

http://www.st.com/en/evaluation-tools/stm32f4discovery.html

's virtual com port are not available. because ST-Link are not connected to the USART of the STM32F407.

ST-Link of old reference doesn?t support VCP at all.

ST-Link of the new ref (

http://www.st.com/en/evaluation-tools/stm32f4discovery.html

) support VCP but is NOT connected to target.

So, if you want to use it must do configuration as shown in below picture.

0690X00000609exQAA.png

Source:

http://www.st.com/content/ccc/resource/technical/document/user_manual/70/fe/4a/3f/e7/e1/4f/7d/DM00039084.pdf/files/DM00039084.pdf/jcr:content/translations/en.DM00039084.pdf

Best regards,

View solution in original post

20 REPLIES 20
Sam Q.
Associate III
Posted on November 10, 2017 at 10:47

Hello,

did you solve this problem? I also have problem connecting Simulink to my STM32F4 Discovery Board in external mode.

Best Regards

XJ Q

Sam Q.
Associate III
Posted on November 10, 2017 at 10:51

I noticed that according to the MAT/TARGET instruction the port named 'STMicroelectronics STLink Virtual COM Port' is selected as PC COM port. But I don't think it's right.  Did you also configure it as described?

Sam Q.
Associate III
Posted on November 10, 2017 at 11:48

Hi guy,

Finally, I troubleshot this problem.

Point 1): By step 'PC COM Port selection', DO NOT select the port 'STMicroelectronics STLink Virtual COM Port' for the communication between the PC and your target board. Instead, you should select your USB Serial Port. So, it means that what is described in the MAT/TARGET instruction (Hands On, Rev 2.2, PC COM Port selection, Page 91) is not correct.

Point 2): If you use Keil as your IDE, don't forget to start debug session and start code execution after downloading your code to the board. In this way, click Debug >> Start/Stop Debug Session >> OK >> Run (or Ctrl+F5, and then F5)

I hope that it would be helpful for you.

Best regards

XJ Q

Abdulilah Alsulami
Associate II
Posted on November 16, 2017 at 09:31

Hi

xiaojie.qiu

,

Thanks for reply.

I tried this solution but still give me error.

Could any one help.

Sam Q.
Associate III
Posted on November 16, 2017 at 09:49

Hi,

Do you use USART as the communition? If so, please do check, wether the MEX-file name is ext_serial_win32_comm.

0690X0000060PEfQAM.png

Although you selected USART as the communication while generating the code, but actually the MEX-file is still ext_comm, which means that TCP/IP will be used as communication. This bug will lead to the error when you try to connect to your target. According to your error report, your MEX-file is ext_comm.

By the way, youhave to enable USART that you want to use in CubeMX.

Best Regards,

XJ Q

Posted on November 27, 2017 at 17:52

Hi XJ Q thank you for you posts. I tried with your method but my UART communication do not work. I have:

1) Selected 'PC ComPort' (using COM1) and not 'STMicroelectronics STLink Virtual COM Port'

2) Selected 115200 bitrate on COM1 property

3) After Keil project generation, I had running the application in debug mode (Ctrl+F5)

4) I tried to write 'Inf' and '10' in the 'Simulation Stop time' filed on Simulink Model (I have read in web that perhaps it was a problem).

5) I tried with USART2 (PA2 + PA3) and USART3 (PB11 + PD8).

Can you suggest me other try to do?

PS

If you want I can send to you my project with the model, for check if I have hardware problems. I'm really desperate

:(

 

:(

 

Best Regards,

Nifed
Posted on December 05, 2017 at 12:39

Hi guys,

Thanks for replying.

I used USART3 as the communication, since it's already connected to my STM32F429 board through ST Linker. ( I had test it in the past and working properly). Also, I enabled USART3 pins that I used in CubeMX.

Regardings the MEX-file,  I checked and it's, as XJ Q mentioned, ext_comm. So, when I modify it to

ext_serial_win32_comm (Just by clicking on stm32_serial tow times through transport layer options), the previous error cleared and another new error message occurred

.

I attached a snapshot for new error.

So do you have any solution.

Thank you again.

0690X00000608r9QAA.png
Abdulilah Alsulami
Associate II
Posted on December 07, 2017 at 13:25

Hi guys,

I really appreciate you for helping me.

the error was eliminated and the model working properly in External mode.

I want to mention the bugs that I detect, and I hope the ST technical support to solve them very soon.

1. when you generate the code by the matlab and try to build the opened code by keil you will find error and this error because the value of Heap size. even if you had been changed the value of the Heap size (to 0x3000 according to MAT-target PDF) in CubeMx. you will find that it has not changed when check it again in your code.

so to fix this error you need to change it manually again in your code and Rebuild the code. 

2. When you select stm32_serial for Transport layer, MEX-file name stay ext_comm. But this will cause the famous error, so you have to deselect stm32_serial and sellect it again to change the MEX-file name to ext_serial_win32_comm

 .

Last thing I want to say is that I found ST support team was not helpful and I hope them to change their policy towards the customers.

Posted on January 19, 2018 at 14:10

But am not able to get MEX file as ext_serial_win32_comm still it shows ext_comm only how to resolve this