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

Failing to run on RPI 4: DIRTY CLOSE #13

Open
bjufre opened this issue Sep 21, 2019 · 26 comments
Open

Failing to run on RPI 4: DIRTY CLOSE #13

bjufre opened this issue Sep 21, 2019 · 26 comments

Comments

@bjufre
Copy link

bjufre commented Sep 21, 2019

No description provided.

@axelson
Copy link

axelson commented Sep 23, 2019

What version of scenic and scenic_driver_nerves_rpi are you using? Can you provide some logs? That would be helpful in tracking down the problem. Also I don't think anyone has attempted to run Scenic on an RPI 4 yet so you will likely run into some issues getting it to work.

@bjufre
Copy link
Author

bjufre commented Sep 24, 2019

@axelson I'm using scenic: ~> 0.10 and scenic_driver_nerves_rpi: ~> 0.10.
And the logs say nothing really. It seems to work boot normally and everything but it gets stuck. And when you ssh into the device and run RingLogger.next everything seems fine but one line (if you scroll a little bit to the top) that just says: [error]: dirty close.

Another thing I tried to see if I would get something different is stop the application and start it from the iEx session, and as expected I got another message that seems to point to the creation of the window; the message is the following: RPI driver error: Unable create the native window surface.
This points to the line 184 on the c code for the driver when it tries to create the window itself (or so it seems).

Hope this helps.

~ bjufre

@boydm
Copy link
Owner

boydm commented Sep 24, 2019

So far, I haven't done any work to port the driver to the rpi4. In fact, I don't have an rpi4 yet.

I have some other pressing matters for now, so if anyone wants to take a crack at this, that would be nice. The issues will all be in the initialization functions in main.c. I believe the video circuits on the board have change significantly and it may need a new native window surface strategy. I haven't dug into it yet.

@bjufre
Copy link
Author

bjufre commented Sep 26, 2019

@boydm @axelson found this example as to how to set it up on rpi4: https://github.com/matusnovak/rpi-opengl-without-x

Will try and take a closer look.

~ bjufre

@bjufre
Copy link
Author

bjufre commented Sep 30, 2019

@axelson I have tried the previous comment implementation but so far no luck.

Any ideas from your end?

@axelson
Copy link

axelson commented Sep 30, 2019

Sorry, I haven't looked at that portion of scenic's code before so I don't have any ideas at the moment.

@lawik
Copy link

lawik commented Mar 5, 2020

From what I've heard the Pi4 has different graphics underpinnings. I know it doesn't provide a framebuffer which hit some of my use-cases in other libraries. I imagine this means some changes in the driver. But most of the OpenGL/drawing stuff should be the same.

I've mostly absorbed some of this from fhunleth, I wouldn't know where to start on a fix but figured I'd mention this.

@noozo
Copy link

noozo commented Mar 5, 2020

+1 waiting for a fix

@rkenzhebekov
Copy link

@axelson, on your first comment you asked providing some log files. I'm pretty new to scenic and nerves env. Is it possible to find a log file that contains whatever printed on the screen?

For now I can only provide a screenshot

rpi4-raspberry-touchscreen-7

Hardware: RPI4 with 4GB, Official Raspberry 7" Display

@boydm
Copy link
Owner

boydm commented Mar 6, 2020

Yeah. This will likely be pile of work in the main.c file of the driver. The rest of it should be pretty much the same.

I haven't had time to dive into it, but will eventually. If someone else wants to take a crack at at least learning out to initialize OpenGL on the rpi4, that would go a long way. Even getting to the point where it only sets up the display environment, then draws one triangle would be great.

I won't be able to get to this for a while. Am completely swamped with other work. (a good thing!)

@boydm
Copy link
Owner

boydm commented Mar 6, 2020

Oh. I should add. If the solution is different enough with the code for the RPI0/3, then it should be rolled into a new rpi4+ driver so that the old one still works with minimal hacking.

@lawik
Copy link

lawik commented Mar 6, 2020

Good info Boyd :)

@lawik
Copy link

lawik commented Mar 6, 2020

From some reading the Pi 4 has a more standard initialization. I don't know much about OpenGL but according to some thread, this code should work on Raspbian for the Pi4.

I found that in this weird and confusing thread that does discuss the graphics changes a bit.

Here are the video option docs for config.txt. From my reading the Pi4 is very reliant on edid and having a display plugged in for things to work.

The Pi4 apparently uses the v3d driver for 3D rather than the vc4 driver (which it only uses for DRM/KMS compositing support). Taking this from this thread.

