avatar_JonB

Who wants IDE drives on the PCW?

Started by JonB, 12:43, 22 January 17

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

JonB


Prodatron

Finally I got my uIDE working with SymbOS and an old FAT16 formatted 2GB CF card  :D

[attachimg=1]

Thanks so much for this great PCW hardware, JonB!!!  :D :D

I was a little bit lazy during the last monthes, but after some testings last weekend on a vintage computer meeting and buying a CF2IDE adapter it was working directly with the first try!
Now I don't need to swap discs anymore after booting SymbOS, yeah!

GRAPHICAL Z80 MULTITASKING OPERATING SYSTEM

JonB

#177
Well done Prodatron!


Now how about the 6128 SymbOS drivers?  ;)

Prodatron

Quote from: JonB on 16:34, 08 September 17Well done Prodatron!
Thank you :)

Quote from: JonB on 16:34, 08 September 17Now how about the 6128 SymbOS drivers?  ;)
For the next SymbOS CPC version I will introduce a driver system like we have for SymbOS MSX. Currently the drivers are fixed embedded into the code, this will be changed in the next version. Then we can have a SYMBiFACE II/X-MASS IDE driver, an M4Board SD card driver, an uIDE driver, Albireo USB etc. etc.
The uIDE driver for the PCW was exactly the same like the SYMBiFACE II driver just with different port addresses (and more optimized 8bit addressing). So a uIDE-16 driver for the CPC should be done in a few minutes :)

GRAPHICAL Z80 MULTITASKING OPERATING SYSTEM

JonB

It's as I thought... IDE drivers are all basically the same apart from the port numbers.


Interesting though: I wonder of these existing SYMBIFACE drivers would work if you reconfigured the uIDE-16 port address to match the other IDE device?

Prodatron

Here is a short video showing SymbOS PCW playing videos and loading apps from a FAT32 formatted CF card via the uIDE interface. Starting from 0:56 you can see the interface itself connected at the back of my PCW.


https://www.youtube.com/watch?v=0t4ud6GYLLI

The video files are 4colour ones encoded for the CPC and have to be downrendered to 2colours by the Z80 in realtime. Also don't forget about the very special way how the PCW is organising its video memory ("roller ram"), which slows down the plotting of linear bitmap graphics.
But this is just a demo to show, that it's working :)

There is one issue left:
It seems, that I have to initialize the uIDE interface somehow. Currently it only works, when I start XTEST.COM first e.g. with the -im option before I boot SymbOS.
There are currently two other little bugs in this PCW version of SymbOS, if this is fixed I can release this new one.

GRAPHICAL Z80 MULTITASKING OPERATING SYSTEM

Prodatron

Quote from: JonB on 17:12, 08 September 17Interesting though: I wonder of these existing SYMBIFACE drivers would work if you reconfigured the uIDE-16 port address to match the other IDE device?
Good idea! I didn't connect it yet to the CPC, but I will try extactly this as soon as I have done it!

GRAPHICAL Z80 MULTITASKING OPERATING SYSTEM

JonB

Assuming SYBIFACE works in 8 bit mode if course. If it works the IDE interface in 16 bit mode you won't be able to use uIDE with it.


Now - about initialising the IDE device that is plugged into the uIDE card - you need to set IDE 8 bit mode and no caching, like this:



;-----------------------------------------------------------------------------
; IDE interface registers - Base address 0C8h for PCW
CF_BASE equ 0C8h ;IDE I/O Base address
CF_DATA equ CF_BASE ;0C8h $10 dataport
CF_FEATURES equ CF_BASE+1 ;0C9H $11 reg1port
CF_ERROR equ CF_BASE+1 ;0C9h $11 reg1port
CF_SECCOUNT equ CF_BASE+2 ;0CAh $12 reg2port
CF_SECTOR equ CF_BASE+3 ;0CBh $13 reg3port
CF_CYL_LOW equ CF_BASE+4 ;0CCh $14 reg4port
CF_CYL_HI equ CF_BASE+5 ;0CBh $15 reg5port
CF_HEAD equ CF_BASE+6 ;0CEh $16 reg6port
CF_STATUS equ CF_BASE+7 ;0CFh $17 reg7port
CF_COMMAND equ CF_BASE+7 ;0CFh $17 reg7port
CF_LBA0 equ CF_BASE+3 ;0CBh $13 reg3port
CF_LBA1 equ CF_BASE+4 ;0CCh $14 reg4port
CF_LBA2 equ CF_BASE+5 ;0CBh $15 reg5port
CF_LBA3 equ CF_BASE+6 ;0CEh $16 reg6port


;-----------------------------------------------------------------------------
;IDE feature codes (for use with CF_FEATURES command)
CF_8BIT equ 1
CF_NOCACHE equ 082H


;-----------------------------------------------------------------------------
;IDE command codes
CF_READ_SEC equ 020H ; read a sector
CF_WRITE_SEC equ 030H ; write a sector
CF_SET_FEAT equ 0EFh ; Set features
CF_DIAGNOSTIC equ 090h ; Diagnostic
CF_RECALIBRATE equ 010h ; recalibrate drive (seek to 0)
CF_MASKERR equ 001h ; mask out the status error bit
CF_MASKRDY equ 040h ; mask out the READY bit
CF_MASKBSY equ 080h ; mask out the BUSY bit


;-----------------------------------------------------------------------------
; IDE drive addressing
CF_SLAVE equ 0F0h ; specifies slave device (CF_HEAD register)
CF_MASTER equ 0E0h ; specifies master device(CF_HEAD register)


CF_WAITRETRY equ 0ffh ; Number of times to retry cfWait
CF_WRRETRY equ 05h ; Number of times to retry write operation
CF_RDRETRY equ 05h ; Number of times to retry read operation


CF_TOUT equ 0ffh ; cfWait timeout
CF_ERR equ 00fh ; cfWait error
CF_MAXDRIVES equ 16 ; maximum number of drives (partitions)


;-----------------------------------------------------------------------------
; Initialise IDE device
ideinit:call cfWait ; wait for master ide device
cp CF_TOUT ; timeout?
ret z ; yep.. drop out here


; --------------------------------------------
; Initialise the Master IDE device
di ;
ld a,CF_MASTER ; address master device
out (CF_HEAD),a ;
ld a,CF_8BIT ; Set IDE to 8bit transfer mode
out (CF_FEATURES),a ;
ld a,CF_SET_FEAT ;
out (CF_COMMAND),a ;
ei
call cfWait ; wait for master
di ;
ld a,CF_MASTER ; address master device
out (CF_HEAD),a ;
ld a,CF_NOCACHE ; Set IDE to not cache writes
out (CF_FEATURES),a ;
ld a,CF_SET_FEAT ;
out (CF_COMMAND),a ;
ei

xor a ;
ret ; done



I'm not sure if you will need the ei/di instructions in SymbOS. I found the PCW driver drops bytes if I exclude them, due to the clock interrupt. Also, the PCW driver polls the IDE device so there is a "wait until not busy" routine called prior to each IDE operation that ensures the device is ready to receive the operation command:


;-----------------------------------------------------------------------------
; Wait for IDE device to be ready
cfWait: push de
ld d,CF_WAITRETRY ; load retry counter
cfLoop: di ;
in a,(CF_STATUS) ; get IDE status
ei
ld (laststat),a ; save it down
and CF_MASKBSY ; check busy bit
jr z,cfEnd ; if clear, drive is ready
dec d ; otherwise decrement retry counter
jr z,cfTout ; if zero, drive has timed out
jr cfLoop ; otherwise loop back for retry

cfTout: ld a,CF_TOUT ; timeout: load rogue value
jr cfCcy ; jump to abnormal return

cfEnd: ld a,(laststat) ; retrieve status
and CF_MASKERR ; check error flag
jr nz,cfErr ; error exit if set

cfOK: scf ; return with carry set
pop de ; restore
ret ; done

cfErr: di ; error:
in a,(CF_ERROR) ; get error register
ei ;
ld (lasterr),a ; save it down

cfCcy: scf ; clear carry flag
ccf ;
pop de ; restore de
ret ; done


Cheers
JonB

JonB

#183
On the 6128 the I/O addresses are 16 bits and you load them into BC before doing OUT(C),A:




