Pi-based Co-Pro on the cheap - 100MHz 6502 for £10? (now 274MHz)

for bbc micro/electron hardware, peripherals & programming issues (NOT emulators!)
sundbyk
Posts: 90
Joined: Thu Jun 16, 2016 10:03 am
Contact:

Re: Pi-based Co-Pro on the cheap - 100MHz 6502 for £10?

Post by sundbyk » Tue Nov 22, 2016 11:44 am

sundbyk wrote:
hoglet wrote:
hoglet wrote: What I can't currently explain is why on the Model B the initial language transfer always hangs. This seems like a genuine bug that we should try to track down.
This is now resolved, and a fix will be present in the next release.

What was happening was the write of &8E to &FEE0 was being missed, because the Pi is slower to start than the Beeb, and this write happens (I think) before the initial reset message handshake.

This write is important, because it enables tube interrupts.

To work around this, I've just made the tube emulation enable interrupts by default on reset, which seems to solve the hang.

Dave
Excellent, will test this later today.

Kjell S.
It worked perfect. Booted into basic with 6502 Coprocessor active.

Kjell S.
***************************
Kjell Sundby
Web: http://www.sundby.com
****************************

dp11
Posts: 870
Joined: Sun Aug 12, 2012 8:47 pm
Contact:

Re: Pi-based Co-Pro on the cheap - 100MHz 6502 for £10?

Post by dp11 » Wed Nov 23, 2016 10:05 pm

Just pushed some small changes so that the fast 6502 core doesn't have its memory in kernel.img.

This for the single core build reduces the kernel.img from 269K to 105K.

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

Re: Pi-based Co-Pro on the cheap - 100MHz 6502 for £10?

Post by fordp » Fri Nov 25, 2016 8:21 am

Hi All,

It is one year today since the Raspberry Pi Zero was released and I posted the idea of a Pi based co-pro.

Well done everybody (https://github.com/hoglet67/PiTubeDirec ... ledgements) and in particular Dave (Hoglet) who has done most of the the work.

We are well on the way to preserving "Acorn computers" for future generations.

What is even more pleasing is we have opened up the possibility to extend computers of the past with a very low bar to entry.

Here is to the the next 12 months.

P.S. Lets hope I find time to contribute sometime soon too!
FordP (Simon Ellwood)
Time is an illusion. Lunchtime, doubly so!

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

Re: Pi-based Co-Pro on the cheap - 100MHz 6502 for £10?

Post by hoglet » Mon Nov 28, 2016 11:05 am

fordp wrote: Here is to the the next 12 months.
Indeed, there is so much more we could do, if people have the appetite...

The most recent thing being worked on is a native ARM Co Processor with SWI APIs like Sprow's ARM7TDMI Co Pro. This co-exists with all the other Co Pros, and is enabled with *FX 151,230,15.

This work is currently at an early stage and on a branch:
https://github.com/hoglet67/PiTubeDirec ... /nativearm

Enough is working to run BBC Basic V version 1.35.

To say it is fast is a bit of an understatement: :shock:
IMG_0758.JPG
I tried a simple Mandelbrot program and the limiting factor is the speed of plotting individual points over the tube, which was taking up 90% of the time.

Other things that are in progress or in plan are:
- Dominic's further work on speeding up the 6502 (on the fast_6502 branch)
- Adding a 6809 core
- Adding a PDP11 core

Dave

sundbyk
Posts: 90
Joined: Thu Jun 16, 2016 10:03 am
Contact:

Re: Pi-based Co-Pro on the cheap - 100MHz 6502 for £10?

Post by sundbyk » Mon Nov 28, 2016 11:14 am

Very impressive,
Good work,

Kjell S.
***************************
Kjell Sundby
Web: http://www.sundby.com
****************************

User avatar
Lardo Boffin
Posts: 1378
Joined: Thu Aug 06, 2015 6:47 am
Contact:

Re: Pi-based Co-Pro on the cheap - 100MHz 6502 for £10?

Post by Lardo Boffin » Mon Nov 28, 2016 1:33 pm

I hate to ask elementary school level questions but I'm going to anyway...

I have an external converter for the model B (PiTubeDirect v1.2) and will need a cable for it:-
IMG_5131.JPG
I assume the cable will connect onto the pins and the block will plug onto the Pi? So presumably a cable such as the one below should be good?
IMG_5132.JPG
I know it only a few quid if I order the wrong one but hate to waste money!
BBC model B 32k issue 4, 16k sideways RAM, Watford 12 ROM board, Acorn 6502 coproc
BBC model B 32k issue 7, turboMMC, Opus Challenger 3 512k, Pi 3 coproc
USA Model B
BBC Master, Datacentre + HDD, pi co-proc, econet

sundbyk
Posts: 90
Joined: Thu Jun 16, 2016 10:03 am
Contact:

Re: Pi-based Co-Pro on the cheap - 100MHz 6502 for £10?

Post by sundbyk » Mon Nov 28, 2016 1:53 pm

Lardo Boffin wrote:I hate to ask elementary school level questions but I'm going to anyway...

I have an external converter for the model B (PiTubeDirect v1.2) and will need a cable for it:-

IMG_5131.JPG

I assume the cable will connect onto the pins and the block will plug onto the Pi? So presumably a cable such as the one below should be good?

IMG_5132.JPG

I know it only a few quid if I order the wrong one but hate to waste money!
Hi,

That is correct.

Please check the the cable is connected the right way before turning power on.
Image

Kjell S.
***************************
Kjell Sundby
Web: http://www.sundby.com
****************************

iainjh
Posts: 308
Joined: Mon May 14, 2012 11:18 am
Contact:

Re: Pi-based Co-Pro on the cheap - 100MHz 6502 for £10?

Post by iainjh » Mon Nov 28, 2016 2:07 pm

Hi, is this the latest version?:

viewtopic.php?f=3&t=11325&start=300#p152451

if not, is there a pre-built version of the fast 6502 branch https://github.com/hoglet67/PiTubeDirec ... /fast_6502 that I can try out?

and does that contain z80 /other cores too?

thanks!! :):)

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

