Building my own SD card interface for the Apple II

24 replies [Last post]
freitz's picture
Offline
Joined: Jun 11 2013
Posts: 13

Hi there,

just out of curiosity, I am currently in the middle of building my own SD card interface for my enhanced IIe. I am not trying to build a floppy replacement, but more of a ProFile replacement with a SD card with one (later multiple) 32MB ProDos partitions.
The hardware is based around André Fachat's SPI65/B CPLD SPI controller that I have modified for my own needs. My handwired proto board is working fine and I will have a proper PCB made soon.

So far, I have written a ProDos driver (Merlin assembly) for my card, that is nearly working. Currently I install it from floppy as a software driver for the slot the card is in. In the end it should be on the card itself, of course, with auto-boot and so on.
I formatted the card in CiderPress and put a few files and folders on it.
However, when doing a CAT on ProDos I see a few files and then I get a "range error" from basic, just before the "blocks free" message would be printed. When I try to load a program it crashes or hangs.

As this is my first real Apple II project, I am absolutely sure I have multiple issues at once!
First I'd like to make sure I am installing the driver correctly. Right now, the driver is loaded from floppy disk starting at address $8000 and then registered in ProDos' driver table. I am sure there is a much better and safer place in memory, but where? I need about 750 bytes. Can the driver be stored in aux ram?
I suspect when loading a program, the driver is written over and so locking up the machine.

I appreciate your answers and I am happy to share my design and driver source with you, once it is in a working state!
Regards, Flo

__________________

An apple a day keeps the doctor away!

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
freitz's picture
Offline
Joined: Jun 11 2013
Posts: 13
Re: Building my own SD card interface for the Apple II

I was able to solve the problems I described earlier. They were a combination of multiple bugs and not reserving the space for the driver.

After playing around with my handwired prototype for some time, I was confident enough to have the PCB made.
It arrived some weeks ago and after fixing another silly bug in the SD read function it seems to work perfectly. I can even boot off the card! I have to admit, I am kind of proud Wink

I put all the sources (Asm and VHDL), schematics (Eagle) and binaries on Github to share and I'd appreciate any comment!
https://github.com/freitz85/AppleIISd

Have fun, Flo
[image]https://github.com/freitz85/AppleIISd/blob/master/IMG_20170813_124455.jpg[/image]

__________________

An apple a day keeps the doctor away!

Offline
Joined: Jul 31 2014
Posts: 33
Re: Building my own SD card interface for the Apple II

Well done, it's a great feeling when you finally get projects like this working. And thanks for sharing on here.

I'd love to see some pictures of your card.

/Rob

gsmcten's picture
Offline
Joined: Oct 4 2005
Posts: 2599
Re: Building my own SD card interface for the Apple II

Freitz,

Are you planning on taking orders?
And if so, how much would one cost?

Steven Smile

__________________

Steven (gsmcten)

"Apple ][.....It's ALIVE!!!!!"

Offline
Joined: May 9 2014
Posts: 105
Re: Building my own SD card interface for the Apple II

Nice work, freitz! Is the ProDos driver already on ROM and is it autobooting?

Offline
Joined: May 2 2010
Posts: 47
Re: Building my own SD card interface for the Apple II

that is very cool.

a couple of us in Uk would LOVE one of these! Are you by chance planning to sell a few on [please] or could we look at getting a few made up?

i am assuming the cost of parts is quite low from the pic, but i have no idea.

Awesome!

PS you mentioned partitions; presently do you just boot and it reads one file, acts as if it was a single hard drive?

freitz's picture
Offline
Joined: Jun 11 2013
Posts: 13
Re: Building my own SD card interface for the Apple II

The driver is in ROM and it boot from it. To ProDos it acts as a ProFile with 32MB of storage space (65535 Blocks).
Right now, only one partition is supported, but it should be no problem at all to support up to four partitions.

I had only one pcb made and that was 50 eur, but this would become significantly cheaper when ordering more than one.
So, I guess I could supply at least the pcb. As for the parts, the cpld should be the the most expensive part with 6-10 eur. PLCC socket and Sd card socket are 2,50 each. Together below 20 euros, I guess.
Except for a handful of 0603 sized resistors and capacitors everything is normally sized, so it should be possible to build with medium soldering skills.

Now that I see that there is an interest in this card I will add a readme to my repository describing it further.

__________________

An apple a day keeps the doctor away!

Offline
Joined: May 9 2014
Posts: 105
Re: Building my own SD card interface for the Apple II

I took the liberty of using the gerbers on Github and ordered 5 PCBs from Seeed. https://www.seeedstudio.com/ They cost little under $20 delivered. Have to see how they will turn out. Is the datasheets folder practically the BOM?

freitz's picture
Offline
Joined: Jun 11 2013
Posts: 13
Re: Building my own SD card interface for the Apple II

I'm excited that there is such an interest in my little card and I am actually considering having more PCBs made for sale in Europe! Maybe a first run of 10-20 units.

@protek: the price for the PCBs is about what I expected. As for the parts, apart from the CPLD and the SD card slot, there is nothing 'fancy' on the board.

__________________

An apple a day keeps the doctor away!

macnoyd's picture
Offline
Joined: Oct 15 2012
Posts: 212
Re: Building my own SD card interface for the Apple II

Add me to the list of interested parties. Smile

__________________

macnoyd

Offline
Joined: May 9 2014
Posts: 105
Re: Building my own SD card interface for the Apple II

A few questions regarding the components....

Can a 2816 EEPROM be used in place of the 2716?
What values are the resistors and the capacitor(s)?
What component is the red and white block on the top of the board?

freitz's picture
Offline
Joined: Jun 11 2013
Posts: 13
Re: Building my own SD card interface for the Apple II

I have uploaded the schematic in PDF format as well as the BOM.

@protek: The card supports 2716, 2816, 2732 and 2832 (E)EPROMS. Currently 1KB is used.
The red/white block on top is an activity led.

__________________

An apple a day keeps the doctor away!

freitz's picture
Offline
Joined: Jun 11 2013
Posts: 13
Re: Building my own SD card interface for the Apple II

Hi there,
I have decided, that I will offer kits for sale. They will be around 20 Eur, depending on how large the batch is.
Everything will be included: PCB, sockets, CPLD, EPROM, small parts, ...

Write me a PM if you are interested!

__________________

An apple a day keeps the doctor away!

Offline
Joined: May 2 2010
Posts: 47
Re: Building my own SD card interface for the Apple II

hi, thats awesome what you've done, protek has offered me one of his boards - but I think I'll grab another board kit from you as well please Frietz Smile I'll pm

freitz's picture
Offline
Joined: Jun 11 2013
Posts: 13
Re: Building my own SD card interface for the Apple II

I have twelve orders now, so I'll going to make a first batch of 20 boards. I started ordering the parts and expect to ship the kits at the end of September.

__________________

An apple a day keeps the doctor away!

freitz's picture
Offline
Joined: Jun 11 2013
Posts: 13
Re: Building my own SD card interface for the Apple II

Does anyone have a guess what might cause a conflict with a Z80 card?
The card wants to boot, but then hangs during the initialization. I still have to analyze the bus to see at what moment exactly.
It does complete the boot when running in Bugbyter, however.

__________________

An apple a day keeps the doctor away!

gsmcten's picture
Offline
Joined: Oct 4 2005
Posts: 2599
Re: Building my own SD card interface for the Apple II

What is 20 Euros in American money? Smile

__________________

Steven (gsmcten)

"Apple ][.....It's ALIVE!!!!!"

Offline
Joined: Aug 24 2013
Posts: 45
Re: Building my own SD card interface for the Apple II

Flo,

Thank you for creating this, and even more so for releasing it.

I was able to hook it into my FPGA //e with only one minor issue. In the write process, spidataout is not initialized, which causes the Altera Quartus software to optimize out most of the code.

It appears to work the same when linked into both slot 6 and 7 on my implementation.

Do you have a bootable image to share? I believe that others will need it or instructions on how to make one in order for the design to be fully usable.

Thank you again,

Christopher

tokabln's picture
Offline
Joined: Dec 30 2015
Posts: 102
Re: Building my own SD card interface for the Apple II

gsmcten wrote:

What is 20 Euros in American money? Smile

@Steven,

actually it's roundabout 24 Dollar

https://www.oanda.com/currency/converter/

__________________

Kind regards from Berlin (Germany)
Torsten aka tokabln

freitz's picture
Offline
Joined: Jun 11 2013
Posts: 13
Re: Building my own SD card interface for the Apple II

@Christopher,

The VHDL part is basically André Fachat's code from which I have removed the the parts for multiple slaves and added the few bits for the init flag, card detect and write protect. I have to clean it up and look over the code again, but so far, it has worked and I focused on the driver side.
You have added spidataout to the reset part of the write process, I believe? Feel free to suggest further improvements, because VHDL is not really my strong side.
The same goes for everyone! I am open to improvements, bug reports, and so on.

Someone asked me if the card was compatible with the IIgs. I don't have a IIgs (yet), but judging from the timing diagrams and the fact that other cards are working, I suppose that it should. I even bought the book "Exploring Apple GS/OS and ProDOS 8" recently and I will research if there are any things to consider, when dealing with both systems.

I will write a tutorial on how to make a bootable card, which basically is to copy the contents of a bootable floppy to the card using Ciderpress.

__________________

An apple a day keeps the doctor away!

gsmcten's picture
Offline
Joined: Oct 4 2005
Posts: 2599
Re: Building my own SD card interface for the Apple II

freitz,

I would like one too.

Steven Smile

__________________

Steven (gsmcten)

"Apple ][.....It's ALIVE!!!!!"

Offline
Joined: Aug 24 2013
Posts: 45
Re: Building my own SD card interface for the Apple II

freitz wrote:

@Christopher,

The VHDL part is basically André Fachat's code from which I have removed the the parts for multiple slaves and added the few bits for the init flag, card detect and write protect. I have to clean it up and look over the code again, but so far, it has worked and I focused on the driver side.
You have added spidataout to the reset part of the write process, I believe? Feel free to suggest further improvements, because VHDL is not really my strong side.

Yes, just after the divisor line in the cpu_write: process, I added before the elsif:

spidataout <= (others => '0');

As my development board does not have inputs for the card detect and write protect, I have left
those as constants (card present and not write protected.)

Quote:

I will write a tutorial on how to make a bootable card, which basically is to copy the contents of a bootable floppy to the card using Ciderpress.

I am using the 32meg ProDOS disk from apple-2.com, which works in AppleWin without issues as a virtual hard drive.

However, I have found the issue I believe, which is related to the specific card that I am using. I found that I had to adjust the sd driver read code to add an extra dummy 0xFF write after the read completes in order for my card to work properly. I expect (although I have not confirmed) that I will need a similar dummy in the write block code as well.

This is referenced on this stack overflow page:

https://stackoverflow.com/questions/2365897/initializing-sd-card-in-spi-issues

The author mentions that it is important to send an extra 0xFF after receiving responses.

Christopher

freitz's picture
Offline
Joined: Jun 11 2013
Posts: 13
Re: Building my own SD card interface for the Apple II

Quick status update:

I am busy improving the quality and speed of the code, fixing issues, updating documentation, etc.
All parts for my initial batch of 20 kits are ordered, so I should be able to ship by october.
The price for the guinea pig offer* including shipping is as follows:
Germany: 23 Eur
World (uninsured): 24 Eur / 29 USD
World (insured): 28 Eur / 34 USD

So far, there are only 3 kits left for preorder, so hurry!

* The reason I am calling this my guinea pig offer is that I appreciate your trust, but there may be bugs. You should consider the card in beta test phase.

__________________

An apple a day keeps the doctor away!

macnoyd's picture
Offline
Joined: Oct 15 2012
Posts: 212
Re: Building my own SD card interface for the Apple II

No guts, no glory. I'll take the guinea pig! Smile

__________________

macnoyd

gsmcten's picture
Offline
Joined: Oct 4 2005
Posts: 2599
Re: Building my own SD card interface for the Apple II

Guinea pig!
Guinea pig!

Yea Team!

PM me your Paypal and I'll send payment right away.

Steven Smile

__________________

Steven (gsmcten)

"Apple ][.....It's ALIVE!!!!!"