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

for bbc micro/electron hardware, peripherals & programming issues (NOT emulators!)
User avatar
BigEd
Posts: 1983
Joined: Sun Jan 24, 2010 10:24 am
Location: West
Contact:

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

Post by BigEd » Mon Jun 19, 2017 10:23 am

Here's the link to the diamondback release candidate: https://github.com/hoglet67/PiTubeDirec ... ndback-rc0

Edit: note that rc0 was succeeded by rc1 and later by rc2. You can always see the latest here:
https://github.com/hoglet67/PiTubeDirect/releases
Last edited by BigEd on Mon Dec 18, 2017 5:59 pm, edited 1 time in total.

User avatar
guidol
Posts: 38
Joined: Sun Nov 20, 2016 10:29 am
Location: Mudanya - Turkey
Contact:

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

Post by guidol » Mon Jun 19, 2017 10:50 am

dp11 wrote:Please wipe the SDCARD and use the diamondback release. We have changed the build structure to be simpler so less files are needed.
OK :-)
seems to be better....
Now I also used the debug-kernel (some time ago when I last used the PiTube it allways had debug in the kernel)

Do work at 700Mhz, but when I uncomment

# clock frequency override
# all pis bar zero W default to the correct frequency uncomment for pi zero W
arm_freq=1000

the the Pi-Zero-W doenst seem to boot, because it doenst show TUBE and doesnt output debug-code :-(


when the Pi-Zero-W starts with the "normal" 700Mhz then the debug shows:

Code: Select all

**********     Raspberry Pi BBC Micro Coprocessor     **********


    FIRMWARE_VERSION : 573f5f3d
         BOARD_MODEL : 00000000
      BOARD_REVISION : 009000c1
   BOARD_MAC_ADDRESS : e5eb27b8 6361e0c7
        BOARD_SERIAL : eee5c7e0 00000000
           EMMC_FREQ :    250.000 MHz    250.000 MHz    250.000 MHz
           UART_FREQ :      3.000 MHz   1000.000 MHz   1000.000 MHz
            ARM_FREQ :    700.000 MHz    700.000 MHz    700.000 MHz
           CORE_FREQ :    350.000 MHz    350.000 MHz    350.000 MHz
            V3D_FREQ :    250.000 MHz    250.000 MHz    250.000 MHz
           H264_FREQ :    250.000 MHz    250.000 MHz    250.000 MHz
            ISP_FREQ :    250.000 MHz    250.000 MHz    250.000 MHz
          SDRAM_FREQ :    400.000 MHz    400.000 MHz    400.000 MHz
          PIXEL_FREQ :      0.000 MHz  -1894.967 MHz  -1894.967 MHz
            PWM_FREQ :      0.000 MHz    500.000 MHz    500.000 MHz
           CORE TEMP :  35.78 °C
        CORE VOLTAGE :   1.20 V
     SDRAM_C VOLTAGE :   1.20 V
     SDRAM_P VOLTAGE :   1.20 V
     SDRAM_I VOLTAGE :   1.20 V
            CMD_LINE : dma.dmachans=0x7f35 bcm2708_fb.fbwidth=656 bcm2708_fb.fbheight=416 bcm2708.boardrev=0x9000c1 bcm2708.serial=0xeee5c7e0 smsc95xx.macaddr=B8:27:EB:E5:C7:E0 bcm2708_fb.fbswap=1 bcm2708.uart_clock=3000000 vc_mem.mem_base=0x1fa00000 vc_mem.mem_size=0x20000000  copro=0 copro1speed=3 tube_delay=0 elk_mode=0
               COPRO : 0
Tube ULA sample delay  0
emulator speed 3
Copro Memory size 0
Raspberry Pi Direct 0 65C02 (65tube) Client

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

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

Post by dp11 » Mon Jun 19, 2017 11:15 am

Pi Zero W isn't really tested by the developers as we don't have one.

You could try replacing the fixup start and bootcode files from https://github.com/raspberrypi/firmware ... aster/boot

User avatar
guidol
Posts: 38
Joined: Sun Nov 20, 2016 10:29 am
Location: Mudanya - Turkey
Contact:

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

Post by guidol » Mon Jun 19, 2017 12:07 pm

dp11 wrote: You could try replacing the fixup start and bootcode files from https://github.com/raspberrypi/firmware ... aster/boot
Allright :)
I replaced bootcode.bin , fixup_cd.dat and start_cd.elf
(any other file to replace?)

Now the ARM-frequence shows up as
ARM_FREQ : 1000.000 MHz 1000.000 MHz 1000.000 MHz
without uncommenting the "arm_freq=1000" in config.txt

NEW from https://github.com/raspberrypi/firmware ... aster/boot :
19.06.2017 14:37 50.216 bootcode.bin
19.06.2017 14:37 2.593 fixup_cd.dat
19.06.2017 14:37 660.036 start_cd.elf

OLD:
06.05.2017 12:04 17.932 bootcode.bin
06.05.2017 12:04 2.509 fixup_cd.dat
06.05.2017 12:04 615.896 start_cd.elf

WOW - bootcode more than 100% bigger

PS: the Core 9 - 6809 CPU seems to have a (known?) problem?:

many-may times : m6809-run: (at PC=F803) invalid opcode '71' in the serial log
cycle counter = 8275001472
I_CACHE_MISS = 2937151
D_CACHE_MISS = 76801
Attachments
Pi0W_Master_2.jpg
Pi0W_Master_1.jpg
Last edited by guidol on Mon Jun 19, 2017 12:45 pm, edited 1 time in total.

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

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

Post by dp11 » Mon Jun 19, 2017 12:37 pm

Yep the newer bootcode is bigger as it does netboot stuff, but is also slower and so the PI is unlikely to power up in tube mode. Which is why I'm trying to keep the old bootcode.

User avatar
guidol
Posts: 38
Joined: Sun Nov 20, 2016 10:29 am
Location: Mudanya - Turkey
Contact:

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

Post by guidol » Mon Jun 19, 2017 12:47 pm

dp11 wrote:Yep the newer bootcode is bigger as it does netboot stuff, but is also slower and so the PI is unlikely to power up in tube mode. Which is why I'm trying to keep the old bootcode.
But I dont know if there is a older bootcode without netboot for the "new" Pi-Zero-W - the the only chance would be a Pi-Zero-nonW?
Or if an "expert" could strip the netboot-code from the bootcode.bin :)

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

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

Post by hoglet » Mon Jun 19, 2017 12:49 pm

guidol wrote: PS: the Core 9 - 6809 CPU seems to have a (known?) problem?:

many-may times : m6809-run: (at PC=F803) invalid opcode '71' in the serial log
cycle counter = 8275001472
I_CACHE_MISS = 2937151
D_CACHE_MISS = 76801
You get this when you switch from the 6502 to the 6809 Co Pro without pressing Ctrl-Break.

I think it happens because memory is not cleared when switching Co Pros. If you then just do a normal break, the 6809 Co Pro sees the memory contents left by the 6502 Co Pro and gets confused and ends up jumping to &F803 which is data (hence the error).

The fix is easy, just remember to do a Ctrl-break. :D

Dave

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

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

Post by fordp » Mon Jun 19, 2017 12:59 pm

hoglet wrote:
guidol wrote: PS: the Core 9 - 6809 CPU seems to have a (known?) problem?:

many-may times : m6809-run: (at PC=F803) invalid opcode '71' in the serial log
cycle counter = 8275001472
I_CACHE_MISS = 2937151
D_CACHE_MISS = 76801
You get this when you switch from the 6502 to the 6809 Co Pro without pressing Ctrl-Break.

I think it happens because memory is not cleared when switching Co Pros. If you then just do a normal break, the 6809 Co Pro sees the memory contents left by the 6502 Co Pro and gets confused and ends up jumping to &F803 which is data (hence the error).

The fix is easy, just remember to do a Ctrl-break. :D

Dave
Is this not a bug in the 6809 ROM, should it not clear the RAM at boot?
FordP (Simon Ellwood)
Time is an illusion. Lunchtime, doubly so!

