Skip to content

cpu/esp32: replace RTC implementation by RTT implementation#13749

Merged
benpicco merged 5 commits intoRIOT-OS:masterfrom
gschorcht:cpu/esp32/periph_rtt
May 1, 2020
Merged

cpu/esp32: replace RTC implementation by RTT implementation#13749
benpicco merged 5 commits intoRIOT-OS:masterfrom
gschorcht:cpu/esp32/periph_rtt

Conversation

@gschorcht
Copy link
Contributor

@gschorcht gschorcht commented Mar 29, 2020

Contribution description

This PR replaces the RTC implementation with an RTT implementation that uses the RTC hardware timer of the ESP32. The RTC implementation used instead is the RTT based RTC implementation provided by the rtt_rtc module.

Although the RTC hardware module of the ESP32 is called an RTC, it is a Real Time Timer (RTT) rather than a Real Timer Clock. Therefore, the former RTC peripheral driver implementation is replaced by an RTT periphal driver implementation.

Note: An RTT/RTC alarm is not preserved during reboot or deep-sleep.

Testing procedure

tests/periph_rtc and tests/periph_rtc should work

make BOARD=esp32-wroom-32 -C tests/periph_rtt flash test
make BOARD=esp32-wroom-32 -C tests/periph_rtc flash test

Furthermore, use tests/periph_pm can be used to test that the RTT and RTC are retained in sleep modes and during reboot.

CFLAGS='-DESP_PM_WUP_PINS=GPIO0 -DESP_PM_WUP_LEVEL=ESP_EXT1_WAKEUP_ALL_LOW' \
USEMODULE='shell_commands rtt_cmd' \
make BOARD=esp32-wroom-32 -C tests/periph_pm flash term
> rtc settime 2020-03-29 16:17:40
> rtc gettime
2020-03-29 16:17:43
> reboot
...
> rtc gettime
2020-03-29 16:17:49
> set 0
CPU will enter power mode 0.

Press BTN0

...
> rtc gettime
2020-03-29 16:18:01

Issues/PRs references

@gschorcht gschorcht added Area: cpu Area: CPU/MCU ports 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 State: WIP State: The PR is still work-in-progress and its code is not in its final presentable form yet Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation Type: new feature The issue requests / The PR implemements a new feature for RIOT and removed State: WIP State: The PR is still work-in-progress and its code is not in its final presentable form yet labels Mar 29, 2020
@gschorcht gschorcht force-pushed the cpu/esp32/periph_rtt branch from 94c8103 to 0cec439 Compare March 29, 2020 14:35
@gschorcht gschorcht added the State: WIP State: The PR is still work-in-progress and its code is not in its final presentable form yet label Apr 1, 2020
@gschorcht gschorcht force-pushed the cpu/esp32/periph_rtt branch from 0cec439 to e98fa56 Compare April 2, 2020 17:00
@gschorcht gschorcht changed the title cpu/esp32: replaces RTC implementation by RTT implementation cpu/esp32: replace RTC implementation by RTT implementation Apr 2, 2020
@gschorcht gschorcht force-pushed the cpu/esp32/periph_rtt branch from e98fa56 to 4f46ed1 Compare April 2, 2020 23:27
@gschorcht gschorcht removed the State: WIP State: The PR is still work-in-progress and its code is not in its final presentable form yet label Apr 2, 2020
@gschorcht gschorcht force-pushed the cpu/esp32/periph_rtt branch 6 times, most recently from aaff77a to 36be164 Compare April 3, 2020 14:10
Since the attribute is required by EPS8266 as well as ESP32, it is moved to cpu/esp_common.
@gschorcht gschorcht force-pushed the cpu/esp32/periph_rtt branch from 36be164 to f2267b1 Compare April 3, 2020 16:07
@benpicco
Copy link
Contributor

benpicco commented Apr 3, 2020

Could it be that the toolchain on Murdock was upgraded and now compile/tests/libc_newlib/esp32-wrover-kit:gnu is always failing?

Do you have a fix hidden in here? 😉
I think I saw this fail on the same test a little earlier, now it isn't failing that test.

@gschorcht
Copy link
Contributor Author

gschorcht commented Apr 3, 2020

Could it be that the toolchain on Murdock was upgraded and now compile/tests/libc_newlib/esp32-wrover-kit:gnu is always failing?

Do you have a fix hidden in here?
I think I saw this fail on the same test a little earlier, now it isn't failing that test.

I don't know, I saw this problem too. Maybe @kaspar030 updated the toolchain only on one worker and if tests/libc_newlib compilation lands on that worker, it will fail 😟 :

The problem is not really clear to me, but I can also see it locally. The test complains that the addresses of printf and iprintf are the same.

   text	   data	    bss	    dec	    hex	filename
  40646	   3384	   6400	  50430	   c4fe	/home/gs/src/RIOT-Xtensa-ESP.working/tests/libc_newlib/bin/esp32-wroom-32/tests_libc_newlib.elf
Test: comparing addresses of 'printf' and 'iprintf' symbols
[FAILED] '400d0334' != '400d0334' is False

According to the comment in test's README, these symbols should address the same code in newlibc-nano.

OK, I forgot to add newlib_nano as module when providing the new toolchain. But even if I use

USEMODULE=newlib_nano make BOARD=esp32-wroom-32 -C tests/libc_newlib

the linker test fails.

@gschorcht
Copy link
Contributor Author

gschorcht commented Apr 3, 2020

OK, I forgot to add newlib_nano as module when providing the new toolchain. But even if I use

USEMODULE=newlib_nano make BOARD=esp32-wroom-32 -C tests/libc_newlib

the linker test fails.

Forget it, it's too late today ... With

USEMODULE=newlib_nano make BOARD=esp32-wroom-32 -C tests/libc_newlib

the test works. The output seems too similar to the failed one.

   text	   data	    bss	    dec	    hex	filename
  40646	   3384	   6400	  50430	   c4fe	/home/gs/src/RIOT-Xtensa-ESP.working/tests/libc_newlib/bin/esp32-wroom-32/tests_libc_newlib.elf
Test: comparing addresses of 'printf' and 'iprintf' symbols
[SUCCESS] '400d0334' = '400d0334' is True

@gschorcht gschorcht added the State: WIP State: The PR is still work-in-progress and its code is not in its final presentable form yet label Apr 5, 2020
@gschorcht gschorcht force-pushed the cpu/esp32/periph_rtt branch from f2267b1 to ce431b2 Compare April 7, 2020 07:13
@gschorcht gschorcht removed the State: WIP State: The PR is still work-in-progress and its code is not in its final presentable form yet label Apr 7, 2020
@benpicco benpicco requested review from benpicco and maribu April 17, 2020 13:31
Copy link
Contributor

@benpicco benpicco left a comment

Choose a reason for hiding this comment

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

Code looks good!

@gschorcht
Copy link
Contributor Author

I have realized that %llu debugging outputs don't work any longer with the newlib-nano-formatted-io. According to @kaspar030's comment #13812 (comment) it might be better to replace them by %u debugging outputs before this PR is merged instead of reverting newlib-nano-formated-io. There are probably other places where %llu is used in debugging outputsand we could replace them by%u` outputs by a separate PR. What do you think?

@benpicco benpicco merged commit 4150afe into RIOT-OS:master May 1, 2020
@miri64 miri64 added this to the Release 2020.07 milestone Jun 24, 2020
@gschorcht gschorcht deleted the cpu/esp32/periph_rtt branch July 31, 2025 08:05
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 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 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.

3 participants