;-----------------------------------------------------------------------------
; IDE interface registers - for 6128 (16 bit I/O addresses)
CF_BASE      .EQU   0FEF0h      ;IDE I/O Base address
CF_DATA      .EQU   CF_BASE      ; data port
CF_FEATURES   .EQU   CF_BASE+1   ; features (write)
CF_ERROR   .EQU   CF_BASE+1   ; error (read)
CF_SECCOUNT   .EQU   CF_BASE+2   ; multiple sector read count
CF_SECTOR   .EQU   CF_BASE+3   ; sector number
CF_CYL_LOW   .EQU   CF_BASE+4   ; track number, low byte
CF_CYL_HI   .EQU   CF_BASE+5   ; track number, high byte
CF_HEAD      .EQU   CF_BASE+6   ; head number
CF_LBA0      .EQU   CF_BASE+3   ; LBA address, byte 0
CF_LBA1      .EQU   CF_BASE+4   ; LBA address, byte 1
CF_LBA2      .EQU   CF_BASE+5   ; LBA address, byte 2
CF_LBA3      .EQU   CF_BASE+6   ; LBA address, byte 3
CF_COMMAND   .EQU   CF_BASE+7   ; command register (write)
CF_STATUS   .EQU   CF_BASE+7   ; status register (read)


;-----------------------------------------------------------------------------
;IDE feature codes (for use with CF_FEATURES command)
CF_8BIT      .EQU   1
CF_NOCACHE   .EQU   082H


CF_SLAVE   .EQU   0F0h   ; specifies slave device (CF_HEAD register)
CF_MASTER   .EQU   0E0h   ; specifies master device(CF_HEAD register)


CF_WAITRETRY   .equ   0ffffh   ; Number of times to retry the cfWait


;-----------------------------------------------------------------------------
;IDE command codes
CF_SET_FEAT   .EQU   0EFh   ; Set features
CF_IDENTIFY   .EQU   0ECh   ; Identify
CF_RECALIBRATE   .EQU   010h   ; Recalibrate
CF_DIAGNOSTIC   .EQU   090h   ; Diagnostic
CF_MASKERR   .equ   001h   ; mask out the status error bit


;-----------------------------------------------------------------------------
; Initialise IDE device
cfinit:
            ; --------------------------------------------
            ; Initialise the Master IDE device
   call   cfWait      ; wait for master
   ld   a,CF_MASTER   ; address master device
   ld   bc,CF_HEAD   ;
   out   (c),a      ;
   
   ld   bc,CF_FEATURES   ; Set IDE to 8bit transfer mode
   ld    a,CF_8BIT   ;
   out   (c),a      ;
   ld   bc,CF_COMMAND   ;
   ld   a,CF_SET_FEAT   ;
   out   (c),a      ;
            ;
   call   cfWait      ; wait for master
   ld   a,CF_MASTER   ; address master device
   ld   bc,CF_HEAD   ;
   out   (c),a      ;
   
   ld   bc,CF_FEATURES   ; Set IDE to not cache writes
   ld    a,CF_NOCACHE   ;
   out   (c),a      ;
   ld   bc,CF_COMMAND   ;
   ld   a,CF_SET_FEAT   ;
   out   (c),a      ;


   ret
   
;-----------------------------------------------------------------------------
; Wait for disk to be ready (busy=0,ready=1)
cfWait:   ld   de,CF_WAITRETRY
cfLoop:   call   cfcheck
   jr   nz,cfEnd
   dec   de
   ld   a,d
   add   a,e
   jr   z,cfTout
   jr   cfLoop
cfTout   push   hl
   ld   hl,timeout
   call   pstr
   pop   hl
   ld   a,ARGINVAL
cfEnd:   ret
   
;-----------------------------------------------------------------------------
;get the ready status of the CF card
cfcheck:ld   bc,CF_STATUS
   di
   in   a,(c)
   ei
   and   080H   ; busy flag
   cp   080H   ; zero if busy, else not zero
   ret      ; done