User avatar
guidol
Posts: 38
Joined: Sun Nov 20, 2016 10:29 am
Location: Mudanya - Turkey
Contact:

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

Post by guidol » Mon Jun 19, 2017 1:00 pm

hoglet wrote:
guidol wrote: You get this when you switch from the 6502 to the 6809 Co Pro without pressing Ctrl-Break.
I'll think about that when switching in the future :)

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

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

Post by hoglet » Mon Jun 19, 2017 1:29 pm

fordp wrote: Is this not a bug in the 6809 ROM, should it not clear the RAM at boot?
It may seem like this is a bug in the Client ROM, but I'd say really it isn't.

Ideally, PiTubeDirect would clear the memory when changing Co Pros (as all Co Pros are actually sharing the same memory). But clearing 16MB of memory takes some time, and in tests this caused unreliability in the Co Pro being detected after switching.

For now, just get into the habit of always using Ctrl-Break after *FX 151,230,N

If you don't do this, you'll just encounter lots of other weird/random things.

Dave

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

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

Post by dp11 » Mon Jun 19, 2017 1:36 pm

*fx 151,230,128+N should clear the memory IIRC

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

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

Post by dp11 » Mon Jun 19, 2017 1:44 pm

I'm pretty sure the Pi 6809 memory is cleared when you swap from 6502 to 6809 and press break. I suspect something on the host might also need clearing

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

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

Post by hoglet » Mon Jun 19, 2017 3:28 pm

dp11 wrote:I'm pretty sure the Pi 6809 memory is cleared when you swap from 6502 to 6809 and press break. I suspect something on the host might also need clearing
You are right, memory is in fact being cleared.

I've looked into this a bit (using the new debugger), and understand what's actually happening. The problem is arising because when you do a normal break, the host sends a 0x80 response to the 6809's reset message, which means "execute code" (i.e. the currently loaded PROGRAM)

As there is no currently loaded program, this is causing the 6809 to start execution at address 0:

Code: Select all

>> d 0
0000 00 00       NEG   $00
0002 00 00       NEG   $00
0004 00 00       NEG   $00
0006 00 00       NEG   $00
...
F7FE 00 00       NEG   $00
F800 F8 2C F8    EORB  $2CF8
F803 71          ??    $F871          <<< Invalid opcode
Looking at the 6809 Client ROM Initialization Code, you can see how this can arise:

Code: Select all

                        ; STARTUP
                        ; =======
                        ; Tube data: via R1: string $00  --  via R2: $7F or $80
                        ;
f850 :                  STARTUP:
f850 : 1a50             	ORCC #$50	; Disable interupts
f852 : 10ceff28         	LDS  #CLISTK	; Use internal stack
f856 : 8d68             	BSR  MEM_INIT	; Reset user memory limits and error handler
f858 : beff90           	LDX  PROGRAM	; Copy current PROGRAM to ADDRESS
f85b : bfff8e           	STX  ADDRESS+2	;  so will re-enter on Soft Break
f85e : 1c00             	ANDCC #$00	; Clear all flags, enable interupts
f860 : 8ef816           	LDX  #BANNER	; Point to startup banner
f863 : bdf933           	JSR  SEND_TXT	; Print it via Tube WRCH protocol
f866 : bdffe7           	JSR  OSNEWL	; SEND_TXT will use 7 bytes on stack
f869 : 4f               	CLRA		; Set A to zero
                        ;	STA  >ESCFLG	; Clear Escape flag
                        ;	ECSFLG will have been cleared when copying ROM/initialising workspace
f86a : bdffee           	JSR  OSWRCH	; Send terminating zero byte
                        			; This will use 3 bytes on stack
f86d : 4f               	CLRA		; Carry Clear to indicate Reset
f86e : bdfa30           	JSR  CLI_WAIT	; Wait for result byte and enter code
                        			; This will use 14 bytes on stack including data transfer
                        			; Data transfer may happen while waiting
                        			; Fall through to CLICOM if nothing executed
                        
                        ; Command line prompt
                        ; ===================
                        ; Allow user to enter *command
                        ;
