cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 cryptographic library - GCC compatibility

Tantalum
Associate II
Posted on November 11, 2013 at 20:26

Hello

Maybe I'm wrong, but the

http://www.st.com/web/catalog/tools/FM147/CL1794/SC961/SS1743/PF259409

only provides binaries compatible with compilers from Keil or IAR but none for GCC.

Since the sources aren't openly available, for reasons I can understand, is it possible that somebody from ST provides us an GCC compatible version?

Thank you.

#stm32-cryptograhic-library-gcc #understand-your-tools #understand-your-tools #know-your-tools
23 REPLIES 23
Posted on November 12, 2013 at 01:29

I was able to achieve linkage against the IAR's EWARM\M4_CryptoFW_RngHW_2_0_6.a for an STM32F4-Discovery build by adding some shims for the aeabi functions.

abi.c

// IAR to GNU/GCC ABI Shim - sourcer32@gmail.com
#include <
stdlib.h
>
#include <
string.h
>
void __aeabi_memcpy(void *dest, const void *src, size_t n)
{
memcpy(dest, src, n);
}
void __aeabi_memcpy4(void *dest, const void *src, size_t n)
{
memcpy(dest, src, n);
}
void __aeabi_memclr(void *dest, size_t n)
{
memset(dest, 0, n);
}
void __aeabi_memclr4(void *dest, size_t n)
{
memset(dest, 0, n);
}
void __aeabi_memset(void *dest, char c, size_t n)
{
memset(dest, c, n);
}

Still need to evaluate the functionality.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Tantalum
Associate II
Posted on November 12, 2013 at 12:09

Thank you

It compiles. I will have to check if everything works right now.

But if ST wanted to provide us a GCC compatible version it would be even better :)
Tantalum
Associate II
Posted on November 13, 2013 at 12:59

I'm having that error now:

C:\SVN\MCD_STM32_Cryptographic_V2_0_6\LibraryCreation\Cortex_M4_FW\Crypto_Sources_Files\crypto.c:(.text+0x11250): undefined reference to `RCC_AHBPeriphClockCmd'

I don't know how to solve that.

Can someone help me please?

Posted on November 13, 2013 at 13:25

I don't know how to solve that. Can someone help me please?

Must use M4_CryptoFW_RngHW_2_0_6.a not M4_CryptoFW_2_0_6.a

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Tantalum
Associate II
Posted on November 13, 2013 at 15:27

Everything works now.

Thank you for your help!

ababo
Associate II
Posted on November 15, 2013 at 16:23

How can I tell to makefile to include the library? I am using GCC without any IDE.

Posted on November 15, 2013 at 16:41

How can I tell to makefile to include the library? I am using GCC without any IDE.

 

That would depend greatly on the structure/construction of YOUR makefile, wouldn't it?

Libraries are just another list of files passed to the linker.

..

# libraries (additional libraries for linking, e.g. ''-lm -lsome_name'' to link

# math library libm.a and libsome_name.a)

LIBS = M4_CryptoFW_RngHW_2_0_6.a

..

#-----------------------------------------------------------------------------#

# linking - objects -> elf

#-----------------------------------------------------------------------------#

$(ELF) : $(OBJS)

    @echo 'Linking target: $(ELF)'

    $(CXX) $(LD_FLAGS_F) $(OBJS) $(LIBS) -o $@

    @echo ' '

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
ababo
Associate II
Posted on November 21, 2013 at 16:16

Thanks clive1.

I saw that the generated ELF file contains a lot of unused functions from the lib, like SHA functions when I am not selecting them in the config.h file! This produces a long ELF file. 

Is there any way to discard these unnecessary symbols, to get a smaller ELF file???

Posted on November 21, 2013 at 18:04

You'd have to do some analysis of the library itself and understand where the dependencies are coming from, and why the dead code elimination isn't being done by the linker. If the objects within the library are granular enough, perhaps you can use a library manager to extract only the objects you need, and link against those.

You could also try building with Keil or IAR and see if they generate more compact output.

I don't have time/resources to do this analysis for you.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..