cancel
Showing results for 
Search instead for 
Did you mean: 

How to build an example from ST distribution?

ozvena
Associate II
Posted on January 14, 2012 at 06:08

When I try to build an example from ST distribution: STM32F4-Discovery_FW_V1.1.0\Project\Peripheral_Examples\IO_Toggle

I get an error complaining of missing stm32f4_discovery.h.

This header file is distributed in a folder with other .c .h and libPDMFilter_Keil.lib files. If I copy the missing .h and the corresponding .c file into the project folder, I get new errors…and I keep fixing them by copying of the missing files but it seems that there must be a better way.

What are the general steps for building of the examples? I am using CrossWorks IDE.

Thank you.

12 REPLIES 12
myshanr
Associate II
Posted on January 14, 2012 at 07:43

路过,顺便帮顶。。。

sorry。。。

ozvena
Associate II
Posted on January 18, 2012 at 19:22

I am calling functions from stm32f4_discovery.c. In order to build with this source file, I had to modify it to add the following includes:

#include ''stm32f4xx_gpio.h''

#include ''stm32f4xx_rcc.h''

#include ''stm32f4xx_exti.h''

#include ''stm32f4xx_syscfg.h''

#include ''misc.h''

Now it is a ''domino'' effect. Now another file is failing to compile:

/CrossWorks Project 2/stm32f4xx_rcc.c:1088: undefined reference to `assert_param'

This is strange. It seems that the provided source code is defected? It should include the missing includes.

I have to edit stm32f4xx_rcc.c to include:

#define assert_param(expr) ((void)0)

Posted on January 18, 2012 at 20:55

This normally all comes in via stm32f4xx_conf.h

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
ozvena
Associate II
Posted on January 18, 2012 at 21:06

Thank you! Yes, I did notice this header file. I avoided it because the ST firmware distribution has 22 of these files. That seemed strange to me. 

Posted on January 18, 2012 at 21:26

Thank you! Yes, I did notice this header file. I avoided it because the ST firmware distribution has 22 of these files. That seemed strange to me.

 

Yes, because it permits per-project customization. The goal with a project would be to have the IDE/compiler know where the library, and system, include files are located (via search paths). From command line tools this is typically achieved with -I or -L options.

Earlier releases of the library (STM32F1xx V2.x) had you build the library as a separate project and you included the .LIB/.A file into your own project. This has changed somewhat with V3 and CMSIS where the library source, as needed, is typically dumped into your project as a sub-section or sub-project.

Now if the Rowley guys were clever they'd be able to import a project from the Keil or IAR files.
Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
ozvena
Associate II
Posted on January 19, 2012 at 21:43

All are valid points and thanks for all valuable information you provide!

However, 

stm32f4xx_conf.h provided by ST is already customized. I am judging by the folder name/location where these files are stored.

IMHO, there should be one occurrence of the file in the Utilities\STM32F4-Discovery folder where for example stm32f4_discovery.h is stored.

mike_k_cook
Associate II
Posted on January 25, 2012 at 15:31

Thanks for the above information, I managed to get the Toggle example compiling. Two points if you will be so kind:-

1) I only see THUMB Release and THUMB debug as project types offered on Cross Studio, is there a way to get the other?

2) How can I make the program I downloaded just run on the board when I apply the power? At the moment all I can do is download and run from Cross Studio.

Thank you.

ozvena
Associate II
Posted on January 25, 2012 at 16:09

I am new to this too….

You can take the examples prepackaged for other IDEs. Simply take the main.c and other .c & .h files and compile on your IDE. The Peripheral_Examples folder from the FW distribution has many examples you can use.

What happens when you apply the power and push the reset button? I expect that the program you have downloaded before should start running.

mike_k_cook
Associate II
Posted on January 25, 2012 at 16:56

What happens when you apply the power and push the reset button? I expect that the program you have downloaded before should start running.

Yes that is what I thought should happen also. It stops when you press the on board reset switch while connected to Cross Studio. If you just plug it in without Cross Studio running nothing happens, not even when you press the reset button. That is after loading a release version of the code. Is that what happens for you?