Welcome, Guest. Please login or register.


Author Topic: SD card interface (Read 231945 times)

Offline Saint

  • EP user
  • *
  • Posts: 266
  • Country: gb
Re: SD card interface
« Reply #15 on: 2013.October.10. 11:12:17 »
Ok, that makes my life easier... :)

If you needed additional functionality it would of course be possible to reprogram the CPLD and PIC to add it in as well.... :ds_icon_cheesygrin:

Offline BruceTanner

  • EP lover
  • *
  • Posts: 607
  • Country: gb
Re: SD card interface
« Reply #16 on: 2013.October.18. 15:08:36 »
Here's a really interesting SD card:

http://www.amazon.co.uk/Eye-Fi-Connect-Wireless-SDHC-Memory/dp/B003E47XIQ/ref=sr_1_2?ie=UTF8&qid=1382100891&sr=8-2

An SD card with built in wifi interface! (Other makes/sizes are available if you search amazon for wifi SD card - this is the cheapest at £25)

It's intended for use in digital cameras: you connect your smartphone or PC to the camera wirelessly over wifi and can then copy your pictures off it. So if it was in an Enterprise SD card interface you would be able to copy files to and from it using a PC etc.

I have been contemplating an Enterprise ethernet interface. This would use this module to do most of the network protocols. I would write an SMB protocol that runs on the Z80 and would allow eg. :NET USE X: \\server\directory to create an X: drive and allow LOAD and SAVE to "X:name" and also "FTP:name" as well as, with a bit of EXDOS modification, :DIR X:. This would probably be the ideal way of networking an Enterprise but it may be that the wifi SD card would be adequate and would certainly be less work if an SD card interface already existed!

Offline Saint

  • EP user
  • *
  • Posts: 266
  • Country: gb
Re: SD card interface
« Reply #17 on: 2013.October.18. 22:49:50 »
That's extremely cool! My original idea for the SD card interface was to have it internal to the Enterprise like an internal hard drive and have a way to access the SD card via a serial connection. This is just so much better! Awesome find.

Offline BruceTanner

  • EP lover
  • *
  • Posts: 607
  • Country: gb
