nabilt / STM32F4-Discovery-Firmware

Modified STM32F4 Discovery Demo Firmware from ST compile with arm-none-eabi-gcc
134 stars 122 forks source link

Project/Demonstration does not compile. #1

Open chrisdew opened 10 years ago

chrisdew commented 10 years ago

I'm running make in https://github.com/nabilt/STM32F4-Discovery-Firmware/tree/master/Project/Demonstration and just getting:

$ make
arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -mlittle-endian -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb-interwork    -Os  -DUSE_STDPERIPH_DRIVER -DSTM32F4XX -DMANGUSTA_DISCOVERY -DUSE_USB_OTG_FS -DHSE_VALUE=8000000 -I./ -I./ -I../../Utilities/STM32F4-Discovery -I../../Libraries/CMSIS/ST/STM32F4xx/Include/ -I../../Libraries/CMSIS/Include/ -I../../Libraries/STM32F4xx_StdPeriph_Driver/inc/ -I../../Libraries/STM32_USB_Device_Library/Class/hid/inc -I../../Libraries/STM32_USB_Device_Library/Core/inc/ -I../../Libraries/STM32_USB_OTG_Driver/inc/  -Wl,-T,stm32_flash.ld main.c selftest.c stm32f4xx_it.c system_stm32f4xx.c usb_bsp.c usbd_desc.c usbd_usr.c ../../Utilities/STM32F4-Discovery/stm32f4_discovery.c ../../Utilities/STM32F4-Discovery/stm32f4_discovery_lis302dl.c ../../Utilities/STM32F4-Discovery/stm32f4_discovery_audio_codec.c ../../Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_syscfg.c ../../Libraries/STM32F4xx_StdPeriph_Driver/src/misc.c ../../Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_adc.c ../../Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dma.c ../../Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_exti.c ../../Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_flash.c ../../Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_gpio.c ../../Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_i2c.c ../../Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_rcc.c ../../Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_spi.c ../../Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_tim.c ../../Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_dac.c ../../Libraries/STM32_USB_OTG_Driver/src/usb_dcd_int.c ../../Libraries/STM32_USB_OTG_Driver/src/usb_core.c ../../Libraries/STM32_USB_OTG_Driver/src/usb_dcd.c ../../Libraries/STM32_USB_Device_Library/Class/hid/src/usbd_hid_core.c ../../Libraries/STM32_USB_Device_Library/Core/src/usbd_req.c ../../Libraries/STM32_USB_Device_Library/Core/src/usbd_core.c ../../Libraries/STM32_USB_Device_Library/Core/src/usbd_ioreq.c startup_stm32f4xx.s -o demo.elf
/usr/bin/../lib/gcc/arm-none-eabi/4.7.4/../../../../arm-none-eabi/lib/armv7e-m/fpu/libc.a(lib_a-exit.o): In function `exit':
exit.c:(.text.exit+0x16): undefined reference to `_exit'
collect2: error: ld returned 1 exit status
make: *** [demo.elf] Error 1

I've installed the arm-none-eabi toolchain from: deb http://ppa.launchpad.net/terry.guo/gcc-arm-embedded/ubuntu precise main.

Is there something else I need to do?

(Using Ubuntu 12.04LTS on x86_64.)

As the undefined reference is to _exit it could be that I'm missing the C runtime (called crt0, iirc?).

dapperfu commented 10 years ago

http://stackoverflow.com/questions/9632595/compiling-basic-c-file-for-the-arm-processor

I tried both methods and they both worked.

For the assembly version I deleted the comments and placed it right after .global Default_Handler

.globl _exit
_exit:
    b     .

If you do the C implementation with void _exit(void) it will throw a warning of:

warning :conflicting types for build-in function "_exit' [enabled by default]

It apparently has to do with newlib.

harryhaaren commented 9 years ago

@chrisdew , confirmed: i have the same issue here.

@nabilt , Adding --specs=nosys.specs to the MCFLAGS in Makefile seems to fix, perhaps concider?