This code is from XTEST.COM which is currently the only 6128 CP/M Plus program that can access an IDE device via uIDE-16. I have not been able to work out how to integrate the IDE driver into the 6128 CP/M Plus implementation. Use the 6128 version of XTEST.COM in CP/M Plus to prove that the uIDE-16 card is set up correctly before trying it with SymbOS. It is in the downloads section of the uIDE wiki page.

Prodatron

Oh great, thanks for this! This already should answer my question regarding initialization (the SYMBiFACE II is working in 16bit IDE mode like all MSX IDE devices, too, and the X-MASS is switching to 8bit IDE mode byitself). Let's try it...

GRAPHICAL Z80 MULTITASKING OPERATING SYSTEM

Prodatron

Btw, is there a reason for disabling the cache?
Is the uIDE hotswap-capable? (most other IDE interfaces aren't AFAIK)

GRAPHICAL Z80 MULTITASKING OPERATING SYSTEM

Prodatron

Quote from: JonB on 17:38, 08 September 17Now - about initialising the IDE device that is plugged into the uIDE card - you need to set IDE 8 bit mode and no caching
Seems to work fine now, no need to start XTEST anymore before SymbOS boots, thanks a lot! :)

GRAPHICAL Z80 MULTITASKING OPERATING SYSTEM

JonB

Quote from: Prodatron on 18:52, 08 September 17
Seems to work fine now, no need to start XTEST anymore before SymbOS boots, thanks a lot! :)


No particular reason. I don't think caching would make IDE transfers any faster, though, because the IDE device will always be quicker than the PCW. So I feel it is safer to turn caching off, just in case. Besides, the PCW has no shutdown as such - doesn't need it - so people hit the power switch. Not a good thing to do with caching enabled!

JonB

#188
Quote from: Prodatron on 17:54, 08 September 17
Oh great, thanks for this! This already should answer my question regarding initialization (the SYMBiFACE II is working in 16bit IDE mode like all MSX IDE devices, too, and the X-MASS is switching to 8bit IDE mode byitself). Let's try it...


