Skip to content

Conversation

gschorcht
Copy link
Contributor

@gschorcht gschorcht commented Jun 13, 2022

Contribution description

This PR adds a simple implementation of _gettimeofday_r based on the microsecond system timer (system_get_time_64()) without occupying a `TIMER_DEV.

Since PR #18027, the ESP32 port uses the module libc_gettimeofday by default which enables implicitly modules xtimer and ztimer_usec which in turn occupies TIMER_DEV(0).

The changes in this PR

  • allow to remove this dependency on module libc_gettimeofday.
  • fix the execution error in tests/periph_timer due to TIMER_DEV(0) is ocu

In this implementation, the the microsecond system timer is realized on top of a peripheral timer. In future implementations of the ESP32 port, the microsecond hardware system timer will be used for that purpose.

Testing procedure

  1. Check the used modules list:
     BOARD=esp32-wroom-32 make -C tests/shell info-modules
    
    Without this PR the module list is:
    ...
    
    tsrb
    xtensa 
    xtimer
    ztimer
    ztimer64
    ztimer64_init
    ztimer64_usec
    ztimer64_xtimer_compat
    ztimer_convert
    ztimer_convert_frac
    ztimer_convert_shift
    ztimer_core
    ztimer_extend
    ztimer_init
    ztimer_periph_timer
    ztimer_usec
    ztimer_xtimer_compat
    
    With this PR the module list should be:
    ...
    tsrb
    xtensa
    
  2. Flash an test
     BOARD=esp32-wroom-32 make -C tests/periph_timer`
    
    Without this PR the output is:
    Test for peripheral TIMERs
    Available timers: 3
    
    Testing TIMER_0:
    TIMER_0: ERROR on initialization - skipping
    ...
    TEST FAILED
    
    With this PR the output should be:
    Test for peripheral TIMERs
    Available timers: 3
    
    Testing TIMER_0:
    TIMER_0: initialization successful
    ...
    TEST SUCCEEDED
    

Issues/PRs references

Found in test runs in CI for #16833

@github-actions github-actions bot added Area: cpu Area: CPU/MCU ports Area: Kconfig Area: Kconfig integration Platform: ESP Platform: This PR/issue effects ESP-based platforms labels Jun 13, 2022
@gschorcht gschorcht added Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Jun 13, 2022
@gschorcht gschorcht force-pushed the cpu/esp32/remove_dep_on_libc_gettimeofday branch from 423ba3c to 4cf3e1a Compare June 14, 2022 04:41
@chrysn chrysn requested review from fjmolinas and benpicco June 14, 2022 06:45
@chrysn chrysn added CI: run tests If set, CI server will run tests on hardware for the labeled PR CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Jun 14, 2022
@chrysn
Copy link
Member

chrysn commented Jun 14, 2022

Build tests passed, but I'm retriggering CI with tests enabled to see that run_tests are cleared (they currently fail in unrelated builds, which AIU triggered this PR). The change looks good to me, but I don't feel sufficiently confident with the involved systems (neither the POSIX emulation nor the platform) to ack it.

@gschorcht gschorcht removed the CI: run tests If set, CI server will run tests on hardware for the labeled PR label Jun 18, 2022
@gschorcht
Copy link
Contributor Author

I had to rebase to solve the conflicts. There are no code changes. Since the problems of test runs are unrelated to this PR, I removed the label CI: run tests.

@gschorcht gschorcht force-pushed the cpu/esp32/remove_dep_on_libc_gettimeofday branch from 4cf3e1a to 4dc5e86 Compare June 18, 2022 14:38
@benpicco benpicco enabled auto-merge June 18, 2022 16:24
@benpicco benpicco merged commit e32c19f into RIOT-OS:master Jun 18, 2022
@gschorcht gschorcht deleted the cpu/esp32/remove_dep_on_libc_gettimeofday branch June 20, 2022 16:49
@chrysn chrysn added this to the Release 2022.07 milestone Aug 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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: ESP Platform: This PR/issue effects ESP-based platforms Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants