cancel
Showing results for 
Search instead for 
Did you mean: 

Compiling Spirit1 library for STM8l152 with a free toolchain?

dgardner88
Associate II
Posted on November 30, 2016 at 20:46

Hello,

Has anyone had success using the Spirit1 library (provided as part of  http://www.st.com/en/embedded-software/stsw-connect009.html) in a project for an STM8 MCU using a free toolchain?

The library was written in the C99 standard and uses features that are not supported by the SDCC or COSMIC compilers. The library is also >8kb, so the IAR compiler with the free license also throws an error.

Appreciate any help,

-David

4 REPLIES 4
luca239955_stm1_st
Senior II
Posted on December 01, 2016 at 14:01

Hi,

using the -pc99 command line switch enables support of most of the C99 features in the Cosmic compiler: if this is not enough please post the error you get and we will see what we can do.

Regards,

Luca

dgardner88
Associate II
Posted on December 02, 2016 at 07:40

Thanks Luca,

With -pc99 the I get some errors compiling with Cosmic.

The following files in the Spirit1 library and example STM8 implementation declare variables in for loops (i.e. ''for(int i = (cDataLength-1); i>=0; i--)''), which the Cosmic compiler does not handle:

SPIRIT_Aes.c

SPIRIT_Irq.c

SPIRIT_PktBasic.c

SPIRIT_pktcommon.c

SPIRIT_pktstack.c

SPIRIT_radio.c

SDK_EVAL_Gpio.c

SDK_EVAL_Spi_Driver.c

I moved those declarations outside of the for statements which satisfies the compiler. This changes the scope of those variables and could cause issues since most of those functions reuse the variable ''i''.

During linking I also get errors that the following symbols are not defined:

#error clnk Debug\spirit1_lib.lkf:1 symbol _lroundf not defined (Debug\spirit_radio.o )

#error clnk Debug\spirit1_lib.lkf:1 symbol _pow not defined (Debug\spirit_radio.o )

#error clnk Debug\spirit1_lib.lkf:1 symbol _log2 not defined (Debug\spirit_radio.o )

#error clnk Debug\spirit1_lib.lkf:1 symbol _round not defined (Debug\spirit_radio.o )

I think these are standard math functions in c99. I see references to them in the IAR <math.h> header, but it looks like they are missing from the Cosmic <math.h> header. Do you know a workaround for this?

Thank you for the help,

-David
luca239955_stm1_st
Senior II
Posted on December 06, 2016 at 10:57

Hello,

I confirm that the variable declaration in the for loop is not supported.

As for the missing symbols at the linker stage, 3 out of the 4 that you mention are already supported (make sure you link the libf in the linker file) and the fourth (lroundf()) will be added in the next release.

Regards,

Luca

Philipp Krause
Senior II
Posted on December 08, 2016 at 13:22

You might want to check with a current development version of SDCC instead of the 3.6.0 release. Support for variable declarations in for loops as been added to SDCC after the 3.6.0 release. So current development versions (and the future 3.7.0 release) have it.

Philipp