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

communication with device failed #62

Open
galshd opened this issue Apr 1, 2024 · 10 comments
Open

communication with device failed #62

galshd opened this issue Apr 1, 2024 · 10 comments

Comments

@galshd
Copy link

galshd commented Apr 1, 2024

I'm using the 7.5inch display, https://www.waveshare.com/wiki/7.5inch_HD_e-Paper_HAT. I've browsed through similar issues (e.g. #18) and tried the following:

  • lower spi_hz
  • turn spi on and off
  • reboot
  • check the cables, plug and unplug

However I'm still getting "communication with device failed" when running

python3.8 test.py

in IT8951/test/integration

For what it's worth, the C WaveShare code from https://www.waveshare.com/wiki/7.5inch_HD_e-Paper_HAT works fine.

Is there something I might be missing here? I've also read that using the Waveshare code might leave the display in a weird state - is there any way I can completely reset the display? Not sure why rebooting does not work here.

Appreciate any pointers :) thank you!

@Nico04
Copy link

Nico04 commented May 31, 2024

Same here.
Using a Raspberry Pi Zero worked fine, but with my new Pi 5 I have this issue, so sad.
Using https://www.waveshare.com/wiki/9.7inch_e-Paper_HAT
(Works fine with demo sample of Waveshare)

Same issue with a Pi 4 (again, works fine with demo code)

@GregDMeyer
Copy link
Owner

Please let me know if you have any luck figuring out what is going on---unfortunately since I cannot reproduce the issue I don't have a good way of debugging what is happening. I am certainly open to pull requests if you figure out a fix!

@brookstalley
Copy link

brookstalley commented Jul 13, 2024

Having the same issue. Here's what I know:

  • Does not seem related to running as root / sudo or not. I set up a whole install as root, same problem
  • Waveshare demo files work. I've rebooted after running them
  • The error is in interface.py:105, where SPI is initialized and apparently the read function just gets zeros back

I am testing on a RPI 4B / 8GB, running the latest 64-bit Lite OS, and python 3.12.4.

I'm at a loss, but commenting in the hopes someone solves it.

@brookstalley
Copy link

Dove deeper -- no solution but leaving notes in case anyone else runs across this.

The example file in the waveshare repo works when compiled. I've double-checked everything I can find to align implementations between this repo and that one. I confirmed that all constants for pins and message values are the same.

There are a couple of differences between the two. The waveshare version:

  • Implements reset with high for 200ms, low for 10ms, high for 200ms
  • Sets CS low at beginning of write() command and high after write
  • Waits for HRDY / ready between sending preamble and payload

I've aligned my local copy of this repro with the waveshare implementations... and still no luck.

@brookstalley
Copy link

While the example file in IT8951-ePaper does work when compiled with the default BCM driver, it DOES NOT work when compiled to use GPIOD (make -j4 LIB=GPIOD). The program starts but it does not successfully control the display at all.

Similarly, manually accessing the SPI ports using pigpiod / pigs also fails the same way: no errors, but all read bytes are returned as zero.

So I'm pretty confident that this issue is not in this IT8951 library at all, but something at the GPIOD level.

@pipplo
Copy link

pipplo commented Aug 30, 2024

@brookstalley did you have any luck? I'm having what appears to be the same issue. Waveshare examples work when using GPIOD but I end up with a 'communication with device failed' error as well.

@pipplo
Copy link

pipplo commented Aug 30, 2024

Dove deeper -- no solution but leaving notes in case anyone else runs across this.

The example file in the waveshare repo works when compiled. I've double-checked everything I can find to align implementations between this repo and that one. I confirmed that all constants for pins and message values are the same.

There are a couple of differences between the two. The waveshare version:

  • Implements reset with high for 200ms, low for 10ms, high for 200ms
  • Sets CS low at beginning of write() command and high after write
  • Waits for HRDY / ready between sending preamble and payload

I've aligned my local copy of this repro with the waveshare implementations... and still no luck.

Do you happen to have these changes available that you can push? I also noticed a few differences in the startup sequence. It looks like gpiod works for me but not for you so maybe your changes will work on my side?

@pipplo
Copy link

pipplo commented Aug 31, 2024

Well a small update, I just tried refreshing with a new image and not installing or following any of the waveshare instructions. The same hardware with the new image works fine. So something leads to an incompatibility here

🤷

@SandrRu
Copy link

SandrRu commented Nov 3, 2024

Having the same issue.
With 13.3inch e-Paper Module
line 105, in update_system_info raise RuntimeError("communication with device failed")

My Raspberry have BCM2835 SPI

Maybe this will help?
Waveshare write some info about BCM2835

BCM2835
bcm2835_spi_begin(); // Start SPI operations. Forces RPi SPI0 pins P1-19 (MOSI), P1-21 (MISO), P1-23 (CLK), P1-24 (CE0) and P1-26 (CE1) to alternate function ALT0, which enables those pins for SPI interface. You should call bcm2835_spi_end() when all SPI funcitons are complete to return the pins to their default functions. See: http://www.airspayce.com/mikem/bcm2835/group__spi.html
bcm2835_spi_setBitOrder(BCM2835_SPI_BIT_ORDER_MSBFIRST); // Set bit order as MSB First
bcm2835_spi_setDataMode(BCM2835_SPI_MODE0); // Sets the SPI data mode, CPOL = 0, CPHA = 0
bcm2835_spi_setClockDivider(BCM2835_SPI_CLOCK_DIVIDER_128); // Sets the SPI clock divider
bcm2835_spi_chipSelect(BCM2835_SPI_CS0); // Sets the chip select pin(s) When an bcm2835_spi_transfer() is made,
bcm2835_spi_setChipSelectPolarity(BCM2835_SPI_CS0, LOW); // Sets the chip select pin CS0 polarity as active LOW.
bcm2835_spi_transfer(uint_t value); // Transfers one byte
bcm2835_spi_transfernb(char *tbuf,char *rbuf,uint32_t len); // Transfers any number of bytes

@juleaume
Copy link

I had the same issue with a rasp4. The Waveshare tutorial states to change a value in /boot/firmware/config.txt
E-Paper_lg

Restoring the default value (so dtparam=spi=on) solved the issue for me

juleaume pushed a commit to juleaume/IT8951 that referenced this issue Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants