Now Reading
springSD – Dmitry.GR

springSD – Dmitry.GR

2024-01-24 17:55:39

SpringSD

Desk of Contents

  1. Hmm…
  2. The story so far
    1. Springboard Accessories
  3. To make your own springboard device…
    1. The proper way
    2. The cheapskate way
  4. A minimal SD interface
    1. SPI
  5. Interfacing to the 68k bus
    1. The first congruency
    2. Chip select
    3. Not so easy
  6. Drivers
    1. The basics
    2. Polish
  7. Finally
  8. Comments…

Hmm…

What’s the minimal-part-count strategy to join an SD card to a Handspring machine? Three SOT-23 chips, as you possibly can see within the picture. Mainly, an SD card wired on to the 68k bus 🙂

The story up to now

When Handspring launched the Visor PDA line, the primary distinguishing attribute of it was the Springboard slot. It was an enlargement mechanism through which the machine may entry wi-fi web, make telephone calls, play MP3s or radio, seize photos, or export the displayed display picture to an exterior monitor. The springboard slot was very versatile and plenty of equipment for it have been made. Its energy got here from the truth that it was mainly a direct connection to the primary CPU’s bus. The 68k CPU used within the Visor line was the MC68EZ328 for the primary few gadgets. Later gadgets switched to MC68VZ328. For all sensible functions that is simply the SoC model of the great[[citation needed]] previous 68k.

Springboard Equipment

The springboard slot exposes 24 deal with traces (of which the underside isn’t used), 16 knowledge traces, an interrupt request line to the host CPU, two chip choose traces, the same old bus management traces (nOE and nWE), and some different misc issues, like energy provide, low battery indication, floor, and so forth. As per the official docs, the bus is all the time 16-bits-wide (this will truly be configured in any other case, however not through the official API). To the host CPU the springboard machine’s first chip choose is required to appear like a x16 ROM containing a legitimate PalmOS Card. This may often comprise the functions and drivers wanted to utilize the module. Some modules solely contained software program and thus have been product of solely a single x16 flash chip. The extra attention-grabbing modules contained another {hardware}, and thus used the second chip choose to speak with it.

To make your personal springboard machine…


The right means

Handspring revealed great many documents on the best way to make correct a springboard machine. These comprise all the data one must create a correct springboard-compatible accent. The principle situation you’d face right this moment is the 34×2 1.27mm connector. It’s much like PCMCIA, however with completely different plastic keys round it. The opposite possibility is to make use of a connector with out keys. There are such connectors accessible in some locations, however they’re turning into increasingly uncommon. I discovered a source of them on LCSC and ordered just a few dozen for all my future initiatives.

The second required half is the ROM to comprise the driving force. It’s required formally, however not checked for by the machine.

The cheapskate means

If you’re prepared to be a little bit of a ache for the customers, nevertheless, you possibly can skip the ROM and inform them to load the driving force in one other means (infra-red or pc-sync). This could violate the necessities and your module wouldn’t be accepted by Handspring. Handspring now not exists, so we will stay with that. Not having the ROM onboard permits for a a lot easier board and fewer components. A win!

A minimal SD interface

SPI

The SD protocol supplies for a easy strategy to talk with an SD card – SPI. This has been supported since lengthy earlier than dinosaurs roamed the earth, and there are rumors that even single-celled organisms on the daybreak of time interfaced to the SD playing cards of yore through SPI. The SPI protocol requires 4 unidirectional traces. The primary is nCS is used to pick out the cardboard and inform it that upcoming communication is with it. It’s usually excessive, and should go low for each transaction with the SD card. The second is CLK and is the clock for the interface. SD card protocol over SPI is explicitly byte-based (SDIO protocol shouldn’t be) and so clock pulses will all the time are available in teams of eight. The final two are MOSI and MISO. These are the information traces that, when indicated by the clock pulses, carry the information to and from the cardboard.

There are some things about SPI that we will make use of. First is {that a} correct SPI slave doesn’t care about what the MISO, MOSI, and CLK traces do whereas the nCS line is excessive. In actual SPI methods that is what entry to different slaves would appear like. In concept, in SPI mode 0 (the one one which issues), no machine ought to care what MOSI does whereas the clock line shouldn’t be altering. That ought to give us extra leeway about what we do with the MOSI line.

Interfacing to the 68k bus

The primary congruency

Handspring docs (in addition to the MC68k docs) clarify the 68k bus cycles fairly nicely. Right here you possibly can see each the learn and the write cycles. It seems to be nothing like SPI. Not even slightly. So what can we do? First, let’s look solely at learn cycles. Think about the chip choose line being inverted. All of the sudden you see that you may think about any deal with line to be MOSI, any knowledge line to be MISO, and the inverted chip choose as CLK. That is one thing we will construct on.

Chip choose

Clearly there isn’t any sign that we will management long run to behave as nCS for the cardboard. We’ll want one thing that may maintain a state till modified one way or the other. That is a D-latch. We are able to use the opposite chip choose to set off it, and any deal with line as the information enter. Thus, a learn entry to the right deal with can be utilized to set and reset its output. I selected 74LVC1G80GW for this, as it’s simply accessible in a cute SOT-23 package deal. (The inverter I used can also be a SOT-23 – the 74HCT1G04GW). With this we seemingly have all of the constructing blocks we’d like and we’re solely utilizing two tiny chips. All executed, proper?

Not really easy

I attempted this design and it didn’t work. The difficulty is that our MOSI line will transfer wildly whereas CLK is steady, since we’re seeing all the 68k bus accesses. Now, in concept, this could not matter, however in follow all of the SD playing cards appear to care. So what can we do? Stick one other latch into there, in fact. And…that works… Right here you possibly can see the ultimate schematic.

