-
Notifications
You must be signed in to change notification settings - Fork 2
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
add support 2MB card, change support 4/8MB card #23
Comments
Oh, interesting! Could you send me your Wireshark captures for 2MB, 4MB, and 8MB? (Just the "detect" part - don't need any transfers.) I'm trying to understand and simplify your get_iid() and get_unknown() code. I knew they work correctly only after when we select the right page - and of course, we don't know how to select a page until we know the memory layout, so this is circular logic. But, the memory offset 0 is the same for all cards, so I assumed that was the answer. But, looks like your code calls it for different offsets. Don't know if you noticed, but your
So I'm hoping this can become something like:
|
Actually, it could be even dumber than that: maybe the logic is, "Try reading offsets 4 and 6; if they work, it's 8MB; if they don't work, it's 4MB". And it looks like you are right - get_unknown() has to be called before get_iid(), or need to select the page again. Even calling get_unknown() twice in a row returns different values. Can you try this version of
|
I have no backup Wireshark captures (if it's needed I can make new one)
Sorry no ;-), your code is more beautifull , my code contain some subtilities, don't forget this (like write(b"\x50\x04") or write(b"\x50\x03") on call 5 and 6 value return is not all the this the same value, for this reason I store value on call 4 ( last buff1) Unknown identifier work correctly for 2MB for other case , it's not constant, for the same card size value change from one card to one other. I make all test with :
|
PS C:\Users\ABC> jdmtool detect |
Oh damn, I figured out what "get_unknown" actually does. It literally just reads 2 bytes from the data card (and interleaves them with 0s for some reason, so it returns 4 bytes). Normally, JDM reads one block (4 KB) at a time - and I'm guessing I wrote "Hello, World!" to the card:
Then called
And it just returns the bytes of "Hello, World!":
So that of course explains why it returns the same number for the same card, but different numbers for different cards... |
As for your |
It's possible that, for example, a 4MB card treats offsets 0 and 4 as the same, and 2 and 6 as the same. So if they return different values, then you know it's 8MB. But, if they are the same, it could still be 8MB, since it really depends on the contents of the card. E.g., if you completely erase the card, then calling Anyways, I can just add command-line arguments |
My code try to reproduce exactly, request made by jdm, include for 2MB. I think 'write(b"\x50\x04")' return device id from register on chip I have optimized code like as you suggested : on 2M we have 2 chips from jdm log : get_iid with trace and without 2MB (For 2 MB it's different, he use b'\05\x04 and after b'\05\x03) 4MB 8MB 16MB 16MB 8MB 4MB 2MB |
I think the files.zip you attached doesn't actually have your changes... But in any case, your log still gives me enough information that I think I have a good solution! Try the I'm pretty sure that "unknown" is useless here - it just reads bytes from the data card, so its value is only based on the contents of the card, not the type of the card. But, your output shows that IID can be different depending on the offset:
So that's good enough! I'm now checking if the IID at offset 0x01a0 is 0x0100ad00 or 0x90009000. (I guess this is not exactly what JDM does, but I really cannot think of a reason to use Anyways, see if works correctly for you now. Also, |
I went back to reverse-engineering JDM, in case I find anything else useful. Turns out, all of the card programmer logic is in
Response: {
"id":"0",
"jsonrpc":"2.0",
"result":[{
"bus_addr":"1_2",
"carddesc":"16 MB WAAS,silver label",
"cardsizebytes":"16777216",
"cardstyle":"Garmin",
"jeppdrivedll":"20071203",
"lastupdateGMT":"Mon Dec 30 14:40:46 2024",
"memorytype":4,
"sig":1037578355,
"sigidx":"0",
"techsupportdesc":"[0]g2_plugin v:3.2.1.0 G2 firmware v:20071203 isG2Orange: 0 Card:451: 16 MB AMD Series C/D (4 MB x 4) JDA version:1.0.0.6 IID:0x1004100 isOrangeCard: 0"
}]
} (I'm now trying to find a way to modify IID in the debugger, to simulate other cards...) |
I figured out how to intercept the memory offset and the IID in a debugger, so I was able to test every combination! Turns out, there is also a 6MB card! So JDM tests the four chips at the four memory offsets: 0x00E0, 0x0160, 0x01A0, 0x01C0. Results:
I will update the code now. And, this is what it took to figure it out :) |
Whell, I make test with PAGES_PER_OFFSET with value 10, 20 or #40, depending of size of chip memory ( 1MB, 2MB, 4MB) 2MB Card (2x 1MB chips->blocksize =64k(=0x1000)->16(x10) PAGES_PER_OFFSET of 65K->PAGES_PER_OFFSET=0x10/memory in this case the MEMORY_LAYOUT would map the number of memory chip and look like this and maybe : in my test code I update PAGES_PER_OFFSET during with_data_card function to update PAGES_PER_OFFSET with the good value I will check how jdm work during programing for 2MB card, because for now, write_database is not supported, program crash (timeout on first write), for read-database, he pass, but I must will check it's a good mapping for pages. sorry for delayed answers, I am in GMT+1 time zone. |
Got it. I just implemented the new logic and pushed it to And yeah, let me know if you figure out the correct PAGES_PER_OFFSET and BLOCKS_PER_PAGE. I guessed all of that by capturing JDM's USB data, without any understanding of how the chips actually work. |
this is not a criticism, it is already a huge and well written work (i am not a python dev) congratulations for the work done |
Oh, don't worry! I want to get it right. And thank you. |
Test your change with 4 cards and 2 G2 (black and orange) PS C:\Users\ABC> jdmtool detect PS C:\Users\ABC> jdmtool detect PS C:\Users\ABC> jdmtool detect PS C:\Users\ABC> jdmtool detect with bad card : find files with amend
maybe we can add mode verbose to display this info or other only if needed : I must rewrite code to test my logic for PAGES_PER_OFFSET and BLOCKS_PER_PAGE, maybe not today (31/12/24).... I don't want read page in bad order, like page1,page3,page2,pag4 ... I try to get a 3MB card today on airport. |
Update for 1MB, implement write and erase
add comment for G2 black or G2 Orange
TODO : stop write if 16MB Orange card with G2 black Update init_data_card for 3Mb card
test with 2,4,8,16MB card (read, write, erase, detect, transfer) and compare file after read card, with bin source I hope this is okay (it can always be improved) |
Wow, the actual write and erase logic is different for 1MB chips, not just memory offsets. While debugging JDM, I accidentally discovered that IID 0x8900a200 with 4 chips is a valid card: "034: 4 MB Intel Series 2 (1 MB x 4)" - which is also 4MB. So that means, Also, I can see these string in JDM, but don't know which IID maps to them, so can't really test them: Anyways, I will try to understand your changes now... |
for me, iid is device id on datasheet it's true, MEMORY_LAYOUT can become CARD_TYPE (in relation with number of chips not chip type) in my code for 4MB chip, I add 0x200 in an intertwined manner as in your MEMORY_LAYOUT_16MB to support 4 x 1MB today we can use MEMORY_LAYOUT_4MB_INTEL = [0, 1, 2 ,3] # 4 chips
|
I started implementing the logic of the data card hardware in the This way, we can use a "virtual" data card, without using the real hardware. It's not finished yet (only simulates IID and write - no erase or read yet). But, assuming it's correct, it accomplishes several things:
If you want to try it, install |
on main.py
add support 2MB card
change detection of 4MB or 8MB card
(have 2 chips 2MB second have 4 chips 2Mb, wireshark see jdm make 6 call at some adress and check the reply, if cal 5 and 6 is not the same, they have not chip 3 and 4)
on jdmtool list, change alternately the color of the text, it's easier to follow the lines
on _transfer_skybound, add option (fullerase) to have possiblility to erase all the card before write database
on _transfer_skybound, add check if we have 'media/card_size_min' and 'media/card_size_max' on services.xml
on _transfer_skybound, add test for new_metadata on 2MB card
on cmd_transfer add fullerase args for transfer
on cmd_detect move select_page(0) on get_iid and get_unknown, because select_page it' must be sefine before call get_iid or get_unknown
on cmd_detect move get_unknown before , get_iid (like in wireshark)
on cmd_detect call set_led
on cmd_write_metadata test if card is 2MB or 4MB
on _write_database add parameter to get fullerase value
on _write_database add fullerase
on main add_argument fullerase for transfert
on main add_argument fullcard for read-database to have full image of card
on skybound.py
add support 2MB card
add one call write(b"\x50\x03") on get_unknown, because after insert card, the first call write(b"\x50\x03"), return value can be wrong, other call after is ok
rewrite get_iid function to detect carrectly 4 or 8MB card , via get_unknown it's not possible, on same type card (8MB for me) get_unknown return different value.
files.zip
on jum.log:
G2 firmware v:20140530 isG2Orange: 1 Card:032: 2 MB Intel Series 2 (1 MB x 2) IID:0x8900A200 isOrangeCard: 0
G2 firmware v:20140530 isG2Orange: 1 Card:421: 4 MB AMD Series C/D (2 MB x 2) IID:0x0100AD00 isOrangeCard: 0
G2 firmware v:20140530 isG2Orange: 1 Card:441: 8 MB AMD Series C/D (2 MB x 4) IID:0x0100AD00 isOrangeCard: 0
G2 firmware v:20140530 isG2Orange: 1 Card:451: 16MB AMD Series C/D (4 MB x 4) IID:0x89007E00 isOrangeCard: 1
G2 firmware v:20140530 isG2Orange: 1 Card:451: 16MB AMD Series C/D (4 MB x 4) IID:0x01004100 isOrangeCard: 1
The text was updated successfully, but these errors were encountered: