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

ULP RISC-V RTC I2C doesn't work after esp_restart() (IDFGH-9065) #10468

Closed
3 tasks done
schafon opened this issue Dec 30, 2022 · 3 comments
Closed
3 tasks done

ULP RISC-V RTC I2C doesn't work after esp_restart() (IDFGH-9065) #10468

schafon opened this issue Dec 30, 2022 · 3 comments
Assignees
Labels
Resolution: Done Issue is done internally Status: Done Issue is done internally Type: Bug bugs in IDF

Comments

@schafon
Copy link

schafon commented Dec 30, 2022

Answers checklist.

  • I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

IDF version.

v5.1-dev-2066-g7869f4e151-dirty

Operating System used.

macOS

How did you build your project?

Command line with idf.py

If you are using Windows, please specify command line type.

None

Development Kit.

ESP32-s2

Power Supply used.

USB

What is the expected behavior?

After software esp_restart() continue normal ULP I2C operation.

What is the actual behavior?

After a restart ulp will hang on: ulp_riscv_i2c_master_set_slave_reg_addr(reg_addr); OR ulp_riscv_i2c_master_read_from_device(data_out, 1);

and will not run again.

Steps to reproduce.

  1. Get ULP RISC-V I2C example from https://github.com/espressif/esp-idf/tree/master/examples/system/ulp_riscv/i2c
  2. Patch ULP library and example code according to this patch from ulp_riscv_i2c crash (IDFGH-8880) #10301
  3. (Optional) add ulp_riscv_print to debug the ulp core - I do that
  4. When ulp wake up is detected restart the esp using esp_restart()
  5. Watch the UART output of the ulp, after it will reach ulp_riscv_i2c_master_set_slave_reg_addr(reg_addr); OR ulp_riscv_i2c_master_read_from_device(data_out, 1); the code will hang and the esp will not wake up again

Debug Logs.

Not a ULP-RISC V wakeup (cause = 0)
Initializing RTC I2C ...

More Information.

I've tested this on esp32 s2 and esp32 s3, different types of dev boards and 1 custom board.

@schafon schafon added the Type: Bug bugs in IDF label Dec 30, 2022
@espressif-bot espressif-bot added the Status: Opened Issue is new label Dec 30, 2022
@github-actions github-actions bot changed the title ULP RISC-V RTC I2C doesn't work after esp_restart() ULP RISC-V RTC I2C doesn't work after esp_restart() (IDFGH-9065) Dec 30, 2022
@schafon
Copy link
Author

schafon commented Dec 30, 2022

@sudeep-mohanty - Can you take a look?
I would appreciate if you can provide me a patch for this since I'm on a deadline for this project.

@espressif-bot espressif-bot added Status: In Progress Work is in progress and removed Status: Opened Issue is new labels Jan 2, 2023
@sudeep-mohanty
Copy link
Collaborator

sudeep-mohanty commented Jan 2, 2023

Hi @schafon,
Thank you for reporting the issue. Really appreciate it!
I was able to reproduce the problem at my end as well. Turns out, when you perform a soft reset using esp_restart(), not all peripherals are reset. Hence, some configuration information about the RTC I2C peripheral is also not reset. Therefore, this stale configuration leads to an undefined behaviour when we try to initialise the RTC I2C the second time round. The solution here is to manually reset the RTC I2C config, which the current driver is not doing. I have a fix in progress for this and will be deployed once it is tested and reviewed. However, to unblock your project, you may try this at your end and let me know your feedback regarding the issue. Thanks! -

rtc_i2c_esp_restart.patch

@schafon
Copy link
Author

schafon commented Jan 2, 2023

The patch works perfectly.
Thank again Sudeep.

@schafon schafon closed this as completed Jan 2, 2023
@espressif-bot espressif-bot added Resolution: NA Issue resolution is unavailable Status: Done Issue is done internally Resolution: Done Issue is done internally and removed Status: In Progress Work is in progress Resolution: NA Issue resolution is unavailable labels Jan 5, 2023
espressif-bot pushed a commit that referenced this issue Jan 13, 2023
…r esp_restart()

This commit fixes a bug wherein the RTC I2C peripheral got stuck after
the main CPU performs a soft reset by using esp_restart(). This is
because the RTC domain config registers for the RTC I2C domain are not
cleared after the soft restart and hence need to be cleared manually
while initializing the RTC I2C peripheral again.

Closes #10468
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Done Issue is done internally Status: Done Issue is done internally Type: Bug bugs in IDF
Projects
None yet
Development

No branches or pull requests

3 participants