Close

Compact Flash utility finished

A project log for 6809 SBC

A 6809-based SBC with DES encryption hardware.

philmacphailPhil.macphail 03/19/2021 at 14:340 Comments

The Compact Flash utility produced several lessons for me, but I now have a version that I’m happy with. I bought a few 32M cards on Ebay to use as test-cases - it wouldn’t matter if I broke them, and they contained data which would help with checking the sector reading code. This proved to be a mixed blessing as, no matter what I tried, I could only read or write 511 bytes to the cards. I spent a couple of weeks trying different code implementations but they all behaved the same. I could write 512 bytes to the card, and read 512 bytes back, but the last byte was always corrupt. In desperation I tried a new 2G card, and it worked perfectly! I really have no idea what the problem is, but it is with these second-hand cards rather than my code. From a practical point of view they will still be usable as Flex uses 256-byte sectors, and I will fill the rest with $00 when writing, and ignore the ‘extra’ when reading. I have added the stand-alone code to the files section here, and will merge it with Assist09 to simplify programming the EEPROM.

? - List the commands available.

A simple text list of the available commands.

D - Display the RAM buffer contents.

A 512-byte buffer is held in memory, where data read from the CF Card is stored. Calls to the memory dump code in Assist09 displays the data,16 bytes to a line. The buffer starts at $1000 so the sector data address is offset by the same amount. This saved quite a bit of code, so seems like a reasonable compromise.

F - Fill CF Card buffer with a constant.

A two-digit hex value is read from the terminal. If a wrong key is pressed then the number is discarded and input starts from the beginning.

I - Initialise the CF Card.

When this program runs nothing is done to configure the CF Card interface. This command sets the card for an 8-bit interface and LBA addressing. This command must be run before reading or writing to the card.

L - Set the LBA address.

At startup the LBA address is set to $00 $00 $00 $0. This command lets the user navigate to any part of the CF Card.

R - Read a data block from theCF Card.

The 512-byte sector pointed to by the LBA address is copied to the RAM buffer, and can be viewed with the ‘D’ command.

W - Write a data block to the CF Card.

The RAM buffer is written to the sector pointed to by the LBA address.

V - Verify the data block written to the CF Card.

This command reads the sector pointed to by the LBA address, and compares each byte with the corresponding one in the RAM buffer. Any errors are reported with the address of the error, data read and value held in the buffer.

P - Print the properties of the CF Card.

The model number, serial number firmware revision and size of the card in terms of LBA values is reported.

Q - Exit this application & return to the monitor.

Returns to the Assist09 prompt.

The monitor can be used to modify the buffer contents if desired, then the application re-run to write the updated values to the CF Card.

With the listing uploaded here, the code can be downloaded to RAM using the L command in the monitor, and executed with C 2000.
The next steps are to consolidate this code with Assist09, and either write some test code for the 6859 or start on the Flex drivers.

Discussions