Hacking the Motronic ECU (Audi RS2)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • prj
    S2Forum Zealot
    • Mar 2010
    • 6308
    • Country: Estonia

    #76
    Going to post a little bit more on topic.

    Something that is very helpful in finding things is having many different ECU files.
    If you take the 27C512 files from the 551C ECU from an S6 and a 551C ECU from an RS2 they are almost identical, the only difference is in the maps and some constants. This eases the task a lot.

    To look deeper into this, one must understand how the EPROM is generally laid out.
    From what I understand this applies to any ECU used in cars with the AAN, ABY and ADU engines. When you have many files, you can find some similar ones. For example by comparing the software of the late RS2 with the S6 from the ECU with the same number, you can figure out a lot of things.

    This seems to be the EPROM layout of the 27C512 chip:
    From 0x0000 to 0x1FFFF you have from what I understand the main Bosch software provided with any ECU. From what I have read, it used to be in the internal ROM of the CPU in earlier motronics. Luckily it does not seem to be the case here.
    From 0x2000 to 0x7FFF (in the later "C" ecu-s to 0x9FFF) should be the manufacturer specific code.
    Actually it is not that important to know which code belongs to whom, just that 0x0000 to 0x7FFF (or 0x9FFF) is mostly code that can be disassembled and looked at.

    After this, at 0x8000 (A, AA, B) or 0xA000 (C) comes some more data that is static between different car types. I haven't tried to figure out what it is yet.

    Things get interesting after another 300h (0xA300 or 0x8300), where there is a small block of data, some padding and after 20h more (0xA320 or 0x8320) there is a data area, which varies between different cars. The rev limiter is located in this area, and at my guess perhaps the "injector constants" (krkte) are somewhere around here as well.

    Now comes one of the most important parts. At 0x8800 or 0xA800 in the later ECU-s is the master table. It simply contains all 16 bit addresses of the tables found in the ECU. At my guess (again... I hate guessing), almost every table that is referenced by the ECU is here. The only things that are exempt are the constants, such as the rev limiter, about the location of which I wrote above.

    Finally we get to the map data. From 0x8A00 (0xAA00) until 0xFEFF we have all the maps one after another, as referenced by the map table above. The maps are dynamic. It is possible to resize and rescale them, and the ECU will cope. This is evidenced by the fact, that software for the ADU engine is exactly the same as for AAN (bar one byte) and the maps have different dimensions.
    There is enough information online on how to read the maps, no point for me to repeat it here.

    And now we are done. At 0xFF00 we have the checksum, after which we have the ECU version, then for lack of a better name "the string that gets displayed in VAG-COM" and finally the exact version of the software.

    So, this is the structure of the fuel chip. We also of course have the turbo chip, but that is for another time.


    The difficulty comes from understanding what each of these maps and constants do, and how they are read. This is where the real work begins.

    One can get some hints from the assembly:
    The 8051 CPU always uses it's 16 bit register (DPTR) to load data from external memory (EPROM). One of the instructions to load a static location, is MOV DPTR, #data. In hex it is 90 followed by the address. Interaction with the register is little-endian, so if you want to check whether the CPU directly loads a value from somewhere, you can just try to search for 90 XX XX in the hex code. Of course there are other ways to modify the data pointer, but just searching for all memory accesses in the code and mapping them out (while weeding out false positives) will give you a rough idea of what code touches what.

    However, from what I gather (and from what I have been told), it is almost impossible to figure this thing out by assembly alone. A trace and some data logging is required, so that you can get rough ideas on how the multitude of analogue signals coming in and going out of the ECU are scaled and represented in digital form within the ECU software itself.

    I hope this is of some help to someone. Some mistakes might have slipped in, so feel free to correct me, if I got something wrong.

    Oh and, if anyone wants to help me along with figuring a few things out, It'd be pretty cool. Whether it is done in public or privately. Though from what I have seen, if you start digging in this thing, you need to have a head of your own.
    Last edited by prj; 11 June 2010, 11:56.
    http://tuner.ee - http://www.facebook.com/tuner.ee

    Comment

    • S2central.net
      Retired OG Mod
      • Jul 2003
      • 16590
      • Country: Northern Ireland

      #77
      You are making good progress there... you are absolutely right about limitations with assembly code - I thought I would have learnt a lot from it, but you mostly get a headache. This is why you need tracing in real-time and why I decided to go for the engine simulator so that I can traverse maps much more accurately and repeatably on a bench - and to see some other scenarios as well.

      One thing I did learn from disasembly output is that much of the code at the bottom of chip (0x0000) is interrupt routines for the micro - I have never tried to reverse engineer them yet - a memory map would be awful useful as well to know where the I/O for sensors and actuators is addressed... again I hope my simulator will help that.

      I guess you have worked out the trick for calculating axis on the maps - I wrote something in PHP that helps a lot. Tis a pain doing it manually - thank goodness as I have actually forgotten how to do it manually now

      I seem to recall there are some maps not mentioned in the directory but I am not 100% sure sitting here.
      Paul Nugent
      Webmaster http://S2central.net
      Administrator http://S2forum.com

      1994 S2 Coupe ABY - aka Project Lazarus
      2001 A6 allroad 2.5TDi - family tank
      2003 S4 Avant 4.2 V8 - daily burble

      Purveyor of HomeFries and Exclusive agent for Samco hose kits (S2/RS2)

      There are only 10 kinds of people that understand binary - those that do, and those that don't

      Comment

      • prj
        S2Forum Zealot
        • Mar 2010
        • 6308
        • Country: Estonia

        #78
        Originally posted by S2central.net
        You are making good progress there... you are absolutely right about limitations with assembly code - I thought I would have learnt a lot from it, but you mostly get a headache. This is why you need tracing in real-time and why I decided to go for the engine simulator so that I can traverse maps much more accurately and repeatably on a bench - and to see some other scenarios as well.
        Thanks... and we both came to the same conclusion it seems.
        One thing I did learn from disasembly output is that much of the code at the bottom of chip (0x0000) is interrupt routines for the micro - I have never tried to reverse engineer them yet - a memory map would be awful useful as well to know where the I/O for sensors and actuators is addressed... again I hope my simulator will help that.
        Memory map you say. Just checking, but are you aware, that the axis constants in many cases ARE the memory locations? Only some are "fake"...
        I have a pretty good idea on how to figure out what is stored in the memory locations using the trace function on the emu. I can PM you with that, if you like...
        I guess you have worked out the trick for calculating axis on the maps - I wrote something in PHP that helps a lot. Tis a pain doing it manually - thank goodness as I have actually forgotten how to do it manually now
        That is very, very easy. There is enough information on the net that literally spoonfeeds it to you. What is a lot harder is translating those numbers into real world values. Like if you have coolant temp 182 in decimal in the map axis, it tells you nothing. You can only guess without a trace.
        I seem to recall there are some maps not mentioned in the directory but I am not 100% sure sitting here.
        I don't think so. What I found not mentioned in the directory were things like the RPM limiter... I have a lot of work to do still. Most importantly to figure out where the injector constants are and do some more work to understand how some stuff works in the turbo map.
        http://tuner.ee - http://www.facebook.com/tuner.ee

        Comment

        • S2central.net
          Retired OG Mod
          • Jul 2003
          • 16590
          • Country: Northern Ireland

          #79
          I can tell you where the injector constant is... PM coming
          Paul Nugent
          Webmaster http://S2central.net
          Administrator http://S2forum.com

          1994 S2 Coupe ABY - aka Project Lazarus
          2001 A6 allroad 2.5TDi - family tank
          2003 S4 Avant 4.2 V8 - daily burble

          Purveyor of HomeFries and Exclusive agent for Samco hose kits (S2/RS2)

          There are only 10 kinds of people that understand binary - those that do, and those that don't

          Comment

          • kotnelson
            S2Forum Buff
            • Oct 2008
            • 48
            • Country: Thailand

            #80
            Thank you, this is a great info.
            Too bad I do not know assembly.

            I hope you guy post more info.
            Again, thks

            Comment

            • prj
              S2Forum Zealot
              • Mar 2010
              • 6308
              • Country: Estonia

              #81
              Originally posted by kotnelson
              Thank you, this is a great info.
              Too bad I do not know assembly.

              I hope you guy post more info.
              Again, thks
              If you want more info, you must give some info of your own.
              You can not learn this by only reading, and for everyone there is a limit on how much info they will give without getting anything in return.
              http://tuner.ee - http://www.facebook.com/tuner.ee

              Comment

              • vertigone
                S2Forum Addict
                • Nov 2009
                • 253
                • Country: France

                #82
                I don't know if I can ask this here , but it speaks about motronic data too
                1- Anyone has translate to "human language" the block 00 for 3b motor ?
                2 - how do you reset adaptation tables ?


                91' S2 3B Pearl White

                Comment

                • prj
                  S2Forum Zealot
                  • Mar 2010
                  • 6308
                  • Country: Estonia

                  #83
                  This has nothing to do with motronic data. You are posting in the wrong thread.
                  http://tuner.ee - http://www.facebook.com/tuner.ee

                  Comment

                  • vertigone
                    S2Forum Addict
                    • Nov 2009
                    • 253
                    • Country: France

                    #84
                    ok sorry that's why I asked if it was ok
                    you can delete my post I'll ask my question in an other one
                    91' S2 3B Pearl White

                    Comment

                    • prj
                      S2Forum Zealot
                      • Mar 2010
                      • 6308
                      • Country: Estonia

                      #85
                      Made a small addon to the Motronic software, which allows me to monitor various inputs and outputs in the ECU.
                      Here is a sample, monitoring RPM's:


                      I probably should write some custom software, which would also log the data and display it nicely in a digital form, instead of a 16x16 table in TunerPro...
                      http://tuner.ee - http://www.facebook.com/tuner.ee

                      Comment

                      • prj
                        S2Forum Zealot
                        • Mar 2010
                        • 6308
                        • Country: Estonia

                        #86
                        I would like to encourage people to learn the workings of Motronic.

                        I got my AAN engined Audi at the end of April, now it is start of July and I know enough about it to be able to remap the car as needed.
                        This makes two months of tackling it as a hobby project, using 1-2 hours per day on average.
                        Thanks go to everyone who have helped/hinted me in one way or the other .

                        All you need to learn is a wideband lambda+controller (which you need for tuning anyway), an emulator, such as the Ostrich II, and your head on the right way.
                        There is a wealth of information available online regarding to how these ECU-s work, in fact, it is possible to find a lot of stuff without making any investments. The investments only help you verify what you have found.

                        So basically, what I wanted to say, is that you don't need 1 million euros and 2 years to learn this. 400-500 euros and a month or two are enough, given sufficient motivation.

                        Good luck.
                        http://tuner.ee - http://www.facebook.com/tuner.ee

                        Comment

                        • Bram
                          S2Forum Fiend
                          • Aug 2006
                          • 2582
                          • Country: Netherlands

                          #87
                          Nice work. Could you also send different data to the onboard computer in your dash, like boost, etc. or is that display totally disconnected from the ECU?

                          Comment

                          • prj
                            S2Forum Zealot
                            • Mar 2010
                            • 6308
                            • Country: Estonia

                            #88
                            To be honest, I don't really remember how the trip computer gets it's data.
                            I remember there being a good writeup about it somewhere, and reading it, but since I have not really had any interest in it, I've forgot.

                            There is definitely /some/ communication between the ECU and the Computer, since AFAIK for a long time the computer did not work for VEMS users, but it does now. Perhaps that'd be a place to start digging?

                            I think it is possible to make corrections the MPG display using VAG-COM though.
                            http://tuner.ee - http://www.facebook.com/tuner.ee

                            Comment

                            • andy10v
                              S2Forum Zealot
                              • Mar 2009
                              • 5996
                              • Country: Scotland

                              #89
                              Bram there was this for urs4's, the TDS-1



                              There are a few of old threads about getting the display to do other things and one newer one IIRC.
                              Current-2004 Impreza PPP wagon

                              Sold-92 3B coupe-RS2+, 996s, konis, rear torsen, forged rods........
                              Sold ABY-stock

                              Comment

                              • S2central.net
                                Retired OG Mod
                                • Jul 2003
                                • 16590
                                • Country: Northern Ireland

                                #90
                                There is a project in there for someone with a lot of time on their hands... reverse engineering the RDS interface to the trip computer and using that to communicate something like boost pressure.

                                Fuel usage signal is just an analogue voltage output from ECU iirc - the scaling of that is used along with VSS from the speedo to work out MPG.
                                Paul Nugent
                                Webmaster http://S2central.net
                                Administrator http://S2forum.com

                                1994 S2 Coupe ABY - aka Project Lazarus
                                2001 A6 allroad 2.5TDi - family tank
                                2003 S4 Avant 4.2 V8 - daily burble

                                Purveyor of HomeFries and Exclusive agent for Samco hose kits (S2/RS2)

                                There are only 10 kinds of people that understand binary - those that do, and those that don't

                                Comment

                                Working...