Closed ReimuNotMoe closed 3 years ago
Hi @ReimuNotMoe what device are you trying to dump? Do you have a Logic Analyzer to see the bus? Even a "cheaper" logic analyzer can do the trick: https://acassis.wordpress.com/2015/07/19/sigrok-and-a-cheap-saleae-clone-can-save-your-life-i-meant-your-time/ This way you can compare the i2ctool command from NuttX against STM32 HAL and the Raspberry Pi i2ctool.
Hi @ReimuNotMoe what device are you trying to dump? Do you have a Logic Analyzer to see the bus? Even a "cheaper" logic analyzer can do the trick: https://acassis.wordpress.com/2015/07/19/sigrok-and-a-cheap-saleae-clone-can-save-your-life-i-meant-your-time/ This way you can compare the i2ctool command from NuttX against STM32 HAL and the Raspberry Pi i2ctool.
I bought a DSLogic Plus logic analyzer and used it to inspect the i2c lines.
Edit: I selected wrong channels in the previous edit. Here are the correct results.
It seems that i2c
is reading "correct" data, I don't know why.
Nuttx dumping an EPSON RTC, all 0xff:
i2ctool output when dumping a MCP23017 I/O expander, garbled data:
Raspi dumping the same EPSON RTC, everything fine:
Raspi dumping the same MCP23017 I/O expander, everything fine:
So after looking at these screenshots again and again, I found these possible problems:
I went through the datasheets of both chips, they both support incremental reading, so that shouldn't be a problem.
It looks like not sending register addresses is the real problem. Is this intentional or a standardized behavior?
Hi @ReimuNotMoe I just ordered some MCP23017 modules to test. It is not clear for me what is the expected behavior of the i2ctool dump.
Hi @ReimuNotMoe I just ordered some MCP23017 modules to test. It is not clear for me what is the expected behavior of the i2ctool dump.
I mean the NuttX i2ctool isn't telling the device which register to read from. It didn't write register address to device before initializing incremental read. It looks like there's nothing wrong with the hardware drivers.
Since NuttX is trying to be Linux-ish in all ways (AFAIK), it might be better to make the NuttX i2ctool behave like the one in Linux.
Yes, you are right @ReimuNotMoe the NuttX i2ctool needs to duplicate the Linux i2ctool. People can see NuttX as a Linux-like for microcontroler! ;-)
Let's close this issue now, @ReimuNotMoe you can provide a patch to make NuttX i2c-tools more compatible with Linux's version.
I'm currently porting NuttX to a new (not publicly released yet) board. It uses STM32L151C8T6-A MCU.
However, I can't properly read data from I2C devices using the i2ctool.
I can list attached devices using
i2c dev 00 7f
, but dumping registers usingi2c dump -b 1 -a <addr> 256
will return garbage data. Sometimes it returns allff
and sometimes it returns random values.I tried messing with the menuconfig options: Alternate implementation, dynamic timeouts, huge timeout values, etc. And none of these worked.
These I2C devices work well with STM32 HAL APIs and a Raspberry Pi.
Please tell me how to solve this problem, thanks in advance.