PhilCK
Posts: 1
Joined: Sat Jan 14, 2012 8:35 am

Re: Does it work without an operating system?

Sat Jan 14, 2012 8:45 am

Hi Guys,

I know this has to have been answered but I got a bit confused with all this Linux talk. I want to know if you can write programs that can run on the device without an operating system as such. In particular video games.

Much like old the Old GameBoys etc.

Thanks.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 24199
Joined: Sat Jul 30, 2011 7:41 pm

Re: Does it work without an operating system?

Sat Jan 14, 2012 8:51 am

PhilCK said:


Hi Guys,

I know this has to have been answered but I got a bit confused with all this Linux talk. I want to know if you can write programs that can run on the device without an operating system as such. In particular video games.

Much like old the Old GameBoys etc.

Thanks.


Even GameBoys has some sort of rudimentary system that sits there keeping everything going I believe. But as to your question, you could run a application directly from the boot  - just like Linux is run.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I think it’s wrong that only one company makes the game Monopoly.” – Steven Wright

roelfrenkema
Posts: 105
Joined: Sat Jan 07, 2012 5:17 pm

Re: Does it work without an operating system?

Sat Jan 14, 2012 9:04 am

PhilCK said:


Hi Guys,

I know this has to have been answered but I got a bit confused with all this Linux talk. I want to know if you can write programs that can run on the device without an operating system as such. In particular video games.

Much like old the Old GameBoys etc.

Thanks.



PhilCK said:


Hi Guys,

I know this has to have been answered but I got a bit confused with all this Linux talk. I want to know if you can write programs that can run on the device without an operating system as such. In particular video games.

Much like old the Old GameBoys etc.

Thanks.



Sure you an OS is just an other program when it comes to it.

SlayingDragons
Posts: 67
Joined: Wed Sep 14, 2011 3:17 am

Re: Does it work without an operating system?

Sat Jan 14, 2012 4:36 pm

Absolutely, you can learn some ARM assembly, write a program in it, and name it "kernel.img" to have the GPU's bootloader run it. Now that I think of it, if the bootloader handles all the dirty work, you should be able to program C for it just fine.

I plan to write a small bootloader to load multiple kernels and filesystems on it, and I haven't seen anything so far that would stop me.

edit: If you want to program without an OS, some info from here could help even if you're not writing an OS:

http://wiki.osdev.org/Expanded_Main_Page

Keep in mind everything there is for x86 processors, not ARM, but the general theory there may help.

Bakul Shah
Posts: 321
Joined: Sun Sep 25, 2011 1:25 am

Re: Does it work without an operating system?

Sat Jan 14, 2012 5:42 pm

I imagine it wouldn"t be too hard to write a library for such bare metal use. Things like device initialization, thread context switch, setting up interrupt handlers, console io, GPIO, USB, ethernet etc. May be even a syscall framework and virtual memory handling. You supply main()! So basically an os dev kit!

Steady_Bear
Posts: 110
Joined: Sat Jan 14, 2012 12:06 pm

Re: Does it work without an operating system?

Sat Jan 14, 2012 6:47 pm

Not sure if Bakul is being serious or not?

Just to clarify, writing device drivers of any sort is no simple task. Obviously there are people who have written them or we wouldn't have Linux, but you'll find the main bulk of the juicier bits of the Linux kernel were written by professionals (multicore support, although not relevant here, was certainly donated at least in part, by a large firm). The rest was written by truly gifted individuals.

There are, however, some very compact Linux installs out there. Toms RT (really tiny?) Boot is an example of a complete system on a floppy. Someone in the past managed to show a basic GNU/Linux set up with a webserver running in less than 40KB, which is best described as brutal. Also, using such a small distro, it's not hard to have it produce a simple menu to run a small selection of games that you have written. Plenty of people around here to help on the Linux front - it's surprisingly easy to learn.

Bakul Shah
Posts: 321
Joined: Sun Sep 25, 2011 1:25 am

Re: Does it work without an operating system?