f871 :                  WARMS:
f871 :                  CLILOOP:
f871 : 10ceff28         	LDS  #CLISTK	; Initially use internal stack
f875 : 8d49             	BSR  COM_INIT	; Reset user memory limits and error handler
f877 : 10feff8a         	LDS  MEMTOP	; Reset stack to top of user memory
f87b : 8effb9           	LDX  #CLICOM	; Make CLICOM the current program to re-enter
f87e : bfff90           	STX  PROGRAM	;  on soft reset
f881 : 1c00             	ANDCC #$00	; Clear all flags, enable interupts
In this particular case, PROGRAM (at f858) is being used before it is set (at f87b).

What's peculiar about this case is that by switching Co Pros we are managing to start the 6809 with just a normal break. That would never be possible with an original Co Processor.

Now, the 6809 Client ROM could quite easily be modified to deal with this case, but I don't want to start creating PiTubeDirect specific Client ROMs, because it will be a maintenance nightmare.

So the answer, as we have always said, is to use Ctrl-Break after *FX 151,230,N

Dave

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

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

Post by hoglet » Fri Jun 23, 2017 10:11 am

There is now a release candidate 1 for Diamondback available:
https://github.com/hoglet67/PiTubeDirect/releases

Diamondback is mostly a bug fix release to Cobra.

Features:
- Implemented elk_mode configuration property (enables patching of 6502 code in Client ROMs for Elk Tube address)
- Updated 6809 Client ROM to 1.01a (fe29364a)

Fixes:
- Fixed a GPU issue that might result in lost read messages if there is a glitch in a0
- Fixed a GPU issue that delayed the tube cycle following a nTube glitch causing random failures
- Fixes an issue with Mini UART initialization than sometimes meant receiving didn't work

Dave

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

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

Post by fordp » Fri Jun 23, 2017 10:18 am

hoglet wrote:
--- Snip ---

What's peculiar about this case is that by switching Co Pros we are managing to start the 6809 with just a normal break. That would never be possible with an original Co Processor.

Now, the 6809 Client ROM could quite easily be modified to deal with this case, but I don't want to start creating PiTubeDirect specific Client ROMs, because it will be a maintenance nightmare.

So the answer, as we have always said, is to use Ctrl-Break after *FX 151,230,N

Dave
It just occurred to me that the correct solution this is to ignore the switch of Copro until there is a Ctrl-Break?
FordP (Simon Ellwood)
Time is an illusion. Lunchtime, doubly so!

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

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

Post by hoglet » Fri Jun 23, 2017 10:20 am

fordp wrote: It just occurred to me that the correct solution this is to ignore the switch of Copro until there is a Ctrl-Break?
Indeed it would, but it's very hard for the Co Pro Tube emulation to tell if the Ctrl key is being held down or not.

User avatar
Elminster
Posts: 2649
Joined: Wed Jun 20, 2012 8:09 am
Location: Essex, UK
Contact:

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

Post by Elminster » Fri Jun 23, 2017 10:26 am

My Kjell pi and pi zero shifters have arrived now (thanks), so can swap out John K pi shifter, and use the zero cable setup to see if I can narrow down why masters work and beebs don't. Could be really really stubborn tarnishing but I have pretty much been at the connectors with an angle grinder now.

User avatar
Elminster
Posts: 2649
Joined: Wed Jun 20, 2012 8:09 am
Location: Essex, UK
Contact:

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

Post by Elminster » Fri Jun 23, 2017 8:19 pm

Not sure if good or bad but the new pizero works fine on the misbehaving beeb. In fact 'faster' than pi2. pi2 gives 270mhz on master, pi zero reports 275mhz on the beeb on the combined average test.

Next is to test the original pi but with the new Kjell shifter that also cuts out all the jumber wires (which tested on master and works fine)

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

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

Post by BigEd » Fri Jun 23, 2017 8:23 pm

Just checking - what version of the software are you using in this latest round of tests?

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

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

Post by dp11 » Fri Jun 23, 2017 8:26 pm

Pizero has a high clock rate and a shorter pipeline than Pi2 . Also make sure when you are comparing speed you are using the same version of Basic. BASIC IV on the master is faster than BASIC II on the Beeb.

