Unix on the Beeb

for bbc micro/electron hardware, peripherals & programming issues (NOT emulators!)
RobC
Posts: 1821
Joined: Sat Sep 01, 2007 9:41 pm

Unix on the Beeb

Postby RobC » Fri Nov 03, 2017 6:43 pm

Last week, I built the SIMH PDP-11 emulator for my RiscPC and A540. This runs Unix v7 and works pretty well.

As a bit of fun, I started thinking about getting it running on the Beeb via the ARM co-pro and, after a lot of playing around with many versions of the Norcroft compiler, I was finally able to build a version that works on the Pi co-pro.

Unfortunately, it's painfully slow so isn't really usable but it does work:
IMG_20171103_172728.jpg

IMG_20171103_173608.jpg


In case anyone is mad enough to want to run it, I've attached the disk image with the PDP11 emulator binary, floating point emulator and the startup script. It also needs the Unix v7 disk image (unix_v7_rl.dsk) from here: http://www.jbox.dk/downloads/pdp11-src.zip.

The Unix v7 disk image is 10MB and so needs to be installed on a hard drive in the same directory as the emulator and unixv7 script. To run it do:
*FPE
*PDP11 unixv7

Then at the '@' prompt do:
boot
rl(0,0)rl2unix

As I said, it is *very* slow so be prepared to wait - I may look at building it for the native ARM core to see if I can get it to work a bit faster!
Attachments
PDP.zip
(111.18 KiB) Downloaded 6 times

philb
Posts: 118
Joined: Sat Aug 05, 2017 6:05 pm

Re: Unix on the Beeb

Postby philb » Fri Nov 03, 2017 10:24 pm

Does v7 run natively on the PDP-11 copro? Seems like cutting SIMH out of the equation would be the way to success :D

But of course, what you really want to do is build a Unix kernel that executes on the 6502 directly. DId v7 require an MMU?

RobC
Posts: 1821
Joined: Sat Sep 01, 2007 9:41 pm

Re: Unix on the Beeb

Postby RobC » Fri Nov 03, 2017 10:57 pm

philb wrote:Does v7 run natively on the PDP-11 copro?

I don't think so but I believe that JGH has been looking at getting Unix running on it:
http://mdfs.net/Software/PDP11/BBCUnix/

philb wrote:Seems like cutting SIMH out of the equation would be the way to success

Yes, although this was only a bit of fun after getting the emulator running on my RiscPC and A540. It runs fairly respectably on them and it was easy to port to the co-pro once I'd sorted out the compiler flags for v3 of the Norcroft compiler.

I might look at putting it on Sprow's ARMTDMI copro but I think I'll need to use the GNU toolchain as the Norcroft one won't do floating point.

User avatar
jgharston
Posts: 2759
Joined: Thu Sep 24, 2009 11:22 am
Location: Whitby/Sheffield

Re: Unix on the Beeb

Postby jgharston » Sat Nov 04, 2017 12:12 am

The next step is clearly to run PDP11 BBC BASIC on it. :)

example

Code: Select all

$ bbcbasic
PDP11 BBC BASIC IV Version 0.25
(C) Copyright J.G.Harston 1989,2005-2015
>_

crj
Posts: 322
Joined: Thu May 02, 2013 4:58 pm

Re: Unix on the Beeb

Postby crj » Sat Nov 04, 2017 12:40 am

Wait... this is a PDP-11 running on an emulator framework, ported to the ARM Second processor, which is in turn being emulated by a bit-banging Raspberry Pi. I can't help feeling there must be an easier way. (-8

crj
Posts: 322
Joined: Thu May 02, 2013 4:58 pm

Re: Unix on the Beeb

Postby crj » Sat Nov 04, 2017 1:19 am

philb wrote:But of course, what you really want to do is build a Unix kernel that executes on the 6502 directly. DId v7 require an MMU?

