[HN Gopher] Raspberry Pi 4 OpenBSD based home computer/gaming co...
___________________________________________________________________
Raspberry Pi 4 OpenBSD based home computer/gaming console
When I started programming as a kid, I had a Commodore 64 and later
an amiga 500. Those machines came with very simple software and
expected you to write some, rather than giving you thousands of
pre-made packages to learn and play with. A lot of existing
software was video games. They were much simpler than those people
play nowadays but they were still a lot of fun. Part of the fun was
low latency. I started working on a gaming console based on the
raspberry pi that would have the kind of low latency that older
home computers and gaming consoles had, and found a way to do that.
At some point, I realised that users would want to use a keyboard,
read and write files, connect to the internet, stuff that is taken
for granted with computers today. So I wanted not to run on bare
metal anymore, I needed an OS. Writing one from scratch would take
me years and it probably would not be as good as an existing one.
But existing desktop operating systems tend not to be good for
games, as they introduce latency and are able to stop a game at any
time to do some other task, which can result in stuttering that the
game developers cannot fully control or avoid. I modified the
OpenBSD kernel for the raspberry pi with gaming related extensions,
in such a way that when the game runs there is no latency and no
stuttering. A game on my own fork of OpenBSD has the same
performance of the bare metal code that I have written previously.
And it can do file I/O, connect to the net and all that kind of
stuff. And when you quit the game it's just like normal OpenBSD so
you can program it and make games yourself, browse the web and do
all sort of stuff. I am thinking that other people may want to
have something like that, both for nostalgic reasons and for
learning programming, so I thought of asking around and, if enough
people like the idea, turn this into a product.
Author : alehyze
Score : 48 points
Date : 2021-06-02 19:40 UTC (3 hours ago)
| penguinlinux wrote:
| this could be a great project. also the raspberry pi is very
| affordable. However, i think the best raspberry pi would be the
| raspberry pi 3 as the raspberry pi 4 requires a different ac
| adapter with usbc c and also a special hdmi cable so that
| increases the price of entry.
|
| Even writing a game system for the raspberry pi zero w would be
| amazing.
| alehyze wrote:
| True.
|
| The fact is that the zero does not have the computing power I
| want. The 3 does not have USB3 and that is a big issue for
| another reason.
|
| It has to be the raspberry pi 4 :-)
| Lewisssss wrote:
| I would be interesting only for performance reasons.
| onurcel wrote:
| On my TO-DO project list, there is "BASIC compiler/interpreter
| for raspberry(-like) computers".
|
| I am nostalgic of Commodore64 too.
|
| The thing that made many of us go down the rabbit hole was the
| immediacy of the interpreter, begging you to enter some commands
| 2 seconds after turning on your computer.
|
| The perceived small gap between the commands you enter in a
| programming language and the games you could play with the
| machine contributed largely to the curiosity and willing to learn
| more.
|
| On a modern computer, building the right interpreter is
| challenging. There is a trade-off between the simplicity of the
| language and what you can achieve with it. You won't impress
| today's kids if it allows you to only print text on a scrolling
| page.
|
| But I think one can build something really great. There could be
| an integrated sprite editor (with a graphic UI) and the
| interpreter can use them right away with something like:
| Sprite1.visible Sprite1.x = 10
|
| emphasising again the immediacy. Those "sprites" could be 3d
| objects as well.
| sleepybrett wrote:
| Yeah there is something really special about essentially
| booting into a basic prompt/interpreter. You get some of that
| from booting into a bash/zsh/sh/ksh/blah shell, but it's not
| quite the same.
| alehyze wrote:
| As mentioned in another comment, I am planning to add a C/C++
| interpreter and I have put GNUstep in there, so that people can
| easily build their sprite editors and other game dev tools :-)
| xeeeeeeeeeeenu wrote:
| You can configure RISC OS to boot directly into the BBC BASIC
| interpreter:
| https://www.riscosopen.org/forum/forums/5/topics/15793
| [deleted]
| notaplumber wrote:
| > I modified the OpenBSD kernel for the raspberry pi with gaming
| related extensions, in such a way that when the game runs there
| is no latency and no stuttering.
|
| What does that even mean? What "gaming related extensions"?--
| could you elaborate?
|
| OpenBSD doesn't have any accelerated drivers for the GPU on the
| RPi, so I'm curious what your "no latency/no stuttering"
| modifications would even be, beyond perhaps maybe recompiling the
| kernel with HZ=1000 or something else..
| alehyze wrote:
| Without going into the details: I have read the linux drivers
| and understood how HDMI audio and hardware sprites (planes)
| work amongst other details. Then implemented that myself in C
| and assembly with no OS. Then modified the OpenBSD kernel in a
| way that it can use that stuff and do even more sophisticated
| stuff. This is not just recompiling the kernel with some
| different options. It's writing substantial code. I modified
| 6.8 because 6.9 was not even out when I started, so it's been a
| couple of months of very hard work on the kernel only, not
| counting all the time I spent on it before when I was working
| bare metal. And it's not finished yet :-)
| notaplumber wrote:
| This is HN, I'm sure people would appreciate hearing the
| details. Like how does this integrate with OpenBSD's existing
| audio/graphics stacks, do you plan to upstream your work?
| With it being OpenBSD, are there security implications?
| dr_zoidberg wrote:
| Well, he did say he wants to turn that into a product, so I
| understand he won't release details as they are a form of
| trade secret for his idea.
| alehyze wrote:
| I just released the "big picture". I am sure that the
| OpenBSD kernel devs can redo what I did ten times quicker
| (in terms of development time) and a million times better
| (in terms of clean integration with the kernel and
| security) if they want to. They know all of the details
| of the kernel :-)
|
| That said yes, I would like to be able to turn this into
| a product.
| SLWW wrote:
| I'm interested in this; though i struggle to understand
| how you could turn something like this into a product.
|
| There's a lot of logistics in selling this type of thing.
| Also the BSD license isn't exactly easy to sell something
| alongside of.
|
| Have you considered open-sourcing and doing the ol' "if
| you like my work, buy me a coffee"
|
| I know it's extremely communist of me, but I just can't
| imagine you not stepping on a lot of toes (both legally
| and otherwise) because of the spirit that OpenBSD was
| written in.
| ac29 wrote:
| > BSD license isn't exactly easy to sell something
| alongside of
|
| Why's that? There's no reason you cant have a closed-
| source commercial fork of BSD code. The Playstation 4 OS
| is a fork of FreeBSD: https://en.wikipedia.org/wiki/PlayS
| tation_4_system_software
| alehyze wrote:
| What it does at the moment is a bit hacky, in that it does
| not integrate with the existing graphics stack in the way
| people could think.
|
| I haven't written a driver for the pi graphics card or for
| HDMI audio. What I do with graphics is to save the existing
| state before beginning the game, do whatever I want during
| the game and restoring the state when it ends. With audio I
| am not doing it that cleanly as I believe that OpenBSD does
| not currently even touch HDMI audio registers.
|
| As for the reduction of stuttering, when the game begins I
| stop 3 of the four cores, assign them entirely to the game
| ( also with new interrupt vector tables both in EL0 and EL1
| ) and when the game exits give them back to OpenBSD. That
| way, while the game is running without interruption, the
| single core that is left to OpenBSD is free to run admin
| tasks. Since the game has a process that can be scheduled
| by that single core, the game can do networking or file I/O
| using OpenBSD, because the different cores have the same
| entries in the user space MMU tables and so they share
| memory and can talk to each other. OpenBSD cannot interrupt
| the game, it can only kill it if needed.
|
| Regarding upstreaming my work the answer is "Probably not.
| But if the world wants it open sourced I am not against it
| and could think about doing a fork (Say we call it
| OpenBSD4Games). Or I could just give some help with the
| raspberry pi drivers."
|
| The reason for that is that I am doing quite some stuff
| that am pretty sure the OpenBSD devs would not be happy to
| put in. OpenBSD is strongly focused on security. I am
| pretty sure they would not want to have some code in there
| that hijacks 3 cores out of 4 and gives them to a user
| process. Another example: I have been told that giving
| several contiguous memory pages to a user task is something
| that should not be done in OpenBSD. I understand why but
| then I give a game quite a few contiguous memory pages that
| the hardware will use for the frame buffer and so has to be
| contiguous.
|
| Also, this is prototype code. It works for me, it still
| needs a ton of work and might not even be 100% correct. I
| cannot possibly understand all of the little details in the
| kernel in 2 months.
|
| I am proud of this achievement though and would love to be
| able to turn this into a real product that many people
| enjoy.
|
| Regarding the "home computer" part, I thought about game
| devs. When doing a game, it's not only the game code that
| is important. The tools are very important as well. So I
| built GNUstep ( on OpenBSD it does not currently work on
| arm64 ) so that it's super easy to build tools for game
| development in Objective-C.
|
| Also I thought about playing around and experimenting, and
| I am planning a GUI app with GNUstep that integrates a
| C/C++ interpreter called cling, which is developed by CERN
| for their physics simulations if I am not wrong. With that,
| a game developer will be able to experiment with code and
| tweak it in a way that is similar to what Xcode playgrounds
| does with swift on the Mac.
| alehyze wrote:
| By the way, here is a video demonstration of all this.
| It's not very polished and VSYNC does not work, but it
| works pretty much how I describe here.
|
| https://youtu.be/KhRnGbVhejk
| gbrown_ wrote:
| For those intertested OP's blog and prior submission [1][2].
|
| > I am thinking that other people may want to have something like
| that, both for nostalgic reasons and for learning programming, so
| I thought of asking around and, if enough people like the idea,
| turn this into a product.
|
| Is a HN post the place for this?
|
| [1] https://raspberrypi4gameconsole.blogspot.com/
|
| [2] https://news.ycombinator.com/item?id=26544635
| alehyze wrote:
| I am sorry if people feel like this is not the right place for
| this post.
|
| If the admins feel like that, please remove the offending
| post(s). Or ask me to amend them.
|
| I have made something that I think is cool and with the hope
| that others liked it, but if it's out of place I can only
| apologise.
| detaro wrote:
| Not an admin, but this seems totally appropriate
| (resubmitting your blogpost would have been the more
| "correct" way, since HN generally prefers links over text
| submissions, but doesn't really matter)
|
| Cool project!
| alehyze wrote:
| thanks :-)
| OldHand2018 wrote:
| What you've written is interesting and I hope you are successful.
| That said, I can already buy a Raspberry Pi at MSRP (sometimes
| even less). If I do that, I get access to a lot of software at no
| cost to me.
|
| Low latency is great, but not a reason to pay more than MSRP.
| You'll need to show me why it makes a difference and why it is
| worth paying the extra money. Also, I already have a Raspberry Pi
| 4 - can your "product" be added on to the one I already have?
___________________________________________________________________
(page generated 2021-06-02 23:01 UTC)