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

Invalid MBR error with certain CF cards, CF to SD flash adapters #7

Open
crozone opened this issue Feb 19, 2024 · 11 comments
Open

Invalid MBR error with certain CF cards, CF to SD flash adapters #7

crozone opened this issue Feb 19, 2024 · 11 comments

Comments

@crozone
Copy link
Owner

crozone commented Feb 19, 2024

Some CF cards and CF to SD card adapters appear to be causing an "Invalid MBR" error. The MBR appears to be incorrect.

lwbfeib3i96c1

So far these all appear to be for LBA28 (<128GB) cards, so it is worth investigating if there's something wrong with the LBA28 codepath side the LBA48 patch.

@EvergreenTrone
Copy link

Hey did you find a solution ? thanks

@crozone
Copy link
Owner Author

crozone commented Feb 26, 2024

Not as clean cut as I was hoping, no. I have rewritten a lot of the ATA layer to clean up a bunch of messy and hacky code, with improvements to the caching layer, but nothing that would directly fix this.

Would it be possible for you to dump the very first sector of the disk for me, so we can identify whether this is an incorrect sector read or ipodloader mis-recognising a good MBR?

You can use HxD to do it, simply run it as administrator, then go to Tools > Open Disk > Physical disks > Select iPod

Then click and drag all of the hex data for Sector 0, and then Right Click -> Copy. Then just paste it into here as a comment, it should come out as a long line of hex.

@crozone
Copy link
Owner Author

crozone commented Feb 28, 2024

I have received the boot sector for this iPod:

000: EB 3C 90 2A 55 4F 4B 4A 49 48 43 00 02 20 20 00 <-- 0x000: Bootstrap code area (part 1)
010: 02 00 00 00 00 F8 00 00 3F 00 FF 00 C5 39 01 00
020: 2C 46 8E 0E D6 E8 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: 00 01 29 FA 10 38 61 49 50 4F 44 20 20 20 20 20
050: 20 20 46 41 54 33 32 20 20 20 0E 1F BE 5B 7C AC
060: 22 C0 74 0B 56 B4 0E BB 07 00 CD 10 5E EB F0 32
070: E4 CD 16 CD 19 EB FE 7B 7B 7E 7E 7C 20 53 20 54
080: 20 4F 20 50 20 7C 20 54 68 69 73 20 69 73 20 41
090: 70 70 6C 65 20 69 50 6F 64 20 6E 6F 74 20 61 20
0A0: 62 6F 6F 74 61 62 6C 65 20 64 69 73 6B 2E 50 6C
0B0: 65 61 73 65 20 74 72 79 20 61 67 61 69 6E 20 2E
0C0: 2E 2E 20 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 <-- 0x0DA: Disk Timestamp
0E0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <-- 0x0E0: Bootstrap code area (part 2)
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 <-- 0x01B8: disk signature, 0x1BE: Start of partition table
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 <-- 0x01FE: boot signature (55AA)

This is definitely an iTunes restored iPod since it contains the dummy bootloader to print "S T O P | This is Apple iPod not a bootable disk. Please try again"

There are two issues:

  • There is no disk timestamp, no disk signature, and a totally blank partition table! It's all just zeroed out until the MBR boot signature at the end.

  • The MBR data printed in the debug information does not match this data. "Invalid MBR" is only printed if the boot signature was not found, and the debug information shows a different start (504d...) and a different end (all zeroes, no boot signature).

So something extremely weird is going on.

@EvergreenTrone
Copy link

Hey ! thanks for your response. Do you have ipodloader v2.5 ? i want to test it but i can't find on internet

@crozone
Copy link
Owner Author

crozone commented Mar 5, 2024

Ipodloader2-2.5.tar.gz

Found it!

@crozone
Copy link
Owner Author

crozone commented Mar 6, 2024

loader.readtest.bin.zip

@EvergreenTrone I've built a quick debug version which will read the first 4 sectors from the disk and print the number of bytes read and any errors. Could you please give this a spin and post a screenshot of the output?

@crozone
Copy link
Owner Author

crozone commented Mar 6, 2024

loader.2.9.0d.zip

Okay, here is a development version of v2.9.0. It has completely rewritten ATA code and cache, as well as improved MBR handling and partition detection. It might not magically fix the issue, but it will at least detect a whole lot more errors now, and show a lot better debug output.

@rafkt
Copy link

rafkt commented Mar 20, 2024

