Re: C-lib status


Erwin Rol
 

Hey Paul,

time() was just the first thing I tried to see how well newlib works,
and the results was it doesn't. And that it compiles without warning and
than hangs in an endless loop sounds like a bug to me, no matter how
useful/useless a time() call would be.

But your point about version 1.9 is interesting, "POSIX API Layer", "BSD
Socket Support", "Build and Configuration System", and "Zephyr SDK NG"
sound like very big changes to how Zephyr can/should be used.

I think I'll wait for that release (when it really comes in August) to
reevaluate if Zephyr is usable for me or if it would be better to put
energy and effort in for example RTEMS.

- Erwin

On 10-6-2017 14:12, Paul Sokolovsky wrote:
Hello Erwin,

On Sat, 10 Jun 2017 13:38:33 +0200
Erwin Rol <mailinglists@...> wrote:

Hey all (yeah there he is again),

I was wondering what the status and planning is for the C-library? I
tried a simple example and I guess I directly hit a problem. The
"buildin" mini C-lib doesn't offer much (I wanted the time(NULL)
When you want time(NULL), what are your expectations? Because as you
know, what it's supposed to do is to return number of seconds since
1970-01-01. Does your board even have an idea how long ago 1970 was? I
own ~ couple of dozens of MCU boards, and none of them has
battery-backed RTC as required to know when 1970-01-01 was. The
remaining alternative is to pray that a board has MCU-internal RTC
which doesn't reset with MCU reset, and set it up (usually manually)
on each power up, which is hardly practical.

function), so I selected newlibc. That compiles but doesn't work, it
ends up in an endless loop where gettimeofday calls _gettimeofday_r
and that calls gettimeofday again (see stack trace below).

Am I doing something wrong here (Zephyr configuration or something
like that) or is newlib support just not yet ready to use ?
I guess a fair answer is that Zephyr will never work like Linux.
Otherwise, functions which make sense for MCU boards get tried in one by
one manner, issues found and fixed (e.g. errno didn't work for newlib
few weeks ago:
https://github.com/zephyrproject-rtos/zephyr/commit/8cc6f6ddd6e0ff882ec5bd10700058df345cea19).

Otherwise, if you read TSC planning notes for 1.9, they include
"POSIX API". It's not very clear what that means, but making time()
work somehow would fit that line, but as usual would require
stakeholders interested to RFC and implement it.

Otherwise, Zephyr has native time API which you can use to measure
duration between events, etc.


- Erwin

#0 gettimeofday (ptimeval=ptimeval@entry=0x20001720
<_main_stack+4052>, ptimezone=ptimezone@entry=0x0)
at /usr/src/debug/newlib/2.4.0-r0/newlib-2.4.0/newlib/libc/syscalls/sysgettod.c:12
#1 0x0800091c in _gettimeofday_r (ptr=0x20000008 <impure_data>,
ptimeval=ptimeval@entry=0x20001720 <_main_stack+4052>,
ptimezone=ptimezone@entry=0x0)
at /usr/src/debug/newlib/2.4.0-r0/newlib-2.4.0/newlib/libc/reent/gettimeofdayr.c:71
#2 0x0800093c in gettimeofday (ptimeval=ptimeval@entry=0x20001720
<_main_stack+4052>, ptimezone=ptimezone@entry=0x0)
at /usr/src/debug/newlib/2.4.0-r0/newlib-2.4.0/newlib/libc/syscalls/sysgettod.c:12
#3 0x0800091c in _gettimeofday_r (ptr=0x20000008 <impure_data>,
ptimeval=ptimeval@entry=0x20001720 <_main_stack+4052>,
ptimezone=ptimezone@entry=0x0)
at /usr/src/debug/newlib/2.4.0-r0/newlib-2.4.0/newlib/libc/reent/gettimeofdayr.c:71
#4 0x0800093c in gettimeofday (ptimeval=ptimeval@entry=0x20001720
<_main_stack+4052>, ptimezone=ptimezone@entry=0x0)
at /usr/src/debug/newlib/2.4.0-r0/newlib-2.4.0/newlib/libc/syscalls/sysgettod.c:12
#5 0x0800091c in _gettimeofday_r (ptr=0x20000008 <impure_data>,
ptimeval=ptimeval@entry=0x20001720 <_main_stack+4052>,
ptimezone=ptimezone@entry=0x0)
at /usr/src/debug/newlib/2.4.0-r0/newlib-2.4.0/newlib/libc/reent/gettimeofdayr.c:71
#6 0x0800093c in gettimeofday (ptimeval=ptimeval@entry=0x20001720
<_main_stack+4052>, ptimezone=ptimezone@entry=0x0)
at /usr/src/debug/newlib/2.4.0-r0/newlib-2.4.0/newlib/libc/syscalls/sysgettod.c:12
#7 0x0800091c in _gettimeofday_r (ptr=0x20000008 <impure_data>,
ptimeval=ptimeval@entry=0x20001720 <_main_stack+4052>,
ptimezone=ptimezone@entry=0x0)
at /usr/src/debug/newlib/2.4.0-r0/newlib-2.4.0/newlib/libc/reent/gettimeofdayr.c:71
#8 0x0800093c in gettimeofday (ptimeval=ptimeval@entry=0x20001720
<_main_stack+4052>, ptimezone=ptimezone@entry=0x0)
at /usr/src/debug/newlib/2.4.0-r0/newlib-2.4.0/newlib/libc/syscalls/sysgettod.c:12
#9 0x0800091c in _gettimeofday_r (ptr=0x20000008 <impure_data>,
ptimeval=ptimeval@entry=0x20001720 <_main_stack+4052>,
ptimezone=ptimezone@entry=0x0)
at /usr/src/debug/newlib/2.4.0-r0/newlib-2.4.0/newlib/libc/reent/gettimeofdayr.c:71
#10 0x0800093c in gettimeofday (ptimeval=ptimeval@entry=0x20001720
<_main_stack+4052>, ptimezone=ptimezone@entry=0x0)
at /usr/src/debug/newlib/2.4.0-r0/newlib-2.4.0/newlib/libc/syscalls/sysgettod.c:12
#11 0x0800091c in _gettimeofday_r (ptr=0x20000008 <impure_data>,
ptimeval=ptimeval@entry=0x20001720 <_main_stack+4052>,
ptimezone=ptimezone@entry=0x0)
at /usr/src/debug/newlib/2.4.0-r0/newlib-2.4.0/newlib/libc/reent/gettimeofdayr.c:71
#12 0x080008ee in time (t=t@entry=0x0)
at /usr/src/debug/newlib/2.4.0-r0/newlib-2.4.0/newlib/libc/time/time.c:46
#13 0x0800094a in main ()
at /home/erwin/zephyr/samples/hello_world/src/main.c:43
_______________________________________________
Zephyr-devel mailing list
Zephyr-devel@...
https://lists.zephyrproject.org/mailman/listinfo/zephyr-devel

Join devel@lists.zephyrproject.org to automatically receive all group messages.