* Posix timer creation failure
@ 2024-04-16 9:49 Cédric Chépied
2024-04-16 14:06 ` Cédric Chépied
0 siblings, 1 reply; 2+ messages in thread
From: Cédric Chépied @ 2024-04-16 9:49 UTC (permalink / raw)
To: xenomai
Hi all,
I'm trying to execute a simple posix timer example (see code below). When I
compile it "normally", it works fine but when I add xeno-config generated flags
(to add RT tasks later) the create_timer function fails (invalid argument).
Can somebody tell me what I am doing wrong please ?
I'm running it on a 32 bit arm (imx6), could it be the "-D_TIME_BITS=64
-D_FILE_OFFSET_BITS=64" options ?
Thanks,
Here is the code :
static unsigned int pass_value_by_pointer = 42;
void Timer_has_expired(union sigval timer_data)
{
printf("Timer expiration handler function; %d\n",
*(int*) timer_data.sival_ptr);
}
int main(void)
{
struct sigevent timer_signal_event;
timer_t timer;
struct itimerspec timer_period;
printf("Create timer\n");
timer_signal_event.sigev_notify = SIGEV_THREAD;
timer_signal_event.sigev_notify_function = Timer_has_expired;
timer_signal_event.sigev_value.sival_ptr =
(void*) &pass_value_by_pointer; // as will this (both in a structure)
timer_signal_event.sigev_notify_attributes = NULL;
int ret = timer_create(CLOCK_MONOTONIC, &timer_signal_event, &timer);
if (ret)
{
perror("timer_create");
exit(EXIT_FAILURE);
}
printf("Start timer\n");
timer_period.it_value.tv_sec = 1; // 1 second timer
timer_period.it_value.tv_nsec = 0; // no nano-seconds
timer_period.it_interval.tv_sec = 0; // non-repeating timer
timer_period.it_interval.tv_nsec = 0;
timer_settime(timer, 0, &timer_period, NULL);
sleep(2);
printf("----------------------------\n");
printf("Start timer a second time\n");
timer_settime(timer, 0, &timer_period, NULL);
sleep(2);
printf("----------------------------\n");
printf("Start timer a third time\n");
timer_settime(timer, 0, &timer_period, NULL);
printf("Cancel timer\n");
timer_delete(timer);
sleep(2);
printf(
"The timer expiration handler function should not have been called\n");
return EXIT_SUCCESS;
}
Here are compilation flags :
sdk/sysroots/x86_64-fslcsdk-linux/usr/bin/arm-fslc-linux-gnueabi/arm-fslc-linux-gnueabi-gcc -mthumb -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a7 -fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=sdk/sysroots/cortexa7t2hf-neon-fslc-linux-gnueabi --sysroot=sdk/sysroots/cortexa7t2hf-neon-fslc-linux-gnueabi -O2 -pipe -g -feliminate-unused-debug-types -Isdk/sysroots/cortexa7t2hf-neon-fslc-linux-gnueabi/usr/include/xenomai/cobalt -Isdk/sysroots/cortexa7t2hf-neon-fslc-linux-gnueabi/usr/include/xenomai -O2 -pipe -g -feliminate-unused-debug-types -fmacro-prefix-map=/workdir/build/tmp/work/cortexa7t2hf-neon-fslc-linux-gnueabi/xenomai/3.2.4-r0=/usr/src/debug/xenomai/3.2.4-r0 -fdebug-prefix-map=/workdir/build/tmp/work/cortexa7t2hf-neon-fslc-linux-gnueabi/xenomai/3.2.4-r0=/usr/src/debug/xenomai/3.2.4-r0 -fdebug-prefix-map=sdk/sysroots/cortexa7t2hf-neon-fslc-linux-gnueabi= -fdebug-prefix-map=sdk/sysroots/cortexa7t2hf-neon-fslc-linux-gnueabi-native= -D_GNU_SOURCE -D_REENTRANT -fasynchronous-unwind-tables -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 -D__COBALT__ -Isdk/sysroots/cortexa7t2hf-neon-fslc-linux-gnueabi/usr/include/xenomai/alchemy -MD -MT CMakeFiles/timer.dir/timer.c.o -MF CMakeFiles/timer.dir/timer.c.o.d -o CMakeFiles/timer.dir/timer.c.o -c Tests/posixTimer/timer.c
sdk/sysroots/x86_64-fslcsdk-linux/usr/bin/arm-fslc-linux-gnueabi/arm-fslc-linux-gnueabi-gcc -mthumb -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a7 -fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=sdk/sysroots/cortexa7t2hf-neon-fslc-linux-gnueabi --sysroot=sdk/sysroots/cortexa7t2hf-neon-fslc-linux-gnueabi -O2 -pipe -g -feliminate-unused-debug-types -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -Wl,-z,relro,-z,now -Wl,--no-as-needed -Wl,@sdk/sysroots/cortexa7t2hf-neon-fslc-linux-gnueabi/usr/lib/modechk.wrappers -lalchemy -lcopperplate sdk/sysroots/cortexa7t2hf-neon-fslc-linux-gnueabi/usr/lib/xenomai/bootstrap.o -Wl,--wrap=main -Wl,--dynamic-list=sdk/sysroots/cortexa7t2hf-neon-fslc-linux-gnueabi/usr/lib/dynlist.ld -Lsdk/sysroots/cortexa7t2hf-neon-fslc-linux-gnueabi/usr/lib -lcobalt -lmodechk -lpthread -lrt -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -fmacro-prefix-map=/workdir/build/tmp/work/cortexa7t2hf-neon-fslc-linux-gnueabi/xenomai/3.2.4-r0=/usr/src/debug/xenomai/3.2.4-r0 -fdebug-prefix-map=/workdir/build/tmp/work/cortexa7t2hf-neon-fslc-linux-gnueabi/xenomai/3.2.4-r0=/usr/src/debug/xenomai/3.2.4-r0 -fdebug-prefix-map=sdk/sysroots/cortexa7t2hf-neon-fslc-linux-gnueabi= -fdebug-prefix-map=sdk/sysroots/cortexa7t2hf-neon-fslc-linux-gnueabi-native= -Wl,-z,relro,-z,now -Wl,@sdk/sysroots/cortexa7t2hf-neon-fslc-linux-gnueabi/usr/lib/cobalt.wrappers -Wl,@sdk/sysroots/cortexa7t2hf-neon-fslc-linux-gnueabi/usr/lib/cobalt-glibc-time64.wrappers CMakeFiles/timer.dir/timer.c.o -o timer
--
Cédric Chépied
<cedric.chepied@drotek.com>
<http://events.drotek.com/>
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Posix timer creation failure
2024-04-16 9:49 Posix timer creation failure Cédric Chépied
@ 2024-04-16 14:06 ` Cédric Chépied
0 siblings, 0 replies; 2+ messages in thread
From: Cédric Chépied @ 2024-04-16 14:06 UTC (permalink / raw)
To: Cédric Chépied; +Cc: xenomai
Cédric Chépied wrote:
> I'm trying to execute a simple posix timer example (see code below). When I
> compile it "normally", it works fine but when I add xeno-config generated flags
> (to add RT tasks later) the create_timer function fails (invalid argument).
>
> Here are compilation flags :
>
> sdk/sysroots/x86_64-fslcsdk-linux/usr/bin/arm-fslc-linux-gnueabi/arm-fslc-linux-gnueabi-gcc -mthumb -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a7 -fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=sdk/sysroots/cortexa7t2hf-neon-fslc-linux-gnueabi --sysroot=sdk/sysroots/cortexa7t2hf-neon-fslc-linux-gnueabi -O2 -pipe -g -feliminate-unused-debug-types -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -Wl,-z,relro,-z,now -Wl,--no-as-needed -Wl,@sdk/sysroots/cortexa7t2hf-neon-fslc-linux-gnueabi/usr/lib/modechk.wrappers -lalchemy -lcopperplate sdk/sysroots/cortexa7t2hf-neon-fslc-linux-gnueabi/usr/lib/xenomai/bootstrap.o -Wl,--wrap=main -Wl,--dynamic-list=sdk/sysroots/cortexa7t2hf-neon-fslc-linux-gnueabi/usr/lib/dynlist.ld -Lsdk/sysroots/cortexa7t2hf-neon-fslc-linux-gnueabi/usr/lib -lcobalt -lmodechk -lpthread -lrt -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -fmacro-prefix-map=/workdir/build/tmp/work/cortexa7t2hf-neon-fslc-linux-gnueabi/xenomai/3.2.4-r0=/usr/src/debug/xenomai/3.2.4-r0 -fdebug-prefix-map=/workdir/build/tmp/work/cortexa7t2hf-neon-fslc-linux-gnueabi/xenomai/3.2.4-r0=/usr/src/debug/xenomai/3.2.4-r0 -fdebug-prefix-map=sdk/sysroots/cortexa7t2hf-neon-fslc-linux-gnueabi= -fdebug-prefix-map=sdk/sysroots/cortexa7t2hf-neon-fslc-linux-gnueabi-native= -Wl,-z,relro,-z,now -Wl,@sdk/sysroots/cortexa7t2hf-neon-fslc-linux-gnueabi/usr/lib/cobalt.wrappers -Wl,@sdk/sysroots/cortexa7t2hf-neon-fslc-linux-gnueabi/usr/lib/cobalt-glibc-time64.wrappers CMakeFiles/timer.dir/timer.c.o -o timer
>
Wrappers seem to be the problem. When I link without
"-Wl,@sdk/sysroots/cortexa7t2hf-neon-fslc-linux-gnueabi/usr/lib/cobalt.wrappers
-Wl,@sdk/sysroots/cortexa7t2hf-neon-fslc-linux-gnueabi/usr/lib/cobalt-glibc-time64.wrappers",
timers work. But I won't be able to use the rtcan driver (I won't be able to
call ioctl on the socket).
It seems to work by adding "-nostdlib" when linking but then I got "undefined
reference to symbol '__aeabi_unwind_cpp_pr0@@GCC_3.5'".
If I disable exceptions with "-fno-exceptions" it compiles and runs fine. But I
need C++ exceptions for my "real" code.
What is the correct way to fix this ?
Thanks,
--
Cédric Chépied
<cedric.chepied@drotek.com>
<http://events.drotek.com/>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-04-16 14:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-16 9:49 Posix timer creation failure Cédric Chépied
2024-04-16 14:06 ` Cédric Chépied
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.