@crozone Not sure if I should comment on this issue.
On an iPod 5.5 (originally fat model 80GB as such I would assume under LBA48 (?)), the latest release fails to read /boot/vmlinux. Not entirely sure if that's the issue you had resolved under commit 42b2721. However loader.2.9.0d seems to fix it.

iPod modded with iFlash Quad & 512GB storage.

@crozone
Copy link
Owner Author

crozone commented Mar 21, 2024

@rafkt I think you may have a separate but related issue relating to the iPod 5.5G MBR. I've created a separate issue here: #11

@bachterman
Copy link

bachterman commented Jun 8, 2024

hey, I have a similar problem. I have a modified ipod mini 2, with a generic cf-to-microsdxc adapter.
here's my hexdump from the boot sector:
EB 58 90 4D 53 44 4F 53 35 2E 30 00 02 20 00 02 02 00 00 00 00 F8 00 00 3F 00 FF 00 00 00 00 00 FF BF 47 07 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 29 52 36 8B A8 69 50 6F 64 00 4D 45 20 20 20 20 46 41 54 33 32 20 20 20 33 C9 8E D1 BC F4 7B 8E C1 8E D9 BD 00 7C 88 4E 02 8A 56 40 B4 08 CD 13 73 05 B9 FF FF 8A F1 66 0F B6 C6 40 66 0F B6 D1 80 E2 3F F7 E2 86 CD C0 ED 06 41 66 0F B7 C9 66 F7 E1 66 89 46 F8 83 7E 16 00 75 38 83 7E 2A 00 77 32 66 8B 46 1C 66 83 C0 0C BB 00 80 B9 01 00 E8 2B 00 E9 48 03 A0 FA 7D B4 7D 8B F0 AC 84 C0 74 17 3C FF 74 09 B4 0E BB 07 00 CD 10 EB EE A0 FB 7D EB E5 A0 F9 7D EB E0 98 CD 16 CD 19 66 60 66 3B 46 F8 0F 82 4A 00 66 6A 00 66 50 06 53 66 68 10 00 01 00 80 7E 02 00 0F 85 20 00 B4 41 BB AA 55 8A 56 40 CD 13 0F 82 1C 00 81 FB 55 AA 0F 85 14 00 F6 C1 01 0F 84 0D 00 FE 46 02 B4 42 8A 56 40 8B F4 CD 13 B0 F9 66 58 66 58 66 58 66 58 EB 2A 66 33 D2 66 0F B7 4E 18 66 F7 F1 FE C2 8A CA 66 8B D0 66 C1 EA 10 F7 76 1A 86 D6 8A 56 40 8A E8 C0 E4 06 0A CC B8 01 02 CD 13 66 61 0F 82 54 FF 81 C3 00 02 66 40 49 0F 85 71 FF C3 4E 54 4C 44 52 20 20 20 20 20 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0D 0A 41 70 70 6C 65 20 69 50 6F 64 20 20 20 20 20 20 00 01 01 00 00 FE 3F 04 3F 00 00 00 86 39 01 00 00 00 01 05 0B 08 D4 FF C5 39 01 00 3A 86 46 07 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 AA

I've tried to put rockbox onto it, but it fails with not finding the FAT32 partition. The strange thing that your loader also drops the same error:

LBA28 addessing
HDDid: INIC 2051
CompactFlash card
invalid MBR
00000000 00000000
00000000 00000000
00000000 00000000

Also that's why the "Rockbox @ (hd0,1)/.rockbox/rockbox.ipod" line is not recognized in the loader.cfg.

Here's ipodpatcher's output with ipodloader2 v2.8.1 installed:

[INFO] Scanning disk devices...
[INFO] Read XML info (2456 bytes)
[INFO] Ipod found - 2nd Generation Mini ("winpod") - disk device 1
[INFO] Reading partition table from \\.\PhysicalDrive1
[INFO] Sector size is 512 bytes
[INFO] Part    Start Sector    End Sector   Size (MB)   Type
[INFO]    0              63         80324        39.2   Empty (0x00)
[INFO]    1           80325     122142718     59600.8   W95 FAT32 (0x0b)
[INFO] Read XML info (2456 bytes)
[INFO] Ipod model: 2nd Generation Mini ("winpod")

Listing firmware partition contents:

Image 1:
    Main firmware - 3403264 bytes
    Third-party bootloader - 56912 bytes
Image 2:
    AUPD - 1086536 bytes