I think we might need to look into whether everything is as it should in the Nerves Pi4 system as well. Assuming people want to use this with Nerves, which seems to be the common case.

@lawik
Copy link

lawik commented Mar 6, 2020

I checked the nerves_system_rpi4 and from a fairly uninformed point of view it does seem to have the necessary stuff. I would recommend someone start by just seeing if they can fix the OpenGL initialization.

@fhunleth
Copy link
Contributor

FYI - This is worth looking at again. nerves_system_rpi4 v1.11.0 (just released) updates the vc4 driver and mesa3d support. I'm not sure on the timing correlates to this issue, but I did learn that at one point nerves_system_rpi4 was including a version of mesa3d that would never have worked. I think the time is good for someone to start writing a scenic_driver_nerves_rpi4 (interest and time-permitting, of course)

@lawik
Copy link

lawik commented Mar 23, 2020

Sweet, very good to know.

@boydm
Copy link
Owner

boydm commented Mar 31, 2020

Sigh... The irony is that while New Zealand under lockdown (giving me the time to work on this), the stores are closed, so I can't go out and buy an rpi4. Would be fun about now.

@Damirados
Copy link

Scenic is running fine on rpi4 with raspbian and glfw, maybe there is a way to reuse glfw for nerves setup.

@boydm
Copy link
Owner

boydm commented May 11, 2020

I wish it were that easy. Need to get down into the low-level display surface apis that are set up by raspian. Those dont exist under Nerves, and it is main piece of work that needs to happen.

@zacky1972
Copy link

zacky1972 commented Jun 19, 2020

I'd like to assist this issue, because I also hope that Scenic supports RasPi 4.
I have some knowledge to support GPUs, through development of Pelemay.

I haven't understood the structure of Scenic, because I've just know it by the presentation at ElixirConf EU virtual. Let me know what of source code of Scenic I should read at first.

@lawik
Copy link

lawik commented Jun 20, 2020

@zacky1972 this repo is specifically for rendering Scenic on the Pi with Nerves. It implements what Scenic calls a Driver. Which takes the primitives and turns them into something to show on the screen. This Driver uses NanoVG to render which is a library that provides som graphics primitives and renders them with OpenGL.

It currently supports up to Pi3. If you look in the c_src folder you’ll find main.c which is where the driver is initialized. It does some initialization that is specific to the Pi devices if I recall correctly and from my comment further up and fhunleth’s comment about the updates in the Nerves system for Pi 4, I think this could be made to work if you could change how we initialize OpenGL.

Let me know if anything I wrote feels unclear. I would be very happy to see someone do this but I dont have the time right now and am very bad at C ;)

@boydm
Copy link
Owner

boydm commented Jun 20, 2020

That is exactly right. The way the rpi4 initializes OGL changed. One of these days I'll actually get an rpi4 and maybe make some progress on it, but if anyone else takes a crack at it that would be be great. Basically, you start by making an port (exe) that does nothing. Then slowly build it up so that you draw one triangle. After that triangle shows, it's 90% there...

@zacky1972
Copy link

zacky1972 commented Jun 20, 2020

I'm confused because I heard Scenic on Raspbian works well, though that on Nerves doesn't. I guess porting the initialization of that on Raspbian to that on Nerves will fix this issue. Let me know why not.

@lawik
Copy link

lawik commented Jun 20, 2020

Scenic on raspbian works well with the glfw-based driver. If the pi4 system has been updated as fhunleth said, I guess you could try that on Nerves. But I imagine there is still quite a difference in how much graphics-stuff raspbian ships by default compared to nerves.

@fhunleth
Copy link
Contributor

fhunleth commented Jun 20, 2020

I was recently pointed to this repository: https://github.com/ardera/flutter-pi. From a skim, it looks like if you delete all of the user input and flutter integration code, that what remains is an example for setting up the display on the RPi4 without using X-Windows or Wayland.

@boydm
Copy link
Owner

boydm commented Jun 21, 2020

Thank you @fhunleth. That is a great start. (flutter is also something I'm interested in learning more about, so double-win?)

@zacky1972, @lawik and Everyone else: Scenic should work well on raspbian on an rpi4. The issue isn't the OGL calls, it is setting up the low-level graphics drawing planes, hardware windows and such. This work is done by raspbian when it boots up. Scenic on Nerves is much more low-level than that. The scenic rpi driver has to boot the graphics hardware from scratch. On the rpi3, that meant figuring out how graphics chip needed to be initialized. Same will need to be done for the rip4, which has a new graphics pipeline.

Not the easiest work, mostly because it isn't that well documented.

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

9 participants