ARM Assembly / Operating System

Drop in for a chat and a cup of tea

49 posts   Page 2 of 2   1, 2
by itsapieceofcake » Wed Apr 04, 2012 5:36 pm
rurwin said:


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.


from your comments you seem to imply that assembly is really  hard to learn when in fact it is not much harder than BASIC if your mind is wired in the right way, by this i do not mean that you are more intelligent its just that you learn in such a way that you find assembly easier to understand than some higher level languages.

I have taught many people to code in assembly language most take one look at it and run a mile with out even trying, but those who stick at it and give it a full try make as fast a progress as with any other language. I have found the best way not to scare them is to use what i call  MacroBasic to start with and then insert small pieces of assemble like you would in other high level languages use inline, you soon find them optimising and modifying the macros and adding new ones, but code written like this is still full assembly code even though it may look like a higher level language.

Here is a quick linux/x86 example

Mbasic.asm

include "MacroL.inc"
CLS
LOCATE 5,14
PRINT "raspberry pi is cool"
LOCATE 5,16
PRINT "This may look like basic"
LOCATE 5,18
PRINT "but its fully written in assembly"
END

MacroL.inc

format ELF executable
entry start

;==
; CLS.
;==
macro CLS
{
local .Done
local .a
local .b

mov eax,4
mov ebx,1
mov ecx,.a
mov edx,.b
int 80h
jmp .Done

.a db 1bh, "[2J",1bh, "[01;01H"
.b = $-.a
.Done:
}

;==
; PRINT.
;==
macro PRINT String{
local .Done
local .a
local .b

mov eax,4
mov ebx,1
mov ecx,.a
mov edx,.b
int 80h
jmp .Done

.a db String,0xa
.b = $-.a
.Done:
}

;==
; LOCATE.
;==
macro LOCATE col,row
{
local .Done
local .CursorX
local .CursorY
local .ColumnRow
local .ColumnRowSize
pushad
mov dh, 10
;
mov ax, row
and ax, 0FFh
div dh
add ax, "00"
mov [.CursorX], ax

mov ax, col
and ax, 0FFh
div dh
add ax, "00"
mov [.CursorY], ax

mov eax,4
mov ebx,1
mov ecx,.ColumnRow
mov edx,.ColumnRowSize
int 80h
jmp .Done

.ColumnRow db 1bh, "["
.CursorX dw 0
db ";"
.CursorY dw 0
db "H"
.ColumnRowSize = $-.ColumnRow
.Done:
popad
}

;==
; END.
;==
macro END
{
mov eax,1
xor ebx,ebx
int 80h
}

;==
; START of Program.
;==
segment readable writeable executable
start:

This could easily be rewritten in ARM for the R-PI

[edited to format code segments - hope that helps! :) Lynbarn]
Posts: 9
Joined: Sun Mar 11, 2012 11:32 pm
by Joe Schmoe » Wed Apr 04, 2012 5:45 pm
It would be nice if you could remove all the HTML gibberish from the post.  My screen was full of <br>s
Never answer the question you are asked. Rather, answer the question you wish you had been asked.

- Robert S. McNamara - quoted in "Fog of War" -
Posts: 2731
Joined: Sun Jan 15, 2012 1:11 pm
by itsapieceofcake » Wed Apr 04, 2012 5:56 pm
To all those who are thinking about writing an OS for the R-PI, anything bigger than an Hello World is a very big undertaking for one person, I have spent the last ten years coding a full assembly OS for both x86 and ARM, if I knew what a big job it was going to be I would not of started, if you think it is going to get you a well paid job in the UK you would be wrong.

My OS is regularly in the worlds top ten hobby OS's list yet i would not even get an interview to work as a programmer in the UK because of the lack of a university degree.

I suppose with so much publicity surrounding the R-PI the first person to get a hobby OS on to it will get some kudos .
Posts: 9
Joined: Sun Mar 11, 2012 11:32 pm
by bobc » Sat Apr 07, 2012 1:17 pm
itsapieceofcake said:


To all those who are thinking about writing an OS for the R-PI, anything bigger than an Hello World is a very big undertaking for one person, I have spent the last ten years coding a full assembly OS for both x86 and ARM, if I knew what a big job it was going to be I would not of started, if you think it is going to get you a well paid job in the UK you would be wrong.


How long would it have taken if you had written it in C? ;)


My OS is regularly in the worlds top ten hobby OS's list yet i would not even get an interview to work as a programmer in the UK because of the lack of a university degree.

I suppose with so much publicity surrounding the R-PI the first person to get a hobby OS on to it will get some kudos .


Of course, now I am wondering which OS you are referring to. Recruitment policies in the UK are pretty arbitrary in my experience, but at the moment there is a big shortage of embedded programmers in the UK (and there is demand across EU), so if anyone with minimal experience is thinking of applying, give it a shot. And if you are keen hobbyist, getting a degree as a mature student is quite doable. We recently hired a guy with just such a background.
Posts: 86
Joined: Fri Apr 06, 2012 8:01 am
by andyl » Sat Apr 07, 2012 2:18 pm
bobc said:


itsapieceofcake said:


To all those who are thinking about writing an OS for the R-PI, anything bigger than an Hello World is a very big undertaking for one person, I have spent the last ten years coding a full assembly OS for both x86 and ARM, if I knew what a big job it was going to be I would not of started, if you think it is going to get you a well paid job in the UK you would be wrong.


How long would it have taken if you had written it in C? ;)


My OS is regularly in the worlds top ten hobby OS's list yet i would not even get an interview to work as a programmer in the UK because of the lack of a university degree.

I suppose with so much publicity surrounding the R-PI the first person to get a hobby OS on to it will get some kudos .


Of course, now I am wondering which OS you are referring to. Recruitment policies in the UK are pretty arbitrary in my experience, but at the moment there is a big shortage of embedded programmers in the UK (and there is demand across EU), so if anyone with minimal experience is thinking of applying, give it a shot. And if you are keen hobbyist, getting a degree as a mature student is quite doable. We recently hired a guy with just such a background.


I would also say that there are loads of professional programmers in the UK without degrees.  I'm one.  I've also been responsible for recommending (at interview) others who haven't had degrees and some who have had.  It might well be that itsapieceofcacke has been knocked back for other reasons.
Posts: 265
Joined: Tue Jan 10, 2012 11:05 am
by David_H » Sun Apr 08, 2012 10:20 am
andyl: "I would also say that there are loads of professional programmers in the UK without degrees" and loads of highly-paid electronic engineers such as myself. In my experience, what determines your interview success is your work/task experience.... and attitude. Employers like you to be able to "hit the ground running" and don't like to have to train folk...

bobc: "And if you are keen hobbyist, getting a degree as a mature student is quite doable" indeed. 100% online in most cases. I am just in the final part of my software engineering MSc with a top university at the age of 58..... I am actually really just "validating" knowledge I had already acquired over the years...
Posts: 6
Joined: Thu Mar 08, 2012 3:06 pm
by nick.mccloud » Sun Apr 08, 2012 10:34 am
itsapieceofcake said:


My OS is regularly in the worlds top ten hobby OS's list



Can you give us a link – would love to know more …
User avatar
Posts: 795
Joined: Sat Feb 04, 2012 4:18 pm
by spurious » Sun Apr 08, 2012 10:47 am
Posts: 343
Joined: Mon Nov 21, 2011 9:29 pm
by andyl » Sun Apr 08, 2012 12:26 pm
David_H said:


andyl: "I would also say that there are loads of professional programmers in the UK without degrees" and loads of highly-paid electronic engineers such as myself. In my experience, what determines your interview success is your work/task experience.... and attitude. Employers like you to be able to "hit the ground running" and don't like to have to train folk...


I'm wasn't an employer, I was just the technical team leader.  However IME the difference in training between someone coming from a degree and someone coming without a degree is minimal.  Unless it has been someone with relevant work experience (in that language) there is a fair amount of on the job training.

You are right about attitude.  You are looking for someone who will play will in a team, who shows a degree of self-reflection, of being responsible for their own continual education, who isn't stuck in a cul-de-sac, who is flexible and shows little ego (in a code-ownership sense) but pride in what they do.
Posts: 265
Joined: Tue Jan 10, 2012 11:05 am
by itsapieceofcake » Sun Apr 08, 2012 9:49 pm
I do not want to name my os as that would be seen as spamming, but it is one of these in these links

http://www.techradar.com/news/.....ems-934484

http://royal.pingdom.com/2008/.....he-future/

and it is based on a games console for the x86, the links show the old version and i have been updating and stripping it down.

I have never applied for programming jobs but when i have looked most of them require a university degree of some description and somebody once told me you never get fired if you hire a person with a degree and they mess up but if you hire someone without a degree then you in trouble just as much as them when they mess up
Posts: 9
Joined: Sun Mar 11, 2012 11:32 pm
by nick.mccloud » Sun Apr 08, 2012 9:55 pm
itsapieceofcake said:


I do not want to name my os as that would be seen as spamming,


Er, why????


but it is one of these in these links

http://www.techradar.com/news/.....ems-934484

http://royal.pingdom.com/2008/.....he-future/

and it is based on a games console for the x86, the links show the old version and i have been updating and stripping it down.


It would be so much simpler if you could just tell us it's name and provide a link ...
User avatar
Posts: 795
Joined: Sat Feb 04, 2012 4:18 pm
by Vindicator » Sun Apr 08, 2012 10:24 pm
Alright I'll play it is Dexos or Amiga os from the links LOL, do I get a prize or better a big fat raspberry LOL
If you are more worried about ,spelling, punctuation or grammar you have probably already missed the point so please just move on.
User avatar
Posts: 314
Joined: Sat Sep 17, 2011 11:10 pm
Location: Susanville Ca USA
by Dave_G_2 » Sat Apr 14, 2012 8:57 pm
Hi all

Just joined after hearing much about the RPI.

The way I see it is there are two distinct ways to use it.

1) Load one of the Linux based distros on it and "hack" away.

2) Write a small simple OS for it.

There has been much speculation and comments about thefeasibility of writing a simple OS for the Pi in assembler and the complexities of the "blob".

Correct me if I'm wrong but is the "blob" not very similar to BIOS on a x86 machine?

If so then of course the manufactures are not going to release the source code any time soon.

However this does not mean it cannot be used.

On a x86 BIOS, there are standard calls/routines/API which any OS can use, surely this is also the case for the Pi?

For example, calling Int 15h with ah=86h and cx and dx populated with a value will cause the machine to pause for the specified amount of microseconds then return control to the calling app.

Surely some documentation exists for the "blob" API?

A hardware "map" must also exist which shows what hardware is located at what addresses.

A "homemade" OS does not need a GUI, compilers, word processing packages and other goodies.

A simple TUI and access to the serial port, the video port and possibly the keyboard will suffice.

Obviously one isn't going to be watching Youtube videos or sending emails on such a simple OS, but an OS it is.

Furthermore, if I'm not mistaken, the "blob" even loads the video port and resolution at boot time via the config.txt file making things considerable easier.

The whole OS could be compiled on a Linux machine then dd'ed onto a SD card and inserted into the PI.

The way I see it, the only real hard part is coding/porting the keyboard interface.

However since a simple OS is not going to have multitasking, only a single app will have access to the keyboard at any one time and much of the required info could be "gleaned" from the keyboard driver in one of the current RPI distros.

This would make for a great project which could teach the fundamentals of a OS and get down to the "core" of computer programming.

Your thoughts??
User avatar
Posts: 196
Joined: Sat Apr 14, 2012 7:04 pm
by bobc » Sat Apr 14, 2012 10:26 pm
The blob is not a BIOS, it does not have general purpose functions. The blob is accessed via a Linux kernel driver, and the graphics interface via closed source OpenGL driver, so to just display text,  you would need Linux compatible architecture to run that code.

Without Linux, I don't think you can feasibly use the GPU at all, i.e. no video. From the ARM you can access serial port, USB and GPIO.

I have to say that while the Pi is a great Linux platform, it is not really the best for low level stuff, and I think it is fair to say that was never it's design intention. If you really want to get down to the metal, any of the other ARM development boards would be a better route. Olimex are preparing a low cost ARM platform which is not as powerful as the Pi, but much more accessible for low-level hackers.
Posts: 86
Joined: Fri Apr 06, 2012 8:01 am
by tufty » Sun Apr 15, 2012 5:25 am
No, Dave is right. The "blob" /is/ equivalent to (i.e at the same conceptual level as) a bios. Its interface is documented, and yes, you can get video (although non accelerated unless you can link the linux opengl binaries). There"s nothing majick about linux.

The hardest thing isn"t gonna be the blob anway. It"s USB.

Simon
Posts: 1368
Joined: Sun Sep 11, 2011 2:32 pm
by Dave_G_2 » Sun Apr 15, 2012 7:41 am
Thanks tufty, your comments gave me encouragement for seriously considering attempting to write a small assembler based OS.

As regards the video, I was thinking along the lines of basic stuff like text or simple bit bliting pixels for graphics similar to writing directly to VGA memory (A000h) whilst in video mode 13h on the x86.

No fancy accelerated opengl stuff.

Just need to study the RPI hardware addresses more closely.

The USB, like you say will be a bit more involved but I"m hoping to base it on a "cut" down version of the existing drivers.

My thoughts here are to include some routines in the kernel which the apps can then call to get keyboard strokes.

There can be a small circular buffer to hold some keystrokes which are then read out by the calling app.

I haven"t studied the "blob" API, there might even be a generic USB keyboard driver/functions available.

Another approach is to ignore USB completely for now and use a PS2 type keyboard connected to some GPIO pins and emulate the PS2 protocol, not ideal but at least it would allow for rudimentary keyboard support.

For "headless" applications a keyboard would not even be required or one could access the RPI via a serial terminal type setup.

Taking this one step further, one could even write a small Xmodem type app and then be able to transfer pre-compiled apps from say a Linux box to the RPI where they are executed.

By pre-compiled I mean to  ELF ARM binary and not a Linux ELF for x86.

As long as the compiler has the correct libs on the development machine then the resulting binaries would be ARM compatible.

Any idea where I can get the documentation on the "blob" and a list of what hardware is at what addresses?
User avatar
Posts: 196
Joined: Sat Apr 14, 2012 7:04 pm
by tufty » Sun Apr 15, 2012 4:13 pm
Documentation for the hardware addresses and so on can be got from the datasheet. With that in hand, you can reverse-engineer the important "blob" bits from the linux kernel source. There"s extremely little you can (or want) to do with the gpu interface anyway, it pretty much comes down to "set up a framebuffer".

In terms of how to deal with the framebuffer, I"d suggest looking at the accelerated x server thread. Interesting stuff on DMA in there.

USB is a pain as the datasheet for the controller isn"t easily available, and the linux driver is fairly impenetrable. Same goes for the SD interface.

Serial is easy enough, and gpio to keyboard should be do-able (I have a pile of ADB devices, as well as a couple of serial keyboards, that"s the way I"m going too).

See my .sig, use what you like, but none of the pi side stuff is tested (or, indeed, up to date)

Simon
Posts: 1368
Joined: Sun Sep 11, 2011 2:32 pm
by Dave_G_2 » Sun Apr 15, 2012 6:15 pm
Thank you, will have a look.
User avatar
Posts: 196
Joined: Sat Apr 14, 2012 7:04 pm
by itsapieceofcake » Fri Apr 27, 2012 10:40 pm
Vindicator said:


Alright I'll play it is Dexos or Amiga os from the links LOL, do I get a prize or better a big fat raspberry LOL



Go to the top of the class, yes it was DexOS.
Posts: 9
Joined: Sun Mar 11, 2012 11:32 pm
by mahjongg » Sun Apr 29, 2012 6:51 am
tufty said:


No, Dave is right. The "blob" /is/ equivalent to (i.e at the same conceptual level as) a bios. Its interface is documented, and yes, you can get video (although non accelerated unless you can link the linux opengl binaries).


The "blob" contains the firmware for the GUI, and indeed also contains stuff like a font for the basic text modes it supports. and interfaces for calling the many other services it supports.

In many ways it is indeed comparable to a "video BIOS".

The standard BIOS of a PC seeks extension ROM's, and includes their services into its own service calls. Normally this means it includes the BIOS services of the video card, which has a "video BIOS" ROM.

see: http://en.wikipedia.org/wiki/Video_BIOS
User avatar
Forum Moderator
Forum Moderator
Posts: 5571
Joined: Sun Mar 11, 2012 12:19 am
by bobc » Sun Apr 29, 2012 10:19 am
tufty said:


Documentation for the hardware addresses and so on can be got from the datasheet. With that in hand, you can reverse-engineer the important "blob" bits from the linux kernel source.


So there is no actual document for the blob interface apart from the code?

See my .sig, use what you like, but none of the pi side stuff is tested (or, indeed, up to date)

Untested for lack of a Pi, I guess? I will have a go with it when my Pi arrives...

I don't know if there is a page on wiki for "bare metal" programming, perhaps we should start one.
Posts: 86
Joined: Fri Apr 06, 2012 8:01 am
by lonebaggie » Tue May 29, 2012 9:25 pm
I was also wanting a simple OS , just enough for programming in basic or forth, Although the PI is cheap it is still complex , and programming is still only possible when you have loaded and installed a huge OS which via a 4GB SD card. Then you only use 1% of OS to create a programming enviroment.

I just want an OS to boot into an editor quickly and allow me to interact with the hardware simply and directly.

This seem to fit the bill:-

A remake of the Jupiter Ace 8bit computer
https://sites.google.com/site/libby8dev/fignition

I know I can load emulators into linux , but if it it was possible to boot a "PI-Forth" via a simple kernel, with direct access to the harware , maybe we could control a power station :D
Posts: 1
Joined: Tue May 29, 2012 9:01 pm
by DexOS » Thu May 31, 2012 1:36 pm
lonebaggie wrote:I was also wanting a simple OS , just enough for programming in basic or forth, Although the PI is cheap it is still complex , and programming is still only possible when you have loaded and installed a huge OS which via a 4GB SD card. Then you only use 1% of OS to create a programming enviroment.

I just want an OS to boot into an editor quickly and allow me to interact with the hardware simply and directly.

This seem to fit the bill:-

A remake of the Jupiter Ace 8bit computer
https://sites.google.com/site/libby8dev/fignition

I know I can load emulators into linux , but if it it was possible to boot a "PI-Forth" via a simple kernel, with direct access to the harware , maybe we could control a power station :D

Thanks for the link, saw one of those in a youtube video, i think i may get one of those.
Its possible to have a bare bones OS running on the raspberry pi running forth.
This is the start of porting my OS to raspberry pi.
viewtopic.php?f=31&t=7004
We did have a forth port in the old ver.
Batteries not included, Some assembly required.
User avatar
Posts: 863
Joined: Wed May 16, 2012 6:32 pm
by tufty » Thu May 31, 2012 4:28 pm
If you're interested in forth, Riscy Pygness might be worth looking at.

Simon
Posts: 1368
Joined: Sun Sep 11, 2011 2:32 pm