cancel
Showing results for 
Search instead for 
Did you mean: 

crt0 for STM32L-Discovery C/C++ development?

gryan
Associate II
Posted on October 24, 2013 at 21:18

Hello,

I am new to developing on an STM32L. I'm using IAR Workbench to compile for it using FreeRTOS. I don't seem to be able to be able to get it running using any of the C/C++ functions.

I can build a simple task and it runs fine, but if I simply include <string.h> without even declaring any variables, the software compiles, but it hang before reaching main. Do I have to supply a CRT of my own, or is there something else I may be doing wrong?

#stm32
5 REPLIES 5
crt2
Associate II
Posted on October 25, 2013 at 09:28

I think you could help us by posting an example. Include string.h does not bring anything new so compiler should not generate anything more in binary code than without that include.

frankmeyer9
Associate II
Posted on October 25, 2013 at 11:53

Do I have to supply a CRT of my own, or is there something else I may be doing wrong?

The IDE usually does link in an appropriate startup file automatically, mostly in the form of a asm file. Don't know how IAR does it, just check your project settings. You may configure the debugger to stop at the reset vector, and not at main when debugging. You can then step through your init process.

But be aware that C++ projects usually need other startup code than C projects. One important point here is the additional ctor/dtor initialization code. Thus, adding C++ files to a project wizard-generated as ''C'' will not work.

gryan
Associate II
Posted on October 25, 2013 at 13:48

Thanks. Here's what I can reduce it to:

#include ''FreeRTOS_Kernel.h''

#include ''do_something.h''

void main(void)

{

  xTaskCreate( do_something, (signed char*)''do_something'', configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY+1, NULL );

  vTaskStartScheduler();

 

  for( ;; );

}

#ifndef do_something_h_included

#define do_something_h_included

void do_something( void* p );

#endif

#include ''do_something.h''

#include <string.h>

void do_something( void* p )

{

  for ( ;; );

}

If I compile and link do_something.o and main.o, main never gets called.

gryan
Associate II
Posted on October 25, 2013 at 13:50

Thanks! I am linking in a file called startup_stm32l1xx_md.s. I assume that contains the basic C runtime as well?

Posted on October 25, 2013 at 14:06

I am linking in a file called startup_stm32l1xx_md.s. I assume that contains the basic C runtime as well?

It does not, it calls __iar_program_start, at least the IAR variant should.

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