RISC OS on the Raspberry Pi ZERO
The Raspberry Pi Zero was released on 26 November 2015 as a £4 computer circuit board, the first 10,000 units being given away with issue 40 of the MagPi magazine, stocked by popular high street shops. It sold out almost immediately and boards were being sold on ebay for ridiculous prices. The board is designed to be cheap and small but, functionally, extremely similar to the model A+. It is therefore not ideal as a desktop computer, with a large and fast SD card, driving a monitor, with keyboard and mouse and connected to the internet. So naturally that is what I set out to do.
Firstly though, I must say that as a control board, using the GPIO pins to operate some attached hardware, the board is perfectly conceived. It has miniature connectors: two micro USB ports - one for power and one for data (and power if you like) - plus a mini HDMI port. A micro SD card socket is provided for the software. There is an unpopulated 40pin header providing the GPIO (general purpose inout/output) lines, a pad for a reset switch and a pad for a composite video cable to be soldered.
So what is the 'Zero'?
The latest version of the Raspberry Pi is the Zero - a much smaller (and cheaper) circuit board similar in function to the model A (i.e. with one USB port and no Ethernet socket) but designed to be small and cheap. The Raspberry Pi Zero will shortly be available more widely after the initial batch at the end of November quickly sold out. Here it is installed in a small case:
The most likely application for this board is as a control board soldered inside some sort of hardware project, possibly with a touchscreen, rather than as a desktop machine. A model B might be used to develop and test the software on the SD card. Using the Zero as a desktop machine requires a lot of added bits and pieces such as USB hub, Ethernet adapter and special cables to fit the miniature sockets, pushing up the price.
So can you simply clone the SD card from your model B running RISC OS and put it in the Zero?
Unfortunately not - the Zero needs the latest firmware. RISC OS has supported dynamic clock switching for some time now (on Beagleboard, Pandaboard, ARMX6, Titanium and IGEPv5) using the Portable_Speed SWI, but this had not been implemented on the Pi as it (originally) had no ability to switch speed.
Since 26 March 2016, through the efforts of Jeffrey Lee, RISC OS now supports speed switching on the model 0, model 2 and model 3 Pi - the model 1 Pi does not switch speed.
Using the new firmware the Pi Zero needs a ROM dated 20-Dec-2015 or later - this allows ZeroPain to tolerate zero page access - but the Pi 3 needs a ROM dated 29-Mar-2016 or later - this means that the standard ZeroPain will abort on any zero page access.
Another problem is that the new firmware will operate the CPU at 600MHz (the designated 'slow' speed) unless RISC OS implements speed switching. Although the Pi Zero allows an explicit speed setting (in CONFIG/TXT) using the commands:
the Pi 3 does not. In any case the force_turbo=1 command sets the warranty bit.
Some software still makes zero page access (for example LanMan98 version 2.05) and it would seem sensible to continue (for the moment) to allow this. Two possible solutions suggest themselves - a low vector rom build for the Pi using the latest sources or a high vector build accompanied by a 'kludged' ZeroPain module.
Can you add a popular make of USB to Ethernet adapter (more likely to be necessary on a machine with no Ethernet socket)?
Only if you use a RISC OS ROM from 20-Dec-2015 (which has drivers for AX8872B-based adapters) - any later (e.g. a latest development rom from the ROOL download page) and complications arise from ZeroPain (don't ask).
How do you update your existing RC14-based SD card running RISC OS 5.2x to allow dynamic speed switching and to work on all models Zero, 1, 2 and 3 as well?
This process is described here - a zip file which can simply be downloaded on your existing Raspberry Pi running RISC OS and the contents copied over your existing !Boot directory. It will update your firmware and ROM. Provided you are running RISC OS 5.2x this should work without affecting any of your data or programmes that you might have added since creating your SD card. You may need to update your configuration settings within RISC OS (such as screen size) as a new ROM will start with default settings.
An update zip file containing the latest firmware (BOOTCODE.BIN, FIXUP.DAT and START.ELF) a recent RISC OS ROM, the ZeroPain module (where required) and a utility to display clock speed can be downloaded. Two versions are available - one which has a high processor vector build and requires you to download a kludged version of the ZeroPain module separately if you want to permit zero page access without aborting. The other has a low processor vector build of RISC OS and thus does not need ZeroPain at all. High vector build
Special low vector build
What is provided in the zip file?
A picture speaks more than words:
What if you are starting afresh with just a Zero?
You will need to wait until ROOL update the RC14 SD card image to cope with the Pi Zero - this requires testing and may take some time.
So what can you do with a Pi Zero?
I can describe what I did with one, with a touchscreen in place of mouse and keyboard for input, and how I went about it. I took out a subscription to the MagPi magazine on 23 December and the magazine dropped through my door on 8 January, complete with Raspberry Pi Zero, mini HDMI to HDMI adaptor and micro USB to USB socket short cable. I had already downloaded the RISC OS ROM image on 30 December, along with the latest firmware, and set it up on a model A+, along with a recommended AX8872B-based Ethernet dongle so that I would be ready when the Zero arrived. Now I was all ready and so I (reluctantly) ordered a Pi Zero from ebay, where the price had, by now, dropped to £21.99 'buy it now', after trying (unsuccessfully) to bid a few lower offers. It arrived on 5 January.
I was keen to take a working Pi Zero along to the Bristol RISC OS User Group meeting on Wednesday 13th January (besides patience has never been one of my strengths). You quickly realise that by the time you have obtained the necessary, rather uncommon, leads to connect everything up, what looked like a bargain at £4 is starting to look the same price as the model A or B.
I had been looking for some time for a 5V powered small HDMI display and found one from adafruit, available in the UK at £56. I had already obtained a 5V power pack from Maplin, which had 5000mAh capacity for my Digiwalker pocket PC (the previous Chinese import had started bulging and when I opened it found the lithium polymer battery was just a plastic bag full of gunk). Hastily replacing the lid, I decided to replace it with something more reputable. I had also bought a Samsung 16GB micro SD card for testing (rated at read speed 90MB/s, write speed 50MB/s) from Maplin.
Now I have battery, display, computer, SD card and leads. The next problem is connecting it all together without letting the leads make the thing into a huge tangle! My first stab is shown below:
The first tricky thing was getting the 'CONFIG.TXT' file correct for the 800x480 display:
fake_vsync_isr=1 framebuffer_swap=0 gpu_mem=48 hdmi_force_hotplug=1 hdmi_group=2 hdmi_mode=1 hdmi_mode=87 hdmi_cvt 800 480 60 6 0 0 0 max_usb_current=1 init_emmc_clock=100000000 arm_freq=1000 gpu_freq=300 core_freq=400 sdram_freq=450 force_turbo=1 kernel=RISCOS.IMG
It works! It is (as you can see) consuming 0.83 A at (about) 5V - that is the display (400mA), computer (180mA), wireless keyboard/mouse dongle, ethernet adapter (200mA) and USB hub. All via the micro USB power input to the Pi Zero:
RISC OS is quite happy at 1920x1200 or using mode 21 (640x512) leaving the GPU to mungle that into the display's native resolution of 800x480. I was quite happy to see my fruit machine programme running happily:
The fruit machine simulation is a single-tasking programme that works outside the desktop. I wrote the first version of this programme in 1972 in a Sixth Form computing course at school on a Hatfield Polytechnic time-sharing terminal at Borehamwood College of Further Education. It was subsequently developed on a Compukit UK101 (adding 6502 machine code), a Nascom 2 (Z80 machine code), a BBC model B (6502 again), a BBC Master, and finally an Acorn Archimedes A310 in 1988 (ARM machine code). As it still worked on an Iyonix under Aemulor (for the 16 colour screen mode) twenty five years later, I tried to get it working on a Raspberry Pi Pico. I had to make a few adjustments (to set spritesize to 320k and to use mode 21 rather than mode 15) and now it works.
Getting it working with a touchscreen and battery proved an interesting challenge. It consumes 580mA in the configuration shown below which will give about five or six hours (at present the battery has been removed for charging, which is faster if it is not also supplying a load). The case is 5″ x 3″ x 2½″ and the white/black lead will be replaced by a single USB micro B male to USB micro B male lead in due course.
Turning it over, you can see the view underneath showing the Pi Zero connected to the display by four HDMI adapters: a mini to HDMI, a male to male, and two 270° adapters! The display USB micro B socket provides power and data, appearing as a USB mouse and is connected to the Pi Zero's USB OTG socket. The other (black) lead is the power lead, which would normally be a USB A to USB micro B lead to the battery.
Finally a close up of the touch screen - at 800 x 480 it is very readable. If you connect a USB hub, USB/Ethernet adapter and wireless mouse and keyboard in lace of the power and data lead to the display, you can have networking. Clicking with the SELECT button is simply achieved by tapping the screen. Dragging is also simple. Haven't yet worked out how to ADJUST-click or to click with the MENU button...
RISC OS is quite usable at 800x480.
Now I want to add a digital voltmeter (£2.15 from ebay) and find some thinner right-angle leads to reduce the rat's nest a bit.
Benchmarks updated to show the Pi Zero clocked at 1000MHz.