Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Eirik's flash tools #49

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions tools/SMCBLD2.BAS
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
5 REM COPYRIGHT 2024 EIRIK STOPLE
10 PRINT "DUMP SMC FLASH TO $7E00-$7FFF"
20 OFFSET=$1E00
21 RAM=$7E00
24 REM SET SMC PAGE TO BOOTLOADER (120)
25 I2CPOKE $42,$90,120
30 REM START A NEW LINE
40 IF OFFSET < 256 THEN PRINT "00";
50 PRINT HEX$(OFFSET) " ";
60 FOR I=0 TO 15
65 BYTE=I2CPEEK($42,$91)
68 POKE RAM,BYTE
70 PRINT " " HEX$(BYTE);
80 RAM=RAM+1
90 NEXT
100 PRINT " "
110 OFFSET = OFFSET + 16
120 IF OFFSET < 8192 GOTO 40
125 GOSUB 1000
130 PRINT "DUMPED TO $7E00-$7FFF"
140 PRINT "DUMP TO SD CARD WITH THE COMMAND"
150 PRINT "BSAVE " CHR$($22) "DUMPSMC.BIN" CHR$($22) ",8,1,$7E00,$7FFF"
160 END
1000 REM COMPUTE AND EVALUATE CHECKSUM FROM 7E00 TO 7FFF
1010 POKE 2,0
1020 POKE 3,$7E
1030 POKE 4,0
1040 POKE 5,2
1050 SYS $FEEA
1060 CRC16 = PEEK(7) * 256 + PEEK(6)
1070 PRINT "CRC-16: $" HEX$(CRC16) " ";
1080 IF CRC16 = $19B5 THEN PRINT "BOOTLOADER V1":RETURN
1090 IF CRC16 = $15C7 THEN PRINT "BOOTLOADER V2":RETURN
1100 IF CRC16 = $7594 THEN PRINT "BOOTLOADER V2 (BAD)":RETURN
1110 IF CRC16 = $6995 THEN PRINT "BOOTLOADER MISSING":RETURN
1120 PRINT "CRC-16 NOT RECOGNIZED":RETURN
Binary file added tools/SMCBLD2.PRG
Binary file not shown.
75 changes: 75 additions & 0 deletions tools/SMCBLW16.BAS
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
5 COPYRIGHT 2024 EIRIK STOPLE
10 A$ = "BOOT2.BIN"
20 PRINT "BOOTLOADER PROGRAMMER FOR SMC"
30 PRINT "SELECTED FILE: " CHR$($22) A$ CHR$($22)
40 BLOAD A$,8,1,$7C00
50 OFFSET=$1E00
60 RAM=$7C00
70 REM START A NEW LINE
80 PRINT HEX$(OFFSET) " ";
90 FOR I=0 TO 15
100 BYTE=PEEK(RAM)
110 PRINT " " HEX$(BYTE);
120 RAM=RAM+1
130 NEXT
140 PRINT " "
150 OFFSET = OFFSET + 16
160 IF OFFSET < 8192 GOTO 80
170 REM COMPUTE AND EVALUATE CHECKSUM FOR $7C00-$7DFF
180 POKE 2,0
190 POKE 3,$7C
200 POKE 4,0
210 POKE 5,2
220 SYS $FEEA
230 CRC16 = PEEK(7) * 256 + PEEK(6)
240 PRINT "CRC-16: $" HEX$(CRC16) " ";
250 GOSUB 1000
260 PRINT "PROCEED WITH PROGRAMMING? YES / NO / CHANGE FILE"
270 INPUT "Y/N/C"; B$
280 IF B$ = "C" GOTO 310
290 IF B$ = "Y" GOTO 2000
300 END
310 INPUT "FILE"; A$
320 GOTO 30
1000 REM EVALUATE CHECKSUM
1010 IF CRC16 = $19B5 THEN PRINT "BOOTLOADER V1":RETURN
1020 IF CRC16 = $15C7 THEN PRINT "BOOTLOADER V2":RETURN
1030 IF CRC16 = $7594 THEN PRINT "BOOTLOADER V2 (BAD)":RETURN
1040 IF CRC16 = $6995 THEN PRINT "BOOTLOADER MISSING":RETURN
1050 PRINT "CRC-16 NOT RECOGNIZED":RETURN
2000 REM CHECK IF FLASH MANIPULATION IS ACTIVATED
2010 IF I2CPEEK($42,$93) = 1 GOTO 3000
2020 IF I2CPEEK($42,$93) <> 0 THEN PRINT "SMC VERSION NOT SUPPORTED":END
2030 PRINT "FLASH MANIPULATION REQUIRES UNLOCKING USING BUTTON COMBINATION."
2040 PRINT "BUTTONS: POWER + RESET"
2050 PRINT "BUTTONS MUST BE PRESSED WITHIN A 20 SECOND TIMEOUT."
2060 INPUT "ARE YOU READY? Y/N"; B$
2070 IF B$ <> "Y" THEN END
2074 I2CPOKE $42,$93,1
2075 TM = 20
2080 PRINT TM
2090 SLEEP 60
2091 IF I2CPEEK($42,$93) = 1 GOTO 3000
2100 TM = TM - 1
2110 IF TM > 0 GOTO 2080
2120 GOTO 2000
3000 INPUT "SMC READY FOR PROGRAMMING. START PROGRAMMING? Y/N"; B$
3010 IF B$ <> "Y" GOTO 9000
4021 RAM=$7C00
4024 REM SET SMC PAGE TO BOOTLOADER (120)
4025 I2CPOKE $42,$90,120
4065 BYTE=PEEK(RAM)
4068 I2CPOKE $42,$92,BYTE
4080 RAM=RAM+1
4090 IF RAM < $7E00 GOTO 4065
4100 PRINT "READ FLASH AND VALIDATE CONTENTS"
4110 REM SET SMC PAGE TO BOOTLOADER (120)
4120 I2CPOKE $42,$90,120
4130 RAM=$7C00
4140 IF I2CPEEK($42,$91) <> PEEK(RAM) THEN PRINT "VERIFY FAILED":GOTO 3000
4150 RAM=RAM+1
4160 IF RAM < $7E00 GOTO 4140
4170 PRINT "PROGRAMMING SUCCEEDED"
9000 REM LOCK SMC, WILL ALSO ENABLE POWER BUTTON AGAIN
9010 I2CPOKE $42,$93,0
9020 END
Binary file added tools/SMCBLW16.PRG
Binary file not shown.
Loading