Re: Pi-based Co-Pro on the cheap - 100MHz 6502 for £10?

Post by hoglet » Mon Nov 28, 2016 2:15 pm

Hi Iain,
iainjh wrote: Hi, is this the latest version?:

viewtopic.php?f=3&t=11325&start=300#p152451
That is the latest "official" version.
iainjh wrote: if not, is there a pre-built version of the fast 6502 branch https://github.com/hoglet67/PiTubeDirec ... /fast_6502 that I can try out?
I believe the latest code in git has some bugs (to do with the carry flag).

It's also untested on anything apart from the Pi Zero.

Do you really want/need this (275MHz) rather than the released version (225MHz)?
iainjh wrote: and does that contain z80 /other cores too?
Yes it does.

Dave

dp11
Posts: 870
Joined: Sun Aug 12, 2012 8:47 pm
Contact:

Re: Pi-based Co-Pro on the cheap - 100MHz 6502 for £10?

Post by dp11 » Mon Nov 28, 2016 2:24 pm

There is an issue in the 274MHz 6502 version. I'm likely to be busy with other things this week. If anyone had a moment to binary chop the commits and see where it sneaked in I would be greatful, I can then fix it. I'm told in Elite " The difference is this: when the ship explodes with a noise, the random pixels overspill the frame and do not successfully undraw, leaving a mess during the next few seconds of scroll text."

The current version passes the Dorman tests and is likely to run basic correctly, so I think the issue is with a rarely used instruction.

User avatar
Lardo Boffin
Posts: 1378
Joined: Thu Aug 06, 2015 6:47 am
Contact:

Re: Pi-based Co-Pro on the cheap - 100MHz 6502 for £10?

Post by Lardo Boffin » Mon Nov 28, 2016 2:54 pm

sundbyk wrote:
Lardo Boffin wrote:I hate to ask elementary school level questions but I'm going to anyway...

I have an external converter for the model B (PiTubeDirect v1.2) and will need a cable for it:-

IMG_5131.JPG

I assume the cable will connect onto the pins and the block will plug onto the Pi? So presumably a cable such as the one below should be good?

IMG_5132.JPG

I know it only a few quid if I order the wrong one but hate to waste money!
Hi,

That is correct.

Please check the the cable is connected the right way before turning power on.
Image

Kjell S.
Many thanks Kjell.

