I tried a couple of other cards and found that they have different MBR formats with no header. I noted this in a previous log. There's an offset at 0x01BE that points to the MBR. My theory is this is true for "bigger" cards. I think the reason I could get it to work on the other card is that it is a small card. I think that bigger cards contain this offset to the MBR and smaller cards don't.
Why Big Cards?
I think the answer is that larger cards have a lot of "wasted" space at the start. There's really no point in supporting smaller cards. I tried to buy some 8GB SD cards and they are getting hard to find and expensive. 32 Gb seems to be the sweet spot at the moment. Of course, all of the existing software in the world for the OSI could easily fit onto one of these SD cards, so why not? 64 GB cards are formatted as exFAT and older devices like cameras don't support exFAT so there's likely to be some market "life" left in 32GB cards.
INIT STATUS - OK LBA0 ? 0 LBA1 ? 0 LBA2 ? 0 000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 080 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 090 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0C0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0D0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0E0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 100 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 110 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 120 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 130 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 140 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 150 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 160 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 170 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 180 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 190 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 1A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 1B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 82 ................ 1C0 03 00 0C FE FF FF 00 20 00 00 00 04 B7 03 00 00 ....... ........ 1D0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 1E0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 1F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 AA ..............U.
Is the first sector Partition Table?
A comment on this page helped.
...the four entry partition table stars at 0x1BE. Each entry is 16 bytes and in this case it's pretty clear only one is filled...
Also, on this FAT32 Structure Information - MBR, FAT32 Boot Sector Introduction page:
...The Master Boot Record is the same for pretty much all Operating Systems. It is located on the first Sector of the Hard Drive, at Cylinder 0, Head 0, Sector 1. It is the first piece of code that your computer runs after it has checked all of your hardware (POST) and turned control of loading software over the hard drive. It also contains the partition table, which defines the different sections of your hard drive...
Also see Hard Drive Partition. Partition Table - NTFS.com
provides information how to determine if LBA 0 is a partition table or not.
Byte Offset | Field Length | Sample Value | Meaning |
---|---|---|---|
00 | BYTE | 0x80 | Boot Indicator. Indicates whether the partition is the system partition. Legal values are: 00 = Do not use for booting. 80 = System partition. |
For that example:
00 03 33 00 06 02 E2 CA EF 00 00 00 11 EB 0E 00 00 - bootable 03 33 00 - CHS of start (ignore cos LBA used these days) 06 - partition type (DOS 3.31+ 16 bit FAT) 02 E2 CA - CHS of end (ignore) EF 00 00 00 - start LBA is 0x000000EF (sector 239) 11 EB 0E 00 - end LBA is 0x000EEB11 (sector 977,681)
My 32GB card has:
00 82 03 00 0C FE FF FF 00 20 00 00 00 04 B7 03 ADDR OFF VALS 01BE 0 00 - bootable 01BF 1 82 03 00 - CHS (ignore) 01C2 4 0C - partition type WIN95 OSR2 FAT32, LBA-mapped 01C3 5 FE FF FF - CHS of end (ignore) 01C6 8 00 20 00 00 - start LBA is 0x00002000 01CA 12 00 04 B7 03 - end LBA is 0x03B70400
Added addresses to last few rows. Fields are:
Offset (bytes) | Len | Description | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0x00 | 1 | Status or physical drive (bit 7 set is for active or bootable, old MBRs only accept 0x80, 0x00 means inactive, and 0x01–0x7F stand for invalid)[c] | ||||||||||||||||||
0x01 | 3 | CHS address of first absolute sector in partition.[d] The format is described by three bytes, see the next three rows. | ||||||||||||||||||
0x01 | 1 |
| ||||||||||||||||||
0x02 | 1 |
| ||||||||||||||||||
0x03 | 1 |
| ||||||||||||||||||
0x04 | 1 | Partition type[15] | ||||||||||||||||||
0x05 | 3 | CHS address of last absolute sector in partition.[d] The format is described by 3 bytes, see the next 3 rows. | ||||||||||||||||||
0x05 | 1 |
| ||||||||||||||||||
0x06 | 1 |
| ||||||||||||||||||
0x07 | 1 |
| ||||||||||||||||||
0x08 | 4 | LBA of first absolute sector in the partition[f] | ||||||||||||||||||
0x0C | 4 | Number of sectors in partition[f] |
0x002000 is LBA0-2 - 0,32,0
INIT STATUS - OK LBA0 ? 0 LBA1 ? 32 LBA2 ? 0 000 EB 00 90 20 20 20 20 20 20 20 20 00 02 40 92 04 ... ..@.. 010 02 00 00 00 00 F8 00 00 3F 00 FF 00 00 20 00 00 ........?.... .. 020 00 04 B7 03 B7 1D 00 00 00 00 00 00 02 00 00 00 ................ 030 01 00 06 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 040 80 00 29 39 62 35 30 4E 4F 20 4E 41 4D 45 20 20 ..)9b50NO NAME 050 20 20 46 41 54 33 32 20 20 20 00 00 00 00 00 00 FAT32 ...... 060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 080 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 090 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0C0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0D0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0E0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 100 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 110 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 120 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 130 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 140 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 150 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 160 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 170 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 180 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 190 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 1A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 1B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 1C0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 1D0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 1E0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 1F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 AA ..............U.
FAT32 shows up there. Automated BASIC code is:
100 REM OSISDOS READ DIR FROM SD CARD IN BASIC 110 SAVE:REM TURN ON LOGGING TO SERIAL PORT 120 REM SDCARD BASE ADDRESS = $F010 (61456 DEC) 130 DT=61456:ST=61457:A0=61458:A1=61459:A2=61460:REM SD INTERFACE REGISTER ADDRESSES 140 DIM MA(512):REM RESERVE ARRAY SPACE FOR SD CARD DATA 150 GOSUB 2200:REM CHECK CARD INIT STATUS 160 REM READ FIRST LBA 170 L0=0:L1=0:L2=0 180 GOSUB 3800:REM POKE LBA VALS 190 GOSUB 2200:REM CHECK CARD INIT STATUS 200 GOSUB 2400:REM READ IN BLOCK 210 GOSUB 3000:REM DUMP ARRAY 220 GOSUB 3600:REM PRINT FIRST SECTOR KEY VALUES 230 L0=MA(454):L1=MA(455):L2=MA(456) 240 GOSUB 3800:REM POKE LBA VALS 250 GOSUB 2200:REM CHECK CARD INIT STATUS 260 GOSUB 2400:REM READ IN BLOCK 270 PRINT "FIRST BLOCK" 280 GOSUB 3000:REM DUMP ARRAY 290 GOSUB 4000:REM PRINT KEY VALUES IN FIRST BLOCK 1990 END 2200 REM CHECK CARD INIT STATUS 2210 IF PEEK(ST) = 128 THEN RETURN 2220 PRINT "BAD INIT STATUS" 2230 PRINT PEEK(ST) 2240 END 2400 REM READ BLOCK TO ARRAY 2410 POKE ST,0 2420 REM WAIT FOR READ VALUE READY 2430 FOR MO=0 TO 511 2440 SV=PEEK(ST) 2450 IF SV <> 224 GOTO 2440 2460 MA(MO)=PEEK(DT) 2470 NEXT MO 2480 RETURN 3000 REM DUMP TO SCREEN 3010 FOR I=0 TO 31 3020 DV=I 3030 GOSUB 3200 3040 PRINT "0 "; 3050 SA=(I*16) 3060 FOR J=0 TO 15 3070 DV=MA(SA+J) 3080 GOSUB 3200 3090 PRINT " "; 3100 NEXT J 3110 GOSUB 3400 3120 NEXT I 3130 RETURN 3200 REM PRINT DECIMAL NUMBER AS TWO HEX DIGITS 3210 NB=(DV AND 240)/16 3220 GOSUB 3300 3230 NB=DV AND 15 3240 GOSUB 3300 3250 RETURN 3300 REM PRINT NIBBLE 3310 IF NB>9 GOTO 3350 3320 VL=NB+48 3330 PRINT CHR$(VL); 3340 RETURN 3350 REM CHARACTER IS LETTER A-F 3360 VL=NB+55 3370 PRINT CHR$(VL); 3380 RETURN 3400 REM PRINT THE ASCII TABLE TO THE RIGHT 3410 PRINT " "; 3420 FOR OF=SA TO (SA+15) 3430 IF MA(OF)<32 THEN PRINT "."; 3450 IF MA(OF)>126 THEN PRINT "."; 3460 IF MA(OF)>31 AND MA(OF)<127 THEN PRINT CHR$(MA(OF)); 3470 NEXT OF 3480 PRINT 3490 RETURN 3600 REM PRINT FIRST SECTOR KEY VALUES 3610 PRINT "FIRST SECTOR KEY VALUES" 3620 PRINT "LBA0";MA(454) 3630 PRINT "LBA1";MA(455) 3640 PRINT "LBA2";MA(456) 3650 PRINT "LBA3";MA(457) 3660 RETURN 3800 REM POKE LBA VALUES 3810 POKE A0,L0 3820 POKE A1,L1 3830 POKE A2,L2 3840 RETURN 4000 REM PRINT RESERVED SECTOR KEY VALUES 4010 PRINT "ID S/B FAT32, IS: "; 4020 FOR I=82 TO 86 4030 PRINT CHR$(MA(I)); 4040 NEXT I 4050 PRINT 4100 RETURN
Output is:
000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 080 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 090 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0C0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0D0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0E0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 100 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 110 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 120 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 130 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 140 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 150 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 160 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 170 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 180 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 190 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 1A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 1B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 82 ................ 1C0 03 00 0C FE FF FF 00 20 00 00 00 04 B7 03 00 00 ....... ........ 1D0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 1E0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 1F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 AA ..............U. FIRST SECTOR KEY VALUES LBA0 0 LBA1 32 LBA2 0 LBA3 0 FIRST BLOCK 000 EB 00 90 20 20 20 20 20 20 20 20 00 02 40 92 04 ... ..@.. 010 02 00 00 00 00 F8 00 00 3F 00 FF 00 00 20 00 00 ........?.... .. 020 00 04 B7 03 B7 1D 00 00 00 00 00 00 02 00 00 00 ................ 030 01 00 06 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 040 80 00 29 39 62 35 30 4E 4F 20 4E 41 4D 45 20 20 ..)9b50NO NAME 050 20 20 46 41 54 33 32 20 20 20 00 00 00 00 00 00 FAT32 ...... 060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 080 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 090 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0C0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0D0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0E0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 0F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 100 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 110 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 120 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 130 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 140 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 150 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 160 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 170 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 180 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 190 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 1A0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 1B0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 1C0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 1D0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 1E0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 1F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 AA ..............U. ID S/B FAT32, IS: FAT32
Looks good! Now to pick apart the block to get to the directory using the information from this log entry.
Previous Example
FirstDataSector = BPB_RsvdSecCnt + (BPB_NumFATs * BPB_FATSz32) + RootDirSectors;
= 2106 + (2 * 15331)
= 32,768
Bytes Content 14-15 BPB_RsvdSecCnt Number of reserved sectors (1) FAT12 and FAT16 use 1. FAT32 uses 32. <0x083a> = 2106 decimal 16 BPB_NumFATs Number of FAT copies <0x02> 36-39 BPB_FATSz32 This field is the FAT32 32-bit count of sectors occupied by ONE FAT. Sectors per FAT <0x00003BE3> = 15331 dec
Getting to the Directory
Need to also add in the offset to the block found above. Doing that the directory can be found:
BPRsvdSecCnt 1170 BPNumFATs 2 BPFATSz32 7607 DIR SECTOR 24576 96 0 000 42 20 00 49 00 6E 00 66 00 6F 00 0F 00 72 72 00 B .I.n.f.o...rr. 010 6D 00 61 00 74 00 69 00 6F 00 00 00 6E 00 00 00 m.a.t.i.o...n... 020 01 53 00 79 00 73 00 74 00 65 00 0F 00 72 6D 00 .S.y.s.t.e...rm. 030 20 00 56 00 6F 00 6C 00 75 00 00 00 6D 00 65 00 .V.o.l.u...m.e. 040 53 59 53 54 45 4D 7E 31 20 20 20 16 00 99 98 8C SYSTEM~1 ..... 050 A9 54 A9 54 00 00 99 8C A9 54 03 00 00 00 00 00 .T.T.....T...... 060 41 48 00 6F 00 63 00 6B 00 65 00 0F 00 69 79 00 AH.o.c.k.e...iy. 070 2E 00 62 00 61 00 73 00 00 00 00 00 FF FF FF FF ..b.a.s......... 080 48 4F 43 4B 45 59 20 20 42 41 53 20 00 23 BD 8C HOCKEY BAS .#.. 090 A9 54 A9 54 00 00 F5 91 4D 54 05 00 B9 20 00 00 .T.T....MT... .. 0A0 41 48 00 6F 00 72 00 73 00 65 00 0F 00 63 52 00 AH.o.r.s.e...cR. 0B0 61 00 63 00 65 00 2E 00 62 00 00 00 61 00 73 00 a.c.e...b...a.s. 0C0 48 4F 52 53 45 52 7E 31 42 41 53 20 00 4B BD 8C HORSER~1BAS .K.. 0D0 A9 54 A9 54 00 00 01 92 4D 54 06 00 C6 0B 00 00 .T.T....MT...... 0E0 41 48 00 75 00 72 00 6B 00 6C 00 0F 00 39 65 00 AH.u.r.k.l...9e. 0F0 2E 00 62 00 61 00 73 00 00 00 00 00 FF FF FF FF ..b.a.s......... 100 48 55 52 4B 4C 45 20 20 42 41 53 20 00 52 BD 8C HURKLE BAS .R.. 110 A9 54 A9 54 00 00 F7 54 F1 52 07 00 6E 05 00 00 .T.T...T.R..n... 120 41 4B 00 69 00 6E 00 65 00 6D 00 0F 00 17 61 00 AK.i.n.e.m....a. 130 2E 00 62 00 61 00 73 00 00 00 00 00 FF FF FF FF ..b.a.s......... 140 4B 49 4E 45 4D 41 20 20 42 41 53 20 00 55 BD 8C KINEMA BAS .U.. 150 A9 54 A9 54 00 00 F7 54 F1 52 08 00 2D 03 00 00 .T.T...T.R..-... 160 41 4B 00 69 00 6E 00 67 00 2E 00 0F 00 DD 62 00 AK.i.n.g......b. 170 61 00 73 00 00 00 FF FF FF FF 00 00 FF FF FF FF a.s............. 180 4B 49 4E 47 20 20 20 20 42 41 53 20 00 58 BD 8C KING BAS .X.. 190 A9 54 A9 54 00 00 F7 54 F1 52 09 00 F6 22 00 00 .T.T...T.R...".. 1A0 42 69 00 63 00 00 00 FF FF FF FF 0F 00 A4 FF FF Bi.c............ 1B0 FF FF FF FF FF FF FF FF FF FF 00 00 FF FF FF FF ................ 1C0 01 6C 00 61 00 62 00 79 00 72 00 0F 00 A4 69 00 .l.a.b.y.r....i. 1D0 6E 00 74 00 68 00 2E 00 62 00 00 00 61 00 73 00 n.t.h...b...a.s. 1E0 4C 41 42 59 52 49 7E 31 42 41 53 20 00 5E BD 8C LABYRI~1BAS .^.. 1F0 A9 54 A9 54 00 00 F8 54 F1 52 0A 00 7C 13 00 00 .T.T...T.R..|...
The BASIC code to get to the directory is then:
100 REM OSISDOS READ DIR FROM SD CARD IN BASIC 110 SAVE:REM TURN ON LOGGING TO SERIAL PORT 120 REM SDCARD BASE ADDRESS = $F010 (61456 DEC) 130 DT=61456:ST=61457:A0=61458:A1=61459:A2=61460:REM SD INTERFACE REGISTER ADDRESSES 140 DIM MA(512):REM RESERVE ARRAY SPACE FOR SD CARD DATA 150 GOSUB 2200:REM CHECK CARD INIT STATUS 160 REM READ FIRST LBA 170 L0=0:L1=0:L2=0 180 GOSUB 3800:REM POKE LBA VALS 190 GOSUB 2200:REM CHECK CARD INIT STATUS 200 GOSUB 2400:REM READ IN BLOCK 210 REM GOSUB 3000:REM DUMP ARRAY 220 REM GOSUB 3600:REM PRINT FIRST SECTOR KEY VALUES 230 L0=MA(454):L1=MA(455):L2=MA(456) 232 FS=((L1*256)+L0) 235 PRINT "FIRST SECTOR LBA ";:PRINT FS 240 GOSUB 3800:REM POKE LBA VALS 250 GOSUB 2200:REM CHECK CARD INIT STATUS 260 GOSUB 2400:REM READ IN BLOCK 270 PRINT "FIRST BLOCK" 280 GOSUB 3000:REM DUMP ARRAY 290 REM GOSUB 4000:REM PRINT RESERVED SECTOR KEY VALUES 300 GOSUB 4200:REM CALCULATE DIR SECTOR VALUES 310 L0=DS AND 255:L1=DS/256:L2=0:L3=0 320 GOSUB 3800:REM POKE LBA VALS 330 GOSUB 2200:REM CHECK CARD INIT STATUS 340 GOSUB 2400:REM READ IN BLOCK 350 GOSUB 3000:REM DUMP ARRAY 1990 END 2200 REM CHECK CARD INIT STATUS 2210 IF PEEK(ST) = 128 THEN RETURN 2220 PRINT "BAD INIT STATUS" 2230 PRINT PEEK(ST) 2240 END 2400 REM READ BLOCK TO ARRAY 2410 POKE ST,0 2420 REM WAIT FOR READ VALUE READY 2430 FOR MO=0 TO 511 2440 SV=PEEK(ST) 2450 IF SV <> 224 GOTO 2440 2460 MA(MO)=PEEK(DT) 2470 NEXT MO 2480 RETURN 3000 REM DUMP TO SCREEN 3010 FOR I=0 TO 31 3020 DV=I 3030 GOSUB 3200 3040 PRINT "0 "; 3050 SA=(I*16) 3060 FOR J=0 TO 15 3070 DV=MA(SA+J) 3080 GOSUB 3200 3090 PRINT " "; 3100 NEXT J 3110 GOSUB 3400 3120 NEXT I 3130 RETURN 3200 REM PRINT DECIMAL NUMBER AS TWO HEX DIGITS 3210 NB=(DV AND 240)/16 3220 GOSUB 3300 3230 NB=DV AND 15 3240 GOSUB 3300 3250 RETURN 3300 REM PRINT NIBBLE 3310 IF NB>9 GOTO 3350 3320 VL=NB+48 3330 PRINT CHR$(VL); 3340 RETURN 3350 REM CHARACTER IS LETTER A-F 3360 VL=NB+55 3370 PRINT CHR$(VL); 3380 RETURN 3400 REM PRINT THE ASCII TABLE TO THE RIGHT 3410 PRINT " "; 3420 FOR OF=SA TO (SA+15) 3430 IF MA(OF)<32 THEN PRINT "."; 3450 IF MA(OF)>126 THEN PRINT "."; 3460 IF MA(OF)>31 AND MA(OF)<127 THEN PRINT CHR$(MA(OF)); 3470 NEXT OF 3480 PRINT 3490 RETURN 3600 REM PRINT FIRST SECTOR KEY VALUES 3610 PRINT "FIRST SECTOR KEY VALUES" 3620 PRINT "LBA0";MA(454) 3630 PRINT "LBA1";MA(455) 3640 PRINT "LBA2";MA(456) 3650 PRINT "LBA3";MA(457) 3660 RETURN 3800 REM POKE LBA VALUES 3810 POKE A0,L0 3820 POKE A1,L1 3830 POKE A2,L2 3840 RETURN 4000 REM PRINT RESERVED SECTOR KEY VALUES 4010 PRINT "ID S/B FAT32, IS: "; 4020 FOR I=82 TO 86 4030 PRINT CHR$(MA(I)); 4040 NEXT I 4050 PRINT 4100 RETURN 4200 REM PRINT DIR SECTOR VALUES 4210 B0=MA(14):B1=MA(15) 4220 NF=MA(16) 4230 S0=MA(36):S1=MA(37):S2=MA(38):S3=MA(39) 4240 RS=((256*B1)+B0) 4250 SZ=((256*S1)+S0) 4260 PRINT "BPB_RsvdSecCnt ";:PRINT RS 4270 PRINT "BPB_NumFATs ";:PRINT NF 4280 PRINT "BPB_FATSz32 ";:PRINT SZ 4290 DS=FS+RS+(NF*SZ) 4300 PRINT "DIR SECTOR ";:PRINT DS; 4310 PRINT (DS/256);:PRINT (DS AND 255) 4390 RETURN
I've parsed directories before in this log.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.