cancel
Showing results for 
Search instead for 
Did you mean: 

STM32-MAT Simulink problems

sebastiaan goossens
Associate II
Posted on March 16, 2017 at 13:08

I am trying to get the STM32-MAT package to work with Simulink to do some test on a stm32f4discovery board and I am running into multiple issues.

1. A simple Simulink setup for a normal build:

0690X00000606a4QAA.png

When building this simple model, the above error occurs.

2. Trying out the PIL filter demo from the STM32demos folder of the STM32-MAT package.

I select the correct uart settings, the processor and speed. For the uart I use usart2 at PA3 and PA2. The toolchain I use is SW4STM32.

When the configuration for STM32CubeMX opens, the uart port has the following configuration error:

0690X00000606aOQAQ.png

The correct keyword according to the program should be WORDLENTH_8B, not UART_WORDLENGTH_8B. This has to be fixed manually every time and prevents the project generation from working when the call to CubeMX is hidden.

3. If the issue above is fixed manually and the project is generated and opened with SW4STM32, the compilation errors out with missing files. This is due to the include paths being messed up with the quotes:

0690X00000606DdQAI.png

These can be fixed manually but then it errors out because there is an extra file which has no rule for make:

0690X00000606XzQAI.png

This file seems to be included by accident and the include itself is some hardcoded path to a username (not mine). The file and include can be deleted to make the compilation finally succeed.

4. If the compiled image then is uploaded to the target (stm32f4discovery) and simulink is continued, it times out on the uart communication. I can verify something is sent from the windows machine, but for some reason nothing is done with the command. I have also verified in the debugger that the correct uart device is receiving this command.

For every simulation, the paths to stm32-mat and STM32CubeMX have been set up correctly.

I have the following versions of programs:

Matlab r2016b (with all the required toolboxes)

STM32CubeMX 4.20.0 with STM32F4 package 1.15.0

SW4STM32 v1.14.0

STM32-MAT_TARGET 4.4.1

Does anyone have any idea on how to get the normal compiling working and how to get the demo working?

Any help would be highly appreciated!

Regards,

Sebastiaan

#simulink #stm32f4 #stm32cubemx #stm32f4-discovery #sw4stm32 #compile #matlab #stm32-mat/target-matlab
5 REPLIES 5
Imen.D
ST Employee
Posted on March 16, 2017 at 15:15

Hi,

Please find attached 'STM32-MAT/TARGET Hands On' document which help you to configure and developSTM32 graphical applications using MATLAB® Simulink environment.

You may refer to this thread

https://community.st.com/0D50X00009XkYEASA3

,this may help you on your issue.

Imen

________________

Attachments :

STM32_MAT-TARGET_HandsOn_v1_0.pdf : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HymF&d=%2Fa%2F0X0000000bCK%2FIfJHT1orBALW0EMu9PmO7NoahrRKW6TXNMrj4S80xeM&asPdf=false
When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
Posted on March 17, 2017 at 14:40

Hi,

Regarding 1 :

Generally it is problems of access rights to files.

For example, if the file is locked during opening and you are trying to write it again.

Another point of attention, there is a bug in the 4.20 which makes the default values are not always good, especially for the generation of the code of the clock, a 4.20.1 is prepared.

Regarding 2:

Sorry, STM32CubeMx keyword has changed. It will be integrated for next STM32-MAT/TARGET release.

Regarding 3:

It looks strange that getBuffPtr is included to project. Can you please verify that it is not included from Project Configuration parameters window > Code Generation >STM32 Project Files ?

Regarding quotes, I will give you answer asap.

Regarding 4:

What discovery do you use?

Because, stm32f4-discovery do not provide Virtual Com Port.

stm32f4-discovery_disc1 provides VCP but you must add wires as described in documentation (UM1472) page13/39.

Best regards

Pascal

Posted on March 20, 2017 at 15:17

Dear Pascal,

Regarding 1:

I got the project generation working, my mistakes were that the Simulink file and CubeMX config file were not in the same locations and that I didn't specify any toolchain during CubeMX config file generation (I was used to the PIL setup where a toolchain would be specified in a separate dialog from Simulink).

Now a new problem arises. In SW4STM32, the automatic makefile generation fails to include the MATLAB folder so the compilation fails once again:

0690X00000606bvQAA.png

A workaround for this is moving the test.c file to the <project root>/Src folder next to main.c or creating the makefile manually. Do you have any idea why this folder isn't included in the makefiles?

EDIT: It seems that deselecting '' Generate Under Root'' from the CubeMX project settings screen solves this issue (This option is enabled by default!!). This also makes the folder structure in the project explorer much nicer. I also tested some other toolchains. Atollic TrueSTUDIO (evaluation version) also suffers from an issue like this (some files are missing in the project file explorer and compiling fails. Both TrueSTUDIO and SW4STM32 are eclipse based so not really unexpected). Also here, deselecting ''Generate Under Root'' solves this problem. Keil MDK-ARM v5 (evaluation version) and IAR EWARM (evaluation version) work just fine.

Regarding 2:

I'm glad to hear a new release is being prepared. Do you have any indication when the new releases of STM32-MAT and CubeMX are planned?

Regarding 3:

I found the source of the include issue. These are located in the configuration section of ''IIR_Filter_int32.mdl'' and, not in the configuration of ''Test_PIL_IIR_Filter.mdl'', which is the main file and thus it was not clear where these includes were coming from.

IIR_Filter_int32.mdl configuration:

0690X00000606bRQAQ.png

Test_PIL_IIR_Filter.mdl configuration:

0690X00000606YYQAY.png

Also, the paths of STM32CubeMX and STM32-MAT are not correct by default, but I guess that does not really matter as we're supposed to update those anyways:

0690X00000606bWQAQ.png

In my case, the correct paths are:

0690X00000606bbQAA.png

With this, the issue of the misplaced quotes isn't fixed however, only the extra included file path.

Regarding 4:

I am using the STM32F407G-DISC1 board in combination with an external FTDI converter. This setup has worked fine while running some tests from the stm32f4discovery board support package from Mathworks. I have tried out this setup again and now it works apparently, so I must have done something wrong by accident earlier. I was able to run the PIL demo from both IAR-EWARM and SW4STM32 (although I needed to fix the includes manually as described earlier).

Many thanks for all the help!

Regards,

Sebastiaan

Posted on March 20, 2017 at 16:38

Hi Sebastiaan,

project generation between Eclipse based IDE and IAR/Keil one is different.

I will transmit your notes regarding 'generate under root' option setting to SW4STM32 and STM32CubeMx teams.

I will also make tests with SW4STM32.

Until now, I prefer using Keil/IAR because project is directly opened. But I have to focus on SW4STM32 tool of course.

Sorry for the remaining getBuff in 

IIR_Filter_int32.mdl, I will remove it.

Both settings for principal model and included (called) one should be the same, you should get an error if not.

Regarding release, I hope I will be able to provide it by end of April.

Regarding 4, I also used FTDI converter when Virtual Com Port is not present. It should work.

Thank you for your feed back.

Best regards

Pascal

Posted on April 06, 2017 at 15:10

Hey guys,

thank you for the guidance so far! I have exactly the same issues. I'm using the newest versions of all programs (Matlab 2016B with all necessary addons, CubeMX 4.20.1, FW_F4_V.1.15.0 package  and SW4STM32). When I try to compile the PIL Test from the hands on, I cannot build the project.

- When I manually move the .ioc file to the root folder with the Simulink file, the project compiles but it does not have any bindings with the generated code from Simulink.

- When not moving the .ioc file, I get dozens of errors from the build process. Most of them concern the unresolved includes coming with the quotes. After correcting that by hand, I still get the errors. It's strange, because the missing files are now in the include folder of the project - see below.

0690X00000606UrQAI.png

I have almost no experience with eclipse yet, so I don't know if that's a beginners mistake. I tried clean project, rebuild index, freshen files etc. but with no success.

Sebastiaan, would you mind writing step by step instructions how you got the generated code to work on your Discovery board using SW4STM32? I'm completely stuck and don't know what else to try.

In Keil the project is compiling without issues, but I don't want to buy the full version Keil. After flashing the device in Keil, I was not able to get the PIL example to work. I got the same time-out error as you. The host is sending a short message, but the F4 is not answering. The cause could be, that the IIR_Filter_32 Model is defined to run only one second in Simulink. Maybe you have some insights what the issue might be there, too. I'm using a USB-to-Serial Adapter from Polulu which I already used to debug serial communication from the F4 when writing C-code directly.

I'm looking forward to your answer!

Arthur