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

Control never returns from stm32_i2c_msg_write(), whe SCL is pulled low permanently (hardware fault occurs) #26975

Closed
mtahirbutt opened this issue Jul 20, 2020 · 6 comments
Assignees
Labels
area: I2C bug The issue is a bug, or the PR is fixing a bug platform: STM32 ST Micro STM32 priority: low Low impact/importance bug Stale

Comments

@mtahirbutt
Copy link
Contributor

Describe the bug
A clear and concise description of what the bug is.

When there is a faulty hardware sensor connected via I2C interface, the control is not returned from stm32_i2c_msg_write() function even during initialization, I did tests with SHT3xd sensor sample app to conclude to this bug in the software. In order to further confirm the problem, I artificially pulled SCL signal line to low which resulted in the same problem.
I further debugged the stm32_i2c_msg_write(), and found that k_sem_take(&data->device_sync_sem, K_FOREVER); does not return the control, semophore resources are never released by other thread using those resources.

What have you tried to diagnose or workaround this issue?

I tried to reduce timeout value with k_sem_take(,timeout) function and used 5s, the control is returned after 5s but data->current.is_nack is not set which does not return the function with correct error code so that the calling function (driver initialization or sensor read may react appropriately upon such hardware failure).

To Reproduce
Steps to reproduce the behavior:

  1. mkdir build;
  2. cmake -DBOARD=stm32L475
  3. make
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

stm32_i2c_msg_write() should return error code when I2C finds a faulty hardware on the interface.

Impact
What impact does this issue have on your progress (e.g., annoyance, showstopper)

The main application does not handle faulty hardware line effectively.

Logs and console output
If applicable, add console logs or other types of debug information
e.g Wireshark capture or Logic analyzer capture (upload in zip archive).
copy-and-paste text and put a code fence (```) before and after, to help
explain the issue. (if unable to obtain text log, add a screenshot)

Environment (please complete the following information):

  • OS: (e.g. Windows)
  • Toolchain (e.g Zephyr 2.3.0, SDK 0.11.2, ...)
  • Commit SHA or Version used

Additional context
Add any other context about the problem here.

@mtahirbutt mtahirbutt added the bug The issue is a bug, or the PR is fixing a bug label Jul 20, 2020
@erwango erwango assigned ABOSTM and unassigned erwango Jul 20, 2020
@erwango
Copy link
Member

erwango commented Jul 20, 2020

@mtahirbutt can you check https://github.com/zephyrproject-rtos/zephyr/pull/21308/files could solve the issue you're facing ?

@mtahirbutt
Copy link
Contributor Author

@erwango, thanks for a great tip, i am working on that.

@mtahirbutt
Copy link
Contributor Author

mtahirbutt commented Jul 21, 2020

Hi, I tested "i2c_ll_stm32: Add timeout to I2C read/write functions" PR only adjusted semophore timeouts, that works fine with my zephyr 2.3.0 version. I tested with both faulty and open connector for two sensors TMP116 and shtxd35. So far, experienced no problem with 1 ms timeout value. Getting value for timeout from DT is problematic as PR is quite old have to sort out a couple of things.

@ydamigos
Copy link
Collaborator

Hi @mtahirbutt,
I have updated PR #21308, could you check again if it works for you?

@mtahirbutt
Copy link
Contributor Author

Hi @ydamigos, thanks for your nice contribution, i will work on that in some time.

@github-actions
Copy link

This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: I2C bug The issue is a bug, or the PR is fixing a bug platform: STM32 ST Micro STM32 priority: low Low impact/importance bug Stale
Projects
None yet
Development

No branches or pull requests

7 participants