crt0.c & CORTEX_USE_FPU

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
hazelnusse
Posts: 77
Joined: Thu May 24, 2012 8:01 am

crt0.c & CORTEX_USE_FPU

Post by hazelnusse »

I have had USE_FPU=yes in my Makefile (triggers compilation flag -DCORTEX_USE_FPU=TRUE) for several months now and had no problems, but I just went to compile my project with the latest master and got this:

Code: Select all

/home/hazelnusse/toolchain/bin/arm-none-eabi-gcc -c -mcpu=cortex-m4 -O2 -ggdb3 -fomit-frame-pointer -falign-functions=16 -march=armv7e-m -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -ffunction-sections -fdata-sections -fno-common  -Wall -Wextra -Wstrict-prototypes -Wa,-alms=build/lst/crt0.lst  -DCORTEX_USE_FPU=TRUE -DTESTCXXSTUFF=0 -DTHUMB_PRESENT -mno-thumb-interwork -DTHUMB_NO_INTERWORKING -MD -MP -MF .dep/crt0.o.d -mthumb -DTHUMB -I. -I./ChibiOS-RT/os/ports/common/ARMCMx/CMSIS/include -I./ChibiOS-RT/os/ports/common/ARMCMx -I./ChibiOS-RT/os/ports/GCC/ARMCMx -I./ChibiOS-RT/os/ports/GCC/ARMCMx/STM32F4xx -I./ChibiOS-RT/os/kernel/include -I./ChibiOS-RT/test -I./ChibiOS-RT/os/hal/include -I./ChibiOS-RT/os/hal/platforms/STM32F4xx -I./ChibiOS-RT/os/hal/platforms/STM32 -I./ChibiOS-RT/os/hal/platforms/STM32/GPIOv2 -I./ChibiOS-RT/os/hal/platforms/STM32/I2Cv1 -I./ChibiOS-RT/os/hal/platforms/STM32/OTGv1 -I./ChibiOS-RT/os/hal/platforms/STM32/RTCv2 -I./ChibiOS-RT/os/hal/platforms/STM32/SPIv1 -I./ChibiOS-RT/os/hal/platforms/STM32/USARTv1 -I./board/ -I./ChibiOS-RT/os/various/lwip_bindings -I./ChibiOS-RT/ext/lwip/src/include -I./ChibiOS-RT/ext/lwip/src/include/ipv4 -I./ChibiOS-RT/ext/fatfs/src -I./ChibiOS-RT/os/various -I/home/hazelnusse/toolchain/arm-none-eabi/include -ISingleton ./ChibiOS-RT/os/ports/GCC/ARMCMx/crt0.c -o build/obj/crt0.o
./ChibiOS-RT/os/ports/GCC/ARMCMx/crt0.c: In function 'ResetHandler':
./ChibiOS-RT/os/ports/GCC/ARMCMx/crt0.c:267:3: error: 'SCB_FPCCR' undeclared (first use in this function)
./ChibiOS-RT/os/ports/GCC/ARMCMx/crt0.c:267:3: note: each undeclared identifier is reported only once for each function it appears in
./ChibiOS-RT/os/ports/GCC/ARMCMx/crt0.c:267:15: error: 'FPCCR_ASPEN' undeclared (first use in this function)
./ChibiOS-RT/os/ports/GCC/ARMCMx/crt0.c:267:29: error: 'FPCCR_LSPEN' undeclared (first use in this function)
./ChibiOS-RT/os/ports/GCC/ARMCMx/crt0.c:270:3: error: 'SCB_CPACR' undeclared (first use in this function)
./ChibiOS-RT/os/ports/GCC/ARMCMx/crt0.c:275:3: error: 'SCB_FPDSCR' undeclared (first use in this function)
make: *** [build/obj/crt0.o] Error 1

The code compiles fine if I change my Makefile to have USE_FPU = no, which then causes the compilation flag -DCORTEX_USE_FPU=FALSE. This is with ChibiOS from the latest git master.

I looked at git blame for crt0.c and this part of the code is about a year old so perhaps something else somewhere changed? Regardless, these symbols are defined in os/ports/common/ARMCMx/nvic.h, but the only file included by crt0.c is stdint.h. So it seems that either these symbols need to be defined in crt0.c or somehow nvic.h needs to be included, perhaps conditionally?

I think this is a bug but I'm not sure why it wouldn't have triggered for the last 6 months when I've been using USE_FPU=yes that whole time.

Luke
hazelnusse
Posts: 77
Joined: Thu May 24, 2012 8:01 am

Re: crt0.c & CORTEX_USE_FPU

Post by hazelnusse »

A simpler way to recreate this bug is to do:

Code: Select all

make USE_FPU=yes

in any of the ARMCM4 demos.

Luke
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: crt0.c & CORTEX_USE_FPU

Post by Giovanni »

Hi,

It has been caused by a recent change, I will look into this ASAP, thanks for finding.

Giovanni
hazelnusse
Posts: 77
Joined: Thu May 24, 2012 8:01 am

Re: crt0.c & CORTEX_USE_FPU

Post by hazelnusse »

Great, I look forward to testing it out.

Luke
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: crt0.c & CORTEX_USE_FPU

Post by Giovanni »

Hi,

I committed a fix for this issue, please could you verify on your side?

Giovanni
hazelnusse
Posts: 77
Joined: Thu May 24, 2012 8:01 am

Re: crt0.c & CORTEX_USE_FPU

Post by hazelnusse »

This fixes the compilation issue. I will test on Monday to make sure it runs fine on my hardware.

Thanks for the fast fix!

Luke
Post Reply