recipes/rc2014/sdcard: use "sdci" and blockdev rather than user prog
This commit is contained in:
parent
2c80924df9
commit
8cfe834edb
@ -5,7 +5,8 @@
|
|||||||
;
|
;
|
||||||
; Note that SPI can't really be used directly from the z80, so this part
|
; Note that SPI can't really be used directly from the z80, so this part
|
||||||
; assumes that you have a device that handles SPI communication on behalf of
|
; assumes that you have a device that handles SPI communication on behalf of
|
||||||
; the z80. This device is assumed to work in a particular way.
|
; the z80. This device is assumed to work in a particular way. See the
|
||||||
|
; "rc2014/sdcard" recipe for details.
|
||||||
;
|
;
|
||||||
; That device has 3 ports. One write-only port to make CS high, one to make CS
|
; That device has 3 ports. One write-only port to make CS high, one to make CS
|
||||||
; low (data sent is irrelevant), and one read/write port to send and receive
|
; low (data sent is irrelevant), and one read/write port to send and receive
|
||||||
@ -305,8 +306,7 @@ sdcReadBlk:
|
|||||||
sdcInitializeCmd:
|
sdcInitializeCmd:
|
||||||
.db "sdci", 0, 0, 0
|
.db "sdci", 0, 0, 0
|
||||||
call sdcInitialize
|
call sdcInitialize
|
||||||
call sdcSetBlkSize
|
jp sdcSetBlkSize ; return
|
||||||
ret
|
|
||||||
|
|
||||||
; *** blkdev routines ***
|
; *** blkdev routines ***
|
||||||
|
|
||||||
|
1
recipes/.gitignore
vendored
1
recipes/.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
*.bin
|
*.bin
|
||||||
|
*.cfs
|
||||||
|
@ -1,9 +1,16 @@
|
|||||||
TARGETS = os.bin sdinit.bin
|
TARGETS = os.bin
|
||||||
ZASM = ../../../tools/emul/zasm/zasm
|
TOOLS = ../../../tools
|
||||||
|
ZASM = $(TOOLS)/emul/zasm/zasm
|
||||||
|
CFSPACK = $(TOOLS)/cfspack/cfspack
|
||||||
|
|
||||||
.PHONY: all
|
.PHONY: all
|
||||||
all: $(TARGETS)
|
all: $(TARGETS) sdcard.cfs
|
||||||
os.bin: glue.asm
|
os.bin: glue.asm
|
||||||
sdinit.bin: sdinit.asm
|
|
||||||
$(TARGETS):
|
$(TARGETS):
|
||||||
$(ZASM) < $< > $@
|
$(ZASM) < $< > $@
|
||||||
|
|
||||||
|
$(CFSPACK):
|
||||||
|
make -C $(TOOLS)/cfspack
|
||||||
|
|
||||||
|
sdcard.cfs: cfsin $(CFSPACK)
|
||||||
|
$(CFSPACK) $< > $@
|
||||||
|
@ -81,26 +81,22 @@ should have [glue code that looks like this](glue.asm).
|
|||||||
Initially, when you don't know if things work well yet, you should comment out
|
Initially, when you don't know if things work well yet, you should comment out
|
||||||
the block creation part.
|
the block creation part.
|
||||||
|
|
||||||
## Testing CD card initialization
|
## Reading from the SD card
|
||||||
|
|
||||||
This receipes contains a little [user program](sdinit.asm) that initializes a
|
|
||||||
SD card, reads the first 12 bytes from its first sector and prints it.
|
|
||||||
|
|
||||||
The first thing we'll do is fill the SD card's first 12 bytes with "Hello
|
The first thing we'll do is fill the SD card's first 12 bytes with "Hello
|
||||||
World!":
|
World!":
|
||||||
|
|
||||||
echo "Hello World!" > /dev/sdX
|
echo "Hello World!" > /dev/sdX
|
||||||
|
|
||||||
Then, you can run `make` from within this folder to compile `sdinit.bin` and
|
Then, insert your SD card in your SPI relay and boot the RC2014.
|
||||||
then [upload and run][run-from-mem] that code from memory. You might need to
|
|
||||||
call the routine more than once (On my local tests, I need to call it twice).
|
|
||||||
|
|
||||||
If all goes well, you should see your "Hello World!" printed to the console!
|
Run the `sdci` command which will initialize the card. Then, run `bsel 1` to
|
||||||
|
select the second blockdev, which is configured to be the sd card.
|
||||||
|
|
||||||
## Create a block device from the SD card reader
|
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
|
||||||
TODO
|
wrote to your sd card earlier. You can then `peek d` and see that your
|
||||||
|
"Hello World!\n" got loaded in memory!
|
||||||
|
|
||||||
[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
|
||||||
[run-from-mem]: ../../../doc/load-run-code.md
|
|
||||||
|
1
recipes/rc2014/sdcard/cfsin/hello.txt
Normal file
1
recipes/rc2014/sdcard/cfsin/hello.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
Hello World!
|
@ -41,14 +41,14 @@ jp aciaInt
|
|||||||
#include "stdio.asm"
|
#include "stdio.asm"
|
||||||
|
|
||||||
.equ SHELL_RAMSTART STDIO_RAMEND
|
.equ SHELL_RAMSTART STDIO_RAMEND
|
||||||
.equ SHELL_EXTRA_CMD_COUNT 3
|
.equ SHELL_EXTRA_CMD_COUNT 4
|
||||||
#include "shell.asm"
|
#include "shell.asm"
|
||||||
.dw sdcInitializeCmd, blkBselCmd, blkSeekCmd
|
.dw sdcInitializeCmd, blkBselCmd, blkSeekCmd, sdcInitializeCmd
|
||||||
|
|
||||||
.equ SDC_RAMSTART SHELL_RAMEND
|
.equ SDC_RAMSTART SHELL_RAMEND
|
||||||
.equ SDC_PORT_CSHIGH 6
|
.equ SDC_PORT_CSHIGH 6
|
||||||
.equ SDC_PORT_CSLOW 5
|
.equ SDC_PORT_CSLOW 5
|
||||||
.equ SDC_PORT_SPI 4
|
.equ SDC_PORT_SPI 4
|
||||||
#include "sdc.asm"
|
#include "sdc.asm"
|
||||||
|
|
||||||
init:
|
init:
|
||||||
|
@ -1,52 +0,0 @@
|
|||||||
.equ JUMP_PRINTSTR 0x03
|
|
||||||
.equ JUMP_PRINTHEX 0x06
|
|
||||||
.equ JUMP_SDCINITALIZE 0x09
|
|
||||||
.equ JUMP_SDCSENDRECV 0x0c
|
|
||||||
.equ JUMP_SDCWAITRESP 0x0f
|
|
||||||
.equ JUMP_SDCCMD 0x12
|
|
||||||
.equ JUMP_SDCCMDR1 0x15
|
|
||||||
.equ JUMP_SDCCMDR7 0x18
|
|
||||||
.equ JUMP_SDCREAD 0x1b
|
|
||||||
.equ JUMP_SDCSETBLKSIZE 0x1e
|
|
||||||
.org 0x9000
|
|
||||||
|
|
||||||
call JUMP_SDCINITALIZE
|
|
||||||
or a
|
|
||||||
jp nz, error
|
|
||||||
|
|
||||||
ld hl, sOk
|
|
||||||
call JUMP_PRINTSTR
|
|
||||||
|
|
||||||
call JUMP_SDCSETBLKSIZE
|
|
||||||
or a
|
|
||||||
jp nz, error
|
|
||||||
|
|
||||||
ld hl, sOk
|
|
||||||
call JUMP_PRINTSTR
|
|
||||||
|
|
||||||
; read sector 0
|
|
||||||
xor a
|
|
||||||
call JUMP_SDCREAD
|
|
||||||
or a
|
|
||||||
jp nz, error
|
|
||||||
|
|
||||||
push hl
|
|
||||||
ld hl, sOk
|
|
||||||
call JUMP_PRINTSTR
|
|
||||||
pop hl
|
|
||||||
; SDC buffer address is in HL
|
|
||||||
; YOLO! print it!
|
|
||||||
call JUMP_PRINTSTR
|
|
||||||
|
|
||||||
ret
|
|
||||||
|
|
||||||
error:
|
|
||||||
call JUMP_PRINTHEX
|
|
||||||
ld hl, sErr
|
|
||||||
call JUMP_PRINTSTR
|
|
||||||
ret
|
|
||||||
|
|
||||||
sOk:
|
|
||||||
.db "Ok", 0xa, 0xd, 0
|
|
||||||
sErr:
|
|
||||||
.db "Err", 0xa, 0xd, 0
|
|
Loading…
Reference in New Issue
Block a user