@crozone
Copy link
Owner Author

crozone commented Jun 8, 2024

@bachterman Thank you for the report, your boot sector looks like:

00000000  EB 58 90 4D 53 44 4F 53 35 2E 30 00 02 20 00 02  ëX.MSDOS5.0.. ..
00000010  02 00 00 00 00 F8 00 00 3F 00 FF 00 00 00 00 00  .....ø..?.ÿ.....
00000020  FF BF 47 07 00 00 00 00 00 00 00 00 00 00 00 00  ÿ¿G.............
00000030  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
00000040  01 00 29 52 36 8B A8 69 50 6F 64 00 4D 45 20 20  ..)R6ܬiPod.ME  
00000050  20 20 46 41 54 33 32 20 20 20 33 C9 8E D1 BC F4    FAT32   3ɎѼô
00000060  7B 8E C1 8E D9 BD 00 7C 88 4E 02 8A 56 40 B4 08  {ŽÁŽÙ½.|ˆN.ŠV@´.
00000070  CD 13 73 05 B9 FF FF 8A F1 66 0F B6 C6 40 66 0F  Í.s.¹ÿÿŠñf.¶Æ@f.
00000080  B6 D1 80 E2 3F F7 E2 86 CD C0 ED 06 41 66 0F B7  ¶Ñ€â?÷â†ÍÀí.Af.·
00000090  C9 66 F7 E1 66 89 46 F8 83 7E 16 00 75 38 83 7E  Éf÷áf‰Føƒ~..u8ƒ~
000000A0  2A 00 77 32 66 8B 46 1C 66 83 C0 0C BB 00 80 B9  *.w2f‹F.fƒÀ.».€¹
000000B0  01 00 E8 2B 00 E9 48 03 A0 FA 7D B4 7D 8B F0 AC  ..è+.éH. ú}´}‹ð¬
000000C0  84 C0 74 17 3C FF 74 09 B4 0E BB 07 00 CD 10 EB  „Àt.<ÿt.´.»..Í.ë
000000D0  EE A0 FB 7D EB E5 A0 F9 7D EB E0 98 CD 16 CD 19  î û}ëå ù}ëà˜Í.Í.
000000E0  66 60 66 3B 46 F8 0F 82 4A 00 66 6A 00 66 50 06  f`f;Fø.‚J.fj.fP.
000000F0  53 66 68 10 00 01 00 80 7E 02 00 0F 85 20 00 B4  Sfh....€~...… .´
00000100  41 BB AA 55 8A 56 40 CD 13 0F 82 1C 00 81 FB 55  A»ªUŠV@Í..‚...ûU
00000110  AA 0F 85 14 00 F6 C1 01 0F 84 0D 00 FE 46 02 B4  ª.…..öÁ..„..þF.´
00000120  42 8A 56 40 8B F4 CD 13 B0 F9 66 58 66 58 66 58  BŠV@‹ôÍ.°ùfXfXfX
00000130  66 58 EB 2A 66 33 D2 66 0F B7 4E 18 66 F7 F1 FE  fXë*f3Òf.·N.f÷ñþ
00000140  C2 8A CA 66 8B D0 66 C1 EA 10 F7 76 1A 86 D6 8A  ŠÊf‹ÐfÁê.÷v.†ÖŠ
00000150  56 40 8A E8 C0 E4 06 0A CC B8 01 02 CD 13 66 61  V@ŠèÀä..̸..Í.fa
00000160  0F 82 54 FF 81 C3 00 02 66 40 49 0F 85 71 FF C3  .‚Tÿ.Ã..f@I.…qÿÃ
00000170  4E 54 4C 44 52 20 20 20 20 20 20 00 00 00 00 00  NTLDR      .....
00000180  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
00000190  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
000001A0  00 00 00 00 00 00 00 00 00 00 00 00 0D 0A 41 70  ..............Ap
000001B0  70 6C 65 20 69 50 6F 64 20 20 20 20 20 20 00 01  ple iPod      ..
000001C0  01 00 00 FE 3F 04 3F 00 00 00 86 39 01 00 00 00  ...þ?.?...†9....
000001D0  01 05 0B 08 D4 FF C5 39 01 00 3A 86 46 07 00 00  ....ÔÿÅ9..:†F...
000001E0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
000001F0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 AA  ..............Uª

This appears to have a legitimate iTunes created boot sector (which happens to look like a Windows XP era boot sector targeting NT Loader).

Here's the boot sector from my iPod Mini 2nd generation with an iFlash SD adapter:

0000000000  EB 58 90 4D 53 44 4F 53 35 2E 30 00 02 20 00 02  ëX.MSDOS5.0.. ..
0000000010  02 00 00 00 00 F8 00 00 3F 00 FF 00 00 00 00 00  .....ø..?.ÿ.....
0000000020  FF DF 96 3B 00 00 00 00 00 00 00 00 00 00 00 00  ÿß–;............
0000000030  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0000000040  01 00 29 52 36 8B A8 69 50 6F 64 00 4D 45 20 20  ..)R6ܬiPod.ME  
0000000050  20 20 46 41 54 33 32 20 20 20 33 C9 8E D1 BC F4    FAT32   3ɎѼô
0000000060  7B 8E C1 8E D9 BD 00 7C 88 4E 02 8A 56 40 B4 08  {ŽÁŽÙ½.|ˆN.ŠV@´.
0000000070  CD 13 73 05 B9 FF FF 8A F1 66 0F B6 C6 40 66 0F  Í.s.¹ÿÿŠñf.¶Æ@f.
0000000080  B6 D1 80 E2 3F F7 E2 86 CD C0 ED 06 41 66 0F B7  ¶Ñ€â?÷â†ÍÀí.Af.·
0000000090  C9 66 F7 E1 66 89 46 F8 83 7E 16 00 75 38 83 7E  Éf÷áf‰Føƒ~..u8ƒ~
00000000A0  2A 00 77 32 66 8B 46 1C 66 83 C0 0C BB 00 80 B9  *.w2f‹F.fƒÀ.».€¹
00000000B0  01 00 E8 2B 00 E9 48 03 A0 FA 7D B4 7D 8B F0 AC  ..è+.éH. ú}´}‹ð¬
00000000C0  84 C0 74 17 3C FF 74 09 B4 0E BB 07 00 CD 10 EB  „Àt.<ÿt.´.»..Í.ë
00000000D0  EE A0 FB 7D EB E5 A0 F9 7D EB E0 98 CD 16 CD 19  î û}ëå ù}ëà˜Í.Í.
00000000E0  66 60 66 3B 46 F8 0F 82 4A 00 66 6A 00 66 50 06  f`f;Fø.‚J.fj.fP.
00000000F0  53 66 68 10 00 01 00 80 7E 02 00 0F 85 20 00 B4  Sfh....€~...… .´
0000000100  41 BB AA 55 8A 56 40 CD 13 0F 82 1C 00 81 FB 55  A»ªUŠV@Í..‚...ûU
0000000110  AA 0F 85 14 00 F6 C1 01 0F 84 0D 00 FE 46 02 B4  ª.…..öÁ..„..þF.´
0000000120  42 8A 56 40 8B F4 CD 13 B0 F9 66 58 66 58 66 58  BŠV@‹ôÍ.°ùfXfXfX
0000000130  66 58 EB 2A 66 33 D2 66 0F B7 4E 18 66 F7 F1 FE  fXë*f3Òf.·N.f÷ñþ
0000000140  C2 8A CA 66 8B D0 66 C1 EA 10 F7 76 1A 86 D6 8A  ŠÊf‹ÐfÁê.÷v.†ÖŠ
0000000150  56 40 8A E8 C0 E4 06 0A CC B8 01 02 CD 13 66 61  V@ŠèÀä..̸..Í.fa
0000000160  0F 82 54 FF 81 C3 00 02 66 40 49 0F 85 71 FF C3  .‚Tÿ.Ã..f@I.…qÿÃ
0000000170  4E 54 4C 44 52 20 20 20 20 20 20 00 00 00 00 00  NTLDR      .....
0000000180  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
0000000190  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
00000001A0  00 00 00 00 00 00 00 00 00 00 00 00 0D 0A 41 70  ..............Ap
00000001B0  70 6C 65 20 69 50 6F 64 20 20 20 20 20 20 00 01  ple iPod      ..
00000001C0  01 00 00 FE 3F 04 3F 00 00 00 86 39 01 00 00 00  ...þ?.?...†9....
00000001D0  01 05 0B 27 CF FF C5 39 01 00 3A A6 95 3B 00 00  ...'ÏÿÅ9..:¦•;..
00000001E0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
00000001F0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 AA  ..............Uª

The two are extremely similar. I'm going to look into the differences now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants