undefined reference to `_times'
Hello,
I keep running into this problem where every time I build one of my projects, The console will read out:
Building target: Lab 8 V2.elf
Invoking: MCU GCC Linker
arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -T”C:\Users\petzkemb\workspace\Lab 8 V2\LinkerScript.ld” -Wl,-Map=output.map -Wl,--gc-sections -o “Lab 8 V2.elf” @”objects.list” -lm
c:/ac6/systemworkbench/plugins/fr.ac6.mcu.externaltools.arm-none.win32_1.15.0.201708311556/tools/compiler/bin/../lib/gcc/arm-none-eabi/6.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m/fpv4-sp/hard\libc.a(lib_a-timesr.o): In function `_times_r’:
timesr.c:(.text._times_r+0x2): undefined reference to `_times’
collect2.exe: error: ld returned 1 exit status
makefile:34: recipe for target ‘Lab 8 V2.elf’ failed
make: *** Lab 8 V2.elf Error 1
I was able to narrow the problem down to calling (Branching and linking to) one of my subroutines which the only purpose of which is to start a timer.
The relevant subroutine:
.global Timer2_init_count
Timer2_init_count:
PUSH {R0-R3,LR}
# Timer2 = NVIC28
LDR R0,=NVIC_BASE
LDR R1,R0,#ISER0_OFFSET
LDR R2,=tim2_en
ORR R1,R1,R2
STR R1,R0,#ISER0_OFFSET
LDR R0,=TIM2_BASE
# Store counts
STR R3,R0,#ARR_OFFSET
STR R3,R0,#CCR2_OFFSET
LDR R1,R0,#DIER_OFFSET
ORR R1,R1,(0b1) // Enable update interrupt
STR R1,R0,#DIER_OFFSET
LDR R1,R0,#SR_OFFSET
BIC R1,R1,0b1 // Clear interrupt flag
STR R1,R0,#SR_OFFSET
LDR R1,R0,#CR1_OFFSET
ORR R1,R1,(0b1001) // Enable One Pulse Mode and Start counter
STR R1,R0,#CR1_OFFSET
POP {R0-R3,PC}
I’ve tried to comment different things out within the subroutine to find what exactly is causing the problem, but nothing came of that. The only thing that allows the project to fully build is commenting out the BL to this subroutine in my main. I have no idea how to fix this and any help will be greatly appreciated.