pappersverk / scenic_driver_inky

A Scenic driver for running the Inky eInk display from Pimoroni on nerves.
17 stars 5 forks source link

Error: rpi_fb_capture: Unable to open primary display [pi4 problem] #5

Open kottkrig opened 4 years ago

kottkrig commented 4 years ago

Expected Behavior

I'm new to Nerves and Scenic but I hoped that I could follow along the guide at An eink display with Nerves and Elixir but use an Inky wHAT instead of a pHAT.

Current Behavior

I'm unable to render the Scenic graph from the example on an Inky wHAT display. I get the error message rpi_fb_capture: Unable to open primary display.

Failure Information

I can render a checkerboard pattern (described in the tutorial) with pure Inky but the Scenic render fails.

Hardware

Config

My scenic viewport configuration and the changes I made from the original example.

config :eink, :viewport, %{
  name: :main_viewport,
  default_scene: {Eink.Scene.Main, nil}
- size: {212, 104},
+ size: {400, 300},
  opts: [scale: 1.0],
  drivers: [
    %{
      module: ScenicDriverInky,
      opts: [
-       type: :phat,
+       type: :what,
        accent: :red,
        opts: %{
          border: :black
        }
      ]
    }
  ]
}

Failure Logs

00:05:30.953 [error] Jan  1 00:05:30 rpi_fb_capture: Unable to open primary display

