0

Right now this is all hypothetical, but I'm interested in planning ahead. I've been watching Ben Eater's 6502 computer videos, and bought his kit. And even though I haven't assembled it yet, I have ideas. I want to turn it into a functional computer, with long term storage that I don't have to program through an EEPROM writer, and eventually I'd like to be able to write assembly for the machine, on the machine. That would of course require an operating system, and while an assembler, and keyboard handler could fit on the EEPROM, there's no way to save a program to run later. So I would need mass storage, and a way to read/write from it, and store files.

Ben's last video was about SPI, and I remembered something, SD cards use SPI. This little thingy makes it easy to attach the SD card to the breadboard computer, and the protocol to read\write isn't too complicated. So now my EEPROM needs to have code to read an SD card with SPI, but all the rest can be in the mass storage, so I was hoping, rather than writing all the code for a FAT-16 storage handler onto the EEPROM, I could just write enough code to load the boot sector. Then I could pull the the FAT-16 code from there, and anything else can come from the file system. Basically I'm hoping to build my own computer and write my own OS for it. That way my EEPROM will only have to load sector 0 (or 6 if I feel fancy enough to sanity check and try to recover) into RAM and jump to it, like a mini-BIOS.

So my question is, once I have something built that I can test, how can I write my assembled code to the boot sector of an SD card with my Windows laptop? Is there a way to do that so the card is still read/writable through normal means? In other words, is there a utility, or way that I can overwrite just the boot code in sector 0 (and maybe sector 6, too)? I don't need or want the card to be bootable on a normal machine (in fact allowing it to be recognized as such would probably be a very, very, bad thing for other machines) but I do want to be able to load/save files to it on a normal machine, and read them on my tinker machine.

Thanks for taking the time to read my very explanation and question.

Lorraine
  • 1,189
  • 14
  • 30
MatrixPeckham
  • 447
  • 1
  • 4
  • 16
  • 1
    Follow this article - but for writing, not reading: https://stackoverflow.com/questions/38190/how-do-i-read-a-disk-directly-with-net – Dai Sep 05 '21 at 00:41
  • So, I would have to write my own utility in order to try to write to the boot sector. It appears that that API will just treat a drive as a single file the size of the drive. So I would have to have my boot code ready, read the first 3 bytes to get the jump instruction, use that to determine where the boot code starts. SetFilePointer to that point, then write my code. I'm surprised there isn't a utility for this already. – MatrixPeckham Sep 05 '21 at 15:35

0 Answers0