Also do I need to leave J1 on to get power from the Beeb?
BBC model B 32k issue 4, 16k sideways RAM, Watford 12 ROM board, Acorn 6502 coproc
BBC model B 32k issue 7, turboMMC, Opus Challenger 3 512k, Pi 3 coproc
USA Model B
BBC Master, Datacentre + HDD, pi co-proc, econet

sundbyk
Posts: 90
Joined: Thu Jun 16, 2016 10:03 am
Contact:

Re: Pi-based Co-Pro on the cheap - 100MHz 6502 for £10?

Post by sundbyk » Mon Nov 28, 2016 3:25 pm

Yes, you need to use jp 1 to get power from the BBC.
Do not use external power and jp 1 power at the same time.

Kjell S.
***************************
Kjell Sundby
Web: http://www.sundby.com
****************************

User avatar
Lardo Boffin
Posts: 1378
Joined: Thu Aug 06, 2015 6:47 am
Contact:

Re: Pi-based Co-Pro on the cheap - 100MHz 6502 for £10?

Post by Lardo Boffin » Mon Nov 28, 2016 3:30 pm

sundbyk wrote:Yes, you need to use jp 1 to get power from the BBC.
Do not use external power and jp 1 power at the same time.

Kjell S.
Thanks! I will leave the PI's power supply in its box!
BBC model B 32k issue 4, 16k sideways RAM, Watford 12 ROM board, Acorn 6502 coproc
BBC model B 32k issue 7, turboMMC, Opus Challenger 3 512k, Pi 3 coproc
USA Model B
BBC Master, Datacentre + HDD, pi co-proc, econet

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

Re: Pi-based Co-Pro on the cheap - 100MHz 6502 for £10?

Post by hoglet » Mon Nov 28, 2016 7:02 pm

Hi Dominic,
dp11 wrote:There is an issue in the 274MHz 6502 version. I'm likely to be busy with other things this week. If anyone had a moment to binary chop the commits and see where it sneaked in I would be greatful, I can then fix it. I'm told in Elite " The difference is this: when the ship explodes with a noise, the random pixels overspill the frame and do not successfully undraw, leaving a mess during the next few seconds of scroll text."
The bug was introduced in commit:
3388f80c394d4f51a753ec7db29b5fa32f0af20f

Was that change intended to be macro-only? (i.e. the binary should be the same?)

Dave

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

Re: Pi-based Co-Pro on the cheap - 100MHz 6502 for £10?

Post by hoglet » Mon Nov 28, 2016 7:15 pm

Dominic,

The bug was introduced by:

Code: Select all

.macro WRAP_MEMORY
#if defined(CLEAR_MEMORY_OVERFLOW)        
        bic     r0, r0, #0x10000
#endif
.endm 
Defining the symbol CLEAR_MEMORY_OVERFLOW fixes the issue.

But it does reduce performance from 274MHz to 267MHz.

If we eventually use the MMU with 8K pages, then we could possibly map the first 8K page into virtual address space twice and then not need to explicitely wrap r0 at 64K. That's if the Pi data cache will work with this.

Dave
Last edited by hoglet on Mon Nov 28, 2016 7:35 pm, edited 2 times in total.

iainjh
Posts: 308
Joined: Mon May 14, 2012 11:18 am
Contact:

Re: Pi-based Co-Pro on the cheap - 100MHz 6502 for £10?

Post by iainjh » Mon Nov 28, 2016 7:18 pm

thanks for confirming the latest official release. And yes, 225mhz is enough :)

I was just wondering which was the actual latest so i can start playing with getting DOS and others also set up on my CF card image. thanks!


hoglet wrote:Hi Iain,
iainjh wrote: Hi, is this the latest version?:

viewtopic.php?f=3&t=11325&start=300#p152451
That is the latest "official" version.
iainjh wrote: if not, is there a pre-built version of the fast 6502 branch https://github.com/hoglet67/PiTubeDirec ... /fast_6502 that I can try out?
I believe the latest code in git has some bugs (to do with the carry flag).

It's also untested on anything apart from the Pi Zero.

Do you really want/need this (275MHz) rather than the released version (225MHz)?
iainjh wrote: and does that contain z80 /other cores too?
Yes it does.

Dave

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

Re: Pi-based Co-Pro on the cheap - 100MHz 6502 for £10?

Post by hoglet » Mon Nov 28, 2016 7:20 pm

iainjh wrote: I was just wondering which was the actual latest so i can start playing with getting DOS and others also set up on my CF card image. thanks!
I'd definitely stick with the official release.