00:05:30.954 [error] GenServer #PID<0.31658.6> terminating
** (stop) bad return value: {:stop, :port_crashed}
Last message: {#Port<0.77607>, {:exit_status, 1}}
State: %RpiFbCapture.State{display_height: 0, display_id: 0, display_width: 0, height: 300, port: #Port<0.77607>, request: {{#PID<0.31655.6>, #Reference<0.27677081.805830660.247102>}, :rgb24}, width: 400}

00:05:30.955 [error] GenServer #PID<0.31655.6> terminating
** (MatchError) no match of right hand side value: {:error, :port_crashed}
    (scenic_driver_inky) lib/scenic_driver_inky.ex:90: ScenicDriverInky.handle_info/2
    (scenic) lib/scenic/view_port/driver.ex:215: Scenic.ViewPort.Driver.handle_info/2
    (stdlib) gen_server.erl:637: :gen_server.try_dispatch/4
    (stdlib) gen_server.erl:711: :gen_server.handle_msg/6
    (stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message: :capture
State: %{driver_module: ScenicDriverInky, driver_state: %{cap: #PID<0.31658.6>, color_affinity: :low, color_high: 180, color_low: 75, dithering: false, inky_pid: #PID<0.31657.6>, interval: 1000, last_crc: -1, size: {400, 300}, viewport: #PID<0.31640.6>}, viewport: #PID<0.31640.6>}

00:05:30.957 [error] GenServer #PID<0.31656.6> terminating
** (stop) bad return value: {:stop, :port_crashed}
Last message: {:EXIT, #PID<0.31655.6>, {:bad_return_value, {:stop, :port_crashed}}}
State: %{driver_module: Scenic.Driver.Nerves.Rpi, driver_state: %{clear_color: {0, 0, 0, 255}, closing: false, currently_drawing: [], debounce: %{}, dirty_graphs: [], dl_block_size: 128, dl_map: %{}, draw_busy: false, end_dl: nil, fonts: %{}, inputs: 0, last_used_dl: nil, pending_flush: false, port: #Port<0.77606>, ready: false, root_ref: nil, screen_factor: 1.0, start_dl: nil, sync_interval: 15, textures: %{}, used_dls: %{}, viewport: #PID<0.31640.6>}, viewport: #PID<0.31640.6>}

00:05:30.959 [error] dirty close
kottkrig commented 4 years ago

I’m happy to dive deeper into the code and eventually submit a PR. But I’m unsure on where to begin.

lawik commented 4 years ago

Sorry about the slow response. The GitHub notification system and I are not in agreement.

I think this could be related to some previous regression we've seen with the nerves system image missing the correct drivers that rpi_fb_capture requires to work. It was covered in this issue.

If you can give me what kind of Pi you are using and what your Nerves system version is (maybe what nerves bootstrap version you have), that'd be helpful. Also, check that thread, make sure you are on recent versions.

The fact that Inky works is reassuring. This error just means that rpi_fb_capture isn't working which we use to slurp the scenic render into Inky and onto your display. My hardware is packed for moving so I won't be able to verify the issue on my end but I'm sure we can figure it out :)

kottkrig commented 4 years ago

Thanks for the pointers. It looks very promising. 👍

I won't be able to test it out until sometime next week but I'll be sure to update this issue with my findings.

kottkrig commented 4 years ago

Unfortunately, I'm still getting the same error. I've tried my best to make sure I'm up to date by moving code from a new nerves_bootstrap project to my current project.

Link to current commit in the project in case there is some setup info I forgot to mention: kottkrig/Restidscreen.

My next step will be to see if I can replicate the issue in a minimal test case based of nerves bootstrap. But I won't be able to do that for another week. :)

10:22:32.044 [error] Jan 25 10:22:32 rpi_fb_capture: Unable to open primary display

10:22:32.046 [error] GenServer #PID<0.25990.43> terminating
** (stop) bad return value: {:stop, :port_crashed}
Last message: {#Port<0.327035>, {:exit_status, 1}}
State: %RpiFbCapture.State{backend_name: "unknown", display_height: 0, display_id: 0, display_width: 0, height: 300, port: #Port<0.327035>, request: {{#PID<0.25956.43>, #Reference<0.3707906347.809762818.188483>}, :rgb24}, width: 400}

10:22:32.047 [error] GenServer #PID<0.25956.43> terminating
** (MatchError) no match of right hand side value: {:error, :port_crashed}
    (scenic_driver_inky) lib/scenic_driver_inky.ex:90: ScenicDriverInky.handle_info/2
    (scenic) lib/scenic/view_port/driver.ex:215: Scenic.ViewPort.Driver.handle_info/2
    (stdlib) gen_server.erl:637: :gen_server.try_dispatch/4
    (stdlib) gen_server.erl:711: :gen_server.handle_msg/6
    (stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message: :capture
State: %{driver_module: ScenicDriverInky, driver_state: %{cap: #PID<0.25990.43>, color_affinity: :low, color_high: 180, color_low: 75, dithering: false, inky_pid: #PID<0.25979.43>, interval: 1000, last_crc: -1, size: {400, 300}, viewport: #PID<0.26004.43>}, viewport: #PID<0.26004.43>}

10:22:32.047 [error] dirty close
lawik commented 4 years ago

Hmm, I think this might be related to the graphics driver changes for the Pi4 and them not working with the rpi_fb_capture. I will check with Frank on this.

lawik commented 4 years ago

Also, I still would want to make a Scenic Driver for more primitive screens that could skip the framebuffer business. But time is a thing :P

kottkrig commented 4 years ago

Hmm, I think this might be related to the graphics driver changes for the Pi4 and them not working with the rpi_fb_capture. I will check with Frank on this.

Alright. A valid workaround for me might be to pick up another Pi then? :D Would a Raspberry Pi 3A+ be more reliable for this specific setup?

Also, I still would want to make a Scenic Driver for more primitive screens that could skip the framebuffer business. But time is a thing :P

It sure is. ⏳

lawik commented 4 years ago

I've run it off a Pi3 and Pi Zero W, not sure I tried it with the A+ but that one works with both pi3a system and pi3 system for nerves and is well loved and supported. It should work great.

lawik commented 4 years ago

Frank who maintains the rpi_fb_capture library figures the Pi 4 has some DRM API stuff that would prohibit us from accessing a framebuffer in the way that works on the older pis. I'll edit the issue title to match the problem.

We can't really solve this right now. I have plans for a less framebuffer reliant Scenic driver that would work on the pi4.

kottkrig commented 4 years ago

I can confirm that the same code works on a Raspberry Pi 3 Model A+. 👍