Pages: [1] 2
Author Topic: Damos address corrector (Python script)  (Read 30573 times)
Polo35580
Newbie
*

Karma: +9/-0
Offline Offline

Posts: 12


« on: March 05, 2019, 07:34:40 AM »

Hello


I'd like to share a python script I wrote to convert a damos (A2L) to fit a new dump.
I wrote it in python to allow everybody to improve it. (and check there is no worm in it) Wink


You can imagine that the damos need to be as close as possible of the new dump.
I mean same hardware but different software is ok but it's not applicable with different hardware.

The script use a valid damos/dump couple in entry and a new dump to produce a new damos file.

Supported ecus: ME7.5, MED91, EDC16U34, MED17 and SID208.
The format of the dumps can be Intel Hex, Motorola S19 or Binary.
The size must be 1024kb, 1504kb, 2048kb or 4096kb.

It's possible to add support to new ecus by adding a new ecu definition in the script.
For that the script contains a supportedeculist variable which hold ecu definition dictionaries.
Ex:
# MED17 - 0x80045320
  "ecu"              : "MED17",
  "cpu"              : "TriCore",
  "addresslen"     : 10,
  "addressstart"  : '0x80',
  "addressformat": '0x80%06X\n'
Meanings:
#  "ecu"              : Ecu string found in A2L MOD_PAR entry                                                                        (Ex: ECU "MED17")
#  "cpu"              : Cpu type string found in A2L MOD_PAR entry                                                                 (Ex: CPU_TYPE "TriCore")
#  "addresslen"     : Length of address string in A2L CHARACTERISTIC records                                                (Ex: 0x800574D8 -> 10)
#  "addressstart"  : Sub string to remove to obtain an hex address where data can be found in dump file            (Ex: 0x800574D8 -> '0x80')
#  "addressformat": Format use to rebuild an address line where 6 is the len of hex address without addressstart (Ex: 0x800574D8 -> '0x80%06X\n')

The script will ask for an ecu and cpu type if there is no MOD_PAR entry in the A2L.


Here is how the script process:
- Read the damos file and create an address table
- Read the original dump
- Read the new dump
- Correct the address table by searching best match pattern from original dump in new dump using dycothomic search method from original address
- Linearize the address table
- Create a new damos using the address table

And here the command line to execute it:
Code:
python correct-damos-address.py DamosFile.A2L OriginalDump NewDump

It take less than 10 minutes to correct most damos on my computer.
There may be some mistakes due to linearization but it work pretty well in most case.

Feel free to test it and report if it fit your needs.   Cheesy


Edit:

Update script to version 1.1.
# ChangeLog  : v1.0 - Original release
#                          - Add MED17 Ecus support
#                          - Add Intel Hex dump support

Edit2:

Update script to version 1.2.
# ChangeLog  : v1.2 - Add ME7.5 Ecus support

Edit3:

# ChangeLog  : v1.3 - Add MED9.1 Ecus support
#                          - Add EDC16U34 Ecus support
#                          - Add Motorola S19 dump support
#                          - Add supported ecu list to allow adding ecu type (See "Supported Ecu List")

Edit4:

# ChangeLog  : v1.4 - Rewrite Intel Hex and Motorola S19 support to handle address bases
#                          - Add SID208 Ecus support


Best regards

Polo
« Last Edit: April 05, 2019, 06:49:14 AM by Polo35580 » Logged
Blazius
Hero Member
*****

Karma: +89/-40
Offline Offline

Posts: 1282



« Reply #1 on: March 05, 2019, 11:19:04 AM »

Did you actually test this with 2 different files ( use script to match damos, change something , flash file without issues ) on a car yet? Anyway nice job.
Logged
Polo35580
Newbie
*

Karma: +9/-0
Offline Offline

Posts: 12


« Reply #2 on: March 05, 2019, 01:35:44 PM »

I created damos with this script for my 2 cars.
A Seat Altea 1.9TDI and a Scirocco 1.4TSI 118kw both modded and working perfectly.  Smiley
Though the Scirocco was a pain to mod but that's not related to the damos. (MED17.5.5...)

I double checked all "important" address of the new damos by comparison in winols when I wrote the script.
I'm currently working on converting the Scirocco to E85 and I can confirm that singles like KRKATE are at good address.

Remember to use a damos as close as possible of your hardware/software to minimize mistakes.

Best regards

Polo
Logged
Blazius
Hero Member
*****

Karma: +89/-40
Offline Offline

Posts: 1282



« Reply #3 on: March 05, 2019, 01:52:28 PM »

I created damos with this script for my 2 cars.
A Seat Altea 1.9TDI and a Scirocco 1.4TSI 118kw both modded and working perfectly.  Smiley
Though the Scirocco was a pain to mod but that's not related to the damos. (MED17.5.5...)

I double checked all "important" address of the new damos by comparison in winols when I wrote the script.
I'm currently working on converting the Scirocco to E85 and I can confirm that singles like KRKATE are at good address.

Remember to use a damos as close as possible of your hardware/software to minimize mistakes.

Best regards

Polo

Nice good job , maybe I'll give this a try for my N/A software see how well it works with slight mismatch, as the closest thing I can use is Me7.5 dbw narrowband turbo files Tongue
Logged
Polo35580
Newbie
*

Karma: +9/-0
Offline Offline

Posts: 12


« Reply #4 on: March 06, 2019, 10:12:18 AM »

Hello

I updated the script to v1.1 with binary dump file of 1504ko support.
So you can now mix Intel hex and binary files.

Ex:
Code:
python correct-damos-address.py DamosFile.A2L OriginalDump.HEX NewDump.BIN

Best regards

Polo
Logged
Blazius
Hero Member
*****

Karma: +89/-40
Offline Offline

Posts: 1282



« Reply #5 on: March 07, 2019, 02:51:46 PM »

I just tried this with the AWM damos and it says a2l doesnt contain any adress, while infact it does in WinOls. Any idea whats wrong?
Logged
Polo35580
Newbie
*

Karma: +9/-0
Offline Offline

Posts: 12


« Reply #6 on: March 10, 2019, 10:03:59 AM »

Hello

I just updated the first post with a new version with ME7 support.
I'll have to find a better way to identify the ecu type...

I first created the script for my Seat Altea 1.9TDI but I mess the script when I convert it to MED17 and I can't find my old backup...
I'm no more able to create a correct damos for my Seat Altea 1.9TDI.
I'll try to find my backup and restore support for EDC16 also.

Best regards

Polo
« Last Edit: March 10, 2019, 10:08:18 AM by Polo35580 » Logged
Polo35580
Newbie
*

Karma: +9/-0
Offline Offline

Posts: 12


« Reply #7 on: March 15, 2019, 03:29:18 AM »

Hello

An other update with MED9 and EDC16U34 support.
I also added support of Motorola S19 dump file.

The Ecu is now identified by parsing the A2L.
This identification allow to select an ecu definition in a list of supported ecu.
It's possible to add new definitions in this list in the script. (See first post and script)

Best regards

Polo
« Last Edit: March 15, 2019, 03:32:50 AM by Polo35580 » Logged
Bitshifter
Full Member
***

Karma: +10/-7
Offline Offline

Posts: 94


« Reply #8 on: March 15, 2019, 08:23:16 PM »

Tested it with MED 9.1 file. Script don`t work for me, it shows error "Input is not a file !!!"

Could somebody upload a working example, please.
Logged
nyet
Administrator
Hero Member
*****

Karma: +607/-168
Offline Offline

Posts: 12268


WWW
« Reply #9 on: March 16, 2019, 10:38:49 AM »

Tested it with MED 9.1 file. Script don`t work for me, it shows error "Input is not a file !!!"

Could somebody upload a working example, please.

copy/paste what you tried to do at the command line.
Logged

ME7.1 tuning guide
ECUx Plot
ME7Sum checksum
Trim heatmap tool

Please do not ask me for tunes. I'm here to help people make their own.

Do not PM me technical questions! Please, ask all questions on the forums! Doing so will ensure the next person with the same issue gets the opportunity to learn from your ex
Polo35580
Newbie
*

Karma: +9/-0
Offline Offline

Posts: 12


« Reply #10 on: March 19, 2019, 01:30:32 AM »

Hello

Here my test folder for MED9 and MED17.
https://mega.nz/#!iFcQxArS!BNg0BZWY8XtKNFdt8f4uegHMUZ9K4gThWKBk-y8akgU

There is 2 damos + dump of Golf 5 2.0T MED9.1 and 2 damos + dump of Golf 6 1.4TSI MED17.5.5.
So it's easy to compare created damos with real ones.

Here the commands MED9:
Code:
python correct-damos-address-v1.3.py "1K0907115G_0010-41WE20BKGC1G.A2L" "1K0907115G_0010.s19" "1K0907115S_0030.s19" debug
Code:
python correct-damos-address-v1.3.py "1K0907115S_0030-44D100BKIA3G.A2L" "1K0907115S_0030.s19" "1K0907115G_0010.s19" debug
And for MED17:
Code:
python correct-damos-address-v1.3.py "V4N350FM10KJ2g.A2L" "Ser_V4N350FM10KJ2g_Complete.HEX" "SER_V5O360F10KM01g_Complete.HEX" debug
Code:
python correct-damos-address-v1.3.py "V5O360F10KM01g.A2L" "SER_V5O360F10KM01g_Complete.HEX" "SER_V4N350FM10KJ2g_Complete.HEX" debug

Best regards

Polo
Logged
Polo35580
Newbie
*

Karma: +9/-0
Offline Offline

Posts: 12


« Reply #11 on: April 05, 2019, 01:54:27 AM »

Hello

I just updated the first post with support for SID208.
I also rewrote the Intel Hex and Motorola SRec parsing to handle address bases.

The script will ask for an ecu and cpu type if there is no MOD_PAR entry in the A2L so it's possible to add new ecu support even if the A2L don't contains ECU and CPU type.

Best regards

Polo
Logged
jcsbanks
Full Member
***

Karma: +19/-3
Online Online

Posts: 146


« Reply #12 on: April 05, 2019, 02:52:24 AM »

Line 411 and 644 need * in:
dumplinebin[2] * 0x10000
Logged
jcsbanks
Full Member
***

Karma: +19/-3
Online Online

Posts: 146


« Reply #13 on: April 05, 2019, 04:04:41 AM »

I tried an MED17 and at a quick glance the KFs I looked at were well formed. Nice work.
Logged
Polo35580
Newbie
*

Karma: +9/-0
Offline Offline

Posts: 12


« Reply #14 on: April 05, 2019, 06:50:02 AM »

Line 411 and 644 need * in:
dumplinebin[2] * 0x10000
Thanks for the report.  Wink
I just updated the file in first post.

Best regards

Polo
Logged
Pages: [1] 2
  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Page created in 0.024 seconds with 17 queries. (Pretty URLs adds 0s, 0q)