Loading...
 

SW4STM32 and SW4Linux fully supports the STM32MP1 asymmetric multicore Cortex/A7+M4 MPUs

   With System Workbench for Linux, Embedded Linux on the STM32MP1 family of MPUs from ST was never as simple to build and maintain, even for newcomers in the Linux world. And, if you install System Workbench for Linux in System Workbench for STM32 you can seamlessly develop and debug asymmetric applications running partly on Linux, partly on the Cortex-M4.
You can get more information from the ac6-tools website and download (registration required) various documents highlighting:

System Workbench for STM32


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.

France

Hi,

Obviously, it’s not in this routine that you reference times; however, as you provide assembly code, the fact you call this function will link in your program all other code from the same source file, so I suspect the problem may come from other pieces of code in the same file (even if they are not called...)

Note that the times’ C library routine is useless on an MCU (it summarize execution time for a linux process and its children) and needs a support function called _times’’ to gather these, function that does not exist as it has no use. You could just provide it in syscalls.c by adding:

#include "sys/times.h"
clock_t _times(struct tms* tms) {
    errno = EINVAL;
    return (clock_t)-1;
}

However this will just allow your code to link, but either it will not work as expected (if times if effectively called) or will contain dead code (due to your assembly-level code).

Just a question: why did you code in assembly language, instead of C? Your function could as well have been written in C; moreover you seem to pass only one single parameter in the R3 register, which is quite unusual (parameters must be passed in R0, R1, R2 and R3, that do not have to be saved as they are scratch registers). As is, your function could only be called from assembly-level code, not from C code.

Bernard (Ac6)