NefMoto

Technical => Reverse Engineering => Topic started by: kartoffelpflanze on July 30, 2025, 05:25:36 AM



Title: ODIS/MCD project explorer (.db .key file parser)
Post by: kartoffelpflanze on July 30, 2025, 05:25:36 AM
Many years after people started asking around here (http://nefariousmotorsports.com/forum/index.php?topic=10318.msg108305#msg108305 (http://nefariousmotorsports.com/forum/index.php?topic=10318.msg108305#msg108305)) for information about ODIS projects (folders with .db and .key files), I have created a few Python scripts to open and dump them.

GitHub repo: https://github.com/kartoffelpflanze/ODIS-project-explorer (https://github.com/kartoffelpflanze/ODIS-project-explorer).

I hope someone will find it useful. It took and embarassing amount of work, and I'm sure it can be improved. The good news is, it's open-source, so anyone can contribute :D

It can dump the data necessary for measuring values (service 0x22) and also parse such a response. Probably this will be the most useful part of the project.


Title: Re: ODIS/MCD project explorer (.db .key file parser)
Post by: jcsbanks on August 26, 2025, 09:43:26 AM
Thanks, great project.

The DTC dump didn't work for me, but I parsed 0.0.0@BL_ECMDFCC.sd.c, or rather ChatGPT did.

https://dynospectrum.com/C7_ECU_DTC.html (https://dynospectrum.com/C7_ECU_DTC.html)


Title: Re: ODIS/MCD project explorer (.db .key file parser)
Post by: aaronc7 on August 26, 2025, 08:06:27 PM
Thanks for sharing, everything works great for me-- DTCs, PIDs.

Only thing I had to do to get it working was install older version of jpype1, 1.5.2 to be exact.  The latest at the time was 1.6.0 iirc and it errored out.


Title: Re: ODIS/MCD project explorer (.db .key file parser)
Post by: kartoffelpflanze on August 27, 2025, 11:03:40 PM
I parsed 0.0.0@BL_ECMDFCC.sd.c
I don't know if I would recommend that, those are some sort of libraries that get referenced by higher levels.

Instead, this is how you would dump the DTCs for the ECM (replace the paths with yours):
Code:
python dumpDTC.py basevariant "C:/ProgramData/OE/MCD-Projects-E/VWMCD/AU21X" "0.0.0@BV_EnginContrModul1UDS.bv" "O:/DTCs" "C:/ProgramData/OE/DIDB/db" en_US

You can omit the last part with DIDB if you don't want translated/detailed descriptions. Those strings are often XML with simple HTML elements, you could parse them.

Different ECU-VARIANTs may support slightly different DTCs, or they might be named differently. On your C7 tool you should probably make a dropdown to select the ECU-VARIANT, you can use dumpECUVariantPatterns (or reimplement your own script based on it) to get them. To be honest, the DTC entry could be a dropdown too instead of text input :)


Title: Re: ODIS/MCD project explorer (.db .key file parser)
Post by: kartoffelpflanze on August 27, 2025, 11:15:26 PM
The latest at the time was 1.6.0 iirc and it errored out.

Hm, I'm pretty sure I've had 1.6.0 since the beginning and there were no problems. Now I get a few warnings about an unnamed module, but no error, it still works apart from that.
What error do you have?


Title: Re: ODIS/MCD project explorer (.db .key file parser)
Post by: jcsbanks on August 28, 2025, 04:55:49 AM
I don't know if I would recommend that, those are some sort of libraries that get referenced by higher levels.

Instead, this is how you would dump the DTCs for the ECM (replace the paths with yours):
Code:
python dumpDTC.py basevariant "C:/ProgramData/OE/MCD-Projects-E/VWMCD/AU21X" "0.0.0@BV_EnginContrModul1UDS.bv" "O:/DTCs" "C:/ProgramData/OE/DIDB/db" en_US

You can omit the last part with DIDB if you don't want translated/detailed descriptions. Those strings are often XML with simple HTML elements, you could parse them.

Different ECU-VARIANTs may support slightly different DTCs, or they might be named differently. On your C7 tool you should probably make a dropdown to select the ECU-VARIANT, you can use dumpECUVariantPatterns (or reimplement your own script based on it) to get them. To be honest, the DTC entry could be a dropdown too instead of text input :)

Thanks. That same command produces no files with only the output path changed. I do have AU21X and BV_EnginContrModul1UDS.bv at the same path. I had been trying AU57X and a few others before and wanted to recheck AU21X in case there was some difference from what you tested. There is a slight delay when run, and no errors shown. Perhaps I could add some output to show what it is doing. I don't mind a superset of DTCs for all variants, it is just a guide for users that don't have ODIS/VCDS and where there is a VAG DTC we can show but no OBD code, and it picks up ones that were missing in previous lists I'd amalgamated. It would be interesting to see how different the output is for individual variants though and whether there are any misleading conflicts doing it the way I have so far. I'd previously done similar for OBD 22 requests with info from another source, and checked for conflicts and decided to group them by number of cylinders and fuel type as there were a few conflicts otherwise where the same PID was different, but I found no conflicts when grouped like that. Would be interesting to see for the DTCs, especially if I put this in a memory constrained device as a gzip html file like I did before, then one list suits 30+ ECU versions and I only have to maintain a few.


Title: Re: ODIS/MCD project explorer (.db .key file parser)
Post by: jcsbanks on August 28, 2025, 05:55:17 AM
I'm not very pythonic, but I'm guessing that perhaps an import isn't working properly as even a print("hello") works at the top before the imports but not before "#Handle usage as script"


Title: Re: ODIS/MCD project explorer (.db .key file parser)
Post by: jcsbanks on August 28, 2025, 05:58:06 AM
It is failing on import LongNameTranslation based on showing progress then commenting that out.


Title: Re: ODIS/MCD project explorer (.db .key file parser)
Post by: jcsbanks on August 28, 2025, 06:19:17 AM
import jpype is failing but JPype1 is installed. I think it is something to do with Java paths. Will report back.


Title: Re: ODIS/MCD project explorer (.db .key file parser)
Post by: kartoffelpflanze on August 28, 2025, 06:25:35 AM
This is my output for AU57X:
Code:
BASE-VARIANT BV_EnginContrModul1UDS
  Has no DTCs
ECU-VARIANT EV_ECM00TDI01104L907309AA_001
  Has no DTCs
ECU-VARIANT EV_ECM00TFS02006K907425J_001
  Has no DTCs
ECU-VARIANT EV_ECM18TFS0204G0906264_001
ECU-VARIANT EV_ECM20TDI01103L906018GT_003
ECU-VARIANT EV_ECM20TDI01103L906018HA_003
ECU-VARIANT EV_ECM20TDI01103L906018LA_003
ECU-VARIANT EV_ECM20TDI01103L906018LB_003
...

Here is a sample of the first file generated:
Code:
(627) {
  [0] {
    trouble_code: 0x39E7
    dtc: 'P060600'
    level: 0x2
    raw_description: 'ECM/PCM Processor'
    translated_description: 'ECM/PCM Processor'
  }
  [1] {
    trouble_code: 0x39EB
    dtc: 'P157100'
    level: 0x2
    raw_description: 'Left Electro-Hydraulic Engine Mount Solenoid Valve Short circuit to B+'
    translated_description: '<?xml version="1.0" encoding="UTF-8"?><String>Left Electro-Hydraulic Engine Mount Solen.val.<BR/>Short circuit to B+</String>'
  }
  [2] {
    trouble_code: 0x39EC
    dtc: 'P157200'
    level: 0x2
    raw_description: 'Left Electro-Hydraulic Engine Mount Solenoid Valve Short circuit to ground'
    translated_description: '<?xml version="1.0" encoding="UTF-8"?><String>Left Electro-Hydraulic Engine Mount Solen.val.<BR/>Short circuit to Ground (GND)</String>'
  }
...

If there are import errors, I would expect them to show up in standard output. You can avoid the long name translation by calling only:
Code:
python dumpDTC.py basevariant "C:/ProgramData/OE/MCD-Projects-E/VWMCD/AU57X" "0.0.0@BV_EnginContrModul1UDS.bv" "O:/DTCs"


Title: Re: ODIS/MCD project explorer (.db .key file parser)
Post by: jcsbanks on August 28, 2025, 07:07:58 AM
Thanks.

import jpype now works (after setting JAVA_HOME and PATH and installing VC++ 64 bit redistributable) and the script is running without "C:/ProgramData/OE/DIDB/db" en_US as the translations aren't working yet on my system, will look at that, but what descriptions there are without are already in English so far.

Without all those steps import jpype failed silently, couldn't print an exception, using Python REPL, import jpype just crashed Python silently without VC redist installed.

Interestingly the number of DTCs for specific ECU versions is very short compared to the other file I extracted, perhaps there is redundancy or a hierarchy involved?


Title: Re: ODIS/MCD project explorer (.db .key file parser)
Post by: kartoffelpflanze on August 28, 2025, 07:39:27 AM
Give me an example of ECU-VARIANT and DTC that exists in the other file but is not exported by dumpDTC, I will check in MCD-Kernel if it gets decoded or not.


Title: Re: ODIS/MCD project explorer (.db .key file parser)
Post by: jcsbanks on August 28, 2025, 08:09:47 AM
I'm trying various combinations of JDK to see if I can get it to work.

Tried JDK 7 fresh install and it can't find org.jpype.jar support library

Now trying JDK 11.

Have Python 3.13, looks like a few versions earlier work better with jpype.

Which JDK and python versions did you develop this with?


Title: Re: ODIS/MCD project explorer (.db .key file parser)
Post by: jcsbanks on August 28, 2025, 08:22:54 AM
JDK 11 and Python 3.13 now works for the translations.

The JRE that is with ODIS did not work. JDK 7 did not work.

Now looking at the DTC content.


Title: Re: ODIS/MCD project explorer (.db .key file parser)
Post by: EanDem on August 28, 2025, 08:49:52 AM
It does job. Great work!


Title: Re: ODIS/MCD project explorer (.db .key file parser)
Post by: jcsbanks on August 28, 2025, 01:57:28 PM
I did a check for conflicts with an individual ECU file and nothing that is in it is missing in 0.0.0@BL_ECMDFCC.sd.c and the descriptions are functionally identical. Some of the PCBU codes are different but the descriptions are functionally the same, so am going to keep one master file for the ECUs on that platform for now.

For an example individual ECU file, there are 899 common entries, 83 with conflicts in the given PCBU code, and 20384 DTCs only present in 0.0.0@BL_ECMDFCC.sd.c


Title: Re: ODIS/MCD project explorer (.db .key file parser)
Post by: kartoffelpflanze on August 28, 2025, 08:51:31 PM
I prepared my UDS emulator with F19E=EV_ECM18TFS0204G0906264 and F1A2=001000 and configured the response for service 0x19 to send DTCs 14823, 14827, 23147, 14828. Out of them, 23147 is only defined in BL_ECMDFCC and the other 3 are defined for the ECU-VARIANT I mentioned.

I loaded AU57X in VW-MCD Client, selected LL_EnginContrModul1UDS, started communication and went to FAULTREAD. This was the output:
(http://nefariousmotorsports.com/forum/index.php?action=dlattach;topic=23836.0;attach=41635;image)

As expected, since the BASE-VARIANT does not have any DTCs defined.

Then, I did variant identification and selection to select the ECU-VARIANT. This was the output of FAULTREAD:
(http://nefariousmotorsports.com/forum/index.php?action=dlattach;topic=23836.0;attach=41637;image)

Clearly, the DTC which is defined in BL_ECMDFCC but not in the ECU-VARIANT (3rd one) is not supported (exactly as I expected).



Unrelated note: in VCDS I always noticed DTC descriptions in which 2 words were concatenated towards the middle, such as "Invalid Data Received FromAnti-Lock Brake System Control Module". I just realized it's because there is a newline between them and it's being discarded ;D VW-MCD Client makes the same mistake.


Title: Re: ODIS/MCD project explorer (.db .key file parser)
Post by: jcsbanks on August 29, 2025, 12:21:47 AM
Thanks, so this suggests if I want to make a unified list for one engine type it would be 20 times smaller if I combined all the individual ECU files rather than use the “big” one. I only did that initially due to Java/jpype problems making the individual ECU files, so would be worth me redoing. It does look like you have all the required data for DTCs in the individual files.


Title: Re: ODIS/MCD project explorer (.db .key file parser)
Post by: kartoffelpflanze on August 29, 2025, 12:55:08 AM
Something that might help for grouping files is the description provided for every file generated by dumpECUVariantPatterns. Here is the description of GV_ECM30BTD011AU57X_210:
Code:
<p>@@failureclass("1","KD-Fehler (NICHT OBD-relevant) ( mit Priorität 2 "Fehler" für KD-Tester ) [nur KD]","no")</p>
<p>@@failureclass("3","OBD-relevante Fehler (mit Priorität "Fehler" für KD-Tester) [MIL]","yes")</p>
<p>@@failureclass("2","KD-EGAS-Fehler (NICHT OBD-relevant) [KD + SYS/EPCL]","no")</p>
<p>@@failureclass("11","KD-Fehler (NICHT OBD-relevant) ( mit Priorität 6 "Hinweis" für KD-Tester ) [KD Hinweis]","no")</p>
<p>@@failureclass("4","OBD-relevante EGAS-Fehler [MIL + SYS/EPCL]","yes")</p>
<p>@@failureclass("17","MIL und EPCL sofort an (z.B. P-Mode, Deaktivierung Katheizen in der Produktion) [MIL + EPCL]","yes")</p>
<p>@@failureclass("14","OBD-relevante EGAS-Fehler (mit MIL on im 1. DCY) [MIL + SYS/EPCL]","yes")</p>
<p>@@failureclass("7","OBD-relevante Fehler Misfire Monitoring (Otto und Diesel) [MIL + Otto zus. blinkende MIL]","yes")</p>
<p>@@failureclass("13","OBD-relevante Fehler (mit MIL on im 1. DCY) [MIL]","yes")</p>
<p>@@failureclass("5","OBD-relevante Fehler Fuel System Monitoring (Otto und Diesel) [MIL]","yes")</p>
<p>@@failureclass("6","OBD-relevante EGAS-Fehler Fuel System Monitoring (Diesel) [ MIL + SYS/EPCL]","yes")</p>
<p>@@failureclass("9","OBD-relevante Fehler mit schnellem Löschen des Fehlers wie PendingFaultCode [MIL]","yes")</p>
<p>@@failureclass("18","Grobleck-Fehler / Offener Tankdeckel (Tankleckdiagnose) [MIL]","yes")</p>
<p>@@exchange-xml("bosch_exchange_002042.xml")</p>
<p>@@program_version("C1249CDGC")</p>
<p>@@dataset("10SW079892_Logistic_Data.DCM")</p>
<p>@@odx-basispaket("ECM_ODX-Basispaket_KW48_2020.pdx")</p>
<p>@@basevariant("BV_EnginContrModul1UDS_002110.odx")</p>
<p>@@xv("XV_ECMMEDC1710_016040_20.odx")</p>
<p>@@mappinglist("ECM_Bosch_Signal-Mappingliste_V3.0.16a.xml")</p>
<p>@@used_norms(VW80114="",VW80124="",VW80125="4.0",VW80126="",VW80127="")</p>
<p>@@measurement-library(null)</p>
<p>@@ecu_type("EDC17CP44-3.3 neues Speicherlayout C7 PA W37 MJ15")</p>
<p>@@project_description("SW für 4G0 907 589 F")</p>
<p>@@transmission_variant("AL551-8Q")</p>
<p>@@engine_code_letters("CVUA")</p>
<p>@@engine_power("235")</p>
<p>@@modelyear("2015")</p>
<p>@@emission_standard("EU6 plus (+7MM)")</p>

Also, I don't know very much about this, but it seems like variants starting with "GV_" are more of a top-level. I know EV means ECU-VARIANT but no clue about GV, maybe someone can help.


Title: Re: ODIS/MCD project explorer (.db .key file parser)
Post by: jcsbanks on August 29, 2025, 04:27:06 AM
Think I have a 11KB gzipped unified list that covers the 2.5T, 4.0T and 5.2 our users need. I picked the longest of translated descriptions and they were functionally identical across all versions and engines, and just show the multiple P codes they are listed under.


Title: Re: ODIS/MCD project explorer (.db .key file parser)
Post by: jcsbanks on August 29, 2025, 04:45:36 AM
Is there a donation link I can include for users to show their appreciation?


Title: Re: ODIS/MCD project explorer (.db .key file parser)
Post by: kartoffelpflanze on August 29, 2025, 08:09:34 AM
I'm flattered you think anyone would pay for a pretty much completed open source project :o