So what are the bus accesses wanted? As I had talked about, solely learn accesses are used, since we use knowledge pins for output and deal with traces for enter. Bit 17 of any entry (inverted) turns into the brand new worth for card’s nCS pin. Bit 8 (inverted) turns into the MOSI that the cardboard sees. Because of this doing a learn to chip choose 1 deal with 0x20100 will set MOSI low and nCS low. A learn entry to any deal with in chip choose 2 deal with house will clock a bit in from the cardboard (on knowledge line 0). Thus, we have despatched a 1 to the cardboard and browse in a bit. An entry to chip choose 1’s offset 0x20000 will set MOSI excessive whereas maintaining nCS low. That is how a zero is distributed to the cardboard. So, for each SPI bit transacted we have to do two accesses. This isn’t too dangerous speed-wise. For pure learn transactions (when MOSI state needn’t change), we will learn in a bit in just one entry. That is fairly quick.

Drivers

The fundamentals

Some Handspring gadgets shipped with PalmOS sufficiently old that it could not correctly assist putting in Enlargement Supervisor. Fortunately I had resolved this problem before. From there, I picked up the PalmOS patches, a FAT12/16/32 filesystem driver, and the patched Enlargement Supervisor. The one factor left was to put in writing a Slot Driver that accesses this {hardware} correctly. I configure the chip selects to be 1MB in measurement every, beginning at 0x28000000, and the remaining is so simple as promised:

See Also

#outline ADDR_PIN_NCS 17
#outline ADDR_PIN_MOSI 8 //some asm code is dependent upon this
#outline CS_SIZE (0x100000ul)

#outline NCS_BASE 0x28000000ul
#outline UNSELECTED_BASE (NCS_BASE + (0ul << ADDR_PIN_NCS))
#outline SELECTED_BASE (NCS_BASE + (1ul << ADDR_PIN_NCS))
#outline SELECTED_BASE_0 (SELECTED_BASE + (1ul << ADDR_PIN_MOSI))
#outline SELECTED_BASE_1 (SELECTED_BASE + (0ul << ADDR_PIN_MOSI))
#outline UNSELECTED_BASE_0 (UNSELECTED_BASE + (1ul << ADDR_PIN_MOSI))
#outline UNSELECTED_BASE_1 (UNSELECTED_BASE + (0ul << ADDR_PIN_MOSI))
#outline CLK_BASE (NCS_BASE + CS_SIZE)

static uint8_t sdSpiByte(uint16_t val)
{
uint_fast8_t i;

val = ~val;
for (i = 0; i < 8; i++) {
val <<= 1;
(void)*(unstable uint16_t*)(SELECTED_BASE + (val & 0x100));
val += (1 & *(unstable uint16_t*)CLK_BASE);
}
return val;
}

static void sdChipSelect(void)
{
(void)*(unstable uint16_t*)SELECTED_BASE;
}

static void sdChipDeselect(void)
{
(void)*(unstable uint16_t*)UNSELECTED_BASE_1;
}

Polish

The code above is fairly sluggish. However that is good since SD card init must be executed at a clock of 400KHz or much less. After init is accomplished, larger clock charges are allowed. This may require meeting. The state of affairs the place pace is most essential is studying the information, so probably the most effort went into that. A number of intelligent tips go into this, together with the truth that studying a 32-bit worth from a 16-bit interface will carry out two back-to-back accesses, a lot sooner than they might be carried out another means. Moreover, MOSI can simply keep excessive all the time and wishes no adjustments. Here’s what the code seems to be like that can learn “sz” bytes right into a block pointed to by “knowledge”, assuming that measurement is a a number of of two bytes and knowledge is appropriately aligned.

(void)*(unstable uint16_t*)SELECTED_BASE_1;
sz = sz / 2 – 1;
asm unstable(
“2: nt”
” moveq #0, %2 nt”
“.rept 8 nt” //unrolling is quicker than loop management
” transfer.l (%4), %0 nt”
” and.l %5, %0 nt”
” lsl.l #2, %2 nt”
” or.l %0, %2 nt”
“.endr nt”
” transfer.w %2, %0 nt” //lows
” swap %2 nt”
” lsl.w #1, %2 nt” //highs << 1
” or.w %0, %2 nt” //interleave
” transfer.w %2, (%1)+ nt”
” dbra %3, 2b nt”
:”=&d”(dummy0), “+a”(knowledge), “=&d”(dummy1), “+d”(sz)
:”a”(CLK_BASE), “d”(0x00010001)
:”cc”, “reminiscence”
);

Why do I have to masks the information with 0x00010001? As a result of I don’t drive the information traces aside from 0. This AND instruction might be eliminated if I have been to incorporate 15 pull-down resistors on the cardboard, however that may make it much less easy, and I like easy. There may be additionally an meeting implementation of write, however that’s much less attention-grabbing. You may see it within the supply code archive.

Lastly

So, does it work? Sure, it does and the boards (which George graciously designed in ten minutes) may be assembled for $3 every at JLC. With my driver, any Handspring machine with this $3 board can now learn/write SD playing cards, and so can all PalmOS functions. This identical low cost SD-card-interfacing technique can be utilized for another 68k machine! All of the {hardware} design recordsdata may be downloaded here. The slot driver sources and binaries are here. You will additionally want the next recordsdata from the SASD web page: ExpansionMgr, SlimFat, and RetroFix. The license is easy: free for all non-commercial use. For industrial use (like when you want to promote kits of this challenge), contact me.


Feedback…

Source Link

What's Your Reaction?
Excited
0
Happy
0
In Love
0
Not Sure
0
Silly
0
View Comments (0)

Leave a Reply

Your email address will not be published.

2022 Blinking Robots.
WordPress by Doejo

Scroll To Top