ARM Assembly / Operating System

Drop in for a chat and a cup of tea

49 posts   Page 1 of 2   1, 2
by goakley » Mon Mar 05, 2012 6:40 pm
I was thinking of developing an operating system from scratch for the Raspberry Pi for educational purposes.  However, I have never worked with the ARM architecture before.  Can anyone point me to some development tools to help me get started?  Google is being unhelpful to me.
Posts: 1
Joined: Mon Mar 05, 2012 6:35 pm
by johnbeetem » Mon Mar 05, 2012 8:00 pm
There's a good introduction to ARM at Wikipedia.

For official ARM documentation: http://infocenter.arm.com/help/index.jsp

At some point you'll want to get the ARM Architectural Reference Manual (the "ARM ARM").  You need to register as a customer to download it.  You'll want the ARMv7-AR version, which covers RasPi's ARMv6.

For compiling, you'll probably want GCC: http://www.gnu.org/software/gcc/

This page includes links to documentation.

If you want to cross-compile for ARM using a PC, this page (mostly for the BeagleBoard) is useful: http://www.elinux.org/ARMCompilers
User avatar
Posts: 942
Joined: Mon Oct 17, 2011 11:18 pm
Location: The Coast
by David_H » Fri Mar 09, 2012 11:10 am
goakley said:


I was thinking of developing an operating system from scratch for the Raspberry Pi for educational purposes.  However, I have never worked with the ARM architecture before.  Can anyone point me to some development tools to help me get started?  Google is being unhelpful to me.


That is a very good way to learn… May I respectfully suggest you consider learning Forth as a means to achieving knowledge of OS's "from scratch"….

We are talking about "Bare Metal" programming here and it's the best way to learn…

I am looking at developing a Forth for the ARM with a view to implementing "Smart Objects"…. See http://www.smartobjects.co.uk/  The RPI seems to be an ideal platform for this (along with others). I have already written a Forth Object Request Broker for my MSc dissertation…
Posts: 6
Joined: Thu Mar 08, 2012 3:06 pm
by winwaed » Fri Mar 09, 2012 4:03 pm
You know, I was actually thinking of a Baby-Forth this morning. Such a system could be very basic and supplied complete with source code. It could then be hacked / extended by kids. Instructions could be added to directly access a GertBoard - making it ideal for tinkering.

I know as a teen (yeah, before girls, etc) I wrote my own for an 8086. Took a whole two segments and was limited to signed 32 bit math, but I still managed to implement some colour wire frame 3d graphics on an attached 'Pluto' graphics board.
Posts: 16
Joined: Wed Mar 07, 2012 9:13 pm
by Velko » Fri Mar 09, 2012 8:15 pm
Great site on OS developement: http://www.osdev.org/

While it's somewhat x86-centric, you can find some pointers for ARM too (even a few bare-bones tutorials).
Posts: 7
Joined: Mon Feb 20, 2012 9:50 pm
by Jim Manley » Sat Mar 10, 2012 5:04 am
If you're not already aware, the R-Pi boots directly from the SD card via the GPU ROM, which loads and executes a bootloader that then brings up the ARM CPU in what eventually becomes a more-or-less standard ARM startup (think of the BCM2835 as a screaming 26 GFLOPS floating-point/matrix-multiplying microsupercomputer that just happens to have a 700 MHz ARM CPU tacked on as a traffic cop to route non-video/audio I/O (USB/Ethernet/SD/GPIO/etc.) between the ports and the GPU, 256 MB POP RAM, etc.

I don't know whether the process is documented yet, beyond whatever may be included as readmes/comments in the existing ports of Fedora, Debian, ArchLinux and now, OpenELEC/XBMC, with Puppy Linux and others reportedly coming, sooner or later.  The GPU ROM, its internal hardware details, and assembly source are not going to be released, so, you will need to use the binary blob the GPU uses to boot, and whatever other helper files are needed to make the bootloader happy to kickstart the CPU.

We can hope that, if it's not already clearer than mud from existing documentation, the Foundation or one of the OS partners will be providing the info needed to develop our own OS flavors.  However, I suspect this is not a priority, as they're just now getting the very first versions of the Linux ports out into the wild, and there still isn't any hardware to run any of them, and possibly weeks before even the (Randomly) Chosen 10,000 can try anything out on an actual board.

Since secondary (and, eventually, primary) education is the current initial intended audience for the R-Pi, I wouldn't hold my breath for detailed assistance in bringing up a DIY OS, so, unless you can either figure it out from the initial Linux ports, or some of us other end-user unofficial developers are able to do so, it's going to be a challenge-and-a-half.  Personally, I would be interested in porting/implementing some experimental OSes that minimize the cruft that inevitably winds up in kitchen-sink general-purpose OSes.
The best things in life aren't things ... but, a Pi comes pretty darned close! :D
"Education is not the filling of a pail, but the lighting of a fire." -- W.B. Yeats
In theory, theory & practice are the same - in practice, they aren't!!!
User avatar
Posts: 1358
Joined: Thu Feb 23, 2012 8:41 pm
Location: SillyCon Valley, California, USA
by tufty » Sat Mar 10, 2012 6:32 am
The usual "see my .sig" may apply here.
Posts: 1371
Joined: Sun Sep 11, 2011 2:32 pm
by itsapieceofcake » Wed Mar 21, 2012 12:12 am
Making a bare-bones ASM os is not that hard,  but in the raspberry pi case it is.

Not only does the gpu binary blob make it harder than normal but also you need some sort of debugging info and means of input, in the raspberry pi's case the need for a usb stack give's you the problem of the chicken and the egg.

I would advice you to start with a device like friendlyarm , and you can start with an os like StartOS (do a google search), Also take a look at simple os's like DexOS, MikeOS and Baremetal OS .

Also take a look at fasmarm for the assembler , you could even try getting a game boy emulater and useing that to learn asmarm on .

Hope this helps.
Posts: 9
Joined: Sun Mar 11, 2012 11:32 pm
by tufty » Wed Mar 21, 2012 6:33 am
itsapieceofcake said:


Not only does the gpu binary blob make it harder than normal


Tosh.  It makes it easier than usual, as it deals with 90% of the boilerplate rubbish you usually have to do when you're bringing up an ARM, the stuff you normally need a JTAG for.


but also you need some sort of debugging info and means of input, in the raspberry pi's case the need for a usb stack give's you the problem of the chicken and the egg.


If you look at the gpio pinout, you'll notice RX and TX.  That's a UART, and it's the usual way of talking to embedded systems.  It's certainly enough to get started.  And getting video output is pretty damned easy.

There's 2 things that make it hard to develop on OS on Pi.

1 - lack of JTAG means early boot is gonna be real hard to debug, but that's alleviated by a lot of "standard" ARM bringup stuff simply not being needed.

2 - documentation for the arasan SD card interface and the USB controller is relatively difficult to find.
Posts: 1371
Joined: Sun Sep 11, 2011 2:32 pm
by David_H » Mon Mar 26, 2012 10:28 am
"If you look at the gpio pinout, you'll notice RX and TX.  That's a UART, and it's the usual way of talking to embedded systems…."

And that is all you need to get a Forth up, too… which is why I put it forward as a suggestion…. Forth also contains enough of an operating system to do loads of other things too… And you have all the source code, so you can learn how it all works....
Posts: 6
Joined: Thu Mar 08, 2012 3:06 pm
by itsapieceofcake » Mon Mar 26, 2012 9:18 pm
I think that you are all missing the point , RPI is not a PIC  or a AVR as that is what you are trying to turn the RPI into.

To make an OS for the RPI  you will need a GUI of some sort and keyboard input (which means using usb as i stated ) the only other option would be to go headless but that would need a full TCP/stack  .

I can very easily buy the ARM 11chip much cheaper and with out the binary blob getting in my way ,writing an OS is hard enough without things like binary blobs getting in the way , I mean for example the timing for the Ethernet and usb is controlled by the binary blob, but  the problem here is that no one has made an OS and i am trying to teach you.

Making an OS is more than just reading a few books there is an art to it , gather round and i will teach you
Posts: 9
Joined: Sun Mar 11, 2012 11:32 pm
by David_H » Fri Mar 30, 2012 7:07 am
"the problem here is that no one has made an OS [....] gather round and i will teach you…"

I think you are being rather presumptuous (on a number of fronts)…. so "thanks, but no thanks…" and please mind your head on the way out…. lol
Posts: 6
Joined: Thu Mar 08, 2012 3:06 pm
by bbramble » Fri Mar 30, 2012 11:36 am
itsapieceofcake said:


To make an OS for the RPI  you will need a GUI of some sort and keyboard input (which means using usb as i stated ) the only other option would be to go headless but that would need a full TCP/stack  .

Making an OS is more than just reading a few books there is an art to it , gather round and i will teach you



I think it is you who is confused about what an OS is, and what it needs to consist of. A GUI is not required (it might be desirable, but that is a different matter). As stated, for initial development and debugging, a UART is all that is needed, and is the standard, easy way to get information in and out of most development boards.

Once you have an OS that can talk to the hardware, THEN you go ahead and worry about a graphical environment for userland.
Posts: 60
Joined: Wed Jan 04, 2012 4:10 pm
by CarlGundel » Fri Mar 30, 2012 1:21 pm
I agree with the idea that Forth could form a very simple and flexible starting point for a do it yourself operating system.  What's especially beautiful about it is that you can implement your own Forth system by hand very quickly in assembler.  Once you have it running you can extend it interactively.
Posts: 19
Joined: Wed Mar 21, 2012 9:53 pm
by jamesh » Fri Mar 30, 2012 1:39 pm
itsapieceofcake said:


I think that you are all missing the point , RPI is not a PIC  or a AVR as that is what you are trying to turn the RPI into.

To make an OS for the RPI  you will need a GUI of some sort and keyboard input (which means using usb as i stated ) the only other option would be to go headless but that would need a full TCP/stack  .

I can very easily buy the ARM 11chip much cheaper and with out the binary blob getting in my way ,writing an OS is hard enough without things like binary blobs getting in the way , I mean for example the timing for the Ethernet and usb is controlled by the binary blob, but  the problem here is that no one has made an OS and i am trying to teach you.

Making an OS is more than just reading a few books there is an art to it , gather round and i will teach you


Just out of interest, what Arm11 chips are there out there, and what sort of prices are they?
Volunteer at the Raspberry Pi Foundation, helper at Picademy September and October 2014.
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 12102
Joined: Sat Jul 30, 2011 7:41 pm
by itsapieceofcake » Fri Mar 30, 2012 11:23 pm
Prices of the ARM11 chip may seem on the out side dearer than what you are selling the R-PI for but if you look at the overall package then they are at best the same,  This is from an OSDev's point of view, and when you weigh this with the lack of documentation on parts of the hardware it is not a good choice for OSDev .

This is a pity as there is a shortage of suitable devices for the want to be hobby OSDev'er, when i first read about R-PI i got very excited but as i got more information i came to realise that this was quite unsuitable for OSDev''ers , to me there is to much focus on higher level language''s which is the main problem with today''s want to be programme''s, 95% of our top programmer's learnt there skills at a much lower level. That's why it is important to have access to all hardware , the best part about the R-PI is the GPU, if you can not access it from an OSDev point of view then i would like to know what advantage the R-PI has over a x86 eBOX if you are wanting to write your own OS(please don't say price as by the time you have bought a case and all the add ons there is very little in it).

NOTE: This is from an OSDev'ers point of view and i fully support what the foundation wants to achieve .
Posts: 9
Joined: Sun Mar 11, 2012 11:32 pm
by hzrnbgy » Sat Mar 31, 2012 4:40 am
For a starter developing an OS, you might want to start small. The Broadcom SoC is fairly complex. Might I suggest starting with a fairly simple 8-bit MCU, just enough to get you started with the basics of OS development
Posts: 106
Joined: Mon Dec 26, 2011 10:55 pm
by David_H » Tue Apr 03, 2012 12:54 pm
Carl: "What's especially beautiful about it is that you can implement your own Forth system by hand very quickly in assembler.  Once you have it running you can extend it interactively...."

This is true and is a big attraction (for me) with the RPI for that reason.... Just learn how to generate an RPI boot-load image on an SD card and it just boots itself up... To get started, just learn how to do that and write a little ARM assembler routine to set up a serial port, then output a string and off you go....

JamesH: "Just out of interest, what Arm11 chips are there out there, and what sort of prices are they?"

The attraction of the RPI to me is that (hopefully) it will be a very cheap, widely and easily available source of ARM11 processing power, interfaces, ethernet, RAM and plug-in ROM via the SD card for £30-£40..... There is no way to "roll-yer-own" for anything like that price...

Modern processors being BGA or suchlike are nightmares for the hobbyist to even mount on a circuit board...
Posts: 6
Joined: Thu Mar 08, 2012 3:06 pm
by David_H » Tue Apr 03, 2012 12:59 pm
"For a starter developing an OS, you might want to start small. The Broadcom SoC is fairly complex. Might I suggest starting with a fairly simple 8-bit MCU, just enough to get you started with the basics of OS development" This is very true and a very good point.... but, of course, some folk may have "been there, done that" many years ago (with a Nascom II or Acorn Atom, ZX81, Sprectrum, etc) and are now looking to implement something rather more of a challenge...
Posts: 6
Joined: Thu Mar 08, 2012 3:06 pm
by hzrnbgy » Wed Apr 04, 2012 12:53 am
David_H said:


"For a starter developing an OS, you might want to start small. The Broadcom SoC is fairly complex. Might I suggest starting with a fairly simple 8-bit MCU, just enough to get you started with the basics of OS development" This is very true and a very good point.... but, of course, some folk may have "been there, done that" many years ago (with a Nascom II or Acorn Atom, ZX81, Sprectrum, etc) and are now looking to implement something rather more of a challenge...

Posts: 106
Joined: Mon Dec 26, 2011 10:55 pm
by arturo777 » Wed Apr 04, 2012 8:30 am
I'm also looking forward to this challenge :)

Initially I was a little disheartened by the complexity / binary "blob" issue, but now I realize that almost any device suffers from these issues and that the Raspberry Pi offers a special opportunity by collecting so many like-minded people. And the low price barrier helps too: I know I have a USB charger floating around, a spare SD card and probably some sort of case, so I really feel I can play with this device.

I think / hope that once the new forum system is up, there will be a forum especially for low-level and OS development for sharing knowledge, and you'll be surprised just how many people are interested in this challenge!
Posts: 27
Joined: Sat Mar 24, 2012 10:02 am
by rurwin » Wed Apr 04, 2012 8:59 am
itsapieceofcake said:

95% of our top programmer"s learnt there skills at a much lower level.

I would argue with that. It seems to me, from the comments made on these boards, that 99% of our programmers learned their skills on BBC Micros and Sinclair ZX81s. Some of them then learned assembler, but it was not the first thing they learned, and I know of no introductory computer course that ever started with assembler and then moved up to BASIC.
User avatar
Forum Moderator
Forum Moderator
Posts: 2933
Joined: Mon Jan 09, 2012 3:16 pm
by jamesh » Wed Apr 04, 2012 9:06 am
hzrnbgy said:


For a starter developing an OS, you might want to start small. The Broadcom SoC is fairly complex. Might I suggest starting with a fairly simple 8-bit MCU, just enough to get you started with the basics of OS development


It's only as complex as you make it. At its simplest it's an Arm11 core with a memory mapped framebuffer - this is pretty much all Linux sees unless you start using the libraries for acceleration. You don't have to even know the GPU is there.
Volunteer at the Raspberry Pi Foundation, helper at Picademy September and October 2014.
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 12102
Joined: Sat Jul 30, 2011 7:41 pm
by hippy » Wed Apr 04, 2012 10:04 am
itsapieceofcake said:

when i first read about R-PI i got very excited but as i got more information i came to realise that this was quite unsuitable for OSDev'"ers ... the best part about the R-PI is the GPU, if you can not access it from an OSDev point of view then i would like to know what advantage the R-PI has over a x86 eBOX if you are wanting to write your own OS

Maybe it's just me but I don't really see what relevance the GPU has to hobby OS development per se; it's a means to an end but it's not an essential part for OS development, and a good OS should perhaps not even be dependant upon a GPU.

Only having a frame buffer may become a top end limitation to what one hopes to achieve but doesn't prevent OS development in itself. OS development was entirely possible before we had GPU's and will continue to be so.

For most I believe the R-Pi computer is an ideal platform for hobby OS development but for those with more specific or advanced needs then something else may be a better buy.

For those who have hardcore OS development ambitions I would think making the closed userland libraries work with a non-Linux OS would be interesting and challenging projects with plenty of kudos in achieving that; seizing an opportunity from a perceived limitation.

My own bare metal and own-OS plans are rather primitive as they stand so I expect it will be a long time before worrying about the GPU even enters into it. If that arises I can always move on to something more appropriate; the R-Pi computer will still have served me well.
Posts: 826
Joined: Fri Sep 09, 2011 10:34 pm
by tufty » Wed Apr 04, 2012 12:21 pm
hippy said:


I don't really see what relevance the GPU has … it's a means to an end but it's not an essential part for OS development


QFT
Posts: 1371
Joined: Sun Sep 11, 2011 2:32 pm