Prodding around a bit, I'd say "yes". The PDP-11 started out life with an optional-extra MMU that allowed remapping of 512-byte pages, and it seems this was relied upon. And the earlier PDP-11s couldn't run a version of Unix as "recent" as v7.

I'm wondering how far one could get by sticking the kernel in main RAM then installing a specially tricked out sideways RAM that had an MMU. You'd limit the process address space to 16Kbytes, but that's surely plenty? (-8

User avatar
hoglet
Posts: 6623
Joined: Sat Oct 13, 2012 6:21 pm
Location: Bristol

Re: Unix on the Beeb

Postby hoglet » Sat Nov 04, 2017 8:43 am

crj wrote:I can't help feeling there must be an easier way. (-8

A couple of levels could be removed by including a PDP11 emulation directly in PiTubeDirect.

RobC
Posts: 1821
Joined: Sat Sep 01, 2007 9:41 pm

Re: Unix on the Beeb

Postby RobC » Sat Nov 04, 2017 9:19 am

jgharston wrote:The next step is clearly to run PDP11 BBC BASIC on it.

Now that would be funny! I'll have to give it a go :D

crj wrote:Wait... this is a PDP-11 running on an emulator framework, ported to the ARM Second processor, which is in turn being emulated by a bit-banging Raspberry Pi. I can't help feeling there must be an easier way. (-8

I'm sure there must be but it was only a bit of fun after getting the PDP-11 emulator running on the Arcs. Having Unix on the PDP-11 copro would be brilliant but would involve a bit of work. Getting the emulator running on the Pi native ARM or ARMTDMI would simplify things a bit and might not be too difficult.

g7jjf
Posts: 353
Joined: Sun Aug 07, 2005 7:29 pm
Location: Notts, England
Contact:

Re: Unix on the Beeb

Postby g7jjf » Sat Nov 04, 2017 11:14 am

Is this supposed to work with the Arm Co-Pro emulation in BeebEm ?

Just tried it and got an 'Abort on prefetch at ED1FB013' when running pdp11.

RobC
Posts: 1821
Joined: Sat Sep 01, 2007 9:41 pm

Re: Unix on the Beeb

Postby RobC » Sat Nov 04, 2017 12:38 pm

g7jjf wrote:Is this supposed to work with the Arm Co-Pro emulation in BeebEm ?

I'd only tested it on the Pi Copro and matchbox - it hangs on the matchbox (possibly due to lack of memory).

Just tested it now and I get the same error in BeebEm - don't know whether it's a problem with its emulation or an issue with something I've done.

philb
Posts: 118
Joined: Sat Aug 05, 2017 6:05 pm

Re: Unix on the Beeb

Postby philb » Sat Nov 04, 2017 6:02 pm

RobC wrote:Having Unix on the PDP-11 copro would be brilliant but would involve a bit of work.


Yeah. It'd be quite a fun project, but the current PDP11 copro (at least the LX9Co one, which is the only one I have any hardware for :D ) doesn't have an MMU either. So I suppose the first order of business would be to add that, which I guess wouldn't be so hard. Shame it's all in VHDL...

Might be a fun thing to work on over the long winter nights though.

RobC
Posts: 1821
Joined: Sat Sep 01, 2007 9:41 pm

Re: Unix on the Beeb

Postby RobC » Mon Nov 06, 2017 6:37 pm

I've now got this running on Sprow's ARM7TDMI copro. It's much more responsive and borders on the usable (at least with my GoSDC - I haven't tried it with the DC yet). It's certainly comparable to my A540.

Logging on as user dmr gives access to a quicker shell which is fairly responsive (relatively speaking!).

I couldn't get it accept the delete key with code 127 for some reason. So, I modified the input code so that delete is configured to send ^H and wipe out the previous character on the display. I've set up dmr's .profile to do stty erase '^H' and it seems to work.

It's kind of fun seeing BBC BASIC running on it!

[Thanks to pstnotpd and Kieran Mockford for posting their work getting Scheme running on the ARM7TDMI copro - this really helped me to understand how to build this using gcc.]

IMG_20171106_175347.jpg

IMG_20171106_174513.jpg
Attachments
pdp11_arm7tdmi.zip
(91.49 KiB) Downloaded 8 times

User avatar
BigEd
Posts: 1495
Joined: Sun Jan 24, 2010 10:24 am
Location: West
Contact:

Re: Unix on the Beeb

Postby BigEd » Mon Nov 06, 2017 6:46 pm

JGH's PDP-11 Basic runs in Unix? I am surprised! Or did you have to do some kind of port? Or am I confused?

RobC
Posts: 1821
Joined: Sat Sep 01, 2007 9:41 pm

Re: Unix on the Beeb

Postby RobC » Mon Nov 06, 2017 6:49 pm

BigEd wrote:JGH's PDP-11 Basic runs in Unix? I am surprised! Or did you have to do some kind of port? Or am I confused?

Yes - it runs on the copro or on real hardware from Unix:
http://mdfs.net/Software/PDP11/BBCBasic/

I just transferred the binary with UxFiler and called it from the Unix shell.

User avatar
BigEd
Posts: 1495
Joined: Sun Jan 24, 2010 10:24 am
Location: West
Contact:

Re: Unix on the Beeb

Postby BigEd » Mon Nov 06, 2017 9:23 pm

That's great!

User avatar
jgharston
Posts: 2759
Joined: Thu Sep 24, 2009 11:22 am
Location: Whitby/Sheffield

Re: Unix on the Beeb

Postby jgharston » Mon Nov 06, 2017 9:40 pm

RobC wrote:Logging on as user dmr gives access to a quicker shell which is fairly responsive (relatively speaking!).
I usually leave it logged on as boot as then its in single-user mode and a lot of multi-user multi-tasking is turned off. ;)

RobC wrote:I couldn't get it accept the delete key with code 127 for some reason.
It took me some time to work out the weird syntax for stty to specify CHR$127 for erase, and then put it in the .rc file. A quick fiddle suggests stty erase '^?' does it. The confusing thing is that it isn't echoed, so lsls<DEL><DEL> displays as lsls but pressing <RET> correctly executes ls.

Edit: the PDP BASIC zip archive includes the ansi program, which if you pipe through (ie bbcbasic | ansi) gives you ANSI screen control and colours - as long as your terminal supports ANSI codes of course. :)

Code: Select all

$ bbcbasic
PDP11 BBC BASIC IV Version 0.25
(C) Copyright J.G.Harston 1989,2005-2015
>_

RobC
Posts: 1821
Joined: Sat Sep 01, 2007 9:41 pm

Re: Unix on the Beeb

Postby RobC » Mon Nov 06, 2017 10:26 pm

jgharston wrote:I usually leave it logged on as boot as then its in single-user mode and a lot of multi-user multi-tasking is turned off.

Thanks - not sure why things like 'ls' were quicker when I logged in as 'dmr' though.

jgharston wrote:A quick fiddle suggests stty erase '^?' does it. The confusing thing is that it isn't echoed, so lsls<DEL><DEL> displays as lsls but pressing <RET> correctly executes ls.

When I tried that, stty reported erase '^_' even though I'd set it to '^?'! It was originally set to '#' and behaved as you describe. By setting delete to ^H and modifying my terminal routine, I was at least able to get it to erase the characters that had been deleted.

