From 934c38a0118eb69843baeb8e0cb3f52671ded942 Mon Sep 17 00:00:00 2001 From: Dima Ryazanov Date: Mon, 23 Dec 2024 09:46:52 -0800 Subject: [PATCH] Add support for 8MB non-WAAS cards (#17) --- src/jdmtool/main.py | 23 +++++++++++++++++++---- src/jdmtool/skybound.py | 1 + 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/jdmtool/main.py b/src/jdmtool/main.py index fd16047..877c79e 100644 --- a/src/jdmtool/main.py +++ b/src/jdmtool/main.py @@ -110,21 +110,36 @@ def wrapper(dev: SkyboundDevice, *args, **kwargs): # TODO: Figure out the actual meaning of the iid and the "unknown" value. iid = dev.get_iid() + unknown = dev.get_unknown() + if iid == 0x01004100: # 16MB WAAS card print("Detected data card: 16MB WAAS") dev.set_memory_layout(SkyboundDevice.MEMORY_LAYOUT_16MB) elif iid == 0x0100ad00: - # 4MB non-WAAS card - print("Detected data card: 4MB non-WAAS") - dev.set_memory_layout(SkyboundDevice.MEMORY_LAYOUT_4MB) + if unknown >> 30 == 0x00: + # 8MB non-WAAS card + print("Detected data card: 8MB non-WAAS") + dev.set_memory_layout(SkyboundDevice.MEMORY_LAYOUT_8MB) + elif unknown >> 30 == 0x03: + # 4MB non-WAAS card + print("Detected data card: 4MB non-WAAS") + dev.set_memory_layout(SkyboundDevice.MEMORY_LAYOUT_4MB) + else: + raise SkyboundException( + f"Unexpected identifier 0x{unknown:08x} for a 4MB/8MB card. Please file a bug!" + ) elif iid == 0x89007e00: # 16MB WAAS card, the orange one. print("Detected data card: 16MB WAAS (orange)") dev.set_memory_layout(SkyboundDevice.MEMORY_LAYOUT_16MB) + elif iid == 0x90009000: + raise SkyboundException( + "This looks like a Terrain/Obstacles card. It is not supported by Skybound Programmer." + ) else: raise SkyboundException( - f"Unknown data card IID: 0x{iid:08x} (possibly 8MB non-WAAS?). Please file a bug!" + f"Unknown data card IID: 0x{iid:08x}. Please file a bug!" ) f(dev, *args, **kwargs) diff --git a/src/jdmtool/skybound.py b/src/jdmtool/skybound.py index e4f62dc..db72e66 100644 --- a/src/jdmtool/skybound.py +++ b/src/jdmtool/skybound.py @@ -26,6 +26,7 @@ class SkyboundDevice(): MEMORY_LAYOUT_UNKNOWN = [0] MEMORY_LAYOUT_4MB = [0, 2] + MEMORY_LAYOUT_8MB = [0, 2, 4, 6] MEMORY_LAYOUT_16MB = [0, 1, 2, 3, 4, 5, 6, 7] def __init__(self, handle: 'USBDeviceHandle') -> None: