RetroBrew Computers Forum
Discussion forum for the RetroBrew Computers community.

Home » RBC Forums » General Discussion » Plasmo's 68k pathfinder projects (68K, 68000, 68020, 68030, 68040, 100mm x 100mm pc board)
Re: Plasmo's 68k pathfinder projects [message #3154 is a reply to message #3151] Tue, 04 July 2017 12:38 Go to previous messageGo to next message
plasmo is currently offline  plasmo
Messages: 876
Registered: March 2017
Location: New Mexico, USA
Senior Member
Roger,
Thank you for your help. PM sent. I really like "A Simple Approach" described in section 5.3.1 of CP/M-68K System Guide, but the author discouraged the method!
I'm also interested in how you created 4 (or more) drives on a CF. My method was adding successive drives each with track offset greater than the total tracks of the previous drives. It works, but seems a dangerous method because writing boot with PUTBOOT would potentially corrupt the previous drives.
My truly burning question was how to transfer files to/from PC (Windows Vista) to CP/M. I don't have a Linux machine and my hardware does not support floppy disks, CompactFlash is all I got. The way I go from PC to CP/M was to create a CP/M image with cpmtools and write the resulting image to a newly (FAT16) formated CF. Then move the CF to the CP/M machine, located the beginning of the image and copy it starting from sector 0 of the CF. It works, but I can think of many ways it'd blew up. I have absolutely no idea how to transfer CP/M back to FAT16--I'm just not smart enough today to write a FAT16 driver in CP/M.
Bill
Re: Plasmo's 68k pathfinder projects [message #3159 is a reply to message #3154] Tue, 04 July 2017 23:11 Go to previous messageGo to next message
norwestrzh is currently offline  norwestrzh
Messages: 190
Registered: November 2015
Senior Member
Hi Bill,

>> I really like "A Simple Approach" described in section 5.3.1 of CP/M-68K System Guide, but the author discouraged the method!

Not sure what you mean. The simple approach is what I used (I think). Full track, and other caching methods would take a lot more work.

> I'm also interested in how you created 4 (or more) drives on a CF.

What I did was to create a filesystem for the first drive, mount the CF, and initialize (with INIT) the other 3 drives. Then you can copy (with PIP?_) the A: filesystem to B:, C:, or D:. Then repeat to load up the other non-A: filesystems. You can also use cpmtools to build B:, C:, or D: and then write a little C code to move over the first "disk" and copy to another. I'm a Linux guy, so this is pretty easy to do. dd will also work, but is more dangerous.

> My truly burning question was how to transfer files to/from PC (Windows Vista) to CP/M.

I wrote a little utility that reads S-record files, and saves them to "disk" (the CF). I convert source files to S-records and move them over that way. Works most of the time.

>> I have absolutely no idea how to transfer CP/M back to FAT16--I'm just not smart enough today to write a FAT16 driver in CP/M.

No need. Most terminal emulators have a capture function. You can "type" ascii material and capture it with your terminal emulator (assembly listings, for example). 68k CP/M also has a DUMP application, and one called "SENDC68" (I think I remembered that name correctly?_) you can use to display binary, and again capture it with your emulator. I wrote a little application that I call "eatdmp" that converts dump format back to binary, and there are a number of applications you can find on-line to work with S-records (the output from "SENDC68").

Hope this helps.

I'm really interested in your work with 68020, 68030, etc. Would love to get a CPU like that going. *grin*

Roger
Re: Plasmo's 68k pathfinder projects [message #3164 is a reply to message #3159] Wed, 05 July 2017 10:13 Go to previous messageGo to next message
plasmo is currently offline  plasmo
Messages: 876
Registered: March 2017
Location: New Mexico, USA
Senior Member
Roger,
Got your BIOS. Many thanks!

It is interesting that we started with the same sample BIOS, and CPM15000.SR, use the same 68681 DUART and CompactFlash, yet our codes are so different. I put my BIOS code as it stands today in here for your reference.
https://www.retrobrewcomputers.org/lib/exe/fetch.php?media=b uilderpages:plasmo:tiny68k:tinybios.txt

Thanks for the suggestions of using S Record file transfer & terminal screen capture to move data to/from CP/M and PC. That may well be the solution in the near term.

From what I have read in the past year on the subject of retrocomputing, A Linux machine appeared to be a critical tool. Somehow I need to find space on my cluttered desk to accommodate another box and monitor & learn another operating system. heavy sigh!

Thank you for your interests in the 68020 & 68030. I designed them to make sure that parts & tools I have on hand are working. These designs are simple and limited in capabilities. I want to explore the world of DRAM, IDE, VGA, Ethernet and Operating Systems with cheap 68000 designs and then migrate the hardware designs into 020, 030 and even 040.
Bill

[Updated on: Wed, 05 July 2017 10:15]

Report message to a moderator

Re: Plasmo's 68k pathfinder projects [message #3165 is a reply to message #3164] Wed, 05 July 2017 10:31 Go to previous messageGo to next message
norwestrzh is currently offline  norwestrzh
Messages: 190
Registered: November 2015
Senior Member
Hi Bill,

Thanks for your BIOS code. I'll take a detailed look. I find that 68k CP/M is quite different than the Z80 CP/M that I'm most familiar with. Z80 CP/M wants the O.S. to be at the highest memory addresses. Not so with 68k CP/M. But, there are strong similarities too, such as the 100h reserved area that is the "base page". Please note that there is no DUART initialization included in my BIOS. I start it up from a monitor that does that! Also note that I only use lba0 and lba1, so lba2 and the bits of lba3 that are available can be used to address other "drives" on the CF (with much more programming).

If screen capture is too slow for you, take a look at the parallel to USB adapters that can be found on eBay (such as http://www.ebay.com/itm/FT245-USB-FIFO-Board-mini-FT245RL-De velopment-Module-Kit-USB-TO-parallel-FIFO/251042147761?ssPag eName=STRK%3AMEBIDX%3AIT&_trksid=p2060353.m1438.l2649)_. These things can transmit across USB at speeds that are truly amazing. I've found that the 68k doesn't even need to look at the status bits when it sends. Just pump out the data in a tight loop, at ~115k baud.

Roger

[Updated on: Wed, 05 July 2017 11:11]

Report message to a moderator

Re: Plasmo's 68k pathfinder projects [message #3171 is a reply to message #3165] Wed, 05 July 2017 13:10 Go to previous messageGo to next message
plasmo is currently offline  plasmo
Messages: 876
Registered: March 2017
Location: New Mexico, USA
Senior Member
Roger,
I also do not initialize the DUART in the BIOS since it is already initialized in my monitor.

Both our drives are the same size, 8 megabyte. Since I defined my drive with 256 sectors per track and 255 tracks per drive and furthermore each drive is offset by multiple of 256 tracks (drive B is offset 256 track, drive C is offset 512 tracks, and drive D is offset 768 tracks), I don't do any translation between CP/M sector/track/drive to CF sector/track--just copy track & sector values provided by CP/M into CF registers and execute read or write commands. It won't be quite this simple when block/deblock algorithm is implemented.

I gather your CF is bus connected with 16-bit data bus, just like mine. You may noticed that I don't do byte swap when I read the 16-bit data. This is because when I processed the CP/M image created by cpmtools, I did the byte swap and then copy the byte-swapped image back into a CF starting from sector 0, thus creating a CP/M disk partition with bytes already swapped. In the back of my mind I expect to be burnt by this little trick sooner or later...

Retrobrew forum member 'will' has designed a USB FIFO for file transfer. It is based on FTDI's FT232H.
https://www.retrobrewcomputers.org/doku.php?id=boards:ecb:us b-fifo:start
It is another reference design for adding high speed transfer capability.

On a different topic, are you the same Roger on comp.os.cpm a few months ago who was having trouble running CPM400.SR? I want you to know that I have problem with CPM400.SR as well. I used the same procedure as CPM15000.SR and make sure the BIOS is linked correctly. When I go to 0x400, I'll get the >A prompt, but next keystroke will hang up the CPU with the CF disk access light turned on forever. I have 16 megabyte of memory so I'm not concerned about throwing away 128K byte of memory but I'm curious, did you figured out what's the problem was?
Bill

[Updated on: Wed, 05 July 2017 13:13]

Report message to a moderator

Re: Plasmo's 68k pathfinder projects [message #3172 is a reply to message #3171] Wed, 05 July 2017 15:06 Go to previous messageGo to next message
norwestrzh is currently offline  norwestrzh
Messages: 190
Registered: November 2015
Senior Member
Hi Bill --

>> It won't be quite this simple when block/deblock algorithm is implemented.

No, but the way I did it is a little more complicated than it needs to be. I wanted to use the lba bits carefully, so as to allow for future expansion to more "drives". That's why only lba0 and lba1 are used.

>> I gather your CF is bus connected with 16-bit data bus, just like mine.

Yes, and I wonder why you are not having the problems that I'm having. As I told you, my 68k boards are completely TTL, and I find that the direct interface has very tricky timing. I experimented with using an 8255 for the interface, but it is horribly slow. A friend in Norway came up with a way to get the timing right using a dual multivibrator chip, but calibrating that circuit is quite tricky as well. It seems to be speed limited too, maybe 6 or 7 MHz, on top of that. I'm experimenting with using delay lines now to get the timing right, and it seems to work most of the time. I'm running with DTACK* grounded at 12 MHz, but I cannot get the Digital Research BASIC compiler to work properly. It compiles an application OK, but when I try to run the result I get exceptions. I have it working on another of my 68k boards with the multivibrator interface and slower clock, so I'm pretty sure that the BASIC compiler pushes my direct interface to the point of failure. Haven't figured out why.

So, what is the secret of your CF interface? Is the difference programmable logic?

>> Retrobrew forum member 'will' has designed a USB FIFO for file transfer. It is based on FTDI's FT232H.

Yep, that's the one. Well, very similar to what I was suggesting. There are a number of parallel to USB devices out there (one very expensive one is made by FTDI). USB transfer can be very fast!!

> ... are you the same Roger on comp.os.cpm a few months ago who was having trouble running CPM400.SR?

Yep, that's me. I was never able to figure out why that wouldn't work. But the CPM15000.SR image works fine. Maybe some day I'll work on relocating an image a little lower in memory, but as you say with all that memory, is it worth worrying about? I haven't even come close to pushing the limits of 2 MB memory on my boards, so your 16 MB seems HUGE to me! *grin*

Roger
Re: Plasmo's 68k pathfinder projects [message #3173 is a reply to message #3172] Wed, 05 July 2017 17:06 Go to previous messageGo to next message
plasmo is currently offline  plasmo
Messages: 876
Registered: March 2017
Location: New Mexico, USA
Senior Member
Roger,
Somewhere in the CF spec is the requirement that nIORD or nIOWR assert 70ns after nCS0 or nCS1 asserts. It needs to assert for 165ns before negating. After that nCS0 or nCS1 may negate and address change. I meet the timing spec with one wait state when accessing CF. The output of the DTACK gates nIORD or nIOWR thus giving it a delay of 70ns after the assertion of CF chip select. nIORD, nIOWR and nIDECS negate when nAS negates. The design file is here but the logic is scattered over two sheets.
https://www.retrobrewcomputers.org/lib/exe/fetch.php?media=b uilderpages:plasmo:tiny68k:tiny68kcpld.pdf

Here is the same logic redrawn.

index.php?t=getfile&id=539&private=0

At 12MHz I don't believe you can meet the timing spec with DTACK grounded. You need to add at least one wait state, two wait states give you more margin considering you are using analog circuits.
-------------------------------------
Well, it is good to review my circuit. As I go through the timing to explain how it works, I find out it DOESN'T! The wait state generator does not generate one wait state as I've thought. I'm in fact accessing the CF with zero wait. At 8MHz I barely meeting the timing spec of 70ns setup time. I'm meeting the 165ns hold time comfortably. The circuit should works as is, but I'll need to add one more stage of flip flop if I want to raise the clock to 12MHz.

edit: Measure the actual timing with my scope. Yes, I'm accessing the CF with zero wait state. The time from nIDECS0 assert to nIORD asserts is 124ns. nIORD asserts for 194ns and negates the same time as nIDECS0. All works out OK. One more example of "luck beats skill any day!"

[Updated on: Wed, 05 July 2017 17:39]

Report message to a moderator

Re: Plasmo's 68k pathfinder projects [message #3174 is a reply to message #3173] Wed, 05 July 2017 20:16 Go to previous messageGo to next message
norwestrzh is currently offline  norwestrzh
Messages: 190
Registered: November 2015
Senior Member
Bill --
From what you have said, I believe that I'm cutting the IORD/IOWR assertion too close. I think my delay is only around 30 n.s. I think I have a way to increase that to about 50 n.s. (easily)
I'm holding it for about 160 n.s.
Maybe I'm working with an out-of-spec. CF? It is a Transcend 2GB 133x.
I need a good wait state generator (in TTL). Do you think that this will work?
index.php?t=getfile&id=540&private=0
>> One more example of "luck beats skill any day!"
How true!!!
Roger
  • Attachment: plasmo.png
    (Size: 12.60KB, Downloaded 1412 times)
Re: Plasmo's 68k pathfinder projects [message #3175 is a reply to message #3174] Wed, 05 July 2017 21:23 Go to previous messageGo to next message
plasmo is currently offline  plasmo
Messages: 876
Registered: March 2017
Location: New Mexico, USA
Senior Member
Roger,
Q1* is one wait state
Q2* is two wait states
Q3* is three wait states

That was my mistake: I thought *Q0 is one wait state, but that's not so.
Does DTACK* goes to an open collector drive? You are sharing DTACK* with 68681, right? So you need an open collector driver.
Bill
Re: Plasmo's 68k pathfinder projects [message #3177 is a reply to message #3138] Thu, 06 July 2017 06:11 Go to previous messageGo to next message
etchedpixels is currently offline  etchedpixels
Messages: 333
Registered: October 2015
Senior Member
plasmo wrote on Sun, 02 July 2017 16:52
Some performance specs:
- I have not figured out how to block/deblock 128 byte/sector of CP/M into 512 byte/sector of the CF, so each 128-byte CP/M sector takes a full 512-byte CF sector--very wasteful, something to work on in the near term.


CF and SD cards are not designed to expect a lot of rewrites of the same block except in the FAT area with a DOS style fs. From a performance and a card life point of view you may well be better off just using 128 bytes of each block rather than being clever in the BIOS code.

CP/M 3 supports other sizes including 512 byte blocks but this never made CP/M 68K as far as I know because CP/M 68K had a rather brief and very unsuccessful life, being slaughtered in the market by OS/9 68K, and turning into Atari TOS.

Re: Plasmo's 68k pathfinder projects [message #3180 is a reply to message #3177] Thu, 06 July 2017 09:36 Go to previous messageGo to next message
norwestrzh is currently offline  norwestrzh
Messages: 190
Registered: November 2015
Senior Member
>> CF and SD cards are not designed to expect a lot of rewrites of the same block except in the FAT area with a DOS style fs.
>> From a performance and a card life point of view you may well be better off just using 128 bytes of each block rather than
>> being clever in the BIOS code.

Actually, the block/deblock described here will *reduce* the writes/rewrites to the CF. Blocking delays writes/rewrites that are not critical ( non-directory I/O_)_wherever possible.

[Updated on: Thu, 06 July 2017 09:37]

Report message to a moderator

Re: Plasmo's 68k pathfinder projects [message #3192 is a reply to message #3175] Fri, 07 July 2017 11:51 Go to previous messageGo to next message
norwestrzh is currently offline  norwestrzh
Messages: 190
Registered: November 2015
Senior Member
Hi Bill,

>>Does DTACK* go to an open collector drive? You are sharing DTACK* with 68681, right? So you need an open collector driver.

I'm using a 'LS21 to monitor DTACK* coming from several sources. The DTACK* coming from the CF interface just hooks up to one of the unused inputs.

I built a wait state generator from the circuit posted here. Seems to work fine. I'm still experimenting with it. Need to hook up a 'scope to look at what's happening, but so far, so good.!

Roger


Re: Plasmo's 68k pathfinder projects [message #3194 is a reply to message #3192] Fri, 07 July 2017 12:44 Go to previous messageGo to next message
plasmo is currently offline  plasmo
Messages: 876
Registered: March 2017
Location: New Mexico, USA
Senior Member
Roger,
I modified my BIOS to include the block/deblock algorithm you provided. You can find the source code here: https://www.retrobrewcomputers.org/lib/exe/fetch.php?media=b uilderpages:plasmo:tiny68k:tinybios1.txt
It is simpler than yours because I set the sector size to 1024 and each drive has an track offset of 64 from previous drive. So it is not necessary to convert track/sector values from CP/M to CF track/sector values. Disk utilization is now 1/4 that of disk without block/deblock. The program appears to run faster as well.
Thank you for your help!
Re: Plasmo's 68k pathfinder projects [message #3197 is a reply to message #3177] Fri, 07 July 2017 17:00 Go to previous messageGo to next message
plasmo is currently offline  plasmo
Messages: 876
Registered: March 2017
Location: New Mexico, USA
Senior Member
etchedpixels wrote on Thu, 06 July 2017 06:11
plasmo wrote on Sun, 02 July 2017 16:52
Some performance specs:
- I have not figured out how to block/deblock 128 byte/sector of CP/M into 512 byte/sector of the CF, so each 128-byte CP/M sector takes a full 512-byte CF sector--very wasteful, something to work on in the near term.


CF and SD cards are not designed to expect a lot of rewrites of the same block except in the FAT area with a DOS style fs. From a performance and a card life point of view you may well be better off just using 128 bytes of each block rather than being clever in the BIOS code.

CP/M 3 supports other sizes including 512 byte blocks but this never made CP/M 68K as far as I know because CP/M 68K had a rather brief and very unsuccessful life, being slaughtered in the market by OS/9 68K, and turning into Atari TOS.



The current blocking/deblocking algorithm is not sophiscated. The main saving is CF disk space, but it can be argued that the CF disk is cheap and the saving is not worth the complexity, a point well taken. In term of performance, blocking has faster CF reads, but deblocking has slower CF writes because of the extra reads-before-writes. The number of writes are the same between the two algorithms so same amount of wear on CF. The CF should have wear-leveling of the entire disk, but life expectancy of CF is always a concern and this simple algorithm is not helping nor hurting.
I did a couple quick performance comparisons. Copying entire disk A: to disk C: (2200 Kbytes, 126 files) takes 190 seconds for BIOS with blocking/deblocking and 248 seconds for BIOS without blocking/deblocking; executing the reloc1.sub batch file (SUBMIT RELOC1) takes 28 seconds for BIOS with blocking/deblocking and 34 seconds for BIOS without. It is 20-30% faster.
Re: Plasmo's 68k pathfinder projects [message #3200 is a reply to message #3197] Fri, 07 July 2017 23:21 Go to previous messageGo to next message
rhkoolstar is currently offline  rhkoolstar
Messages: 276
Registered: October 2015
Senior Member
In my view blocking/de-blocking helps in extending card life. Because a 512 byte sector is built in RAM before it is written to disk, in the best situation, only one write bappens, instead of four, when only 128 bytes per sector sectors are used. On average I would expect at least halving the active disk writes. It does not help with directory writes though.

Besides, I would not worry too much about excessive writes. Compared to more modern OSes CP/M disk writes are sparse.

Rienk
Re: Plasmo's 68k pathfinder projects [message #3214 is a reply to message #3200] Thu, 13 July 2017 09:13 Go to previous messageGo to next message
plasmo is currently offline  plasmo
Messages: 876
Registered: March 2017
Location: New Mexico, USA
Senior Member
rhkoolstar wrote on Fri, 07 July 2017 23:21
.

Besides, I would not worry too much about excessive writes. Compared to more modern OSes CP/M disk writes are sparse.

Rienk


I modified the BIOS and added a 8 meg RAM drive to drive E. https://www.retrobrewcomputers.org/lib/exe/fetch.php?media=b uilderpages:plasmo:tiny68k:tinybios_rd.txt
The size of TPA is reduced to 7 meg. The RAM drive algorithm is quite small, only about a dozen or so instructions--no blocking/deblocking, no wait on CF interface, just simple read/write to memory. Yet, when I did a benchmark copying entire disk A: to E: (2200kbytes, 126 files), it takes 137 seconds compare to 190 seconds CF to CF copy. execute the RELOC1.SUB in RAM drive takes 24 seconds instead of 28 seconds in CF. The improvement is much smaller than my recollection of the RAM drives speed-up. It is hardly worth the efforts except for the saving on CF write wearing. Perhaps CF accesses are particularly efficient and perhaps CP/M does the minimum disk I/O as you've pointed out.
Re: Plasmo's 68k pathfinder projects [message #3217 is a reply to message #3200] Thu, 13 July 2017 15:21 Go to previous messageGo to next message
yoda is currently offline  yoda
Messages: 125
Registered: October 2015
Location: Cedar Rapids, IA
Senior Member
I could argue this both ways. If you update 128 bytes at a time randomly you could potentially have 4 times the writes to the same block. You really only win if writes are sequential (which happens a lot). If you had a deep cache of blocks in memory you could gain some advantage but copy on modify could not predict either, so really you are doing more potential writes to the same block then 128 bytes per block. I prefer the packing as I don't like leaving holes on the disk and I doubt the wearing of the card is going to be a major problem in my life time of usage.
Re: Plasmo's 68k pathfinder projects [message #3218 is a reply to message #3214] Thu, 13 July 2017 17:03 Go to previous messageGo to next message
mikemac is currently offline  mikemac
Messages: 249
Registered: March 2017
Senior Member
plasmo wrote on Thu, 13 July 2017 09:13
The improvement is much smaller than my recollection of the RAM drives speed-up. It is hardly worth the efforts except for the saving on CF write wearing. Perhaps CF accesses are particularly efficient and perhaps CP/M does the minimum disk I/O as you've pointed out.

Since all accesses are being gated by the 8MHz clock of your CPU, I'd expect both your slow SDRAM and your fast CF to have a similar speed. I'm guessing that if you added up the cycles for accessing the DRAM that they'd come out pretty close to the number of cycles accessing the CF. Looks like the DRAM wins by one or two cycles.

RAM disks really made a difference when our 486/Pentiums running at 66MHz were trying to access our really slow MFM drives. Or even worse, floppy drives!

At 8MHz, everything is equally slow. Sad



Mike

[Updated on: Thu, 13 July 2017 17:06]

Report message to a moderator

Re: Plasmo's 68k pathfinder projects [message #3219 is a reply to message #3217] Thu, 13 July 2017 20:13 Go to previous messageGo to next message
plasmo is currently offline  plasmo
Messages: 876
Registered: March 2017
Location: New Mexico, USA
Senior Member
yoda wrote on Thu, 13 July 2017 15:21
I could argue this both ways. If you update 128 bytes at a time randomly you could potentially have 4 times the writes to the same block. You really only win if writes are sequential (which happens a lot). If you had a deep cache of blocks in memory you could gain some advantage but copy on modify could not predict either, so really you are doing more potential writes to the same block then 128 bytes per block. I prefer the packing as I don't like leaving holes on the disk and I doubt the wearing of the card is going to be a major problem in my life time of usage.


The CF interface protocol requires that every sector read or write move multiple of 512 bytes of data to and from the CF data register. I have not figured out how to gracefully abort the data transfer after 128 bytes. As far as I can find, there are no 'transfer abort' command I can issue. Because of that I'm transferring 512 bytes of data for each CF sector access whether I need 128 bytes or 512 bytes. Even with the simple algorithm without blocking and deblocking, I'd write 128 bytes of actual data followed by 384 zeros to satisfy the CF internal state machine. This is why the amount of write wear is the same whether a CF sector contains 128 bytes of meaningful data or 512 bytes.
Re: Plasmo's 68k pathfinder projects [message #3220 is a reply to message #3218] Thu, 13 July 2017 20:15 Go to previous messageGo to next message
plasmo is currently offline  plasmo
Messages: 876
Registered: March 2017
Location: New Mexico, USA
Senior Member
mikemac wrote on Thu, 13 July 2017 17:03
plasmo wrote on Thu, 13 July 2017 09:13
The improvement is much smaller than my recollection of the RAM drives speed-up. It is hardly worth the efforts except for the saving on CF write wearing. Perhaps CF accesses are particularly efficient and perhaps CP/M does the minimum disk I/O as you've pointed out.

Since all accesses are being gated by the 8MHz clock of your CPU, I'd expect both your slow SDRAM and your fast CF to have a similar speed. I'm guessing that if you added up the cycles for accessing the DRAM that they'd come out pretty close to the number of cycles accessing the CF. Looks like the DRAM wins by one or two cycles.

RAM disks really made a difference when our 486/Pentiums running at 66MHz were trying to access our really slow MFM drives. Or even worse, floppy drives!

At 8MHz, everything is equally slow. Sad


I think you are right, a slow old CPU interfacing with a fast modern peripheral compresses the memory organization hierarchy. Complexity is unnecessary and the design simplifies. Good, I like that.

Re: Plasmo's 68k pathfinder projects [message #3224 is a reply to message #3219] Fri, 14 July 2017 02:59 Go to previous messageGo to next message
etchedpixels is currently offline  etchedpixels
Messages: 333
Registered: October 2015
Senior Member
plasmo wrote on Thu, 13 July 2017 20:13
yoda wrote on Thu, 13 July 2017 15:21
I could argue this both ways. If you update 128 bytes at a time randomly you could potentially have 4 times the writes to the same block. You really only win if writes are sequential (which happens a lot). If you had a deep cache of blocks in memory you could gain some advantage but copy on modify could not predict either, so really you are doing more potential writes to the same block then 128 bytes per block. I prefer the packing as I don't like leaving holes on the disk and I doubt the wearing of the card is going to be a major problem in my life time of usage.


The CF interface protocol requires that every sector read or write move multiple of 512 bytes of data to and from the CF data register. I have not figured out how to gracefully abort the data transfer after 128 bytes. As far as I can find, there are no 'transfer abort' command I can issue. Because of that I'm transferring 512 bytes of data for each CF sector access whether I need 128 bytes or 512 bytes. Even with the simple algorithm without blocking and deblocking, I'd write 128 bytes of actual data followed by 384 zeros to satisfy the CF internal state machine. This is why the amount of write wear is the same whether a CF sector contains 128 bytes of meaningful data or 512 bytes.


You are correct that the ATA interface protocol does not permit smaller than 512 byte transfers.

A CF card isn't a directly mapped pile of flash memory. It's effectively a small flash based intelligent storage appliance. Whenever you write a 512 byte chunk it tries to put that block into an erased block of flash partially based upon wear levelling algorithms. Each update to the same block causes it to be reallocated into a new block and various meta-data updates to occur which cause other writes and potentially erases. The internal controller (which btw is probably more powerful than the 68K you attached it to Cool Wink is optimised for FAT style behaviour down to having magic support for the FAT area and expecting rewrites to be uncommon.
Re: Plasmo's 68k pathfinder projects [message #3231 is a reply to message #3224] Sun, 16 July 2017 04:33 Go to previous messageGo to next message
plasmo is currently offline  plasmo
Messages: 876
Registered: March 2017
Location: New Mexico, USA
Senior Member
All these discussions about compactflash make me wonder has anyone designed a computer system that boot out CF? Another word, no boot ROM, the first instruction fetch out of reset is from CF? Sure, the CF needs prior initializations to point to the right head/track/sector and a read command, but that can be easily handled with a state machine. In addition, there needs to be some temporary 'magic decoding' so the first few hundred instruction fetches after a reset all go to the CF's data register; once a simple bootstrap is copied from CF into memory and executing, it can restore normal memory map and load CP/M or a monitor software. It is a bit convoluted and needs a modest CPLD (such as my favorite EPM7128) to pull it off, but it seems do-able. Then again, if it is so do-able, someone may have done it already. Though?
Re: Plasmo's 68k pathfinder projects [message #3232 is a reply to message #3231] Sun, 16 July 2017 08:56 Go to previous messageGo to next message
mikemac is currently offline  mikemac
Messages: 249
Registered: March 2017
Senior Member
Isn't that what you're essentially doing with your SPI flash? You could have just as easily read the boot sector off of the CF and copied it to 0x0 before releasing RESET.

Or you could memory map the CF's boot sector. But the difference in read sizes between memory (1,2, or 4 bytes) and the CF (128, 512 bytes) usually means you're going to have a "copy" of the boot sector in some memory anyway. So just as well use RAM and do the copy. If you REALLY wanted to avoid the use of any kind of memory buffer, I guess you could reread the boot sector each and every time you wanted to read a word during boot. Obviously that would be a tad slow.



Mike
Re: Plasmo's 68k pathfinder projects [message #3233 is a reply to message #3232] Sun, 16 July 2017 09:02 Go to previous messageGo to next message
mikemac is currently offline  mikemac
Messages: 249
Registered: March 2017
Senior Member
Oh, one other thing. With your SPI flash, you set up the initial read commands and then sequentially do one read after another. That works great for copying the whole boot image. But executing the boot image does not access the image sequentially. Someplace in the boot image will be a loop or jump of some kind. So trying to set up the CF so that you issue a CF read command to it once and read sequentially as the processor executes the image won't work.

At least I don't see how it'd work. If someone better at this knows a trick to do that, I'd love to hear it too!



Mike
Re: Plasmo's 68k pathfinder projects [message #3236 is a reply to message #3233] Mon, 17 July 2017 15:34 Go to previous messageGo to next message
etchedpixels is currently offline  etchedpixels
Messages: 333
Registered: October 2015
Senior Member
The software bit is the easy bit

Your instruction sequence is something like

moev.w #$1000,a0
moev.l #dword0,(a0)+
move.l #dword1,(a0)+
...
jp $1000

in other words your linear code writes a small loop into RAM and runs it.

Re: Plasmo's 68k pathfinder projects [message #3238 is a reply to message #3232] Mon, 17 July 2017 15:54 Go to previous messageGo to next message
plasmo is currently offline  plasmo
Messages: 876
Registered: March 2017
Location: New Mexico, USA
Senior Member
mikemac wrote on Sun, 16 July 2017 08:56
Isn't that what you're essentially doing with your SPI flash? You could have just as easily read the boot sector off of the CF and copied it to 0x0 before releasing RESET.


The method you suggested (hardware copying boot sector to DRAM) is a more intuitive approach but that wasn't what I've in mind when I wrote about booting off CF. I may try that if my original idea failed. The original idea is using hardware to initialize a CF so it behaves like a 256-word deep FIFO in address range 0x0 - 0x7FFF immediately after powering up. The first 2 long words of the FIFO is stack pointer and reset vector (0x8) followed by a series of move immediate instructions and ended with a jump instruction to 0x8000. When 68000 comes out of reset and starts program execution at 0x0, the FIFO feeds it the stack pointer, reset vector, then a stream of move immediate which initialize the area starting from 0x8000 with the actual boot strap code and finishes with a jump to 0x8000. At this point it is about where you are suggesting with hardware copying of boot sector to DRAM. It still needs to restore normal memory map to 0x0 - 0x7FFF and copy the monitor or CP/M from CF into memory to complete the booting process.

It occurs to me that my existing board can be easily modified to boot off CF, so I think I should just go do it and see if the idea really works.

Edit: thank you, etchedpixels, that's exactly the code I have in mind.

[Updated on: Mon, 17 July 2017 15:56]

Report message to a moderator

Re: Plasmo's 68k pathfinder projects [message #3239 is a reply to message #3238] Mon, 17 July 2017 18:54 Go to previous messageGo to next message
mikemac is currently offline  mikemac
Messages: 249
Registered: March 2017
Senior Member
OK, I think I understand what you and etchedpixels are proposing. Yeah, that looks like it'd work.

But why would you want to do that? Other than just to see if it could be done, that is.

Half (?Wink of your 256 word FIFO is taken up with the encoding of all of the immediate moves. So it's seems inefficient.

It's a whole extra set of CPU and memory cycles to get the CPU to do the string of immediate moves. So it seems inefficient that way too.

And it adds an extra step to the steps in preparing the boot image. So that seems like a detriment.

And you still have your state machine in the 7128 to issue the first read commands to the CF to get it started. So not much "savings" there.

But yeah, it'd "work". Smile



Mike
Re: Plasmo's 68k pathfinder projects [message #3246 is a reply to message #3239] Thu, 20 July 2017 17:02 Go to previous messageGo to next message
plasmo is currently offline  plasmo
Messages: 876
Registered: March 2017
Location: New Mexico, USA
Senior Member
These are valid points. In fact, the encoding of the move immediate data is a pain. I haven't figured out how to do it using assembler directives so I ended up cut & paste the bootstrap opcodes from the assembled listing.

What I am concerned with is the complexity of data transfer from CF to DRAM using the hardware state machine. I want to simplify the hardware and push complexity to software. I was hoping I can design both approaches and provide a quantitative measurement of the complexity, but that didn't work out so far. I'm having problems getting the CF initialization to work in hardware. I can initialize CF reliably in software, but something is different with the hardware state machine that the CF is responding differently.

Well, there are too many (non-electronic) tasks waiting, so I'll put this off to another days.

Edit:
The CF initialization for both hardware state machine & software looks like this:

After negation of the Power-on Reset
read CF Status register bit 7 (BSY) & bit 6 (DRDY) until (BSY==0 AND DRDY==1)
Write 0x1 to CF SectorCount register
Write 0x1 to CF Sector register
Write 0x0 to CF Cylinder Low register
Write 0x0 to CF Cylinder High register
Write 0x0 to CF Drive/Head register
Write 0x20 (Read) to CF Command register
Read CF Status register bit 7 (BSY) & bit 3 (DRQ) until (BSY==0 AND DRQ==1)
Remap 0x0 - 0x7FFF to CF Data register and Release 68000 nRESET

If anyone see flaws in CF initialization, please let me know.

Edit-Edit,
The problem I'm having is that I don't see DRQ==1 after writing 0x20 (Read) to CF Command register with hardware state machine, but no problem with software initialization routine.

[Updated on: Thu, 20 July 2017 17:14]

Report message to a moderator

Re: Plasmo's 68k pathfinder projects [message #3250 is a reply to message #3246] Fri, 21 July 2017 04:10 Go to previous messageGo to next message
etchedpixels is currently offline  etchedpixels
Messages: 333
Registered: October 2015
Senior Member
Are you implementing all the time delays required by the ATA and CF standards. In particular your status signals are not immediately valid after a command write. The ATA standards have a complete set of timing diagrams. Your state machine might be fast enough to violate them even if your CPU cannot.

I'm surprised it's easier to have a state machine for the CF rather than one that clocks out the 68K instruction stream (repeating chunks the correct number of times instead of a loop) as the Amstrad PCW does (where they saved a boot rom by hiding the boot code in an 804x I/O microcontroller that managed the printer)

Some devoces also expect you to follow the full initialization process for ATA not just rely on WD1010 compatibility.

Alan
Re: Plasmo's 68k pathfinder projects [message #3252 is a reply to message #3250] Fri, 21 July 2017 20:48 Go to previous messageGo to next message
plasmo is currently offline  plasmo
Messages: 876
Registered: March 2017
Location: New Mexico, USA
Senior Member
The IDE spec I referenced to is ANSI X3T10 dated 1994 that specified status needs to be valid within 400nS for the READ command. My state machine has an access recovery time (from negation of CF chip select to assertion of the next CF chip select) of 500nS. I was concerned about that and lengthened it to 1.5uS, but it makes no difference.

The CPLD I used only have 128 flip flops, too small to contain a boot ROM. That's why I needed an external memory, like CF, to provide the boot code. I looked up Amstrad PCW boot sequence and it sounded like what mikemac is suggesting--copying 256 bytes of boot strap code from printer controller ROM into RAM and executing it, which then load & execute the program from drive A. I may have sufficient logics in the CPLD to do that, but the first step is to initialize the CF correctly so it can supply the necessary data to the CPU.

[Updated on: Fri, 21 July 2017 20:48]

Report message to a moderator

Re: Plasmo's 68k pathfinder projects [message #3254 is a reply to message #3252] Sat, 22 July 2017 10:57 Go to previous messageGo to next message
mikemac is currently offline  mikemac
Messages: 249
Registered: March 2017
Senior Member
Once you can get the CF card to work with your CPLD, what I was proposing is you do essentially the same thing as you're currently do with the SPI flash. Except get rid of the serializer/deserializer [CF is already parallel] and change the state machine count from 32K to 128 or whatever the block size of a CF drive is.

So your CPLD state machine copies the first CF sector to address 0x0, releases the 68000 from reset, the 68000 then executes that first sector's code which then loads the "real" image from the CF. This 2 stage boot loader approach is pretty common.

If you haven't looked yet, I'd recommend you check out https://en.wikipedia.org/wiki/Master_Boot_Record#Sector_layout. So your CPLD loads the first stage boot loader out of the "Bootstrap code area", the first stage boot loader looks in the partition table for a either "bootable" partition or one of a particular type, copies the 2nd stage from that partition, and jumps to it. That 2nd stage is either the image you want to run or it could be a 2nd stage boot loader that looks at the other partitions and gives the user a boot menu to chose from based upon those other partitions contain.

I know it sounds complicated at first glance. But it's actually just a bunch of simple steps. The only one you're really concerned about right now is getting that first sector off the CF and into RAM at 0x0. Then and only then do you make the contents of that first sector a little smarter so it can get the next stage from anyplace on the CF.

I probably haven't explained this very well. Sad



Mike
Re: Plasmo's 68k pathfinder projects [message #3255 is a reply to message #3254] Sat, 22 July 2017 12:13 Go to previous messageGo to next message
plasmo is currently offline  plasmo
Messages: 876
Registered: March 2017
Location: New Mexico, USA
Senior Member
I understand you perfectly. I didn't know anything about file structures, partitions, boot records and master boot record until a few months ago when I studied them closely so my memory is still fresh. That particular wiki page is bookmarked and referred to frequently.

I may continue to boot out of serial EEPROM for the near-term designs because the serial EEPROM is tightly specified whereas CF is a standard so that different brands of CF may behave differently and I wouldn't know my state machine is working until I've tried several different brands of CF. In fact, I was able to boot off a CF, but I don't understand why it worked. And then a small hardware adjustment caused it not to work, so clearly I don't have a good understanding of the CF protocol at this point.
Re: Plasmo's 68k pathfinder projects [message #3256 is a reply to message #3255] Sat, 22 July 2017 12:36 Go to previous messageGo to next message
mikemac is currently offline  mikemac
Messages: 249
Registered: March 2017
Senior Member
You can always put your "boot loader" in the SPI and have it load the CPM/BASIC/ucLinux/Fuzix/... image off of the CF card.

I think I'll stick with SD cards for my future boards. Smile Since I just accepted a new job yesterday, hopefully soon my toy fund will have some money in it so I can get back to building my own designs instead of just telling everyone else how to do theirs! Smile



Mike
Re: Plasmo's 68k pathfinder projects [message #3258 is a reply to message #3256] Sun, 23 July 2017 03:50 Go to previous messageGo to next message
plasmo is currently offline  plasmo
Messages: 876
Registered: March 2017
Location: New Mexico, USA
Senior Member
That's what I've done. I stored the CP/M image on the boot track, added a command to my monitor so I can invoke CP/M with a console command. It works really well. It sure is nice to have a decent size disk and fast data transfer.
Re: Plasmo's 68k pathfinder projects [message #3267 is a reply to message #3258] Tue, 25 July 2017 03:42 Go to previous messageGo to next message
etchedpixels is currently offline  etchedpixels
Messages: 333
Registered: October 2015
Senior Member
The best place to look for the CF protocol are the later versions of the ATA specification. The original IDE spec is a bit light on information, in part because the original IDE is essentially a subset of ISA bus and also because CF was added later.

http://t13.org/Documents/UploadedDocuments/project/d1410r3b- ATA-ATAPI-6.pdf

isn't a bad place to start as it's new enough to incorporate all the clarifications, merge the CF standard and the like but old enough not to dump serial ATA queued commands into the spec. It has the required voltage/current levels listed (which some cards are very fussy about) and all the timings for the different modes (PIO0 being the one you'd use at boot time). Fig 44 has all the timings for PIO0 (which includes the register writes and command issue if you are in that mode or not setting a mode)

A second problem you hit is that some ATA devices don't implement to the spec, they implement to windows. If you do what Windows does in the order Windows does it then it works, if you don't it doesn't.


Re: Plasmo's 68k pathfinder projects [message #3269 is a reply to message #3267] Tue, 25 July 2017 10:15 Go to previous messageGo to next message
plasmo is currently offline  plasmo
Messages: 876
Registered: March 2017
Location: New Mexico, USA
Senior Member
Thanks for the more recent ATA datasheet. It certainly has more details than my older datasheet. The timing on figure 44 is same as my old datasheet, which is to be expected. The figures are clearer and easier to read, so it is a keeper. Thanks,
Bill
Re: Plasmo's 68k pathfinder projects [message #3271 is a reply to message #3269] Tue, 25 July 2017 14:34 Go to previous messageGo to next message
plasmo is currently offline  plasmo
Messages: 876
Registered: March 2017
Location: New Mexico, USA
Senior Member
It is good to walk away from a problem for a while and come back with fresh eyes: The problem with CF initialization is due to a mix-up of the CF addresses. For the state machine to work its magic, it needs to control the CF address lines, so the existing hardwired A1-A3 are cut & re-wired to the CPLD. Well, I made a mistake in wiring the 3 address lines such that A2 & A3 are swapped. Embarrassed This explained fully the weird behaviors of the CF during its initialization. With A2 & A3 fixed, the CF initialized correctly and the bootstrap code loaded the monitor and monitor executed as expected. So now I can throw away the serial EEPROM and boot out of CF--well, not quite, success with one brand of CF does not mean it will work with all brands of CF. I plan to have two version of the 68000 boards, one boots out of serial EEPROM while that other boots out of CF. My preference is booting out of a CF because the state machine is quite simple: 2 cascaded 3-bit counters, 3 registered outputs, and 3 state variables for a total of 12 flip flops, compare that to well over 50 flip flops for the serial EEPROM loader. The CPLD is only 66% utilized whereas the serial EEPROM booting CPLD is 90+% utilized. I need the spare capacity in CPLD to add more features, but at 50 cents per board or $5 per run, it is hardly worth the effort to decide which design to proceed--just do both of them.
Re: Plasmo's 68k pathfinder projects [message #3632 is a reply to message #3271] Thu, 19 October 2017 08:40 Go to previous messageGo to next message
plasmo is currently offline  plasmo
Messages: 876
Registered: March 2017
Location: New Mexico, USA
Senior Member
Rev 1 of Tiny68k. Correct the error of 68000 footprint and add another serial EEPROM so I can reprogram the boot software without removing the part to program it on an external programmer.
index.php?t=getfile&id=623&private=0

[Updated on: Thu, 19 October 2017 08:43]

Report message to a moderator

Re: Plasmo's 68k pathfinder projects [message #3636 is a reply to message #3632] Sat, 21 October 2017 16:51 Go to previous messageGo to next message
mikemac is currently offline  mikemac
Messages: 249
Registered: March 2017
Senior Member
Pretty!!


Mike
Re: Plasmo's 68k pathfinder projects [message #3647 is a reply to message #3636] Tue, 24 October 2017 07:48 Go to previous messageGo to previous message
plasmo is currently offline  plasmo
Messages: 876
Registered: March 2017
Location: New Mexico, USA
Senior Member
Thanks! It works quite well as well. I've started a board wiki page under the "boards/sbc" directory:
https://www.retrobrewcomputers.org/doku.php?id=boards:sbc:ti ny68k
There are a number of things I want to check out:
- Software to program the 2nd serial EEPROM in-situ and boot from the 2nd serial EEPROM
- Auto boot to CP/M68K, perhaps I can boot directly to CP/M when boot out of the 2nd serial EEPROM
- All my tests were done at 8MHz system clock, I want to move up to 12MHz
- Build a CF disk from scratch & document it. I've tried so many different things, I forgot how to do it from the beginning!

Are there interests in this board? I've already built up 2 boards and both are working well. I want to build the third one with sockets for 68000 & 68681 so I can do speed test. The remaining 7 boards are available for anyone interested. The bare board is $1.50 each, I can assemble & program the Altera EPM7128 and program the 24C256 and sell the partial assembly for $8, or I can sell the assembled & tested board for $25 (as shown in the picture but without the CF disk). The socketed parts are SIMM module, 68000, 68681, oscillator, and 24C256 so if you already have these parts, let me know and I'll take them off the $25.
Previous Topic: National Semi NS32000 series -- Any interest?
Next Topic: ECB VDU


Current Time: Thu Apr 18 21:31:24 PDT 2024

Total time taken to generate the page: 0.00862 seconds