The more people we can get using and testing that, the more confidence we will have that it's solid.

It's always good to build on solid foundations!

Dave

dp11
Posts: 870
Joined: Sun Aug 12, 2012 8:47 pm
Contact:

Re: Pi-based Co-Pro on the cheap - 100MHz 6502 for £10?

Post by dp11 » Mon Nov 28, 2016 10:41 pm

Thanks Dave for that. I wouldn't have guessed that elite relied on the memory wrapping. I assume it loads a constant of say -1 0xffff and adds say Y to that. I will fix it by implementing memory mapping to get the performance back.

Are people interested in fast 6502? I've been working on it as a challenge. I think I have a way to get another doubling of speed might be more, but it would be quiet a bit of work. My metal simulation thinks its worth a try.

Thoughts should I have a relaxing Xmas or should I write a lot of code?

User avatar
tricky
Posts: 3164
Joined: Tue Jun 21, 2011 8:25 am
Contact:

Re: Pi-based Co-Pro on the cheap - 100MHz 6502 for £10?

Post by tricky » Tue Nov 29, 2016 7:13 am

dp11 wrote:...
Thoughts should I have a relaxing Xmas or should I write a lot of code?
That is my idea of a relaxing Xmas, or any holiday really ;)

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

Re: Pi-based Co-Pro on the cheap - 100MHz 6502 for £10?

Post by BigEd » Tue Nov 29, 2016 9:02 am

Anyone interested in a further doubling of speed?? Oh yes! (But how is that even possible...)

torne
Posts: 5
Joined: Wed Nov 02, 2016 4:26 pm
Contact:

Re: Pi-based Co-Pro on the cheap - 100MHz 6502 for £10?

Post by torne » Tue Nov 29, 2016 4:26 pm

hoglet wrote:The most recent thing being worked on is a native ARM Co Processor with SWI APIs like Sprow's ARM7TDMI Co Pro. This co-exists with all the other Co Pros, and is enabled with *FX 151,230,15.

This work is currently at an early stage and on a branch:
https://github.com/hoglet67/PiTubeDirec ... /nativearm
This is really interesting as I have some things I'd like to run on native ARM :)
One question I have here is that now the GPU is handling (some of?) the work of implementing the tube interface, what are the interrupt timing constraints on the actual ARM core like? Does the latency still need to be capped to keep everything working, or would it now be possible for the CPU to take an arbitrarily long time to respond to stuff as long as it leaves the GPU alone?

My ideal setup here would be if the Tube interface was basically just a driver that didn't care what the rest of the program running on the ARM was doing at all; is that at all feasible?

dp11
Posts: 870
Joined: Sun Aug 12, 2012 8:47 pm
Contact:

Re: Pi-based Co-Pro on the cheap - 100MHz 6502 for £10?

Post by dp11 » Tue Nov 29, 2016 7:00 pm

Just had a free hour. I've pushed a commit that now uses 4K pages so the >64K access are now wrapped by the mmu.
Performance is now back. I haven't tested elite, but it passes dorman tests and my simple memory wrapping test.

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

Re: Pi-based Co-Pro on the cheap - 100MHz 6502 for £10?

Post by BigEd » Tue Nov 29, 2016 8:30 pm

Excellent - tested with Elite and the attract sequence works as it should!

dp11
Posts: 870
Joined: Sun Aug 12, 2012 8:47 pm
Contact:

Re: Pi-based Co-Pro on the cheap - 100MHz 6502 for £10?

Post by dp11 » Tue Nov 29, 2016 8:35 pm

Thanks so much for testing.

Not much work to add paging now.

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

Re: Pi-based Co-Pro on the cheap - 100MHz 6502 for £10?

Post by hoglet » Tue Nov 29, 2016 8:44 pm

torne wrote: My ideal setup here would be if the Tube interface was basically just a driver that didn't care what the rest of the program running on the ARM was doing at all; is that at all feasible?
Although some of the tube interface emulation is running on the GPU, a good chunk is still running on the ARM. In the new Native ARM Co Pro this runs as part of a GPU mailbox interrupt handler. The program running on the ARM can do pretty much anything it wants, as long as it does't masked FIQ interrupts (for more than a few cycles).

That's the theory anyway!

Dave

