Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cpu/native: implement periph_rtc_ms #19340

Merged
merged 1 commit into from
Mar 6, 2023
Merged

Conversation

benpicco
Copy link
Contributor

@benpicco benpicco commented Mar 2, 2023

Contribution description

periph_rtc on native can have ms accuracy, so implement the periph_rtc_ms interface.

Testing procedure

tests/periph_rtc now shows sub-second precision:

RIOT RTC low-level driver test
This test will display 'Alarm!' every 2 seconds for 4 times
Native RTC initialized.
  Setting clock to   2020-02-28 23:59:57
Clock value is now   2020-02-28 23:59:57.393
  Setting alarm to   2020-02-28 23:59:59
   Alarm is set to   2020-02-28 23:59:59
  Alarm cleared at   2020-02-28 23:59:57.393
       No alarm at   2020-02-28 23:59:59.393
  Setting alarm to   2020-02-28 23:59:61

Alarm!
Alarm!
Alarm!
Alarm!
{ "threads": [{ "name": "idle", "stack_size": 8192, "stack_used": 1100 }]}
{ "threads": [{ "name": "main", "stack_size": 12288, "stack_used": 2732 }]}

Issues/PRs references

@github-actions github-actions bot added Area: boards Area: Board ports Area: cpu Area: CPU/MCU ports Area: Kconfig Area: Kconfig integration Platform: native Platform: This PR/issue effects the native platform labels Mar 2, 2023
@benpicco benpicco added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: new feature The issue requests / The PR implemements a new feature for RIOT labels Mar 2, 2023
@benpicco benpicco requested a review from maribu March 2, 2023 15:47
@riot-ci
Copy link

riot-ci commented Mar 2, 2023

Murdock results

✔️ PASSED

ce36460 cpu/native: implement periph_rtc_ms

Success Failures Total Runtime
6917 0 6919 12m:35s

Artifacts

cpu/native/periph/rtc.c Outdated Show resolved Hide resolved
Copy link
Contributor

@kfessel kfessel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are more uses of time(NULL) in periph/rtc, we should use one source of truth

cpu/native/periph/rtc.c Outdated Show resolved Hide resolved
bors bot added a commit that referenced this pull request Mar 3, 2023
19341: Picolibc updates r=benpicco a=keith-packard

### Contribution description

Minor updates to picolibc support for newer versions of picolibc, including 1.8.


### Testing procedure

Here's the current build result for a board I happen to have on my bench right now:

```
$ make -C examples/blinky BOARD=nucleo-f103rb FEATURES_REQUIRED=picolibc
...
/home/keithp/src/RIOT/sys/picolibc_syscalls_default/syscalls.c:319:1: error: unknown type name '_READ_WRITE_RETURN_TYPE'
  319 | _READ_WRITE_RETURN_TYPE read(int fd, void *dest, size_t count)
      | ^~~~~~~~~~~~~~~~~~~~~~~
/home/keithp/src/RIOT/sys/picolibc_syscalls_default/syscalls.c:351:1: error: unknown type name '_READ_WRITE_RETURN_TYPE'
  351 | _READ_WRITE_RETURN_TYPE write(int fd, const void *src, size_t count)
      | ^~~~~~~~~~~~~~~~~~~~~~~
...
```

### Description of changes

 1. Fix the read/write return values (Picolibc 1.8 uses POSIX standard types now)
 2. Add new symbols to linker scripts (Picolibc needs help dealing with TLS alignment)
 3. Insert carriage return when sending newline to console.


19344: test/periph_rtc: reset struct tm time between tests r=benpicco a=kfessel

### Contribution description

while reviewing #19340 i found test/periph_rtc to be insufficient to prove rtc_set_time is working. this changes that and avoids accidental reuse of struct tm time and ms  values by resetting time and ms;

### Testing procedure

run the test

### Issues/PRs references

#19340

Co-authored-by: Keith Packard <[email protected]>
Co-authored-by: Karl Fessel <[email protected]>
bors bot added a commit that referenced this pull request Mar 3, 2023
19344: test/periph_rtc: reset struct tm time between tests r=benpicco a=kfessel

### Contribution description

while reviewing #19340 i found test/periph_rtc to be insufficient to prove rtc_set_time is working. this changes that and avoids accidental reuse of struct tm time and ms  values by resetting time and ms;

### Testing procedure

run the test

### Issues/PRs references

#19340

Co-authored-by: Karl Fessel <[email protected]>
Copy link
Contributor

@kfessel kfessel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

bors merge

@benpicco
Copy link
Contributor Author

benpicco commented Mar 6, 2023

bors merge

@bors
Copy link
Contributor

bors bot commented Mar 6, 2023

Build succeeded:

@bors bors bot merged commit 777857a into RIOT-OS:master Mar 6, 2023
@benpicco benpicco deleted the cpu/native-rtc_ms branch March 6, 2023 22:34
@MrKevinWeiss MrKevinWeiss added this to the Release 2023.04 milestone Apr 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: boards Area: Board ports Area: cpu Area: CPU/MCU ports Area: Kconfig Area: Kconfig integration CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Platform: native Platform: This PR/issue effects the native platform Type: new feature The issue requests / The PR implemements a new feature for RIOT
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants