Acorn RISC iX Hints and Tips

This page is a collection of hints and tips for setting up and using RISC iX, it is not a manual, but merely things that I need to write down before I forget them ...

A suitable Arculator config

Machine Tab:

Machine: Archimedes 540
CPU: ARM3 @ 26 MHz
FPU: FPA10
Memory: 16 MB
MEMC: MEMC1a (12MHz)
OS: RISC OS 3.11
Monitor: VGA

Podules Tab:

Podules 0: Acorn AKA31 SCSI Podule
 Configure...
  ID 0 type: Hard drive
   Configure ID 0...
    Use 'Load drive...' and point to the hard drive image that you download from this page, this should appear as a 258MB drive.

Podules 1: Acorn Ethernet II podule (AEH50)
 Configure...
  Network: <select PCAP device that matches the primary network card in your computer>

Boot RISC OS, use !Alarm to set the date and time to their correct values. Then use the !Configure tool, in the 'Discs' subsection, change the number of 'SCSI hard discs' to 1, click 'OK'. Reboot Arculator, In the SCSI drive 'RISCiX' shift double click !RISCiX and then double click RiscIxFS, then press F12 to open the commandline and type the following.

*configure Device sd0
*configure Unit 0
*configure Partition 0

Reboot Arculator, then double-click !RISCiX, this will either Boot RISCiX directly, or load to an iconbar icon, click the icon to load riscix.

The disc image from 4corn has the 'root' account set with the password 'Tal540bo'.

Shutting down RISCiX safely

As a unix RISCiX should not just be turned off or the machine reset without first properly exiting the OS. The following commands can be run as root to safely poweroff RISCiX

reboot
(or)
/usr/sbin/shutdown -h now

Alternatively at the Login: prompt type in the username 'halt' which will stop the system.

Moving the cursor in vi

vi is a bit of a pig to use at the best of times, however on the console cursor keys are not supported, use the fallbacks in command mode of:

h - left
j - down
k - up
l - right

Alternatively you can do the following....

Making the cursor keys work everywhere on the console

By default RISC iX defaults the cursor key behaviour to a similar to that used on the BBC Micro or RISC OS, enabling you to select a character and use 'COPY' key to copy the contents under the cursor

You can change the behaviour of this to make sure the cursor keys are treated in a more regular manner (of passing them on to the programs) by hitting the F3 key to enter the 'Terminal Set-Up' menu.

Use the cursor keys to navigate to the 'Cursor Keys:' section and use the + and - keys to select the value 'VT200', then use the cursor keys to navigate to 'Set-Up saved:' and press the + key to save. Then use F3 again to exit terminal setup.

Amongst other places, the cursor keys in 'vi' now work as expected, negating the need for hjkl.

Making local user logins work

/etc/rc.config make sure the following three values near the top are set in the following manner;

STANDALONE=FALSE
FULLNETWORK=TRUE
NIS=FALSE

If NIS is left set to TRUE, RISCiX will try to perform account login over Network Information Services over the network from a master server, this is almost certainly not wanted here.

Creating a new user

RISC Ix does not come with the more common 'useradd' or 'adduser' commands, it does however come with an interactive tool called 'useradmin'.

The following commands must be run as root.

To create a user, first find a free userid number and groupid number, run

more /etc/passwd
more /etc/group

On the install available on 4corn, the free numbers seem to start 1012.

First add a group for the new user

useradmin -g

Hit 'g' to add a group

Group name: <user name>
Group Id: <group id number e.g. 1012>

Then add the user

Hit 'u' to change to the useredit screen, the hit 'u' to add a user,