With delete set to output 0x7F (as you'd expect), it just gave a prompt on a new line every time. I've now got Ultrix and BSD 2.9 boot disks working so I'll see if they behave any better (from first impressions I think they do).

One odd thing I've seen in bbcbasic is that VDU 19, 0, p, 0, 0, 0 behaves as expected for all values of p apart from 4. When I try to make the background blue, I think the foreground text goes black and it hangs until I press a key (can recheck this).

dominicbeesley
Posts: 464
Joined: Tue Apr 30, 2013 11:16 am

Re: Unix on the Beeb

Postby dominicbeesley » Tue Nov 07, 2017 8:58 am

Nice one Rob,

I had a go at getting ucLinux to boot a few years ago on the Sprow ARM copro, it worked ok! I can't remember now how I had it set up in terms of discs, I suspect it ran from RAM disc...

I then went down the rabbit hole of adding a Flash ROM to the board and trying to get that to hold the Kernel, then we had a child....Busy box is worth a look if it will port to whichever *nix you're using to save on expensive disc accesses...

D

RobC
Posts: 1821
Joined: Sat Sep 01, 2007 9:41 pm

Re: Unix on the Beeb

Postby RobC » Tue Nov 07, 2017 1:49 pm

Thanks Dominic - it's fun to see these minicomputer OSs come to life on a Beeb... (Just realised that I forgot to reply to your e-mails about Flex! Sorry - the period just before the London show was very busy.)

I think I'll have a look at putting it on the Pi copro next but that'll probably require more memory than the Pi core currently supports.

User avatar
jgharston
Posts: 2759
Joined: Thu Sep 24, 2009 11:22 am
Location: Whitby/Sheffield

Re: Unix on the Beeb

Postby jgharston » Tue Nov 07, 2017 10:19 pm

RobC wrote:One odd thing I've seen in bbcbasic is that VDU 19, 0, p, 0, 0, 0 behaves as expected for all values of p apart from 4. When I try to make the background blue, I think the foreground text goes black and it hangs until I press a key (can recheck this).
Is that using the ANSI VDU driver? Unix does not understand BBC VDU codes, so sending 19,0,p,0,0,0 will cause the Unix terminal to do whatever the Unix terminal happens to do in response to those character codes. I think CHR$19 is 'pause output', I remember using pressing Ctrl-S for Stop/Start back at Uni.

The ANSI VDU driver does not implement VDU 19 as the ANSI console has no concept of palettes. It implements:
VDU 7,8,9,10,11,12,13
VDU 17 (text colour)
VDU 20 (reset colours)
VDU 22 (mode)
VDU 30 (home)
VDU 31 (tab)
VDU 127
plus characters 32-126, 128-255 sent through unchanged.

Code: Select all

$ bbcbasic
PDP11 BBC BASIC IV Version 0.25
(C) Copyright J.G.Harston 1989,2005-2015
>_

RobC
Posts: 1821
Joined: Sat Sep 01, 2007 9:41 pm

Re: Unix on the Beeb

Postby RobC » Wed Nov 08, 2017 7:41 am

jgharston wrote:Is that using the ANSI VDU driver?

No.

The odd thing is that VDU 19,0,p| works for all other values of p apart from 4. Thinking about it, it's possible that the OS is replacing VDU 4 with some other behaviour - I'll try to do some more digging today.

User avatar
sweh
Posts: 1847
Joined: Sat Mar 10, 2012 12:05 pm
Location: New York, New York
Contact:

Re: Unix on the Beeb

Postby sweh » Thu Nov 09, 2017 1:17 am

Character 4 is the standard Unix EOF character; possibly it's being filtered out? Try doing VDU 19,0,&34,0,0,0 instead...
Rgds
Stephen

RobC
Posts: 1821
Joined: Sat Sep 01, 2007 9:41 pm

Re: Unix on the Beeb

Postby RobC » Thu Nov 09, 2017 12:15 pm

sweh wrote:Character 4 is the standard Unix EOF character; possibly it's being filtered out? Try doing VDU 19,0,&34,0,0,0 instead...

Spot on - &34 set it to blue (so did &14 and &24) so the OS is treating &04 differently.

User avatar
fordp
Posts: 920
Joined: Sun Feb 12, 2012 9:08 pm
Location: Kent, England

Re: Unix on the Beeb

Postby fordp » Thu Nov 09, 2017 1:11 pm

I am guessing you built in for the 26 Bit ARM 2 mode?

Maybe on the Pi CoPro you could build it for the Native ARM mode. This would make it a lot faster ;)
FordP (Simon Ellwood)
Time is an illusion. Lunchtime, doubly so!