Sat Jan 14, 2012 8:52 pm

To do something *no one* has done before, you need to be truly creative/gifted/crazy but to do something that has been done before, you don't! You merely need to understand the solution and your context but all you are doing is "porting" the solution; the hard work has already been done! In fact this has all been done before multiple times (including by me). Not rocket science. There is even a OS toolkit called flux (when I last looked at it (years ago), it seemed too big but I will check it out again)

The Raspi environment is relatively static so such a library of reusable s/w component will be fairly small (I am talking about support for only what is on the Raspi board itself). Not much new code here; you can copy most everything you need from other OSes and adapt it to your needs. If you want to develop a baremetal Scheme (or BASIC or forth or some interpreter of your choice) and want threads, if you want to develop your own game, etc. in each of these projects you will be doing very similar things so it makes sense to factor it out. At least you can treat such a library as a "reference implementation". Of course you won't use such a library for Linux or *BSD or some other mature OS.

tufty
Posts: 1456
Joined: Sun Sep 11, 2011 2:32 pm

Re: Does it work without an operating system?

Sun Jan 15, 2012 8:45 am

Bakul is being totally serious. So am I. Check my .sig.

Simon

slaeshjag
Posts: 9
Joined: Sat Jan 07, 2012 12:57 pm
Contact: Website

Re: Does it work without an operating system?

Sun Jan 15, 2012 9:15 am

PhilCK said:


Hi Guys,

I know this has to have been answered but I got a bit confused with all this Linux talk. I want to know if you can write programs that can run on the device without an operating system as such. In particular video games.

Much like old the Old GameBoys etc.

Thanks.


While this is possible, I wouldn't recomment it for writing programs unless you have very specific security or timing reasons. Using the the bare metal will be way more messy than learning the APIs available on Linux. Remember; the Rpi does not have any fancy BIOS interrupt libraries, and the graphics hardware is probably very undocumented. Not to mention drivers would be required for all hardware you'd like to use.

tufty
Posts: 1456
Joined: Sun Sep 11, 2011 2:32 pm

Re: Does it work without an operating system?

Sun Jan 15, 2012 6:30 pm

I do wish people would stop treating operating systems and bare metal programming as though it were some sort of mystical voodoo that only white-coated evil super-scientists can do, aided by their hunchbacked assistants on stormy nights.
It LIVES!!!!!
It"s not. Operating systems, and drivers, are merely programs like any other. Anyone who"s a half-decent programmer can do it (and, depending on licensing terms, most of the drivers already exist and "only" need porting)

The main reason not to do it on the Pi for gaming purposes is lack of accelerated video outside of linux. That sucks in many ways, but is understandable.

Simon

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 24199
Joined: Sat Jul 30, 2011 7:41 pm

Re: Does it work without an operating system?

Sun Jan 15, 2012 8:29 pm

I say you had to be slightly better than 'half decent' to be able to write a multi threaded OS, along with the appropriate drivers. Assuming that the people we get in for interview are generally supposed to be above average (dross is culled before they get to us!), its quite astounding how much they don't know about this sort of thing.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I think it’s wrong that only one company makes the game Monopoly.” – Steven Wright

User avatar
Jongoleur
Posts: 1179
Joined: Thu Aug 11, 2011 12:47 pm
Location: O'erlooking the sea, and all those effin windfarms...

Re: Does it work without an operating system?

Sun Jan 15, 2012 10:01 pm

Hmmmmmmmmm

There's a thought - how about booting into a clone of v2 BASIC (like a C64), or a simple OS like CP/M?

Its not difficult stuff to implement at that level.....  

*runs and hides*
I'm just a bouncer, splatterers do it with more force.....

Steady_Bear
Posts: 110
Joined: Sat Jan 14, 2012 12:06 pm

Re: Does it work without an operating system?

Sun Jan 15, 2012 10:46 pm

tufty said:


I do wish people would stop treating operating systems and bare metal programming as though it were some sort of mystical voodoo that only white-coated evil super-scientists can do, aided by their hunchbacked assistants on stormy nights.


