Author Topic: stm32 gcc library problem  (Read 3602 times)

0 Members and 1 Guest are viewing this topic.

Offline Doc DaneekaTopic starter

  • Contributor
  • Posts: 36
  • Country: it
stm32 gcc library problem
« on: January 16, 2017, 11:21:49 am »
Hi,

I am trying to get the gcc arm tools working for an stm32f030 however I have a problem - I am trying to use the HAL library from ST, when I call the 'HAL_init' function, the device has a hard fault exception.

I have tracked this down to the __aeabi_uidiv function which is in the armm gcc library which is linked . Does anyone know what I could be doing wrong wrong here? I did find this (from a while ago) https://gcc.gnu.org/ml/gcc-help/2012-12/msg00011.html does anyone know if this is still a problem? does anyone here successfully use gcc and the HAL stuff with a coretex m0 device?

Also I am linking with gcc with the -mthumb and -mcpu=cortex-m0 options, so I don't think it should be linking to the wrong library...

edit:

I just tried explicitly linking with the correct library in the directory \GNU Tools ARM Embedded\lib\gcc\arm-none-eabi\5.4.1\armv6-m and it works. If you link with the library in \thumb it does not work...  once again I'm sure I'm doing something dumb, can anyone correct my ways?
« Last Edit: January 16, 2017, 12:02:02 pm by Doc Daneeka »
 

Offline ataradov

  • Super Contributor
  • ***
  • Posts: 11258
  • Country: us
    • Personal site
Re: stm32 gcc library problem
« Reply #1 on: January 16, 2017, 05:57:44 pm »
Give your full makefile.
Alex
 

Offline andersm

  • Super Contributor
  • ***
  • Posts: 1198
  • Country: fi
Re: stm32 gcc library problem
« Reply #2 on: January 16, 2017, 06:27:15 pm »
The files in the "thumb" directory are the thumb versions of the files in the /lib/gcc/arm-none-eabi/5.4.1 folder, and they are built for for the default architecture armv4t (ie. ARM7TDMI and the like). For other architectures you're supposed to use the versions in their respective folders.
Code: [Select]
$ arm-none-eabi-objdump -f _aeabi_uldivmod.o

_aeabi_uldivmod.o:     file format elf32-littlearm
architecture: armv4t, flags 0x00000011:
HAS_RELOC, HAS_SYMS
start address 0x00000000

Offline Doc DaneekaTopic starter

  • Contributor
  • Posts: 36
  • Country: it
Re: stm32 gcc library problem
« Reply #3 on: January 16, 2017, 10:32:54 pm »
The files in the "thumb" directory are the thumb versions of the files in the /lib/gcc/arm-none-eabi/5.4.1 folder, and they are built for for the default architecture armv4t (ie. ARM7TDMI and the like). For other architectures you're supposed to use the versions in their respective folders.
Code: [Select]
$ arm-none-eabi-objdump -f _aeabi_uldivmod.o

_aeabi_uldivmod.o:     file format elf32-littlearm
architecture: armv4t, flags 0x00000011:
HAS_RELOC, HAS_SYMS
start address 0x00000000

So what options should I use to get it to link with the correct libs for coretex m0 (stm32f030)? Because with just -mcpu=cortex-m0 it definitely does not work... as I said linking it manually with the stuff in armv6-m folder works!
« Last Edit: January 16, 2017, 10:35:05 pm by Doc Daneeka »
 

Offline ataradov

  • Super Contributor
  • ***
  • Posts: 11258
  • Country: us
    • Personal site
Re: stm32 gcc library problem
« Reply #4 on: January 16, 2017, 10:37:00 pm »
"-mcpu=cortex-m0plus -mthumb" should be enough. Since you don't want to post your makefile, make sure you are using gcc for linking, not ld. Ld gets confused like this all the time for some strange reasons.

Also, take the official compiler from https://launchpad.net/gcc-arm-embedded
Alex
 

Offline mrm2007

  • Contributor
  • Posts: 33
  • Country: 00
Re: stm32 gcc library problem
« Reply #5 on: January 17, 2017, 04:34:44 am »
Hi,

 you could use these options too :

  -DSTM32F0XX   -DSTM32F030yy

 you must change the second option according to your microcontroller.(Like  -DSTM32F030K6 )
 

Offline ataradov

  • Super Contributor
  • ***
  • Posts: 11258
  • Country: us
    • Personal site
Re: stm32 gcc library problem
« Reply #6 on: January 17, 2017, 04:36:47 am »
you could use these options too :
That just defines symbols, it does absolutely noting for linking.
Alex
 

Online bingo600

  • Super Contributor
  • ***
  • Posts: 1989
  • Country: dk
Re: stm32 gcc library problem
« Reply #7 on: January 17, 2017, 03:12:44 pm »
And use GCC for linking , do NOT call the linker your self , let GCC do that for you.
Then the correct libs will be used.

/Bingo
 

Offline Canis Dirus Leidy

  • Regular Contributor
  • *
  • Posts: 214
  • Country: ru
Re: stm32 gcc library problem
« Reply #8 on: January 23, 2017, 05:42:12 pm »
I have tracked this down to the __aeabi_uidiv function which is in the armm gcc library which is linked . Does anyone know what I could be doing wrong wrong here? I did find this (from a while ago) https://gcc.gnu.org/ml/gcc-help/2012-12/msg00011.html does anyone know if this is still a problem? does anyone here successfully use gcc and the HAL stuff with a coretex m0 device?
Encountered this when compiled ChibiOS demo for NUCLEO-F030R8 on Calculate Linux (Gentoo based). Playing with compiling and linking options give nothing, so I just remove "system" (i.e. installed with crossdev) compiler and get binaries from https://developer.arm.com/open-source
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf