cancel
Showing results for 
Search instead for 
Did you mean: 

Undefined symbol assert_param (referred from misc.o) in keil with stm32f407

salahuddinash
Associate II
Posted on March 22, 2014 at 08:29

Hi everyone, 

I'm trying to compile and run an example found on the internet implementing USART on an stm32f4Discovery kit, I'm using keil uV5

here is the code 

<p>

#include <stm32f4xx.h>

#include <misc.h> // I recommend you have a look at these in the ST firmware folder

#include <stm32f4xx_usart.h> // under Libraries/STM32F4xx_StdPeriph_Driver/inc and src

#include <stm32f4xx_rcc.h>

#include <stm32f4xx_gpio.h>

#include <system_stm32f4xx.h>

#include ''stm32f4xx_conf.h''

#define MAX_STRLEN 12 // this is the maximum string length of our string in characters

volatile char received_string[MAX_STRLEN+1]; // this will hold the recieved string

void Delay(__IO uint32_t nCount) {

  while(nCount--) {  }

}

void init_USART1(uint32_t baudrate){

GPIO_InitTypeDef GPIO_InitStruct; // this is for the GPIO pins used as TX and RX

USART_InitTypeDef USART_InitStruct; // this is for the USART1 initialization

//NVIC_InitTypeDef NVIC_InitStructure; // this is used to configure the NVIC (nested vector interrupt controller)

RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);

RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE);

GPIO_InitStruct.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7; // Pins 6 (TX) and 7 (RX) are used

GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF; // the pins are configured as alternate function so the USART peripheral has access to them

GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz; // this defines the IO speed and has nothing to do with the baudrate!

GPIO_InitStruct.GPIO_OType = GPIO_OType_PP; // this defines the output type as push pull mode (as opposed to open drain)

GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_UP; // this activates the pullup resistors on the IO pins

GPIO_Init(GPIOB, &GPIO_InitStruct); // now all the values are passed to the GPIO_Init() function which sets the GPIO registers

GPIO_PinAFConfig(GPIOB, GPIO_PinSource6, GPIO_AF_USART1); //

GPIO_PinAFConfig(GPIOB, GPIO_PinSource7, GPIO_AF_USART1);

USART_InitStruct.USART_BaudRate = baudrate; // the baudrate is set to the value we passed into this init function

USART_InitStruct.USART_WordLength = USART_WordLength_8b;// we want the data frame size to be 8 bits (standard)

USART_InitStruct.USART_StopBits = USART_StopBits_1; // we want 1 stop bit (standard)

USART_InitStruct.USART_Parity = USART_Parity_No; // we don't want a parity bit (standard)

USART_InitStruct.USART_HardwareFlowControl = USART_HardwareFlowControl_None; // we don't want flow control (standard)

USART_InitStruct.USART_Mode = USART_Mode_Tx | USART_Mode_Rx; // we want to enable the transmitter and the receiver

USART_Init(USART1, &USART_InitStruct); // again all the properties are passed to the USART_Init function which takes care of all the bit setting

//

USART_ITConfig(USART1, USART_IT_RXNE, ENABLE); // enable the USART1 receive interrupt

//NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn; // we want to configure the USART1 interrupts

//NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;// this sets the priority group of the USART1 interrupts

//NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; // this sets the subpriority inside the group

//NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; // the USART1 interrupts are globally enabled

//NVIC_Init(&NVIC_InitStructure); // the properties are passed to the NVIC_Init function which takes care of the low level stuff

USART_Cmd(USART1, ENABLE);

}

void USART_puts(USART_TypeDef* USARTx, volatile char *s){

while(*s){

while( !(USARTx->SR & 0x00000040) );

USART_SendData(USARTx, *s);

*s++;

}

}

int main(void) {

  init_USART1(9600); // initialize USART1 @ 9600 baud

  USART_puts(USART1, ''Init complete! Hello World!rn''); // just send a message to indicate that it works

  while (1){  }

}

</p>

I've worked for a long time to eliminate too many errors appeared because of linking and finally I've solved all of them except one error

<p>

Build target 'STM32F407 Flash'

compiling stm32f4xx_gpio.c...

compiling stm32f4xx_rcc.c...

compiling stm32f4xx_usart.c...

linking...

.\Flash\Blinky.axf: Error: L6218E: Undefined symbol assert_param (referred from misc.o).

Not enough information to list image symbols.

Finished: 1 information, 0 warning and 1 error messages.

''.\Flash\Blinky.axf'' - 1 Error(s), 0 Warning(s).

Target not created

</p>

I searched a lot for a solution for this assert_param issue but I couldn't 