It LIVES!!!!!


It"s not. Operating systems, and drivers, are merely programs like any other. Anyone who"s a half-decent programmer can do it (and, depending on licensing terms, most of the drivers already exist and "only" need porting)

The main reason not to do it on the Pi for gaming purposes is lack of accelerated video outside of linux. That sucks in many ways, but is understandable.

Simon



Tufty, my little squirrel , I don't think you're giving yourself enough credit. You are perfectly correct in it just being more software and not anything magical, and yes there are drivers that can be ported, but it is no simple task. You have experience and clearly a good mind (having had a quick look at your sig links).

I'm guessing you started with "I'm going to write an OS" not "Hey guys do you need to use an OS?". The original request on this thread implies an ability to program, but not one that has matured enough yet to tackle what you are taking on with WavelengthPi (sorry, I'm an RF engineer)... I also confess to having thought that it was any graphical output that was out of bounds without B/coms driver, not just accelerated.

And, given the people I've met on my travels, please do consider yourself (and anyone else doing similar work) as gifted - and/or very hard working.

Best of luck with LambdaPi, I shall take a deeper look in due course.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 24199
Joined: Sat Jul 30, 2011 7:41 pm

Re: Does it work without an operating system?

Sun Jan 15, 2012 10:51 pm

There are plenty of free, already written embedded OS's that would work fine with a bit of porting effort. I'd say there was no point in reinventing the wheel, but that's just a red rag to a bull.

http://en.wikipedia.org/wiki/L.....s#Embedded
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I think it’s wrong that only one company makes the game Monopoly.” – Steven Wright

Wooloomooloo
Posts: 92
Joined: Fri Nov 25, 2011 10:52 am

Re: Does it work without an operating system?

Sun Jan 15, 2012 11:54 pm

