Announcement

Collapse
No announcement yet.

Flashing the MK60 with ZCP software

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • karter16
    replied
    Nice work Heinz - this is epic! very much enjoying following this along!

    Originally posted by heinzboehmer View Post
    (ignore the decompiled C code in that last screenshot, it's not looking all that great)
    FWIW pretty much all of the weirdness in the Ghidra C-code view can be resolved by making sure your function parameters (number and datatype) and return value (datatype) are correct. For example
    Code:
    int can_rx_797_payload(void)
    I'm willing to bet if you follow where it's called the return value isn't actually used. If so, and you modify the function prototype in Ghidra to be a void return type you'll see a bunch of that weirdness clean itself up.

    Leave a comment:


  • Bry5on
    replied
    Oh baby! Now we’re getting somewhere

    Leave a comment:


  • heinzboehmer
    replied
    Oh shit, I might have found CCP commands in the PT(?)-CAN table.

    Table decodes out to a bunch of CAN IDs that I was going through and, after some indirection, I found a read of the presumed-CCP EEPROM flag through a function pointer. Fortunately 0x797 was the towards the top of the table

    Looking through the payload handler:

    Click image for larger version

Name:	Screenshot 2026-10-30 at 1.28.47 AM.png
Views:	293
Size:	410.7 KB
ID:	614066
    Click image for larger version

Name:	Screenshot 2026-10-30 at 1.20.47 AM.png
Views:	289
Size:	190.1 KB
ID:	614064
    tbl_0f2eb:
    Click image for larger version

Name:	Screenshot 2026-10-30 at 1.21.40 AM.png
Views:	270
Size:	97.2 KB
ID:	614065
    Click image for larger version

Name:	Screenshot 2026-10-30 at 1.49.32 AM.png
Views:	291
Size:	435.5 KB
ID:	614067

    (I still don't know what the `_DAT_00400948` check is. Presumably a `wheel_speed == 0` check since it comes from RAM?)

    So now we know the second conditional in `can_rx_797_payload()` will evaluate to true (because the CCP flag is set). If we go to the function that gets evaluated in the conditional, we see something that looks suspiciously like an interpreter:

    Click image for larger version

Name:	Screenshot 2026-10-30 at 2.24.00 AM.png
Views:	289
Size:	543.1 KB
ID:	614069

    Looking at a CCP command ref (e.g. https://mxhelp.danlawinc.com/ccp_xcp_reference.htm), the `UPLOAD` function (0x4) is immediately interesting. Follow the function call in `case 4:` and jackpot:

    Click image for larger version

Name:	Screenshot 2026-10-30 at 2.05.16 AM.png
Views:	269
Size:	99.9 KB
ID:	614070
    Click image for larger version

Name:	Screenshot 2026-10-30 at 2.05.39 AM.png
Views:	284
Size:	218.6 KB
ID:	614068

    An unauthed, unbounded read in a loop that writes to a buffer (ignore the decompiled C code in that last screenshot, it's not looking all that great). Looks like the `UPLOAD` function to me!

    Lots of words and code to say that I was wrong and I'm now pretty convinced that CCP is supported on the e5 AND it can dump flash.

    Since the EEPROM flag is present on the MK60 dump, I'm pretty confident that it will be supported there too. Amazing.

    I know what the first thing I'm going to do when I get that MK60 is!

    Leave a comment:


  • heinzboehmer
    replied
    Quick update on the leads I have for getting into the bootloader.

    1. ECUProgrammingMode KWP Command
    This is what WinKFP uses and is appears to be officially supported on the e5 only. Mentioned in a previous post, but I tried sending the same KWP commands that the e5 expects and got nowhere.
    2. UART
    This one is a cool new find. There's a serial handler that can respond to commands sent to its RX buffer. If you catch it early enough in boot (maths out to 1.8s after power on) and send the correct handshake + command, it'll trigger a function that sets up some CAN mailboxes (PT/F?), then jumps directly to the bootloader. Promising, but unfortunately there does not seem to be any path into the UART parser besides a write on the RX line. There's no way the line is exposed on the MK60 connector, so this will be useful for bench testing an opened unit only.
    3. CCP
    I haven't found an obvious CCP handler/mailbox like I have for PT-CAN and F-CAN, but I did find a singular function that is reachable from KWP (over CAN) service 0x31 with routine 0x31. All this function does is toggle a single bit flag that gets stored in the EEPROM. The flag looks to be present on the E46 dump as well. I'm hoping this means that there's either an `#ifdef e46_ccp` somewhere in the MK60 source or that the CCP handler lives in the bootloader.

    George Hill is sending me an MK60 to test with (thanks again!), so I'm hoping to answer the CCP question soon.

    If nothing else, I'll be able to talk to it via UART and see if I can get it to reveal some secrets that way.

    Leave a comment:


  • heinzboehmer
    replied
    Originally posted by heinzboehmer View Post

    Thank you! I'll run that through the disassembly workflow as soon as I'm back at my computer.
    Well, unfortunately looks like that EEPROM only holds the calibration data (what you can change with NCS) and things like the VIN.

    We can still learn something from it, though. The e5 disassembly expects most of those fields in the offsets that they're in and also does the XOR 0xFF, which gives credence to the idea that the e5 shares a FW base with the MK60.

    Back to trying to find a way into the bootloader!

    Leave a comment:


  • heinzboehmer
    replied
    Originally posted by sda2 View Post
    Yes, added to this post. But I ended up finding out that its XOR 0xFF in the VIN, so nothing really encrypted.
    Thank you! I'll run that through the disassembly workflow as soon as I'm back at my computer.

    Leave a comment:


  • heinzboehmer
    replied
    Okay, this feels way less illegal: https://github.com/heinzboehmer/MK60...sembly-Process

    You should be able to clone the repo, point the robot of your choice at it, let it work and come back to a clean Ghidra project. I've tested this with the E9x M3, 1M and E9x 335i .0pa files (DSCM90, DSCM80, DSC90) that are typically distributed with INPA/WinKfp/etc. Hopefully this process translates pretty seamlessly over to an E46 MK60 dump.

    Fable 5.1 (way, way overkill for this work) can go from absolutely 0 context to the clean Ghidra state in ~10 min (in a single turn!). You might trigger cybersecurity safeguards with these more capable models, though. I've tested Opus 4.8 and it works too.

    You'll need to point whoever is doing the work for you at a local DSC .0pa file that you want disassembled. They're not included in the repo for copyright reasons.

    Also, have continued chasing the CCP/XCP/other possible flash routes in the disassembly. Will update on that when I have concrete details.

    Leave a comment:


  • sda2
    replied
    Yes, added to this post. But I ended up finding out that its XOR 0xFF in the VIN, so nothing really encrypted.
    Attached Files

    Leave a comment:


  • heinzboehmer
    replied
    Originally posted by sda2 View Post
    Code:
    moderated​
    I found this on the internet the other day. Maybe it helps for E5
    Woah cool! Those keys fit what I have in my disassembly and work with the signing script in the other repo. Nice find.

    Do you happen to still have the dump from when you were trying to read the MK60 EEPROM?
    Last edited by heinzboehmer; 11-05-2026, 10:40 PM.

    Leave a comment:


  • sda2
    replied
    Code:
    moderated
    I found this on the internet the other day. Maybe it helps for E5
    Last edited by sda2; 11-05-2026, 07:35 PM.

    Leave a comment:


  • heinzboehmer
    replied
    Originally posted by liam821 View Post
    The SP_DATEN files do include the MK60e5 firmware, and different versions, so I'm going to assume there is a way to do a firmware update via CAN. Unfortunately, the files don't contain the e46 mk60 firmware.
    Yep, looking like KWP2000 over CAN is how the MK60e5 gets flashed.​

    Originally posted by terra View Post
    does your disassembly indicate whether the pre-BN2000 can communication and K-line mode exist at all in the code? I had hoped there would be a configuration switch since the Z4M Mk60e5 module does speak the old language.
    Just checked and there is no evidence of either, unfortunately. There's PT-CAN and F-CAN handlers, but nothing else. There's also a serial module (think it's for the wheel speed sensors), but there's no KWP handler that interacts with it.

    Also, am kinda struggling to figure out how to share what I have. Ghidra project is looking pretty good (as in "correct", not as in "pretty"), but I hesitate to just throw it on GitHub cause the code is technically copyrighted. Open to suggestions.

    Leave a comment:


  • liam821
    replied
    The SP_DATEN files do include the MK60e5 firmware, and different versions, so I'm going to assume there is a way to do a firmware update via CAN. Unfortunately, the files don't contain the e46 mk60 firmware.

    Leave a comment:


  • heinzboehmer
    replied
    Originally posted by Bry5on View Post

    I wouldn’t be surprised if it were hardware-only, to the contrary. There are already hardware changes for the m-track pin, it might have a permanent pull down enable somewhere on the board.
    Yeah I guess that's a fair point. I'd still be surprised if the HW wasn't physically flashable, though. Lot more effort to implement HW fuses than it is to ship with a different bootloader or some extra populated component, like you suggested.

    It sounds like you're gonna be opening up the unit either way, if you want to use one of the non-flashable ones. So cutting a trace or bridging some pads isn't too much extra work bs BDM flashing a new bootloader.

    Leave a comment:


  • Bry5on
    replied
    Originally posted by heinzboehmer View Post

    Awesome, will send some keys your way when I get to that point.

    I'll need to check the disassembly for that when I get back home. I left the LLM to reconcile the work it had done in ghidra with the disassembly and symbol attribution work in that other repo. Hoping to have a nice and clean ghidra project to share soon, so that others can look through it too.

    And good to know about XCP! I have a script to poke at the MK60 both via CAN and K line to try and get to the bootloader, but I haven't tested it yet. I've got an 817.3 module in my car and it would really suck to mess that one up



    I'll definitely take you up on that!

    I do think there's a lot to learn from the non-M modules, but I also fear that they're gonna be missing the flashing functionality in the bootloader. Getting a dump of the program would still be very valuable.

    Internet lore says only 813.3/817.3 can be flashed, so unsure what the path is for the non-M modules. I would be surprised if the HW was limiting the flashing and instead expect that the 813.3/817.3 were the only ones that shipped with the FW routines for flashing.

    Wouldn't be surprised if the non-M modules can be BDM flashed with the fully featured bootloader, but that involves both cutting the case open and having a binary to flash.
    I wouldn’t be surprised if it were hardware-only, to the contrary. There are already hardware changes for the m-track pin, it might have a permanent pull down enable somewhere on the board.

    Leave a comment:


  • heinzboehmer
    replied
    Originally posted by terra View Post
    If you share whichever keys you need factored, I should be able have my computer going at it. These days I can do them in under 24 hours each.

    does your disassembly indicate whether the pre-BN2000 can communication and K-line mode exist at all in the code? I had hoped there would be a configuration switch since the Z4M Mk60e5 module does speak the old language.

    I think it might be reasonable to poke at the modules with CCP and XCP comms anyway, not impossible for BMW to have left it in an older module. Someone I was corresponding with found the E60 dsc module did leave XCP open and allowed for a full dump
    Awesome, will send some keys your way when I get to that point.

    I'll need to check the disassembly for that when I get back home. I left the LLM to reconcile the work it had done in ghidra with the disassembly and symbol attribution work in that other repo. Hoping to have a nice and clean ghidra project to share soon, so that others can look through it too.

    And good to know about XCP! I have a script to poke at the MK60 both via CAN and K line to try and get to the bootloader, but I haven't tested it yet. I've got an 817.3 module in my car and it would really suck to mess that one up

    Originally posted by George Hill View Post
    heinzboehmer If you need an MK60 that can be sacrificed, I've got a few non-M here I will gladly send you.
    I'll definitely take you up on that!

    I do think there's a lot to learn from the non-M modules, but I also fear that they're gonna be missing the flashing functionality in the bootloader. Getting a dump of the program would still be very valuable.

    Internet lore says only 813.3/817.3 can be flashed, so unsure what the path is for the non-M modules. I would be surprised if the HW was limiting the flashing and instead expect that the 813.3/817.3 were the only ones that shipped with the FW routines for flashing.

    Wouldn't be surprised if the non-M modules can be BDM flashed with the fully featured bootloader, but that involves both cutting the case open and having a binary to flash.

    Leave a comment:

Working...
X