Close

Multi-boot Multicomp (Part 2)

A project log for 3-Chip Z80 Design

Combining a Z80 retro design with a modern PSoC CPU.

land-boardscomland-boards.com 11/14/2019 at 15:450 Comments

I've got the BIOS loading for Multi-boot Multicomp. It boots up to the Multi-boot prompt.

>
  Available Commands:

  :ccxxxxiibbbbbb Load Intel-Hex file record
  Rxxxx           Run from address xxxx
  Sddd            System boot
  Iddd            Init: Format directory
  Pddd[,xxxx]     PutSys: write system image[,loadaddress]
                  (No address: re-use last loadaddress)
  Gddd[,xxxx]     GetSys: load system track

  Dxxxx[,yyyy]  Dump memory from xxxx [,to yyyy]
                D (no address) shows next block
  Cxxxx         Change/show memory at xxxx
                CR advances "," quits

  ddd is a decimal volume number,
  xxxx, yyyy is a hexadecimal address.
  Leading zeros may be omitted.
  ESC or ^C aborts.

>

 When I enter "S1" it hangs. I single stepped through the SD code from the PSoC side and it looks like the SD card is working the same as Grant's CP/M boot (build tested earlier).

At the least the PSoC is not hung but there's no more I/O requests from the Z80.

Bank Switching vs MMU

The previous CP/M design does a bank switch with a write to I/O address 0x38. There is no bank switching with the MMU so it's not the case that it needs to swap out the banks. But I'm not sure what the effect of not having an actual EPROM would be in this case. The BIOS gets loaded into the first 2K of SRAM.

The FPGA version of this design had two addresses for switching ROM and SRAM in/out of the first 2KB. That could be done in this instance by re-copying the monitor program into the SRAM, but probably is unnecessary. There's also no writes in the BIOS to the switching although there has to be something somewhere in the code to do the switching otherwise the bottom 2KB would not be accessible. This command won't work:

When you type "reset" you enact a cold reset, 
returning you to the ROM monitor.

SYSRUN Routine

The SYSRUN routine is short:

; SYSRUN - boot (load and run) from system track of selected volume
;-------------------------------------------------------------
sysrun:    call getargs   ; get volume and loadaddress
    call setDskIO
    call readsys          ; read disk contents to loadaddress
    call getlen           ; find loadaddress and length
    ldir                  ; move buffer to image
    ld A,(aciaCtl)        ; message bootdisk and console to 
    and 02h               ; main program - 2 methods, on stack
    rrca                  ; and in alternate BC registers
    xor 01h               ; convert to iobyte...
    push AF               ; ...to save bytes in BIOS
    ld C,A
    ld A,(volume)         ; tell BIOS which is ...
    push AF               ; ...the active bootvolume
    ld B,A
    exx                   ; also make b'=bootdisk, c'=console
    ld HL,(0FFFEh)        ; pop and run location
    jp (HL)               ; bye bye

Limited Ability to Monitor Z80 Activity

It's a pain to hook up the logic analyzer to the Z80. Rev 3 of this board will make it much easier because it brings out all Z80 signals to a 40 pin header.

All of these signals already go to the Z80. It would be nice to be able to break into the PSoC monitor and single step through Z80 code or at least capture the address/data of the bus.

Stuff I Tried

Also tried G1,4000 to read the SD card for image 1 into memory at 0x4000. It hung PuTTY.

- Command G performs the same service, but stops when the 
image is loaded and returns to the monitor prompt. 
This command is useful to examine the image, 
or prepare it for loading onto a volume.

I am able to Change and Dump memory which makes me conclude that the MMU must be functioning correctly.

> C4000
4000 00 40
4001 01 00
> C8000
8000 00 80
8001 01 00
> CC000
C000 00 C0
C001 01 00
> D4000
4000  40 00 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F       @...............
> D8000
8000  80 00 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F       ................
> DC000
C000  C0 00 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F       @...............

SD Card Sector Map

S1 attempts to load sector 0x4000.

Card layout:
sector  --------------------------------------------------------------
0       the first 8 Mbytes unused:  \    Put partition table here
16384   8MB volume 1                |    if desired.
32768   8MB volume 2                |
49152   8MB volume 3                |
        =    .                      |
        =    .                      | 2 Gbyte maximum reserved memory
1949696 end of 1 GB card, or        |
        =    .                      |
        =    .                      |
4161536 8MB volume 254 (RAMDISK)    |
4177920 8BM left unused (disk -1)   /
4194304 unused space to be formatted as FAT partition
------------------------------------------------------------

 16384 dec = 0x4000