torne
Posts: 5
Joined: Wed Nov 02, 2016 4:26 pm
Contact:

Re: Pi-based Co-Pro on the cheap - 100MHz 6502 for £10?

Post by torne » Tue Nov 29, 2016 9:55 pm

hoglet wrote:
torne wrote: My ideal setup here would be if the Tube interface was basically just a driver that didn't care what the rest of the program running on the ARM was doing at all; is that at all feasible?
Although some of the tube interface emulation is running on the GPU, a good chunk is still running on the ARM. In the new Native ARM Co Pro this runs as part of a GPU mailbox interrupt handler. The program running on the ARM can do pretty much anything it wants, as long as it does't masked FIQ interrupts (for more than a few cycles).
I can treat FIQ as nonmaskable and route all other interrupts to IRQ, sure. Most OSes don't bother using FIQ anyway and it's often "stolen" by lower layers of the software to use as an NMI. I'll take a look when I get a chance to see how I might plug the PiTubeDirect code into the semihosted environment library I wrote to port various things to bare metal :)

User avatar
Lardo Boffin
Posts: 1378
Joined: Thu Aug 06, 2015 6:47 am
Contact:

Re: Pi-based Co-Pro on the cheap - 100MHz 6502 for £10?

Post by Lardo Boffin » Thu Dec 01, 2016 1:57 pm

sundbyk wrote:
Lardo Boffin wrote:I hate to ask elementary school level questions but I'm going to anyway...

I have an external converter for the model B (PiTubeDirect v1.2) and will need a cable for it:-

IMG_5131.JPG

I assume the cable will connect onto the pins and the block will plug onto the Pi? So presumably a cable such as the one below should be good?

IMG_5132.JPG

I know it only a few quid if I order the wrong one but hate to waste money!
Hi,

That is correct.

Please check the the cable is connected the right way before turning power on.
Image

Kjell S.
One last question (at the risk of sounding like Columbo) - is this the right way round? Having read the comment about getting it right I don't want to kill anything!
IMG_5141.JPG
It will be going into the Beeb notch up as shown and the notch side of the cable will be on the side of the connector that is not visible in the photo. I.e. the smooth side of the socket is facing the camera.

Lardo
BBC model B 32k issue 4, 16k sideways RAM, Watford 12 ROM board, Acorn 6502 coproc
BBC model B 32k issue 7, turboMMC, Opus Challenger 3 512k, Pi 3 coproc
USA Model B
BBC Master, Datacentre + HDD, pi co-proc, econet

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

Re: Pi-based Co-Pro on the cheap - 100MHz 6502 for £10?

Post by fordp » Thu Dec 01, 2016 2:02 pm

hoglet wrote: Indeed, there is so much more we could do, if people have the appetite...
Dave
Oh no I just came up with another crazy idea.

How about tunnelling Econet packets through the Wired Ethernet or Pi3 WiFi ?

You can shoot me now ;)
FordP (Simon Ellwood)
Time is an illusion. Lunchtime, doubly so!

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

Re: Pi-based Co-Pro on the cheap - 100MHz 6502 for £10?

Post by hoglet » Thu Dec 01, 2016 2:41 pm

Lardo Boffin wrote: It will be going into the Beeb notch up as shown and the notch side of the cable will be on the side of the connector that is not visible in the photo. I.e. the smooth side of the socket is facing the camera.
That looks right to me.

User avatar
kieranhj
Posts: 755
Joined: Sat Sep 19, 2015 10:11 pm
Location: Farnham, Surrey, UK
Contact:

Re: Pi-based Co-Pro on the cheap - 100MHz 6502 for £10?

Post by kieranhj » Sun Dec 04, 2016 2:43 pm

Just want to add that there's another happy customer here. Just got my PI zero copro working (with Kjell's level shifter - thank you!) on both my Model B and Master, reporting 6502 @ 225MHz - amazing! :) This will come in handy when Simon & I get round to our plan of writing Geometry Wars for the Beeb + 6502 copro. :D

Just to note that the newer build in the thread works with my Master Turbo - I can successfully switch between the internal & external Tubes and get the expected results (4MHz seems less Turbo now ;) ) This was not the case with the older build which made my Master barf big time.
Bitshifters Collective | Retro Code & Demos for BBC Micro & Acorn computers | https://bitshifters.github.io/

Post Reply