Just to be clear about this, writing functioning firmware for some embedded hardware that normally runs Linux is hardly above Arduino level. At least as long as all you want to do is the hardware equivalent of the "hello world" as in blinking some LEDs. Yes, fine, the system clocks and the DDR controller might have to be initialized but that's definitely nowhere near magic (as long as you have proper spec), and seems way, way glorified out of proportions around here. Even some cooperative multitasking is trivial, you just need to make sure you don't block and keep returning control to your main "thread-caller". Now, on the other hand, if one's idea of "hello world" is to see it displayed on a web page served up by the device while also displaying a windowed GUI console on its HDMI ouput, then yes, that's something to keep you occupied until the end of the world (as long as it's this year) if you try to code it yourself from scratch. Even then though, there are plenty of small OS's already written that would only need porting, as in have their HW base level access routines implemented for this particular chip.

But simply running some meaningful code, without any OS? Seriously - peanuts...

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 24199
Joined: Sat Jul 30, 2011 7:41 pm

Re: Does it work without an operating system?

Mon Jan 16, 2012 4:05 pm

I believe the clocks and DDR are all set up by the GPU during boot, so you won't have to worry about those.

I think.

Just package your code in the compressed Linux image format and it should just work. And since there is a memory mapped video display, you can use that too.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I think it’s wrong that only one company makes the game Monopoly.” – Steven Wright

tufty
Posts: 1456
Joined: Sun Sep 11, 2011 2:32 pm

Re: Does it work without an operating system?

Mon Jan 16, 2012 5:07 pm

JamesH said:


a red rag to a bull.


Moo! (or, rather, "Meuh!", given my location)

For most non-linux, "bare metal" uses, even porting an embedded OS is more or less overkill - you're gonna have to write the drivers anyway, so why not go single-threaded, single-tasking and simply port newlib?

Simon

User avatar
Jessie
Posts: 1754
Joined: Fri Nov 04, 2011 7:40 pm
Location: C/S CO USA

Re: Does it work without an operating system?

Wed Jan 18, 2012 6:14 am

Does it work without an OS?  Yes the R-Pi will hold a door open if jammed underneeth.

If you want it to boot and do something you will need something there.  Apps don't load themselvs.

tufty
Posts: 1456
Joined: Sun Sep 11, 2011 2:32 pm

Re: Does it work without an operating system?

Wed Jan 18, 2012 6:37 am

They do if they are called "kernel.img"

plrw
Posts: 12
Joined: Wed Jan 11, 2012 4:59 pm

Re: Does it work without an operating system?

Thu Jan 19, 2012 10:18 am


tufty said:


They do if they are called "kernel.img"



How about a tutorial on that ? Exactly what is needed, do I just program a main in c and use something to create the image ? What memory addresses is the hardware on, for example the mentioned memory mapped video display ?

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 24199
Joined: Sat Jul 30, 2011 7:41 pm

Re: Does it work without an operating system?

Thu Jan 19, 2012 10:50 am

plrw said:



tufty said:


They do if they are called "kernel.img"



How about a tutorial on that ? Exactly what is needed, do I just program a main in c and use something to create the image ? What memory addresses is the hardware on, for example the mentioned memory mapped video display ?


Good idea. Of course, it would have to be written after someone had actually tried to do it, and as far as I know, no-one has!
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I think it’s wrong that only one company makes the game Monopoly.” – Steven Wright

User avatar
Jongoleur
Posts: 1179
Joined: Thu Aug 11, 2011 12:47 pm
Location: O'erlooking the sea, and all those effin windfarms...

Re: Does it work without an operating system?

Thu Jan 19, 2012 2:02 pm

JamesH said:


plrw said:



tufty said:


They do if they are called "kernel.img"



How about a tutorial on that ? Exactly what is needed, do I just program a main in c and use something to create the image ? What memory addresses is the hardware on, for example the mentioned memory mapped video display ?


Good idea. Of course, it would have to be written after someone had actually tried to do it, and as far as I know, no-one has!



Could be an interesting project for when the Pi eventually emerges. 

A Model B to develop on, and a Model A to testbed with.  Lots of fun.  Hahahahahahahahahahahahahahahahahaaaaaaaaaaaaaaaaaaa.  Write a version of CP/M in C, connect an ASR33 to the GPIO pins and wayhey!!!!

Ok, Sorry.  I'll go quietly.....
I'm just a bouncer, splatterers do it with more force.....

albertfrutos
Posts: 28
Joined: Fri Nov 25, 2011 2:56 pm

Re: Does it work without an operating system?

Thu Jan 19, 2012 3:52 pm

If I knew how, I would create a bootloader to allow USB-booting... but I don't know anything about advanced programming.

tufty
Posts: 1456
Joined: Sun Sep 11, 2011 2:32 pm

Re: Does it work without an operating system?

Thu Jan 19, 2012 5:15 pm

JamesH said:


plrw said:



tufty said:


They do if they are called "kernel.img"



How about a tutorial on that ? Exactly what is needed, do I just program a main in c and use something to create the image ? What memory addresses is the hardware on, for example the mentioned memory mapped video display ?


Good idea. Of course, it would have to be written after someone had actually tried to do it, and as far as I know, no-one has!


Not for lack of trying James, merely due to a lack of anyone with an alpha / beta board, a serial cable, and a few minutes to spare.

Simon

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 24199
Joined: Sat Jul 30, 2011 7:41 pm

Re: Does it work without an operating system?

Thu Jan 19, 2012 5:39 pm

tufty said:


JamesH said:


plrw said:



tufty said:


They do if they are called "kernel.img"



How about a tutorial on that ? Exactly what is needed, do I just program a main in c and use something to create the image ? What memory addresses is the hardware on, for example the mentioned memory mapped video display ?


Good idea. Of course, it would have to be written after someone had actually tried to do it, and as far as I know, no-one has!


Not for lack of trying James, merely due to a lack of anyone with an alpha / beta board, a serial cable, and a few minutes to spare.

Simon


Well if you will try and write SW for a non-existent device (at the moment)......!
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I think it’s wrong that only one company makes the game Monopoly.” – Steven Wright

Return to “General discussion”