I think the X-MASS works in 16 bit mode, but presents the two bytes of each 16 bit word to the PCW sequentially and this is done by its hardware. It's not the only IDE solution (for 8-bit machines) that does this; I've seen a few rather elaborate designs that do the same. However, 8-bit mode is part of the CF IDE spec, so should be supported by the majority of cards (DOMs too, which I tend to use on the grounds that they seem to always work and don't require an adapter to connect to uIDE).


Using IDE 8-bit mode also made uIDE very simple and easy / cheap to build, and these considerations formed part of its design objectives.

arnoldemu

Quote from: JonB on 10:12, 09 September 17

I think the X-MASS works in 16 bit mode, but presents the two bytes of each 16 bit word to the PCW sequentially and this is done by its hardware. It's not the only IDE solution (for 8-bit machines) that does this; I've seen a few rather elaborate designs that do the same. However, 8-bit mode is part of the CF IDE spec, so should be supported by the majority of cards (DOMs too, which I tend to use on the grounds that they seem to always work and don't require an adapter to connect to uIDE).


Using IDE 8-bit mode also made uIDE very simple and easy / cheap to build, and these considerations formed part of its design objectives.
@Jon:

X-MASS operates in 8-bit mode. The CPLD programs this at power on and holds the CPC in reset until the device accepts it. So just like the uIDE it requires a device supporting the CF-IDE spec. If I try to enable 16-bit mode with X-MASS I see half the data. (8 bits of each 16bit data).

Symbiface 2 operates in 16-bit mode. It doesn't program anything at power-on and assumes the device is in 16-bit mode from the start. Reading from the data port returns the first byte and then the second. It operates similar to G-IDE but I think the design is independent. Most HD's I've tried don't support 8-bit mode even though the ATA-1 spec mentions it.


My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

Prodatron

Quote from: arnoldemu on 17:02, 09 September 17
@Jon:

X-MASS operates in 8-bit mode. The CPLD programs this at power on and holds the CPC in reset until the device accepts it. So just like the uIDE it requires a device supporting the CF-IDE spec. If I try to enable 16-bit mode with X-MASS I see half the data. (8 bits of each 16bit data).

Symbiface 2 operates in 16-bit mode. It doesn't program anything at power-on and assumes the device is in 16-bit mode from the start. Reading from the data port returns the first byte and then the second. It operates similar to G-IDE but I think the design is independent. Most HD's I've tried don't support 8-bit mode even though the ATA-1 spec mentions it.
Yes, that's exactly how it is. Btw, I have a 10 years old 16GB SanDisc "Extreme" CF card, and it isn't detected on the PCW with uIDE by the XTEST tool and SymbOS. Maybe even some (larger?) CF cards don't support the 8bit mode, too? Anyway all of my smaller ones work fine, and it seems, that it's the same for all DOMs.

GRAPHICAL Z80 MULTITASKING OPERATING SYSTEM

JonB

#191
I stand corrected...  :)


...and by the way, that's one reason I recommend using a DOM with uIDE. However, my use cases are all CP/M based, so a 128MB DOM suffices (also being jolly cheap).

arnoldemu

Quote from: Prodatron on 19:51, 09 September 17
Yes, that's exactly how it is. Btw, I have a 10 years old 16GB SanDisc "Extreme" CF card, and it isn't detected on the PCW with uIDE by the XTEST tool and SymbOS. Maybe even some (larger?) CF cards don't support the 8bit mode, too? Anyway all of my smaller ones work fine, and it seems, that it's the same for all DOMs.
It is possible that the larger CF card needs additional configuration.
I will try and make a test that can be run to confirm it.
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

Sebastian Blanco

Symbios on the uide this is so cool :D, the only thing missing is a mouse interface to use :D.

JonB

Sorry, has Prodatron released it?

Munchausen

Quote from: arnoldemu on 17:02, 09 September 17
X-MASS operates in 8-bit mode. The CPLD programs this at power on and holds the CPC in reset until the device accepts it. So just like the uIDE it requires a device supporting the CF-IDE spec. If I try to enable 16-bit mode with X-MASS I see half the data. (8 bits of each 16bit data).

Symbiface 2 operates in 16-bit mode. It doesn't program anything at power-on and assumes the device is in 16-bit mode from the start. Reading from the data port returns the first byte and then the second. It operates similar to G-IDE but I think the design is independent. Most HD's I've tried don't support 8-bit mode even though the ATA-1 spec mentions it.

Does this mean that you can use devices that only support 16-bit on the uide, but only have access to half the capacity? (And end up using the drive in a way that would be incompatible if e.g. a PC tried to read a symbos fat partition it using standard fat drivers?)

JonB

uIDE operates in 8-bit mode. No wasted bytes. However, when formatted, it cannot be read by a PC directly because the format is a custom one that CP/M can support natively.


You can use CP/M Tools on Windows or Linux to read and write files from / to a uIDE formatted drive, and full instructions are provided on the Wiki page (as well as a download).


To save you from searching for it, it is here: http://www.cpcwiki.eu/index.php/UIDE_Universal_IDE_adapter_cards_for_Z-80_computers .


Read carefully, all the information you need should be there.

Sebastian Blanco

I now it took me a wile but finished assembling the ide adapter from JonB :D.Have everything ready, but for some reason i can't find cp/m .dsk images for the pcw.The only one that i have is cpm 1 that is very old.Looked high and low on the web and nowere found an image.Someone can share the 2.0 o 3.0 cp/m plus images necesary to load the ide drivers ?.Also if it already have the ide tools it could be very good.
:o

Terje_Norway

Hi,


You can have a look at the following link :


http://www.cpcwiki.eu/forum/nc100-nc200-pcw-pda600/cpm-plus-1-11-1-5-download/


The files You need should be available there.


Yours

Terje Grind
NORWAY

PS I have not tried these files myselves.

JonB

Hi Sebastian


You haven't got it working yet?  :o


The download link to the correct version of CP/M Plus was on the uIDE information page all along. That's why I asked everyone to read the whole page (which took more time to write than the uIDE did to design, nearly).


Anyway, click this link and your browser will download the file: http://www.cpcwiki.eu/forum/nc100-nc200-pcw-pda600/cpm-plus-1-11-1-5-download/?action=dlattach;attach=21886


Cheers
JonB




Powered by SMFPacks Menu Editor Mod