stm32 gcc library problem - Page 1
Forum section: electronics / general

author: Doc Daneeka
author_rank: Contributor
timestamp: January 16, 2017, 11:21:49 am
content: 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.htmldoes 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?

author: ataradov
author_rank: Super Contributor
timestamp: January 16, 2017, 05:57:44 pm
content: Give your full makefile.

author: andersm
author_rank: Super Contributor
timestamp: January 16, 2017, 06:27:15 pm
content: 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:$ arm-none-eabi-objdump -f _aeabi_uldivmod.o_aeabi_uldivmod.o: file format elf32-littlearmarchitecture: armv4t, flags 0x00000011:HAS_RELOC, HAS_SYMSstart address 0x00000000

author: Doc Daneeka
author_rank: Contributor
timestamp: January 16, 2017, 10:32:54 pm
content: Quote from: andersm on January 16, 2017, 06:27:15 pmSo 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!

author: ataradov
author_rank: Super Contributor
timestamp: January 16, 2017, 10:37:00 pm
content: "-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 fromhttps://launchpad.net/gcc-arm-embedded

author: mrm2007
author_rank: Contributor
timestamp: January 17, 2017, 04:34:44 am
content: Hi,you could use these options too :-DSTM32F0XX -DSTM32F030yyyou must change the second option according to your microcontroller.(Like -DSTM32F030K6 )

author: ataradov
author_rank: Super Contributor
timestamp: January 17, 2017, 04:36:47 am
content: Quote from: mrm2007 on January 17, 2017, 04:34:44 amThat just defines symbols, it does absolutely noting for linking.

author: bingo600
author_rank: Super Contributor
timestamp: January 17, 2017, 03:12:44 pm
content: And use GCC for linking , doNOTcall the linker your self , let GCC do that for you.Then the correct libs will be used./Bingo

author: Canis Dirus Leidy
author_rank: Regular Contributor
timestamp: January 23, 2017, 05:42:12 pm
content: Quote from: Doc Daneeka on January 16, 2017, 11:21:49 amEncountered 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 fromhttps://developer.arm.com/open-source