Login name: <new user name>
Full user name: <user's real name>
User id: <user id number, e.g 1012>
Group name: <group name from above>
Home Directory: /home/<user name>
Login Shell (B[ourn] or C[sh]: B
Initial password: <A password>
Reenter Initial password: <The same password>

Hit 'q' to exit the program.

Allowing a user to run the 'su' command to become root

... still investigating

Setting up networking

This pre-supposes that you have an ether1, ether2 or ether3 network card in your RISC Ix box (or have configured one under Arculator).

You will need to know the following information about your host network to set up networking

Information RequiredUsed in this example
Network Card InstalledEther 2 (AEH50)
Home Network number192.168.0.0
Home Netmask255.255.255.0 aka 0xFFFFFF00
Home Network Broadcast Address192.168.0.255
Home gateway192.168.0.1
A spare home static IP address192.168.0.7
A DNS server8.8.8.8

As root edit the following files and make the changes specified.


/etc/hosts Change the entry for the 'riscix riscix.localnet' line to be the static IP address on your home network e.g. 192.168.0.7


/etc/netmasks Add or edit the line for the home networks netmask e.g.

192.168.0.0 255.255.255.0

/etc/rc.config make sure the following three values near the top are set in the following manner;

STANDALONE=FALSE
FULLNETWORK=TRUE
NIS=FALSE

/etc/rc.net make sure the value for HOSTNAME=riscix matches the riscix entry in /etc/hosts.

Set the value of BROADCAST to the home networks broadcast address e.g.

BROADCAST='broadcast 192.168.0.255'

Set the value of NETMASK to the hex version of of your home networks netmask e.g.

NETMASK='netmask 0xffffff00'

Set the value of ETHERNET to match your fitted network card et0 for Ether 1, en0 for Ether 2 e.g.

ETHERNET=en0

/etc/resolv.conf Copy the incorrectly named 'resolve.conf' to 'resolv.conf' and edit to contain your DNS server e.g.

nameserver 8.8.8.8

Remove any nameservers that are not present on your network.


Now we should be ready to start networking, you may have to restart RISCiX here.

As root run the following command to connect to the home gateway e.g.

route add default 192.168.0.1 1

Testing the networking

# Can you connect to your home gateway?
ping 192.168.0.1
# Can you connect to a host on the internet?
ping 8.8.8.8
# Are DNS lookups working?
nslookup www.marutan.net

If you are happy with the networking setup, you can add

route add default 192.168.0.1 1

to the end of the file rc.local to make it run on machine startup each time.

Once networking is running, by default telnetd is running on the system, and you should be able to connect to the RISCiX box from a remote machine (telnet on linux, putty on windows etc).

Limitations;

It seems that most programs do not use DNS to lookup hostnames. ftp and telnet don't, but nslookup is working.

Under Arculator, because of the PCAP networking sharing the same network interface on the host machine, you cannot directly connect between your host machine and the emulated machine. However you can successfully connect to other machines on your home network.

Transferring files using FTP

Probably the easiest way to get files on and off the machine once you have networking up and running is 'ftp' (file transfer protocol). Setup an FTP server on a machine on your home network (e.g. BabyFTP on Windows or vsftpd on Linux).

ftp 192.168.0.10

Login using the credentials required for the remote server. Once connected use the command 'bin' to put FTP into binary mode (else it may well corrupt files by attempting to change line endings on them), 'hash' to make transfers print out their progress. 'ls' and 'cd <remote directory>' to navigate the the remote server. 'get <remote file name> to fetch a file to your local machine. 'put <local file name>' to push a local file to the remote machine.

Run X windows in more than 2 colours

When you run;

startx

by default you get 2 colour (black and white) in a resolution that depends on the configured monitor type.

To get 640x480 in 256 colour (8bpp)

startx -- -c8 -mediumres

To get 800x600 in 16 colour (4bpp)

startx -- -c4 -svga

Making backspace work in xterm

By default the backspace key does not work in xterms

type in 'stty erase ' (including the space after it), then hit the backspace key, then enter.

Recursive grep without recursive grep

Sometimes you want to search an entire tree of files and directories for a substring, but RISC Ix's grep doesn't have the -r switch. Here is an alternative method using find.

find . -type f -exec grep search_string {} \; -print

Hints and Tips about compiling programs

Resolving missing symbols at link time when compiling programs

It appears that the linker for C programs uses a file /usr/lib/XOPEN.R to map between calls in the program and calls in the libc that you link against /usr/lib/libc.a

If when compiling you get an error similar to this at link time;

Undefined:
_gethostname
can't mix shared library and undefined symbols

First check to see if the symbol exists in /usr/lib/libc.a, without any preceeding _

$ strings /usr/lib/libc.a | grep gethostname
_$gethostname
gethostname.o
_$gethostname

If there exists a copy of the function name with a _$ on the front, then it appears it's safe to add it to the mapping file /usr/lib/XOPEN.R

At the end of the file add a line similar to

_gethostbyname                     _$gethostbyname

And try a recompile, you may need to do a make clean and recompile, as it appears that just a re-link may not be enough.

strcasecmp, strncasecmp and strdup missing

Some functions that various unixes/gnu are expected to have are missing from the C library /usr/lib/libc.a

Here are some portable versions you can drop into your project.

strcasecmp.c

#include <ctype.h>

int
strcasecmp(const char *a, const char *b)
{
  int ca, cb;
  do {
     ca = * (unsigned char *)a;
     cb = * (unsigned char *)b;
     ca = tolower(toupper(ca));
     cb = tolower(toupper(cb));
     a++;
     b++;
   } while (ca == cb && ca != '\0');
   return ca - cb;
}

strncasecmp.c

#include <string.h>
#include <ctype.h>

int
strncasecmp(const char *s1, const char *s2, size_t n)
{
  if (n == 0) {
    return 0;
  }

  while (n-- != 0 && tolower(*s1) == tolower(*s2))
  {
    if (n == 0 || *s1 == '\0' || *s2 == '\0') {
      break;
    }
    s1++;
    s2++;
  }

  return tolower(*(unsigned char *) s1) - tolower(*(unsigned char *) s2);
}

strdup.c

#include <stdlib.h>

char *
strdup(const char *s)
{
  char *new;

  if(s == NULL) {
    return NULL;
  }

  new = (char *) malloc(strlen(s) + 1);
  if(new != NULL) {
    strcpy(new, s);
  }

  return new;
}

C compiler doesn't support C++ style comments

A common extension to, even pure, C compilers is to support C++ style single line comments that start with //

Norcroft however doesn't support this extension. Here is a quick shell script using sed to convert // in to a pair of /* and */

convertcomments.sh

#!/bin/sh
sed 'sx//\(.*\)x/*\1 */x' $1 > temp && mv temp $1

and run the command using

convertcomments.sh examplefile.c