1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-10 02:38:05 +11:00
collapseos/doc/hw/sdcard.txt
Virgil Dupras 7001446212 Complete overhaul of recipes
Recipes contain bits and pieces of hardware-related knowledge, but
these bits feel sparse. I've been wanting to consolidate hardware-
related documentation for a while, but always fell at odds with the
recipes organisation.

We don't have recipes anymore, just a /doc/hw section that contains
hardware-related documentation which often translate to precise
instructions to run Collapse OS on a specific machine.

With this new organisation, I hope to end up with a better, more
solid documentation.
2020-10-30 20:39:39 -04:00

30 lines
1.2 KiB
Plaintext

# Accessing SD cards
SD cards support the SPI protocol. If you have a SPI relay
(doc/hw/spi.txt) and a driver for it that implement the SPI
protocol (doc/protocol.txt), you're a few steps away from
accessing SD cards!
What you need to do is to add the SDC subsystem to your Collapse
OS binary. First, define SDC_DEVID to a mask selecting the
proper device on your SPI relay (this is what is sent to
"(spie)"). For example, a SDC_DEVID or 1, 2, 4, or 8 would
select SPI device 1, 2, 3 or 4.
The subsystem is loaded with "423 436 LOADR".
Initialization of the SDC system is done in multiple steps.
First, the BLK system needs to be initialized with "BLK$". Then
you can plug SDC@ and SDC! into BLK with "' SDC@ BLK@* !" and
"' SDC! BLK! !". That only needs to be done once per boot.
Then, the SD card that was inserted needs to be initialized. You
can do it with "SDC$". If you have no error, it means that the
system can spek to your card, that sync is fine, etc. You can
read/write right now. SDC$ needs to run every time a new card
is inserted.
Collapse OS' SDC drivers are designed to read from the very
first 512 sector of the card, mapping them to blocks
sequentially, 2 sectors per block.