From 069ae5db4b2e79a897c1f2343142a143379b289e Mon Sep 17 00:00:00 2001 From: Byron Lathi Date: Wed, 9 Aug 2023 22:46:18 -0700 Subject: [PATCH] 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. --- sw/bios/bootloader.s | 35 +++++++++++++++++++++++++++++++++-- sw/script/format_disk.sh | 6 +++--- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/sw/bios/bootloader.s b/sw/bios/bootloader.s index 47ef646..38718e3 100644 --- a/sw/bios/bootloader.s +++ b/sw/bios/bootloader.s @@ -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 jsr _cputs + + lda #addrh + sta sreg + 1 + lda #addrl + jsr pusheax + lda #buf + jsr pushax + lda #ptr1 + jsr _SD_readSingleBlock + + lda #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 diff --git a/sw/script/format_disk.sh b/sw/script/format_disk.sh index 0564b50..787e635 100644 --- a/sw/script/format_disk.sh +++ b/sw/script/format_disk.sh @@ -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)" -