mirror of
https://github.com/hsoft/collapseos.git
synced 2024-12-26 06:18:06 +11:00
recipes/rc2014/sdcard: add instructions to write to SD card
This commit is contained in:
parent
26e71ee580
commit
57356e47b4
@ -90,8 +90,9 @@ World!":
|
|||||||
|
|
||||||
Then, insert your SD card in your SPI relay and boot the RC2014.
|
Then, insert your SD card in your SPI relay and boot the RC2014.
|
||||||
|
|
||||||
Run the `sdci` command which will initialize the card. Then, run `bsel 1` to
|
Run the `sdci` command which will initialize the card. The blockdev 0 is
|
||||||
select the second blockdev, which is configured to be the sd card.
|
already selected at initialization, but you could, to be sure, run `bsel 0` to
|
||||||
|
select the first blockdev, which is configured to be the sd card.
|
||||||
|
|
||||||
Set your memory pointer to somewhere you can write to with `mptr 9000` and then
|
Set your memory pointer to somewhere you can write to with `mptr 9000` and then
|
||||||
you're ready to load your contents with `load d` (load the 13 bytes that you
|
you're ready to load your contents with `load d` (load the 13 bytes that you
|
||||||
@ -109,7 +110,6 @@ Then, you insert your SD card in your SPI relay and go:
|
|||||||
|
|
||||||
Collapse OS
|
Collapse OS
|
||||||
> sdci
|
> sdci
|
||||||
> bsel 1
|
|
||||||
> fson
|
> fson
|
||||||
> fls
|
> fls
|
||||||
helo
|
helo
|
||||||
@ -127,5 +127,41 @@ Now let that sink in for a minute. You've just mounted a filesystem on a SD
|
|||||||
card, loaded a file from it in memory and executed that file, all that on a
|
card, loaded a file from it in memory and executed that file, all that on a
|
||||||
kernel that weights less than 3 kilobytes!
|
kernel that weights less than 3 kilobytes!
|
||||||
|
|
||||||
|
## Writing to a file in the SD card
|
||||||
|
|
||||||
|
Now what we're going to do is to write back to a file on the SD card. From a
|
||||||
|
system with the SD card initialized and the FS mounted, do:
|
||||||
|
|
||||||
|
> fopn 0 hello.txt
|
||||||
|
> bsel 1
|
||||||
|
> mptr 9000
|
||||||
|
9000
|
||||||
|
> load d
|
||||||
|
> peek d
|
||||||
|
48656C6C6F20576F726C64210A
|
||||||
|
|
||||||
|
Now that we have our "Hello World!\n" loaded in memory, let's modify it and make
|
||||||
|
it start with "XXX" and save it to the file. `sdcf` flushes the current SD card
|
||||||
|
buffer to the card. It's automatically ran whenever we change sector during a
|
||||||
|
read/write/seek, but was can also explicitly call it with `sdcf`.
|
||||||
|
|
||||||
|
> poke 3
|
||||||
|
[type "XXX"]
|
||||||
|
> peek d
|
||||||
|
5858586C6F20576F726C64210A
|
||||||
|
> seek 00 0000
|
||||||
|
0000
|
||||||
|
> save d
|
||||||
|
> sdcf
|
||||||
|
|
||||||
|
The new "XXXlo World!\n" is now written to the card, at its proper place in CFS!
|
||||||
|
You can verify this by pulling out the card (no need to unmount it from Collapse
|
||||||
|
OS, but if you insert it again, you'll need to run `sdci` again), insert it in
|
||||||
|
your modern system and run:
|
||||||
|
|
||||||
|
$ head -c 512 /dev/sdX | xxd
|
||||||
|
|
||||||
|
You'll see your "XXXlo World!\n" somewhere, normally at offset `0x120`!
|
||||||
|
|
||||||
[schematic]: spirelay/spirelay.pdf
|
[schematic]: spirelay/spirelay.pdf
|
||||||
[inspiration]: https://www.ecstaticlyrics.com/electronics/SPI/fast_z80_interface.html
|
[inspiration]: https://www.ecstaticlyrics.com/electronics/SPI/fast_z80_interface.html
|
||||||
|
@ -25,10 +25,9 @@ jp aciaInt
|
|||||||
.equ ACIA_RAMSTART RAMSTART
|
.equ ACIA_RAMSTART RAMSTART
|
||||||
#include "acia.asm"
|
#include "acia.asm"
|
||||||
.equ BLOCKDEV_RAMSTART ACIA_RAMEND
|
.equ BLOCKDEV_RAMSTART ACIA_RAMEND
|
||||||
.equ BLOCKDEV_COUNT 3
|
.equ BLOCKDEV_COUNT 2
|
||||||
#include "blockdev.asm"
|
#include "blockdev.asm"
|
||||||
; List of devices
|
; List of devices
|
||||||
.dw aciaGetC, aciaPutC, 0, 0
|
|
||||||
.dw sdcGetC, sdcPutC, sdcSeek, sdcTell
|
.dw sdcGetC, sdcPutC, sdcSeek, sdcTell
|
||||||
.dw blk2GetC, blk2PutC, blk2Seek, blk2Tell
|
.dw blk2GetC, blk2PutC, blk2Seek, blk2Tell
|
||||||
|
|
||||||
@ -43,9 +42,10 @@ jp aciaInt
|
|||||||
#include "fs_cmds.asm"
|
#include "fs_cmds.asm"
|
||||||
|
|
||||||
.equ SHELL_RAMSTART FS_RAMEND
|
.equ SHELL_RAMSTART FS_RAMEND
|
||||||
.equ SHELL_EXTRA_CMD_COUNT 9
|
.equ SHELL_EXTRA_CMD_COUNT 11
|
||||||
#include "shell.asm"
|
#include "shell.asm"
|
||||||
.dw sdcInitializeCmd, sdcFlushCmd, blkBselCmd, blkSeekCmd
|
.dw sdcInitializeCmd, sdcFlushCmd
|
||||||
|
.dw blkBselCmd, blkSeekCmd, blkLoadCmd, blkSaveCmd
|
||||||
.dw fsOnCmd, flsCmd, fnewCmd, fdelCmd, fopnCmd
|
.dw fsOnCmd, flsCmd, fnewCmd, fdelCmd, fopnCmd
|
||||||
|
|
||||||
#include "pgm.asm"
|
#include "pgm.asm"
|
||||||
@ -63,14 +63,17 @@ init:
|
|||||||
ld sp, hl
|
ld sp, hl
|
||||||
im 1
|
im 1
|
||||||
call aciaInit
|
call aciaInit
|
||||||
xor a
|
ld hl, aciaGetC
|
||||||
ld de, BLOCKDEV_GETC
|
ld de, aciaPutC
|
||||||
call blkSel
|
|
||||||
call stdioInit
|
call stdioInit
|
||||||
call shellInit
|
call shellInit
|
||||||
ld hl, pgmShellHook
|
ld hl, pgmShellHook
|
||||||
ld (SHELL_CMDHOOK), hl
|
ld (SHELL_CMDHOOK), hl
|
||||||
|
|
||||||
|
xor a
|
||||||
|
ld de, BLOCKDEV_GETC
|
||||||
|
call blkSel
|
||||||
|
|
||||||
ei
|
ei
|
||||||
jp shellLoop
|
jp shellLoop
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user