8000 Fix FrameBufferDisplay, displayio_display_core_start_refresh & bus_free · Issue #3508 · adafruit/circuitpython · GitHub
[go: up one dir, main page]

Skip to content

Fix FrameBufferDisplay, displayio_display_core_start_refresh & bus_free #3508

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

Closed
jepler opened this issue Oct 2, 2020 · 3 comments
Closed

Comments

@jepler
Copy link
jepler commented Oct 2, 2020

#3507 papers over a problem where we called self->bus_free(self->bus); when bus_free was a NULL function pointer. In the case of RGBMatrix, this is fine. In the case of SharpDisplay, however, there is the possibility that the underlying SPI bus will be locked and we need to deal with it.

This could be done by

  • adding a new Framebuffer protocol to check for bus free (default/NULL function indicates bus is always free)
    • and implementing it for SharpDisplay, checking that the bus is in fact free
  • assigning this protocol to display_core.bus_free
  • removing the NULL check I added for self->bus

Presumably, without this fix, it is possible for a lockup to happen with an auto-refresh SharpDisplay and another foreground use of the SPI bus, including SD cards. However, I did not actually test anything in this area.

@hatchman
Copy link
hatchman commented Oct 9, 2020

Edit: running latest 6.0.0 beta 2, and sharp display is sole device on hardware SPI bus

Edit2: I picked up python about 2 weeks ago, so i'm still learning. Added board.SPI().deinit() after displayio.release_displays() and It no longer holds onto spi. still this seems like odd behavior that in a soft reboot spi clock remains locked. is this by design?

Edit3: is there any way to release/deinit the chip select pin or entirety of a framebuffer easily? I want to de initialize the sharp displayto speed up runtime code, then with an appreciable delay, reinitialize, and redraw from scratch if I need an update. while I can release clocks and SPI native lines, I cannot manage to release the chip select pin even when using digital libraries.

I can confirm some issues with the sharp display not able to access spi in certain conditions. I have a project with a bluefruit sense nrf52840 and a 2.7 sharp memory display. I have code that runs through a menu to inspect and run sub files, and each sub file has a routine with supervisor to issue a soft reboot. Oddly if i use displayio.release_displays() and issue the reboot, on soft reboot it claims spi bus is busy when the display is initialized. If i hard reboot, the code functions as intended.

I also leveraged the gc library to check memory at certain points in my code and found that on a hard reboot i get roughly 7,000 more bytes of free memory available on initialization. on EVERY soft reboot, i loose 7000-10,000 bytes of memory at the start of my code where only libraraies have been called. Not sure what is being held on to but the impact is significant where certain code can only run on a fresh power cycle and not on a ctrl d or softreboot with code.

@dhalbert
Copy link
Collaborator

@tannewt Is this still an issue?

@tannewt
Copy link
Member
tannewt commented Nov 20, 2023

I don't think so. It looks like SharpDisplay knows to bail if the SPI lock fails:

STATIC void common_hal_sharpdisplay_framebuffer_swapbuffers(sharpdisplay_framebuffer_obj_t *self, uint8_t *dirty_row_bitmask) {
// claim SPI bus
if (!common_hal_busio_spi_try_lock(self->bus)) {
return;
}

displayio_display_core_start_refresh no longer manages SPI buses so that doesn't matter for FrameBufferDisplay anymore.

@tannewt tannewt closed this as completed Nov 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants
0