mailto: blog -at- heyrick -dot- eu

Building RISC OS on the Pi

A little treat for you, in the run-up to Christmas (yeah... I know it is Christmas because there are more toys than normal in the supermarket, and it is themed into boy/girl, easily determined by virtue of the girl's aisle being pink - anything and everything is bright pink).
You've used RISC OS, right? On a Beagle? On a Pi? Or maybe just on an emulator?

Get ready for a geekfest!

We're going to elevate it to the next step - we're going to roll our own RISC OS. Yup, we're going to build this baby from source, install it, and run it.

Geek @ work

What you will need

Here is what you will need:
  • A Raspberry Pi...
    The Pi is easy enough to get sorted if you are of geeky inclination and don't mind bare boards with wires hanging out - you can get them from all sorts of places, such as CJE Micro's.
    If you like RISC OS and prefer a computer that looks like a computer, then CJE Micro's has you covered. I would certainly recommend having an RTC module because the build process uses timestamps to know the 'age' of things, so it is rather important that the date and time are correct. If you buy a bare Pi (from CJE or elsewhere) then look at the first CJE link above, you will find some suitable RTC modules.
    [note - I thought I'd better point out that I do not receive a commission from CJE, they have been an Acorn-friendly dealer since forever so it seems only right to recommend them]
     
  • ...that is already running RISC OS.
    If you get a CJE package, you'll be sorted. Otherwise, you have three choices:
    1. Download an SD image from http://www.raspberrypi.org/downloads - the RISC OS link (download or torrent) is about halfway down the page.
      I made a video to guide you through the process of creating the SD image - watch it here.
    2. If you are unsure about writing images to SD cards, you can get started with the Pi "NOOBS" package. This is a set of files that you unzip and drop on an blank SD card (with a PC), insert into the Pi, and then choose "RISC OS" from the menu that appears. It isn't the best way to install RISC OS, but it'll get you going.
    3. If that all looks complicated, you can buy a pre-built SD card from RISC OS Open Ltd - details here (it is £10+VAT+P&P).
    Note that the RaspberryPi.org supplied images are old, so old there are cobwebs all over the place.
     
  • The build environment.
    This is the point, I suspect, when many will stop reading. You'll need to buy the RISC OS development suite. Sorry, but Acorn wrote their OS to run on their processor and build using their tools, and while there have been attempts to go the gcc route, the macro assembler facilities are used extensively and gcc's assembler just isn't up to something like this.
    You have two options. If you plan to write/test code for other RISC OS platforms, you will need the full DDE (C compiler, assembler, debugger, disassembler, and lots of other things). It costs £40+VAT+P&P, details here.
    If you only plan to work with a Pi, you can get a better deal with the NutPi package - for only £35+VAT+P&P you can get an incredible selection of RISC OS software including the DDE. The only restriction is that some (don't know how much) of it has been nobbled so that it will only run on a Pi. But this is reasonable enough given the retail price of the packages alone add up to around £600! Details here.
    If forty quid seems a lot of outlay for a development package, it is when you compare it with the likes of gcc. I now invite you to compare it with other commercial development packages. You might be in for a shock...
     
  • The code.
    Obviously! We can't do anything without code. Show me the code! Show me the code! Wait...hang on...wrong film. Damn.
    Anyway, the source code for all of RISC OS - grab yours here. The one you want is under "Source code archives" and it is called BCM2835Dev.
    You can, optionally, download DiscDev for the files that comprise the applications supplied on disc (!Printers, !Maestro, etc). Installing/building this is not covered in this guide; but it is there if you want it.
    [if you are following this guide with a view to building RISC OS for a different platform - briefly: IOMDHALDev is for anything based upon the RiscPC architecture, including the emulators; OMAP3Dev is for the Beagle boards (plain and xM; ARMini); OMAP4Dev is for the Pandaboard (ARMiniX); and TungstenDev is for the Iyonix. Do not download the incorrect archive - each board has a variety of system-specific parts within, and as such you will need to have the right archive for what you want to build.]
     
    Ignore the tool that is recommended for unpacking the archives. This one is much better, download it.
     
  • You may need a USB stick in order to get the sources on the Pi, if you are downloading them on another machine.
     
  • Final thing? Experience.
    I'm not going to tell you what the Menu button is, or how RISC OS paths work. I am assuming that if you plumped for the DDE then you will at least have some degree of familiarity with RISC OS... this know-how may be necessary.
    I'm sorry - there is a lot said in this article, but there is equally a lot left unsaid. You are building an operating system! If you don't know what a TaskWindow is, or how to get one, then I suggest you politely back away and go play a nice game (of Chess?) instead...
So, let's recap:
  • A RaspberryPi
  • running RISC OS
  • with the DDE development suite installed
  • and a copy of the BCM2835Dev sources (as a compressed "bz2" file) - it will probably have a much longer name, such as "src-bcm2835-dev.5.21.tar.bz2"

 

A brief word about the licence

Just a small point that might be necessary to some - the RISC OS sources are not GPL. They are supplied according to a Castle licence, which you can read here. Basically, it is free for personal private use and hacking is encouraged so long as you grant Castle (and thus ROOL) the ability to merge your modifications into RISC OS to improve the system for everybody. The licence is specifically not an OEM licence, so you cannot distribute RISC OS within embedded products. If this is your wish, you will need the OEM licence (here) plus a licence for the number of copies of RISC OS you will be supplying. Interestingly, the price depends upon how soon you intend to feed your code back into RISC OS, so you can licence "everything" from as little as £3 per copy. Or £2.10 if you only want the kernel (ROM image) stuff. There are further reductions if you intend on supplying devices numbering in the hundreds...

 

Unpacking the sources

I have all of my DDE and source codes within a directory called "Coding", full path "$.Coding". I recommend that you have something similar to keep your directories tidy.
Within this tidy location, create a directory called "RISCOS".

This guide will assume that you will be placing RISC OS at $.Coding.RISCOS. If this is not correct for your setup, kindly ask your eyeballs to do a search-and-replace all occurances of that with the correct path that you are using. ;-)

Using !SparkFS (either the full one or the read-only one), unpack the archive UnTarBz2_106a2.zip into the RISCOS directory. Also place the source archive(s) in there.

Collecting all the things necessary to build RISC OS on a RaspberryPi

Run the !UnTarBZ2 program and drag the BCM2835Dev archive on to the UnTarBZ2 iconbar icon.

A window will appear, that looks like this:

Unpacking RISC OS

In the second, blank, writable icon, enter the full path to the RISCOS directory, like this:

Setting the unpack destination

Don't touch any of the other options (which ought to be as shown above). Just click on "RUN".

If you have a fondleslab or other sort of tablet, fire it up, watch animé or catch up on those episodes of Naniwa Shōnen Tanteidan that you never got around to watching...or is that just me? (^_^)
If you're stuck for ideas, Avril Lavigne's "Here's To Never Growing Up" is on YouTube (HD too). Watch it, and tell me it isn't a darker remake of "Complicated". Then look for a cat called Maru. Or attempt the Gangnam Style dance. Extra points if you can remember any of the words other than "yoe-ja".

Why have I suddenly started talking rubbish? Well, the conversion of the bz2 archive to a tar file will take about 28 minutes on a standard Pi with a Class 4 SD card. A better speed SD card would be preferred, but it seems that Class 10 (the wing-zing type) can suffer...shall we say "compatibility issues"? Annoyingly 7-zip did it on a 1.6GHz Atom in 67 seconds... go figure...

Following this is the unpacking proper. There are 8,369 files to be unpacked and moved and attributes/filetypes fiddled to make it all work correctly under RISC OS. Seriously, we're looking at a couple of hours, so while your lowly PC might be able to extract in a handful of minutes, the result will be pure gibberish to RISC OS. Just... set it going and then go watch a movie. A really long movie, like Space Battleship Yamato (live action) or Suzumiya Haruhi no shōshitsu (my review) or The Man From Nowhere (recommended!).
Alternatively... fire up your PC and write a blog post and whinge about how damn long this takes. ;-)

It this point the process will probably bomb out with the error "File 'SDFS::RISCOS.$.Coding.RISCOS.*.Prepare.!run' not found". Don't worry about this. You can close the UnTarBZ2 window.

The UnTarBZ2 program bombing out due to a star where there ought not be a star!

There is a directory within RISCOS called BCM2835Dev. Open it. Now open the directory Prepare that you now see. Then double-click on the !Run file.

Getting the environment set up

What is happening now is that pieces of your DDE and libraries are being copied into the sources so the build process can find them. Answer Y to set up the build process.
If the filer has not 'seen' the DDE tools, run !SetPaths in the AcornC/C++ directory, then answer Y.

You want to run Builder, so press Y one last time. That done, you can close the TaskWindow.

Click Menu on the Builder icon bar icon (looks like an old-fashioned EPROM with a trowel over it) and select the "Register build tree..." menu option.
Drag the BCM2835Dev directory to the window that appears, then click Save.

Setting up !Builder

NOW SHUT DOWN AND REBOOT. [because if the DDE has been seen, it risks clashing with the builder]

 

Starting the first build

Open the RISCOS directory, then BCM2835Dev, then Apps (or in other words, SDFS::RISCOS.$.Coding.RISCOS.BCM2835Dev.Apps) and double-click !Builder.

Click on the Builder icon bar icon. A window will appear. For the Environment, click on the menu pop-up icon and choose ROOL.BCM2835:

Selecting what to build

Now tick the following boxes (unsure the others are not ticked):

  • List - does stuff (probably not necessary but let's not break things)
  • Clean - cleans out old object files and temp files for a new fresh build
  • Clean all - cleans out even harder, for stuff the "Clean" process missed
  • Export headers - creates all the shared headers that other stuff may require
  • Export libraries - builds the shared libraries that other stuff may require
  • Export resources - builds the resources (messages and such) that each component needs
  • Make ROM - compile/assemble (but don't link) all of the modules and stuff that comprises RISC OS
  • Install ROM - sorts out the stuff to go into the ROM, does a partial link of some things
  • Join ROM - does the final linking and pastes everything together to make the ROM image
Do not touch the version numbering, leave it set as "ImageName" and "Don't".

Setting the build options

Then click on Build.

 

A few brief comments on build failures

The build process should not fail - after all, RISC OS is built every night from this source code. The sources that you downloaded to build this version of RISC OS is current as of yesterday, and the same will be true for you, whenever you download the source archive. However, there is always the possibility that something may be checked into the repository by error, so it might fail, once in a blue moon when Saiph is just about to rise... (^_^)

Just so you know, the string "AMU: ***" (or just "***") is your pointer to build errors. Some can be ignored, like "Nothing to delete", but "Not found" and "exit (1)" indicate serious problems.

If the build fails, it is imperative to correctly resolve the problem and redo the necessary steps. If in doubt, start the build process again from the beginning. It is better to be sure.

Oh, and if the build speed bothers you - try to imagine how it must have been to build RISC OS 3 on a 25MHz machine. Or RISC OS 2 on a 8MHz machine.

 

The conclusion of the build

After what seems like an eternity (about 50 minutes), you will see that a lot of modules (135 in this build) were created, pasted together, and prodded into the form of a RISC OS ROM image.

[...pages and pages of stuff above...]
CDFSSoftSCSI               FC44E6FC         00002514
CDFS                       FC450C14         00004268
CDFSFiler                  FC454E80         00002C60
UnSqzAIF                   FC457AE4         00000318
BlendTable                 FC457E00         000006F4
HeroNames                  FC4584F8         000002B9

Total of 135 modules.
==============================================================================
Starting phase join ...
romlinker: version 0.04 (31 Jul 2011)
romlinker: Standard ROM image construction
romlinker: Image has 686128 bytes spare (670.05K)
romlinker: crc16=8c61

==============================================================================
Finished ROOL.BCM2835 build : Tue Nov  5 18:48:50 2013
------------------------------------------------------------------------------
Closing log file 'SDFS::RISCOS.$.Coding.RISCOS.BCM2835Dev.BuildSys.Logs.dURZ00-00'.
That bit, in bold, is what you want to see.

 

Installing the new ROM image

Now comes the fun.

In the $.Coding.RISCOS.BCM2835Dev directory is a directory called "Images". Open it, and you ought to see a file with a name like dURZ00-00. The letter at the start increments with each build (aURZ00-00, bURZ00-00, cURZ00-00, etc). There can be problems with long file names and DOS partitions (would it be "DURZ00-00" or "DURZ00~1"?), so to keep things simple, just rename that to RISCOS/IMG (all upper case).

Rename the ROM image

Open the directory $.!Boot.Loader, and create a folder called "OLDER". Move the existing RISC OS ROM image (probably called "RISCOS/IMG") into the OLDER folder (do not delete it, you'll need it in case something went wrong).

Now copy the new RISCOS/IMG file from the "Images" directory into the "Loader" directory.

Installing the ROM image

  • While you are here - it might be a good idea to ensure you are using the most recent firmware. If you were running a recent build of RISC OS, you can probably skip this step - but if RISC OS fails to start (as in "nothing happens"), check your firmware is up to date.
    Here's how:
  • Copy the files bootcode.bin, fixup.dat, and start.elf into the "OLDER" directory (in order to keep copies in case you need to revert).
    Now go and download the latest versions of those three files from https://github.com/raspberrypi/firmware/tree/master/boot (click to view 'raw', a download will be offered). Place these in the same directory alongside MYROM/IMG and CONFIG/TXT. If there are other files (512START/ELF and LOADER/BIN, for instance), you can move these files into the backup subdirectory. They don't appear to be required any more (a brief look suggests that LOADER/BIN is now part of START/ELF).

Now open the file CONFIG/TXT in a text editor, and ensure that the line that points to the kernel (probably the last line) correctly refers to the file RISCOS.IMG - note that the file must be given in DOS form, so it's a dot not a slash!
Save the modified configuration file.

Editing the Pi configuration file

Don't worry if your CONFIG/TXT file looks different to mine. I started using composite video, and then moved to an HDMI to VGA adaptor, so there's stuff in there to set all this up correctly.

 

Note - you MUST rename the ROM image "RISCOS/IMG"

The reason for this is the SDCMOS file saves configuration information to the end of the ROM image (!) and it only looks for the image "SDFS::0.$.!Boot.Loader.riscos/img".
If you call your ROM something else, it will work but configuration will not persist between sessions.

 

Going for broke!

Shutdown RISC OS, then click the big inviting Restart button.
This is it! The final click!

Don't breathe!

 

...

 

If everything goes according to plan, you will see a lot of "init mod:" messages scroll up the screen, followed by something about callbacks, and then the familiar RISC OS start-up will appear.
Check the date in the Task Manager.
Go on... You know you want to!

My build is running quite nicely, thank you very much!

 

Normally I use 1280×1024 (as that is the native resolution of my monitor). Here is RISC OS running in a 640×512 mode, so that it will fit into this b.log article without scaling.

RISC OS!

 

Recovery - if nothing happens

If you have not updated your firmware, check it now. Details are above.
At time of writing, the correct firmware is:
  • BOOTCODE/BIN - 17,824 bytes
  • FIXUP/DAT - 5,758 bytes
  • START/ELF - 2,488,796 bytes
If yours differ, or if you have other files (LOADER/BIN, etc) then you may need to update your firmware. Try this first, and if RISC OS still fails to boot.....

The simplest recovery method is to remove the SD card from the Pi, place it into a different machine's SD card reader (such as a PC), and then:

  • create a directory with a suitable name, like "OHBUGGER".
  • move your new image and firmware into that directory.
  • copy the previous ROM image and firmware back into the root.
  • amend CONFIG.TXT to point to this, previous, ROM image (if necessary).
Then put the SD card back into your Pi and boot it up.

If you want to have a crack at doing this again, go back to the "Starting the first build" step, and if there is an error in the build, be sure that you have dealt with it fully.

 

Your comments:

Please note that while I check this page every so often, I am not able to control what users write; therefore I disclaim all liability for unpleasant and/or infringing and/or defamatory material. Undesired content will be removed as soon as it is noticed. By leaving a comment, you agree not to post material that is illegal or in bad taste, and you should be aware that the time and your IP address are both recorded, should it be necessary to find out who you are. Oh, and don't bother trying to inline HTML. I'm not that stupid! ☺ ADDING COMMENTS DOES NOT WORK IF READING TRANSLATED VERSIONS.
 
You can now follow comment additions with the comment RSS feed. This is distinct from the b.log RSS feed, so you can subscribe to one or both as you wish.

Rick, 31st December 2013, 21:09
This article (on building RISC OS from scratch) has been revised and updated to correct a few issues and provide additional information, and also to provide screenshots without the watermarks (as it makes things easier to read).
Rick, 18th March 2016, 23:59
You should now get your RISC OS ROM images from ROOL directly...

Add a comment (v0.11) [help?] . . . try the comment feed!
Your name
Your email (optional)
Validation Are you real? Please type 95244 backwards.
Your comment
French flagSpanish flagJapanese flag
Calendar
«   November 2013   »
MonTueWedThuFriSatSun
    12
467810
12131516
18192021222324
252627282930 

Advent Calendar 2023
(YouTube playlist)

(Felicity? Marte? Find out!)

Last 5 entries

List all b.log entries

Return to the site index

Geekery

Search

Search Rick's b.log!

PS: Don't try to be clever.
It's a simple substring match.

Etc...

Last read at 11:55 on 2024/03/29.

QR code


Valid HTML 4.01 Transitional
Valid CSS
Valid RSS 2.0

 

© 2013 Rick Murray
This web page is licenced for your personal, private, non-commercial use only. No automated processing by advertising systems is permitted.
RIPA notice: No consent is given for interception of page transmission.

 

Have you noticed the watermarks on pictures?
Next entry - 2013/11/09
Return to top of page