Logic Analyzer shows 0xFF in the sector.

Put the SD card into the MultiComp RETRO-EP4CE6 card and it worked so it seems like the card itself is OK.

Not sure if this it doesn't work in this card because the SD card is an SDHC card? Could try this image on an SD card (non-SDHC). Put the image onto a 2 GB card. Didn't boot but this did work:

Read sector from the SD Card
Sector: 0x4000
0000  c3 5c e3 c3 5f e3 7e 00 00 00 00 00 00 00 00 00  .\.._.~.........
0010  00 00 00 00 00 00 20 20 43 43 50 2b 20 76 32 2e  ........CCP+.v2.
0020  32 20 28 43 29 20 31 39 38 36 2c 20 43 2e 42 2e  2.(C).1986,.C.B.
0030  20 46 61 6c 63 6f 6e 65 72 2c 20 54 65 6c 2e 20  .Falconer,.Tel..
0040  28 32 30 33 29 20 32 38 31 2d 31 34 33 38 2c 20  (203).281-1438,.
0050  36 38 30 20 48 61 72 74 66 6f 72 64 20 54 70 6b  680.Hartford.Tpk
0060  2e 2c 20 48 61 6d 64 65 6e 2c 20 43 54 2e 2c 20  .,.Hamden,.CT.,.
0070  55 53 41 00 00 00 00 00 00 00 00 00 00 00 00 00  USA.............
0080  00 00 00 00 00 00 00 00 4e 6f 20 46 69 6c 65 00  ........No.File.
0090  4e 6f 20 72 6f 6f 6d 00 41 6c 6c 20 28 79 2f 4e  No.room.All.(y/N
00a0  29 3f 00 46 69 6c 65 20 65 78 69 73 74 73 00 4e  )?.File.exists.N
00b0  6f 20 55 50 53 48 49 46 54 00 2a fa e7 b7 c8 3d  o.UPSHIFT.*....=
00c0  d6 10 29 3c 20 fc c9 fe 61 d8 fe 7b d0 e6 5f c9  ..)<....a..{.._.
00d0  fe 30 d8 fe 3a 3f c9 3e 0d cd de e0 3e 0a d5 5f  .0..:?.>....>.._
00e0  3e 02 cd 74 e1 d1 c9 fe 0a 38 11 c5 0e 2f 0c c6  >..t.....8.../..
00f0  f6 38 fb c6 0a f5 79 cd de e0 f1 c1 c6 30 18 de  .8....y......0..
0100  3e 0b cd 74 e1 c8 3e 01 18 6a af 32 dc e7 11 bc  >..t..>..j.2....
0110  e7 3a f7 e7 17 38 10 1a b7 20 0c cd 27 e1 c0 3c  .:...8......'..<
0120  12 cd 27 e1 c0 12 c9 3e 0f cd 74 e1 3c c9 3e 10  ..'....>..t.<.>.
0130  18 f7 3e 12 18 f3 11 bc e7 3e 11 18 ec 3e 13 18  ..>......>...>..
0140  e8 11 bc e7 3e 14 18 2c 3e 15 18 28 3e 16 18 d9  ....>..,>..(>...
0150  11 80 00 3e 1a 18 1d 3e 19 18 19 ed 4b bb e7 79  ...>...>....K..y
0160  b7 fc 6c e1 4f ed 43 bb e7 5f 18 02 1e ff 3e 20  ..l.O.C.._....>.
0170  18 02 3e 0d e5 d5 c5 dd e5 4f cd 05 00 b7 dd e1  ..>......O......
0180  c1 d1 e1 c9 3a 98 e7 cd 69 e1 11 99 e7 cd 27 e1  ....:...i.....'.
0190  28 27 d5 3a a8 e7 3d 32 b9 e7 11 07 e0 cd 53 e1  ('.:..=2......S.
01a0  d1 cd 44 e1 20 13 32 86 e0 21 a7 e7 77 23 35 cd  ..D...2..!..w#5.
01b0  2e e1 28 05 cd 00 e1 28 10 3a 98 e7 cd 69 e1 11  ..(....(.:...i..
01c0  99 e7 cd 3d e1 af 32 ba e7 cd 50 e1 3a 04 00 f5  ...=..2...P.:...
01d0  07 07 07 07 e6 0f cd 69 e1 f1 e6 0f 5f e5 2a f8  .......i...._.*.
01e0  e7 cd c0 e0 e1 da 3d e3 3e 0e 18 88 3a ba e7 b7  ......=.>...:...
01f0  c4 84 e1 3a 04 00 f5 e6 0f c6 41 cd de e0 f1 07  ...:......A.....

This makes sense since my SD card code doesn't support SDHC Cards. Seems like I could determine what sort of card is attached and use the right command for SDHC cards. 

Still not sure why it didn't run when I did S1. 

One good sign, G1 worked.

> G1
System Read OK
>

 It looks like this loaded correctly.

> DE000
E000  C3 5C E3 C3 5F E3 7E 00 00 00 00 00 00 00 00 00       C\cC_c~.........
E010  00 00 00 00 00 00 20 20 43 43 50 2B 20 76 32 2E       ......  CCP+ v2.
E020  32 20 28 43 29 20 31 39 38 36 2C 20 43 2E 42 2E       2 (C) 1986, C.B.
E030  20 46 61 6C 63 6F 6E 65 72 2C 20 54 65 6C 2E 20        Falconer, Tel.
E040  28 32 30 33 29 20 32 38 31 2D 31 34 33 38 2C 20       (203) 281-1438,
E050  36 38 30 20 48 61 72 74 66 6F 72 64 20 54 70 6B       680 Hartford Tpk
E060  2E 2C 20 48 61 6D 64 65 6E 2C 20 43 54 2E 2C 20       ., Hamden, CT.,
E070  55 53 41 00 00 00 00 00 00 00 00 00 00 00 00 00       USA.............
> D
E080  00 00 00 00 00 00 00 00 4E 6F 20 46 69 6C 65 00       ........No File.
E090  4E 6F 20 72 6F 6F 6D 00 41 6C 6C 20 28 79 2F 4E       No room.All (y/N
E0A0  29 3F 00 46 69 6C 65 20 65 78 69 73 74 73 00 4E       )?.File exists.N
E0B0  6F 20 55 50 53 48 49 46 54 00 2A FA E7 B7 C8 3D       o UPSHIFT.*zg7H=
E0C0  D6 10 29 3C 20 FC C9 FE 61 D8 FE 7B D0 E6 5F C9       V.)< |I~aX~{Pf_I
E0D0  FE 30 D8 FE 3A 3F C9 3E 0D CD DE E0 3E 0A D5 5F       ~0X~:?I>.M^`>.U_
E0E0  3E 02 CD 74 E1 D1 C9 FE 0A 38 11 C5 0E 2F 0C C6       >.MtaQI~.8.E./.F
E0F0  F6 38 FB C6 0A F5 79 CD DE E0 F1 C1 C6 30 18 DE       v8{F.uyM^`qAF0.^

This matches the dump above.

The load code is

    ld HL,(0FFFEh)        ; pop and run location
    jp (HL)            ; bye bye

Looking at the load showed it loaded 92FE into the last two locations. Is this little or big endian? Dumping the memory at 92FE is opcode 0xF3 leading me to think that it may be the other endian.

> DFFF0,FFFF
FFF0  F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 FA FB FC FD FE FF       pqrstuvwxyz{|}~.
> G1
System Read OK
> DFFF0,FFFF
FFF0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 92 FE       ...............~
> D92FE,9300
92F0  CD D4 EE 20 11 DD CB 0E FE C3 BA F0 CD 0A F3 38       MTn .]K.~C:pM.s8
9300  F4 18 DC CD 47 F1 AF C3 9B EC DD 4E 0C DD 46 0E       t.\MGq/C.l]N.]F.
>

 Dumping at FE92...

> DFE92,FEAF
FE90  50 00 3E 01 D3 38 F1 32 9D F9 F1 32 03 00 21 9D       P.>.S8q2.yq2..!.
FEA0  F9 22 FE FF 21 B4 FE 22 FC FF 3E C3 32 FB FF 0E       y"~.!4~"|.>C2{..
>

Opcode is 0x3E. Entered RFE92 which runs the code at 0xFE92 and the Z80 is stuck doing a write of I/O register at 0x38. That's the bank swap register. I can see the 0x38 a few bytes into the code so this makes sense. I haven't implemented the bank swap yet so that's why the Z80 is hanging.

Put an ackIO( ) in so it gets past the write but it's not running correctly. Unfortunately, it's no longer in the monitor code but is now in the CPM 2.2 code.

S5 started to load BASIC but hung after the prompt came up.

Cold or Warm?

Memory top?
Z80 BASIC Ver 4.7b
Copyright (C) 1978 by Microsoft

 This log is getting long so I think I'll stop it for now and start another log.

Discussions