Re: SD card interface
« Reply #18 on: 2013.October.18. 23:11:27 »
Apparently they have linux running on them! There is a discussion about hacking them here. I must confess I don't understand it all as I'm not a linux expert :(

What a difference 3 decades of tech advances makes!

Offline lgb

  • EP addict
  • *
  • Posts: 3563
  • Country: hu
  • æðsta yfirmaður
    • http://lgb.hu/
Re: SD card interface
« Reply #19 on: 2013.October.19. 14:49:24 »
I've realized that an Ethernet interface for EP can be more useful than an SD card. Why? Because it is a bit cumbersome to always exchange SD card between your PC and EP if you want to copy programs, or better: if you want to cross-develope EP stuff on PC and you need to do lots of data transfer. By contrast, if you have an Ethernet solution you can exchange data easily between your PC and with the whole Internet! You can even have some simple protocol (maybe UDP based) to access a disk image so it would be a quite normal disk from the point of view of EXDOS, just like an SD card solution, or Zozo's IDE interface, etc, just through the net. My home router is always switched on and it has an USB port. I usually keep a bigger pendrive in it (but for sure even a PATA/SATA to USB converter is OK with a harddisk, or any NAS like home stuff), and the router can share the storage via FTP or SMB/CIFS. But I can even run a custom little UDP server for EP for example (it runs Linux so it's not a problem at all to do). So the storage is always there via network, to be used even for EP.

Of course the "disk image level" access can be extended later (as Bruce wrote) to access data not so much with EXDOS but via custom protocol like SMB/CIFS with "a little EXDOS hacking" to support eg DIR on it. I wanted the same with my JavaScript EP emulator via AJAX functionality, and I named it as "NetLinkFS", the theory is similar just I wanted to avoid to hack EXDOS and I used different command set like NDIR instead of DIR, but otherwise the idea is similar.

Meanwhile, if you have Ethernet for EP, you can even load programs for the Net, you can even chat on your EP (like my iRC tries) or even sending/receiving email or some limited text based web browser expereince on EP what I've also tried in my emulator, not only accessing a disk image basically, what would be used with an SD card solution.

At first I thought about implementing a general purpose SPI bus. It would be great to access an SD card and also an ENC28J60 ethernet controller (I have that IC). However Bruce idea about that wiznet module (also Zozo mentioned that idea) is better in the sense that it already supports even TCP/IP by hardware and simple integration on the bus system of a 8 bit machine, no need for SPI at all. Also, writing a TCP/IP stack in Z80 assembly for EP would be a larger work (IP fragmentation, and other issues, especially with TCP; UDP/ICMP/ARP level is much more easy, I've already done it for Commodore 64 some years ago), and it would be somewhat memory hungry solution. That module does that for you, don't need to implement basic network protocols by yourself (of course something like SMB/CIFS should be, but it's another question, the basic of these is UDP, TCP ...).

Offline Saint

  • EP user
  • *
  • Posts: 266
  • Country: gb
Re: SD card interface
« Reply #20 on: 2013.October.20. 23:30:59 »
Another thought is to use something like the PIC18F97J60 for the sd card controller chip. This chip has an in built Ethernet mac and phy and Microchip provide a TCP/IP stack. And it's cheap! Could extend the command set which talks to the SD card to include Ethernet as well...

Offline lgb

  • EP addict
  • *
  • Posts: 3563
  • Country: hu
  • æðsta yfirmaður
    • http://lgb.hu/
Re: SD card interface
« Reply #21 on: 2013.October.21. 02:02:03 »
Quote from: Saint
Another thought is to use something like the PIC18F97J60 for the sd card controller chip. This chip has an in built Ethernet mac and phy and Microchip provide a TCP/IP stack. And it's cheap! Could extend the command set which talks to the SD card to include Ethernet as well...

I have no idea about PICs only AVRs, but indeed. Some MCUs even have USB (but then USB host or at least OTG would be needed) so in theory, a pin-monster and feature-rich enough MCU can give Ethernet, SPI, USB and even serial connection well other things too if needed like I2C (can be used with eg a little RTC chip to provide real time clock as well). And btw USB - maybe implementing USB storage protocol is even more comfortable than having SD card interface: pen drives, most mobil phones / mp players (which uses the generic storage protocol and not some own one), or even harddisk with USB adapters can be accessed then.
« Last Edit: 2013.October.21. 06:30:48 by lgb »

Offline Saint

  • EP user
  • *
  • Posts: 266
  • Country: gb
Re: SD card interface
« Reply #22 on: 2013.October.26. 14:01:08 »
I've started looking into the SD card interface some more now, and I've been looking into the ethernet side as well. You can get the ENC28J60 SPI ethernet controller cheaply, and Microchip offer a free TCP/IP stack. So I can have a PIC controlling both the SD card and ethernet hardware.

I have also been thinking it will be better to do this as an expansion port device if I include ethernet, so I can generate an interrupt on packet receipt. I may also map this as an io device rather than memory in this case. Is there an io map for the Enterprise anywhere?

Also, is it possible to do DMA transfers on the Enterprise, such as using the Z8410? I may be able to do DMA data transfer direct from the CPLD...

Edit: On looking further BUSRQ is tied high on the Enterprise. No DMA possible without internal modification... :(
« Last Edit: 2013.October.26. 14:17:57 by Saint »

Offline Zozosoft

  • Global Moderator
  • EP addict
  • *
  • Posts: 14721
  • Country: hu
    • http://enterprise.iko.hu/
Re: SD card interface
« Reply #23 on: 2013.October.26. 16:35:48 »
Quote from: Saint
Edit: On looking further BUSRQ is tied high on the Enterprise. No DMA possible without internal modification... :(
Yes it is only posible if the CPU and DMA are in same CPU board and looks a "CPU" for the system. (Or some signals directly connected from the Z80 to DMA)
If my Z180 project will be successful then it is have built in DMA channels :-)

Offline lgb

  • EP addict
  • *
  • Posts: 3563
  • Country: hu
  • æðsta yfirmaður
    • http://lgb.hu/
Re: SD card interface
« Reply #24 on: 2013.October.26. 18:42:50 »
Quote from: Saint
I've started looking into the SD card interface some more now, and I've been looking into the ethernet side as well. You can get the ENC28J60 SPI ethernet controller cheaply, and Microchip offer a free TCP/IP stack. So I can have a PIC controlling both the SD card and ethernet hardware.

ENC28J60 was exactly my plan too, I've already bought one, but still I haven't had mentionable freetime to try. I've already posted my original plan somewhere (maybe even this topic) to build a general SPI interface for both of SD card and ENC. Just I thought it's more "EP the boss" feeling to do it on EP not in an MCU to do TCP/IP (it's about the feeling to have an MCU more powerfull than the Z80 itself) too and so. But hmm maybe I am wrong here and these are just feelings nothing more :)

Quote
I have also been thinking it will be better to do this as an expansion port device if I include ethernet, so I can generate an interrupt on packet receipt.

AFAIK, dave has a free interrupt source, it has got two external interrupt possibility, one is used for video interrupt (generated by Nick), but the other is free otherwise.

Quote
I may also map this as an io device rather than memory in this case. Is there an io map for the Enterprise anywhere

I've tried to collect them once in my "epbas" project, but it's not detailed enough. In this forum there are some topics with detailed description on various ports, but mostly in Hungarian and anyway it's hard to collect these together. Anyway this is what I have (you should scroll down to the end of the page).

Quote
Also, is it possible to do DMA transfers on the Enterprise, such as using the Z8410? I may be able to do DMA data transfer direct from the CPLD...

Edit: On looking further BUSRQ is tied high on the Enterprise. No DMA possible without internal modification... :(

I think DMA is not so possible, as Zozo told. I thought about an ugly solution to have some dual port SRAM somewhere in the memory map, and both the MCU and the CPU can access it. However it limits the access to this RAM, and also dual port SRAM is a bit expensive, harder to get, and mosly lower capacity (at least what I've found on the net).

Offline BruceTanner

  • EP lover
  • *
  • Posts: 607
  • Country: gb
Re: SD card interface
« Reply #25 on: 2013.October.26. 20:48:40 »
If the network access could be over wifi, the whole thing could be internal :)

If “someone else“ was handling the tcp/ip stack I wonder if you could get away with not needing to use interrupts for network access - it would be a lot simpler. At the EXOS level everything is synchronous ie the z80 would always send a request and wait around for a reply, possibly repeated several times. Even if the spare interrupt works at the hardware level, interupts always cause complications for software and there could be problems with anything from extra stack usage causing odd crashes (the network interrupt interrupting the system interrupt or vice versa depending on how the priorities work out) to problems due to the time taken copying a packet from the net h/w to the z80 in interrupt time. You'd only need interrupts if the high level protocol (SMB ?) needs to respond to an asychronously-received packet, and I don't think it will (assuming it's not being a server!).

If the wifi SD cards turn out not to do what we want, another possibility is to implement exactly what we do want and not involve the z80 in the network at all ie. write PIC s/w so you can read and write files to the SD card directly over the network.

If you go for an i/o-based solution check out how the ethernet module I previously posted a link to does it - it's use of an auto-incrementing register (effectively a pointer to the on-module memory) would (I think) allow INIR etc to be used.

Offline Saint

  • EP user
  • *
  • Posts: 266
  • Country: gb
Re: SD card interface
« Reply #26 on: 2013.October.26. 23:34:57 »
lgb, I think of the pic controlling the SD card just as the wd1772 controlling the disk access. There's no need to burden the CPU with the details, just get the data to where it needs to be! :)

I'll need to check the api for the tcp/ip stack and see how it all works, but in general I'm not a fan of polled access. But equally I know little of how the z80 handles interrupts, as I'm a 68000 guy, so if it's going to be a pain in the ass, we can stick with polled. :)

It may even be more sensible to have a higher level protocol at the PIC level, if all that is needed is file transfer. I can see ethernet will need more thought! I'll check out existing spectrum ethernet devices and see how they work...

But this should all be pretty redundant if the wifi sd card can provide the file access we want.
« Last Edit: 2013.October.26. 23:49:52 by Saint »

Offline Saint

  • EP user
  • *
  • Posts: 266
  • Country: gb
Re: SD card interface
« Reply #27 on: 2013.October.26. 23:47:35 »
One quick question on the Dave and io requests - how does the io port get passed to the address bus as a14 and a15 are controlled by Dave? The z80 passes the io port to both a0-a7 as well as a8-a15 I believe. Does Dave pass through the top two bits of the io port?

Offline Zozosoft

  • Global Moderator
  • EP addict
  • *
  • Posts: 14721
  • Country: hu
    • http://enterprise.iko.hu/
Re: SD card interface
« Reply #28 on: 2013.October.26. 23:58:42 »
The A14-15 also go through on the paging circuit in IO mode. Then the A14-15 on the System Bus depend of the currently paged segments.
(This is the big problem with the Spectrum Emulator card: for the Spectrum keyboard scan used the top 8 bit of xxFEh port, then the keyboard emulation very buggy with the original ROM. I fixed it with selecting right segments in my enhanced ROM.)

Offline Saint

  • EP user
  • *
  • Posts: 266
  • Country: gb
Re: SD card interface
« Reply #29 on: 2013.October.27. 00:18:14 »
The A14-15 also go through on the paging circuit in IO mode. Then the A14-15 on the System Bus depend of the currently paged segments.

Thanks Zozo, that makes sense. Something to be aware of. :)

I've been looking at SpeccyBoot here --

http://speccyboot.sourceforge.net/
https://svn.code.sf.net/p/speccyboot/code/tags/speccyboot-1.5/

There's some nice code for dealing with the ENC28J60 directly from the Z80. So perhaps just an SPI interface and let the z80 deal with it, after all. I'm a big fan of code re-use, as there will be a fair bit of work on that side...