User avatar
Elminster
Posts: 2649
Joined: Wed Jun 20, 2012 8:09 am
Location: Essex, UK
Contact:

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

Post by Elminster » Fri Jun 23, 2017 8:28 pm

BigEd wrote:Just checking - what version of the software are you using in this latest round of tests?
Stuck with diamondback pre rc1, because that is what I did all the last lot of testing on

User avatar
Elminster
Posts: 2649
Joined: Wed Jun 20, 2012 8:09 am
Location: Essex, UK
Contact:

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

Post by Elminster » Fri Jun 23, 2017 8:32 pm

dp11 wrote:Pizero has a high clock rate and a shorter pipeline than Pi2 . Also make sure when you are comparing speed you are using the same version of Basic. BASIC IV on the master is faster than BASIC II on the Beeb.
Pi2 Looks to be running fine on Beeb as well with new shifter, so can rule out my ribbon cable. Will leave it running a while.

As you say pi2 runs even slower on Beeb than master. But then no surprise as that has the 6502 instead of the 65c02 with those extra instructions for a better basic. So shows pi zero even better if that is showing better figures on Beeb than pi2 on master.

Will test on the b+ next, haven't tried new pi zero on there as screw in the way which I need to remove.

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

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

Post by dp11 » Fri Jun 23, 2017 8:46 pm

Just to clarify the Pi2 runs at the same speed on a beeb and a master . Basic II runs at the same speed on a beeb and a master.

What you are seeing is the performance difference between BASIC II and basic IV .

User avatar
Elminster
Posts: 2649
Joined: Wed Jun 20, 2012 8:09 am
Location: Essex, UK
Contact:

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

Post by Elminster » Fri Jun 23, 2017 8:58 pm

dp11 wrote:Just to clarify the Pi2 runs at the same speed on a beeb and a master . Basic II runs at the same speed on a beeb and a master.

What you are seeing is the performance difference between BASIC II and basic IV .
But they can only fit basic IV in a 16k rom due to extra instructions in 65c02 so it is indirectly the 65c02 that gives the spend increase.

So if real turns the benchmarks run faster on the master due to the 65c02. But I dare say could argue that one all day.

Edit: okay that is gibberish as we are running on the pi. It has been a long week.

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

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

Post by BigEd » Fri Jun 23, 2017 9:01 pm

You can't run basic 4 on the beeb, but you can run basic 2 on the master - if you do that, you'll see that basic 4 is much the faster basic.

Or, you can run - on the master - a different version of ClockSp which is tuned for Basic 4. There is not, I think, any version of ClockSp which detects and adapts to the different interpreters. Remember, the thing we're trying to compare is the clock speed of the CPU, not the quality of the Basic.

User avatar
Elminster
Posts: 2649
Joined: Wed Jun 20, 2012 8:09 am
Location: Essex, UK
Contact:

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

Post by Elminster » Fri Jun 23, 2017 9:04 pm

Yes I realised that after I clicked posted but I just edited the post, rather than delete.

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

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

Post by BigEd » Fri Jun 23, 2017 9:05 pm

Oops. Those pesky edits!

User avatar
Elminster
Posts: 2649
Joined: Wed Jun 20, 2012 8:09 am
Location: Essex, UK
Contact:

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

Post by Elminster » Fri Jun 23, 2017 9:06 pm

Beeb and Beeb + both working fine with pi2 and new shifter.

So my previous issues are either related to the old shifter or the connection between shifter and the pi. For some reason the masters are more tolerant.

User avatar
Elminster
Posts: 2649
Joined: Wed Jun 20, 2012 8:09 am
Location: Essex, UK
Contact:

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

Post by Elminster » Fri Jun 23, 2017 9:09 pm

BigEd wrote:Oops. Those pesky edits!
I should have just deleted it and then no one would know.

Although I could say that basicIV was rewritten because of 65c02 so therefore faster on master ...... okay bit tenous. #-o

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

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

Post by BigEd » Fri Jun 23, 2017 9:11 pm

I think they did both things - made use of the new opcodes and also revamped some of the algorithms.

Post Reply