zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10.77k stars 6.57k forks source link

i2c shell functions non-functional on nRF53 #31248

Closed thedjnK closed 3 years ago

thedjnK commented 3 years ago

Describe the bug I2C is working on an nRF53-based system e.g. using sensor sample apps, however the I2C shell itself does not seem to function at all.

To Reproduce Steps to reproduce the behavior:

  1. Build BME680 sample for nRF53 (nrf5340dk_nrf5340_cpuapp) with shell enabled
  2. Build hello world sample for nRF53 (nrf5340dk_nrf5340_cpuapp) with shell enabled
  3. Flash BME680 sample app
  4. Observe that sensor data is correctly output
  5. Try to scan I2C bus, it returns 0 devices
  6. Flash hello world sample app
  7. Try to scan I2C bus, it returns 0 devices
  8. Try to read from BME680 sensor, it fails

Expected behavior It to work

Impact Seems like a bit of an annoyance if this doesn't work

Logs and console output Output from BME680 sample app: uart:~$ Booting Zephyr OS build zephyr-v2.4.0-2823-gf4a26837c8cb Device 0x20000234 name is BME680 T: 24.100000; P: 100.585000; H: 42.176000; G: 37582.000000 T: 24.180000; P: 100.585000; H: 42.056000; G: 46444.000000 T: 24.220000; P: 100.586000; H: 41.935000; G: 51387.000000 T: 24.250000; P: 100.585000; H: 41.840000; G: 55226.000000

scan I2C_1
       0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:             -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
0 devices found on I2C_1

Output from hello world:

*** Booting Zephyr OS build zephyr-v2.4.0-2823-gf4a26837c8cb  ***
Hello World! nrf5340dk_nrf5340_cpuapp

uart:~$ i2c scan I2C_1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:             -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
0 devices found on I2C_1
[00:00:03.736,206] <err> i2c_nrfx_twim: Error 195952641 occurred for message 0
[00:00:03.736,419] <err> i2c_nrfx_twim: Error 195952641 occurred for message 0
[00:00:03.736,938] <err> i2c_nrfx_twim: Error 195952641 occurred for message 0
[00:00:03.737,121] <err> i2c_nrfx_twim: Error 195952641 occurred for message 0
[00:00:03.737,609] <err> i2c_nrfx_twim: Error 195952641 occurred for message 0
[00:00:03.737,792] <err> i2c_nrfx_twim: Error 195952641 occurred for message 0
[00:00:03.738,311] <err> i2c_nrfx_twim: Error 195952641 occurred for message 0
[00:00:03.738,525] <err> i2c_nrfx_twim: Error 195952641 occurred for message 0
[00:00:03.738,708] <err> i2c_nrfx_twim: Error 195952641 occurred for message 0
[00:00:03.739,013] <err> i2c_nrfx_twim: Error 195952641 occurred for message 0
[00:00:04.239,135] <err> i2c_nrfx_twim: Error on I2C line occurred for message 0

uart:~$ i2c read_byte I2C_1 0x76
Failed to read from device: I2C_1
uart:~$ i2c read I2C_1 0x76
Failed to read from device: I2C_1
uart:~$ i2c read I2C_1 0x76 1
Failed to read from device: I2C_1

Environment (please complete the following information):

Additional context Add any other context about the problem here.

pabigot commented 3 years ago

Initial review suggests the nRF53 doesn't behave the same as nRF52 with respect to transfers with no data, which is the mechanism used to detect presence of a device on the bus. The sensor signals an ACK at the end of the address, but the underlying nrfx driver must be continuing to perform a transaction even though the length should be zero, which produces an error instead of a success return.

This seems to be a difference in behavior at the nrfx driver level for the two chip lines. @anangl any ideas?

github-actions[bot] commented 3 years ago

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.