Here are my questions 

-How to solve this error ?

-What is the importance of  these two header files? 

stm32f4xx_conf.h and misc.h

-Where is the definition of assert_failed function as I used ''go to the definition'' of assert_failed but it wasn't found 

Really I'll appreciate any help 

Thanks a lot
5 REPLIES 5
salahuddinash
Associate II
Posted on March 22, 2014 at 18:29

neil, honestly, I've been through almost every possible solution I found in these links you suggested but none worked with me, may be because they are for different kit ??!!

first I've tried to type this snippet in blinky.c 

<p>

#ifdef  USE_FULL_ASSERT

void assert_failed(uint8_t* file, uint32_t line)

{

  /* Infinite loop */

  while (1)

  {

  }

}

#endif

</p>

but it didn't work 

second, I've tried typing this in project options->C/C++->defines 

<p>USE_STDPERIPH_DRIVER,STM32F401xx</p>

but it didn't work too

third I've tried to type this in project options->C/C++->defines

<p>USE_FULL_ASSERT</p>

but it didn't also work 

the strange thing is that I'm modifying in the example found in 

Keil_v5\examples\Boards\ST\STM32F4-Discovery\Blinky

and also the original unmodified program was compiled well without this silly error, when I modified it and started using standard peripheral library, errors appeared 

really I need your help 

thanks very much
Posted on March 23, 2014 at 02:03

So do you have an STM32F4-DISCO or an STM32F401C-DISCO? This would seem to be an important distinction.

The things you've done, and the errors you are encountering don't sound wholly consistent.

What do you have muddling things up in stm32f4xx_conf.h?

What if you just remove the #ifdef? If it still fails, then some files in the project aren't what they appear to be.

Defines? (STM32F4-Discovery_FW_v1.1.0)

USE_STDPERIPH_DRIVER,STM32F4XX

(STM32F4xx_DSP_StdPeriph_Lib_V1.3.0 STM3240G)

USE_STDPERIPH_DRIVER,STM32F40_41xxx,USE_STM324xG_EVAL

I've used these in my own

USE_STDPERIPH_DRIVER STM32F4XX USE_STM32F4_DISCOVERY USE_USB_OTG_FS HSE_VALUE=8000000
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
salahuddinash
Associate II
Posted on March 23, 2014 at 05:17

I've removed misc.c file from the project and it just compiled without any errors or warnings !!!!

Defines? (STM32F4-Discovery_FW_v1.1.0)

USE_STDPERIPH_DRIVER,STM32F4XX

(STM32F4xx_DSP_StdPeriph_Lib_V1.3.0 STM3240G)

USE_STDPERIPH_DRIVER,STM32F40_41xxx,USE_STM324xG_EVAL

I've used these in my own

USE_STDPERIPH_DRIVER STM32F4XX USE_STM32F4_DISCOVERY USE_USB_OTG_FS HSE_VALUE=8000000

Really I hope you explain what is the importance of these defines and what is the difference between writing them in ''project options'' and just writing them in a header file ?

and how do we know what defines do we need? and does it differ depends on the kit I'm using or the function of each project?

I've tried all these defines you suggest, and the only define worked with me is 

HSE_VALUE=8000000,USE_FULL_ASSERT,

and even when I removed it and recompiled the project it was recompiled fine without errors, so what is the importance of these defines?

So do you have an STM32F4-DISCO or an STM32F401C-DISCO? This would seem to be an important distinction.

I'm working on STM32F4-Disco

What do you have muddling things up in stm32f4xx_conf.h?

 

I've just uncommented those includes related to gpio, rcc, usart,

and the #ifdef  USE_FULL_ASSERT 

What if you just remove the #ifdef? If it still fails, then some files in the project aren't what they appear to be.

 

I've tried it but didn't work

Thanks again for teaching me new stuff 
Posted on March 23, 2014 at 06:19

Defines control the build process, often when there are several possible configurations they bring in or drop out other code. My list comes from a specific USB build I was doing in GNU/GCC not Keil, and was provided to be illustrative of how they might differ between EVAL series boards, and Discovery ones. You need to take the time to review all the code files and include files in a project, and how they interact. You'll learn far more by doing this work. Some of this can be remedied by using stm32f4xx_conf.h, but that depends on whether all files use this, providing command line defines to the compiler ensures all compiled source gets the message.

I've tried it but didn't work - removing #ifdef from assert function, and linker still says it can't find it.

This doesn't compute, if you provide a body function the linker can't possibly complain it didn't find one. You either got a different error, or your project is internally inconsistent. I can not remedy this, I suspect you are changing more things

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..