User avatar
jgharston
Posts: 2759
Joined: Thu Sep 24, 2009 11:22 am
Location: Whitby/Sheffield

Re: Unix on the Beeb

Postby jgharston » Thu Nov 09, 2017 1:21 pm

Ah, what will be happening is that the Unix console will be sending anything it doesn't understand to the the system the emulator is running on. Which in this case is ultimately the BBC VDU, so by the accident of you running the PDP11 emulator on a system with the BBC VDU drivers, you are sending to the BBC VDU drivers.

I've never been able to get SIMH to compile on my RISC OS system, so only have experience of using it on Windows, and of course Windows does not understand BBC VDU sequences. I'll have a go with your build.

Code: Select all

$ bbcbasic
PDP11 BBC BASIC IV Version 0.25
(C) Copyright J.G.Harston 1989,2005-2015
>_

RobC
Posts: 1821
Joined: Sat Sep 01, 2007 9:41 pm

Re: Unix on the Beeb

Postby RobC » Thu Nov 09, 2017 4:09 pm

fordp wrote:I am guessing you built in for the 26 Bit ARM 2 mode?

Yes for the ARM Evaluation system version but the ARM7TDMI version is 32-bit. It is much faster on the ARM7TDMI copro and borders on usable.

fordp wrote:Maybe on the Pi CoPro you could build it for the Native ARM mode. This would make it a lot faster ;)

My plan is to look at this next but I need to figure out how to build C applications for it first. The ARM7TDMI has an application note which goes through how to do it so that was easier...

RobC
Posts: 1821
Joined: Sat Sep 01, 2007 9:41 pm

Re: Unix on the Beeb

Postby RobC » Thu Nov 09, 2017 4:14 pm

jgharston wrote:Ah, what will be happening is that the Unix console will be sending anything it doesn't understand to the the system the emulator is running on. Which in this case is ultimately the BBC VDU, so by the accident of you running the PDP11 emulator on a system with the BBC VDU drivers, you are sending to the BBC VDU drivers.

That makes sense.

jgharston wrote:I've never been able to get SIMH to compile on my RISC OS system, so only have experience of using it on Windows, and of course Windows does not understand BBC VDU sequences. I'll have a go with your build.

I just went for the PDP-11 emulator from here:
http://www.jbox.dk/sanos/pdp11.htm

Using the Norcroft compiler, I just plugged OS_WriteC, OS_Byte 145 and OS_Byte 152 into the terminal routines.

Boydie
Posts: 148
Joined: Sat Oct 24, 2015 8:25 am
Location: Sunny Wigan

Re: Unix on the Beeb

Postby Boydie » Thu Nov 09, 2017 5:25 pm

Is it compiled for arm1 or arm2? ie Will it work on a real arm evaluation system?

RobC
Posts: 1821
Joined: Sat Sep 01, 2007 9:41 pm

Re: Unix on the Beeb

Postby RobC » Thu Nov 09, 2017 5:52 pm

Boydie wrote:Is it compiled for arm1 or arm2? ie Will it work on a real arm evaluation system?

ARM2. I might be able to build it for ARM1 with an early version of the Norcroft compiler - it gave a lot of errors when I tried but it wouldn't be impossible to port.

RobC
Posts: 1821
Joined: Sat Sep 01, 2007 9:41 pm

Re: Unix on the Beeb

Postby RobC » Fri Nov 10, 2017 2:55 pm

I've been looking at building the PDP11 emulator for the native Pi copro and have now figured out how to build C executables for it and have the stubs library connected up.

Unfortunately, the emulator needs more than the current limit of 2MB as it is complaining that it can't allocate enough memory for its buffers. (I had similar issues on the Matchbox ARM2 core).


Return to “hardware”

Who is online

Users browsing this forum: No registered users and 12 guests