-
Notifications
You must be signed in to change notification settings - Fork 143
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
Pin::export() errors out w/ "Device or resource busy" #146
Comments
Ok, I'm trying to see whether it's possible to exit the program without the Pi needing a reboot. So, continuing without exporting CS, RST seems to be the next culprit: let rst = Pin::new(17); //pin 36 //bcm16
rst.export().expect("rst export");
while !rst.is_exported() {}
rst.set_direction(Direction::Out).expect("rst Direction");
// rst.set_value(1).expect("rst Value set to 1");
std::process::exit(0); exit with the line uncommented and the Pi crashes into I/O error until reboot. Exit as above, and it doesn't. Yay! Moving on, let mut epd4in2 =
Epd4in2::new(&mut spi, cs, busy, dc, rst, &mut delay, None).expect("eink initalize error");
std::process::exit(0); It always leave the Pi in crashed state. Looking into the implementation, it manipulates the RST value, so what I am trying now is to manipulate that back before the exit, see whether that changes anything. I'm open for inputs on alternative ways to debug this, resetting a crashed Pi after every failed build is no fun! |
In the 4in2 example, where are the The file mentions a |
I've run into the same issue with my 7.5in display as well. Strangely enough the official Waveshare python code works just fine. I've read some search results that you can remap which GPIO pin SPI uses but I am not really well versed in that kind of stuff so don't know what the side effects would be.
|
I "blindly" remapped the CS0 pin of the SPI interface to a different pin. It seems to work now.
This moves the CS0 pin to 26 and the ResourceBusy error disappears and I can render content to my display. |
Looking at the C code I can see that the SYSFS_GPIO_EXPORT() function does the same as the Rust function: it opens the "/sys/class/gpio/export" file and writes the pin number on it, so not sure why it's throwing the error here.
Device
Waveshare 4.2in on RPi4
Repro
Run
examples/4in2
, withlet cs = Pin::new(8)
to match the Pi4Error
thread 'main' panicked at 'cs export: Io(Os { code: 16, kind: ResourceBusy, message: "Device or resource busy" })', src/main.rs:34:17
Troubleshooting
Other interesting results:
pin_num
inlet cs = Pin::new();
results in the program not erroring out and continuing to the end, but nothing is shown on the screen.drawing is ok, and the program exits without errors, but I get a bunch of
Input/output error
on the pi after that, at any keypress, until I restart the pi, and the e-ink screen is not cleared, not even after callingclear_frame()?;
, which does not error out.The text was updated successfully, but these errors were encountered: