Find bootloader in FAT
This commit is contained in:
@@ -21,7 +21,7 @@ all: $(HEX)
|
||||
|
||||
$(HEX): $(BIN)
|
||||
objcopy --input-target=binary --output-target=verilog $(BIN) $(HEX)
|
||||
diff $(HEX) $(FPGA_IMG)
|
||||
cmp $(HEX) $(FPGA_IMG)
|
||||
|
||||
|
||||
$(BIN): $(OBJS)
|
||||
|
||||
@@ -34,70 +34,6 @@ _main:
|
||||
ldx #>str
|
||||
jsr _cputs
|
||||
|
||||
lda #<_fat_count
|
||||
ldx #>_fat_count
|
||||
jsr pushax
|
||||
lda $8010
|
||||
ldx #$0
|
||||
jsr pushax
|
||||
ldy #$04
|
||||
jsr _cprintf
|
||||
|
||||
; this is offset from bpb?
|
||||
|
||||
lda #<_fat_sectors
|
||||
ldx #>_fat_sectors
|
||||
jsr pushax
|
||||
lda $8026
|
||||
sta sreg
|
||||
ldx $8027
|
||||
stx sreg + 1
|
||||
lda $8024
|
||||
ldx $8025
|
||||
jsr pusheax
|
||||
ldy #$06
|
||||
jsr _cprintf
|
||||
|
||||
lda #<_reserved_sect
|
||||
ldx #>_reserved_sect
|
||||
jsr pushax
|
||||
lda $800E
|
||||
pha
|
||||
ldx $800F
|
||||
jsr pushax
|
||||
ldy #$04
|
||||
jsr _cprintf
|
||||
|
||||
lda #<addrh
|
||||
sta sreg
|
||||
lda #>addrh
|
||||
sta sreg + 1
|
||||
pla
|
||||
clc
|
||||
adc #<addrl
|
||||
ldx #>addrl
|
||||
jsr pusheax
|
||||
lda #<buf
|
||||
ldx #>buf
|
||||
jsr pushax
|
||||
lda #<ptr1
|
||||
ldx #>ptr1
|
||||
jsr _SD_readSingleBlock
|
||||
|
||||
lda #<buf
|
||||
ldx #>buf
|
||||
jsr _SD_printBuf
|
||||
|
||||
lda #<rd_word
|
||||
ldx #>rd_word
|
||||
jsr pushax
|
||||
|
||||
lda buf
|
||||
ldx #$00
|
||||
jsr pushax
|
||||
ldy #$4
|
||||
jsr _cprintf
|
||||
|
||||
; we need to read from data segment 0, that will be the first directory entry
|
||||
; that has sector offset $00ef_e000
|
||||
|
||||
@@ -120,16 +56,63 @@ _main:
|
||||
jsr _SD_printBuf
|
||||
|
||||
|
||||
lda #$20
|
||||
sta ptr2
|
||||
lda #$82
|
||||
sta ptr2 + 1
|
||||
ldy #$0b
|
||||
@1: lda (ptr2),y
|
||||
|
||||
cmp #$0f
|
||||
bne @2
|
||||
clc
|
||||
lda ptr2
|
||||
adc #$20
|
||||
sta ptr2
|
||||
bra @1
|
||||
|
||||
@2: lda #$00
|
||||
sta (ptr2),y
|
||||
lda #<entry
|
||||
ldx #>entry
|
||||
jsr _cputs
|
||||
lda #<name
|
||||
ldx #>name
|
||||
jsr pushax
|
||||
clc
|
||||
tya
|
||||
adc ptr2
|
||||
pha
|
||||
ldx ptr2 + 1
|
||||
phx
|
||||
jsr pushax
|
||||
ldy #$4
|
||||
jsr _cprintf
|
||||
lda #<_boot2_str
|
||||
ldx #>_boot2_str
|
||||
jsr pushax
|
||||
plx
|
||||
pla
|
||||
jsr _strcmp
|
||||
bne @fail
|
||||
lda #<_good
|
||||
ldx #>_good
|
||||
jsr _cputs
|
||||
bra @end
|
||||
|
||||
@fail: lda #<_fail
|
||||
ldx #>_fail
|
||||
jsr _cputs
|
||||
|
||||
@end: bra @end
|
||||
|
||||
_reserved_sect:
|
||||
.asciiz "Reserved Sectors: %x\r\n"
|
||||
_fat_sectors:
|
||||
.asciiz "Sectors per fat: %lx\r\n"
|
||||
_fat_count:
|
||||
.asciiz "Fat Count: %x\r\n"
|
||||
str: .asciiz "Hello from the bootloader!\r\n"
|
||||
rd_word: .asciiz "Read: %x\r\n"
|
||||
str: .asciiz "boot\r\n"
|
||||
lfn: .asciiz "Found LFN\r\n"
|
||||
entry: .asciiz "Found valid entry\r\n"
|
||||
name: .asciiz "entry name: %s\r\n"
|
||||
_boot2_str: .asciiz "BOOT2 BIN"
|
||||
_fail: .asciiz "not bootloader\r\n"
|
||||
_good: .asciiz "found bootloader!\r\n"
|
||||
_end:
|
||||
|
||||
.res (440+_start-_end)
|
||||
|
||||
@@ -3,7 +3,8 @@ MEMORY
|
||||
ZP: start = $0, size = $100, type = rw, define = yes;
|
||||
KERNEL: start = $1000, size = $7000, type = rw, define = yes;
|
||||
SDRAM: start = $9000, size = $5000, type = rw, define = yes;
|
||||
BOOTLOADER: start = $8000, size = $1000, type = rw, define = yes, file = "bootloader.bin";
|
||||
BOOTSECTOR: start = $8000, size = $200, type = rw, define = yes, file = "bootloader.bin";
|
||||
BOOTLOADER: start = $8200, size = $1000, type = rw, define = yes, file = "boot2.bin";
|
||||
ROM: start = $F000, size = $1000, file = %O;
|
||||
}
|
||||
|
||||
@@ -17,7 +18,8 @@ SEGMENTS {
|
||||
CODE: load = ROM, type = ro;
|
||||
RODATA: load = ROM, type = ro;
|
||||
VECTORS: load = ROM, type = ro, start = $FFFA;
|
||||
BOOTSECTOR: load = BOOTLOADER, type = rw, start = $8000;
|
||||
BOOTSECTOR: load = BOOTSECTOR, type = rw, start = $8000;
|
||||
BOOTLOADER: load = BOOTLOADER, type = rw;
|
||||
}
|
||||
|
||||
FEATURES {
|
||||
|
||||
@@ -10,7 +10,7 @@ V=-v
|
||||
STATUS=
|
||||
|
||||
echo "$(tput bold setaf 11)Creating Filesystem$(tput sgr 0)"
|
||||
sudo mkfs.vfat -F32 $DEVICE -n SUPER6502 $V
|
||||
sudo mkfs.vfat -I -F32 $DEVICE -n SUPER6502 $V
|
||||
echo
|
||||
|
||||
echo "$(tput bold setaf 11)Modifying Boot Sector$(tput sgr 0)"
|
||||
|
||||
Reference in New Issue
Block a user