Update format script

I think there may still be some issues with a drive that is formatted
wrong, but it works consistently right now.

When modifying the boot sector, it now leaves alone the partition tables
and the bios parameter block. This does reduce the amount of code from
510 bytes to 380, but this is find as it only takes about 29 bytes to
load a sector into memory.
This commit is contained in:
Byron Lathi
2023-08-09 22:46:18 -07:00
parent d191c1da5b
commit 069ae5db4b
2 changed files with 36 additions and 5 deletions

View File

@@ -1,4 +1,4 @@
.importzp sp, ptr1, ptr2, ptr3, ptr4, tmp1, tmp2, tmp3
.importzp sp, ptr1, ptr2, ptr3, ptr4, tmp1, tmp2, tmp3, sreg
.autoimport on
@@ -11,6 +11,10 @@ _console_read_char = $2
_console_write_char = $4
_sd_readblock = $6
buf = $8200
addrh = $0000
addrl = $0001
.segment "BOOTSECTOR"
_start:
@@ -18,10 +22,35 @@ _start:
.byte "SUPR6502"
_preamble:
.res (11+_start-_preamble)
_bpb: .res 60
_main:
lda #<str
ldx #>str
jsr _cputs
lda #<addrh
sta sreg
lda #>addrh
sta sreg + 1
lda #<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
@end: bra @end
@@ -29,7 +58,9 @@ str: .asciiz "Hello from the bootloader!\r\n"
_end:
.res (446+_start-_end)
.res (440+_start-_end)
.res 6
.res 16
.res 16

View File

@@ -5,7 +5,7 @@ DEVICE=/dev/mmcblk0
TMPBOOTSECT=/tmp/bootsect
TMPMOUNT=/tmp/sd
V=
V=-v
STATUS="status=none"
echo "$(tput bold setaf 11)Creating Filesystem$(tput sgr 0)"
@@ -13,7 +13,7 @@ sudo mkfs.vfat -F32 $DEVICE -n SUPER6502 $V
echo
echo "$(tput bold setaf 11)Modifying Boot Sector$(tput sgr 0)"
sudo dd if=$BOOTLOADER of=$DEVICE bs=446 count=1 $STATUS
sudo dd if=$BOOTLOADER of=$DEVICE bs=1 count=11 $STATUS
sudo dd if=$BOOTLOADER of=$DEVICE bs=1 count=380 seek=71 skip=71 $STATUS
echo "$(tput bold setaf 10)Done!$(tput sgr 0)"