[Coco] CocoFlash (was: Re:  Re: 512K EEPROM...or 4MB!!?)

RETRO Innovations go4retro at go4retro.com
Thu Dec 10 01:21:16 EST 2015

On 12/9/2015 2:05 PM, Zippster wrote:
> Sounds like an ideal way to handle the interface on your 8MB board Jim.
> Very nice.  :)
Thanks, but I doubt I can take credit.

It does make the PCB easy to lay out, since all of the FLASH ROM pins 
can be mapped to any pin on the CPLD.  Layout is a breeze, compared to 
discrete logic.

I spent a bit of time on the design tonight, as I had not done anything 
with it for a few months, and by making a few tweaks and constraining 
the bank granularity to 2kB instead of 1kB, I was able to get the logic 
to synthesize into a xc9572xl, which is cheaper.  I may reduce it down 
to 4kB unless 2kB granularity is really important, because it has a 
programming issue right now:

The 29lv640 supports writes by performing "magic writes", which are 
writes to the FLASH ROM space that don't actually write values, but 
trigger the FLASH ROM state machine to prepare for a command (write, 
read the ID, erase, etc.).  The 29lv640 is nice because it's "magic 
writes" only care about the data value and the low 12 bits of the 
address.  So, $x555,$aa will advance the state machine in the ROM. Thus 
the easiest way to write values to the ROM is to set the FLASH_WRITE 
bit, and then do:


to trigger the state machine.  But, having 2kB granularity causes an 
issue if the bank value is set to, let's say, $01.  In that case, 
address lines 13-11 are added to $01 to get the actual 2kB base address 
in the FLASH ROM:

$c555 -> binary 1100010101010101 -> 000 + $01 = $01

and then the bits 10:0 are added to this:

$c555 -> bits[10:0] = 10101010101 + bank register $01: 0110101010101

Which is 1101 0101 0101 = $d55

which will not trigger the state machine.

This issue only occurs on odd number banks.  Even number banks, like $02 
are OK:

$c555 -> binary 1100010101010101 -> 000 + $02 = $02
$c555 -> bits[10:0] = 10101010101 + bank register $02:  1 0101 0101 0101 
= $1555 == $x555

It's not really an issue per se, because simply aligning on an even bank 
to write the magic values and then moving the bank register value to the 
right bank before writing (or just writing values 2kB into the existing 
bank) will make everything work, but it will trip a developer up if they 
don't consider that the magic values are aligned on 4kB pages.

I also moved the registers around so it mostly mimics the MiniFlash 
($ff59 holds the low 8 bits of the bank register, while $ff5a holds the 
upper 4 bits, though the FLASH_WRITE had to move to $ff58 bit 7 because 
the bank register is much larger)

I also added a trick from my VIC-20 UltiMem cart, which is to disable 
autostart if switch 0 is depressed on boot/reset.  This is useful if one 
"borks" the boot block of the ROM up.  I should probably add a switch to 
completely disable to cart, though.

Finally, I added a "cart ID" on $ff5b: $11 <vendor ID>:<device ID>


More information about the Coco mailing list