Hi!
Ok, I see. Hmm, FAT32 formatter generates a 32-bit ID starting at byte 39 of the filesystem descriptor at sector 0 of the partition. For most disks, you could do a blockread of sector 0 and get that ID. For device D (SD card), you could do
u_int16 buf[256];
VODEV('D')->BlockRead(VODEV('D'), 0, 1, buf);
and get the ID plus a few surrounding bytes there, around buf[20], I'd imagine. That should work for most cases, at least if the disk has just the FAT and no partition table. Usually SD cards and USB sticks don't have partition tables.(if they do, you need to follow the entry for partition 1 to the first sector of the partition that holds the FAT32 BPB info)
VSOS does no such tracking, it manages to manage the entire filesystem with something like 16 words of info in RAM
-Panu
PS. Where do you intend to hold the information? Be extra careful if you intend to write the SPI flash that holds your firmware. Don't write to the root, make a subdirectory for your info so that you don't lose your firmware in the inevitable case where power runs out in the middle of a write and you end up with a corrupted directory.
Personally my vote is to use one fixed 4K block in the SPI flash and erase and write raw data there for stuff that needs updating. This way there's no FAT directory writing ever happening without explicit user interaction. You can do a BlockRead and BlockWrite of negative sector numbers of the S: disk if it's a SPI flash. You can read and write sectors -8 to -1, e.g. the 8 sectors (4 kilobytes) immediately before the start of the FAT S: system disk. Just do a read of sector 0 after the blockwrites to commit the write from RAM buffer to the flash proper.
For the book currently being listened, you can use the 32 bits in the RTC shifter (use RTC battery) to hold immediate information about where you are playing or about volume setting or other such small information.