tock / libtock-c

Userland apps for Tock written in C and C++
Apache License 2.0
82 stars 89 forks source link

500 Second GetTimeAsTicks Wrap #381

Closed tyler-potyondy closed 7 months ago

tyler-potyondy commented 7 months ago

For the nrf52840 board, the gettimeasticks function timer wraps at ~511 seconds.

Sampling getimeasticks every second yields the following:

Time: 509s
Time: 510s
Time: 511s
Time: 0s
Time: 1s
Time: 2s

(@atar13 and @Samir-Rashid have found this to not be a bug, but expected behavior given the nrf52x rtc implementation -- further discussion to be posted by them as an issue in the main Tock repo).

The inconvenience of gettimeasticks wrapping can be resolved through additional logic, but a timer wrapping every 511 seconds seems somewhat cumbersome.

alistair23 commented 7 months ago

Just to be clear. Are you saying that in userspace (libtock-c) the time in seconds is wrapping or the ticks return from the kernel are wrapping?

If it's the first we should fix it in libtock-c. If it's the second there isn't much we can do about that in libtock-c, that will have to be addressed in Tock

alistair23 commented 7 months ago

I'm guessing from https://github.com/tock/tock/issues/3938 that this is a kernel issue. This issue should be closed

atar13 commented 7 months ago

Just to be clear. Are you saying that in userspace (libtock-c) the time in seconds is wrapping or the ticks return from the kernel are wrapping?

We verified the ticks being returned from the kernel were wrapping by printing out the value every second. So yes, this concerns the implementation in the kernel.