Announcement

Collapse
No announcement yet.

CSL '0401' Program Binary Disassembly Notes

Collapse
This is a sticky topic.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Originally posted by karter16 View Post

    Yep that's exactly what I'm thinking. Ideally need to do it on both an HP and a non-HP, however I'd have to port the CAN logging to a non-HP version of the code :-)
    That would be a fun exercise. Curious to know how stressed these things are (i.e. how much more stuff we can make them do).

    I've got both a stock non-HP and a HW converted HP to test with, in case you end up porting the logging!
    2002 Topasblau M3 - Coupe - 6MT - Karbonius CSL Airbox - SSV1 - HJS - Mullet Tune - MK60 Swap - E86 Front Triangulation - ZCP Rack - Nogaros - AutoSolutions - 996 Brembos - Slon - CMP - VinceBar - Koni - Eibach - BlueBus - Journal

    2012 Alpinweiss 128i - Coupe - 6AT - Slicktop - Manual Seats - Daily - Journal

    Comment


      Originally posted by heinzboehmer View Post

      That would be a fun exercise. Curious to know how stressed these things are (i.e. how much more stuff we can make them do).

      I've got both a stock non-HP and a HW converted HP to test with, in case you end up porting the logging!
      Okay awesome I do need to do at least some disassembly of a non-HP program for something else I'm working on so it will be on the cards at some point. The DME bmwfnatic has sent arrived today as well so I now have a second DME for testing purposes too which is amazing!
      2005 ///M3 SMG Coupe Silbergrau Metallic/CSL bucket seats/CSL airbox/CSL console/6 point RACP brace/Apex ARC-8s
      Build Thread | Community Patch | MSS54 DS2 Tool

      Comment


        Well this screenshot doesn't look like much, but it's a big milestone.

        ​

        For some time I've been quietly working on reconstructing C source code from the disassembly work, initially with the primary goal of making the codebase easier to read and understand, but more recently with the goal of being able to compile the source into a binary.

        Vast amounts of effort have yielded the ability to compile (from C code) a full binary that is address-exact with 0401. What I mean by that is that the compiled binary has every RAM variable and every tune parameter at the exact memory address it is located at in 0401 (by linking files and sections in the correct order, not by forcing the location of each variable manually. This means any intentional changes to the codebase will correctly reflow). The actual program code is not a byte-exact match with 0401 because I'm using modern GCC whereas I *think* in the 90's and 00's BMW used a Microtek compiler. The compilers have their own strategies and optimisations, hence the program code is not exactly the same in structure (although my goal is of course that actual behaviour is identical).

        I reached the point this weekend where the next step was to do an initial test/validation. The approach I decided on was to BDM the full binary (bootloader, program and tune) onto the DME. I modified the boot mode variable at 0x4800 to prevent the bootloader from jumping to the main OS, this forces the bootloader to stay in boot mode and service DS2 communication from the bootloader (effectively limiting the scope of what I was testing).

        The screenshot above shows the success. The DME booted into the bootloader, I was able to connect over DS2 (OBD cable) and identify the DME as you can see in the screenshot. My VIN, serial number, and AIF records are shown because I copied over these sections of EEPROM when I BDM'd as I didn't want to cause any EWS de-sync issues, etc.

        I was then able to read off the tune from the DME as a test that the major DS2 functions in the bootloader are working.

        To have got this far is incredible, but there's obviously a lot more work to be done. I'm not going to reflect on that too much right now and just be pleased with this milestone!
        Last edited by karter16; 10-25-2026, 08:37 AM.
        2005 ///M3 SMG Coupe Silbergrau Metallic/CSL bucket seats/CSL airbox/CSL console/6 point RACP brace/Apex ARC-8s
        Build Thread | Community Patch | MSS54 DS2 Tool

        Comment


          That is absolutely epic, man you must have been chugging on this in the shadows for quite some time! Great work!
          ‘02 332iT / 6 | ‘70 Jaguar XJ6 electric conversion

          Comment


            Originally posted by karter16 View Post
            Well this screenshot doesn't look like much, but it's a big milestone.

            ​

            For some time I've been quietly working on reconstructing C source code from the disassembly work, initially with the primary goal of making the codebase easier to read and understand, but more recently with the goal of being able to compile the source into a binary.

            Vast amounts of effort have yielded the ability to compile (from C code) a full binary that is address-exact with 0401. What I mean by that is that the compiled binary has every RAM variable and every tune parameter at the exact memory address it is located at in 0401 (by linking files and sections in the correct order, not by forcing the location of each variable manually. This means any intentional changes to the codebase will correctly reflow). The actual program code is not a byte-exact match with 0401 because I'm using modern GCC whereas I *think* in the 90's and 00's BMW used a Microtek compiler. The compilers have their own strategies and optimisations, hence the program code is not exactly the same in structure (although my goal is of course that actual behaviour is identical).

            I reached the point this weekend where the next step was to do an initial test/validation. The approach I decided on was to BDM the full binary (bootloader, program and tune) onto the DME. I modified the boot mode variable at 0x4800 to prevent the bootloader from jumping to the main OS, this forces the bootloader to stay in boot mode and service DS2 communication from the bootloader (effectively limiting the scope of what I was testing).

            The screenshot above shows the success. The DME booted into the bootloader, I was able to connect over DS2 (OBD cable) and identify the DME as you can see in the screenshot. My VIN, serial number, and AIF records are shown because I copied over these sections of EEPROM when I BDM'd as I didn't want to cause any EWS de-sync issues, etc.

            I was then able to read off the tune from the DME as a test that the major DS2 functions in the bootloader are working.

            To have got this far is incredible, but there's obviously a lot more work to be done. I'm not going to reflect on that too much right now and just be pleased with this milestone!
            This is so awesome. I love reading all this stuff and I know I’m still not smart enough to understand it LOL. Thanks for doing this brother.

            Comment


              Compilable source!? That's incredible. Makes the barrier for actually modifying the program so much lower. Nice work man.

              Originally posted by karter16 View Post
              What I mean by that is that the compiled binary has every RAM variable and every tune parameter at the exact memory address it is located at in 0401 (by linking files and sections in the correct order, not by forcing the location of each variable manually. This means any intentional changes to the codebase will correctly reflow).
              Niiice. That's not an easy thing to get right. Super cool.

              Also, your screenshot seems to be broken.
              2002 Topasblau M3 - Coupe - 6MT - Karbonius CSL Airbox - SSV1 - HJS - Mullet Tune - MK60 Swap - E86 Front Triangulation - ZCP Rack - Nogaros - AutoSolutions - 996 Brembos - Slon - CMP - VinceBar - Koni - Eibach - BlueBus - Journal

              2012 Alpinweiss 128i - Coupe - 6AT - Slicktop - Manual Seats - Daily - Journal

              Comment


                Woooooot! Excellent work!

                2005 IR/IR M3 Coupe
                2012 LMB/Black 128i
                100 Series Land Cruiser

                Comment


                  Originally posted by karter16 View Post
                  Well this screenshot doesn't look like much, but it's a big milestone.

                  ​

                  For some time I've been quietly working on reconstructing C source code from the disassembly work, initially with the primary goal of making the codebase easier to read and understand, but more recently with the goal of being able to compile the source into a binary.

                  Vast amounts of effort have yielded the ability to compile (from C code) a full binary that is address-exact with 0401. What I mean by that is that the compiled binary has every RAM variable and every tune parameter at the exact memory address it is located at in 0401 (by linking files and sections in the correct order, not by forcing the location of each variable manually. This means any intentional changes to the codebase will correctly reflow). The actual program code is not a byte-exact match with 0401 because I'm using modern GCC whereas I *think* in the 90's and 00's BMW used a Microtek compiler. The compilers have their own strategies and optimisations, hence the program code is not exactly the same in structure (although my goal is of course that actual behaviour is identical).

                  I reached the point this weekend where the next step was to do an initial test/validation. The approach I decided on was to BDM the full binary (bootloader, program and tune) onto the DME. I modified the boot mode variable at 0x4800 to prevent the bootloader from jumping to the main OS, this forces the bootloader to stay in boot mode and service DS2 communication from the bootloader (effectively limiting the scope of what I was testing).

                  The screenshot above shows the success. The DME booted into the bootloader, I was able to connect over DS2 (OBD cable) and identify the DME as you can see in the screenshot. My VIN, serial number, and AIF records are shown because I copied over these sections of EEPROM when I BDM'd as I didn't want to cause any EWS de-sync issues, etc.

                  I was then able to read off the tune from the DME as a test that the major DS2 functions in the bootloader are working.

                  To have got this far is incredible, but there's obviously a lot more work to be done. I'm not going to reflect on that too much right now and just be pleased with this milestone!
                  Amazing work.

                  Hypothetically... do you think the code is portable enough that it could be compiled for other embedded platforms?

                  Comment


                    I can't see screenshot of karter16 and all linked pictures: invalid file specified

                    Does anyone know why ?

                    Comment


                      Weird I have no idea what's wrong with the image - here it is again, it really is the least interesting screenshot ever though as it doesn't really demonstrate the achievement in any visible way - I was pretty please when I saw it come up though.

                      terra in terms of portability to other platforms, if you mean closely related DMEs then probably not too bad, if you mean anything else then I think all the hardware interface stuff would need to be rewritten, it's all direct port assignments, etc. If you're thinking to do something like build out equivalent source code for the MSS52 for example I would think that would be possible, albeit a fair chunk of work.

                      Next goal is to get the main program functional. After that I have to work out how to go about testing and proving everything out.



                      Click image for larger version

Name:	image_86453-2.png
Views:	85
Size:	156.8 KB
ID:	613945
                      2005 ///M3 SMG Coupe Silbergrau Metallic/CSL bucket seats/CSL airbox/CSL console/6 point RACP brace/Apex ARC-8s
                      Build Thread | Community Patch | MSS54 DS2 Tool

                      Comment


                        Originally posted by karter16 View Post
                        Well this screenshot doesn't look like much, but it's a big milestone.

                        ​

                        For some time I've been quietly working on reconstructing C source code from the disassembly work, initially with the primary goal of making the codebase easier to read and understand, but more recently with the goal of being able to compile the source into a binary.

                        Vast amounts of effort have yielded the ability to compile (from C code) a full binary that is address-exact with 0401. What I mean by that is that the compiled binary has every RAM variable and every tune parameter at the exact memory address it is located at in 0401 (by linking files and sections in the correct order, not by forcing the location of each variable manually. This means any intentional changes to the codebase will correctly reflow). The actual program code is not a byte-exact match with 0401 because I'm using modern GCC whereas I *think* in the 90's and 00's BMW used a Microtek compiler. The compilers have their own strategies and optimisations, hence the program code is not exactly the same in structure (although my goal is of course that actual behaviour is identical).

                        I reached the point this weekend where the next step was to do an initial test/validation. The approach I decided on was to BDM the full binary (bootloader, program and tune) onto the DME. I modified the boot mode variable at 0x4800 to prevent the bootloader from jumping to the main OS, this forces the bootloader to stay in boot mode and service DS2 communication from the bootloader (effectively limiting the scope of what I was testing).

                        The screenshot above shows the success. The DME booted into the bootloader, I was able to connect over DS2 (OBD cable) and identify the DME as you can see in the screenshot. My VIN, serial number, and AIF records are shown because I copied over these sections of EEPROM when I BDM'd as I didn't want to cause any EWS de-sync issues, etc.

                        I was then able to read off the tune from the DME as a test that the major DS2 functions in the bootloader are working.

                        To have got this far is incredible, but there's obviously a lot more work to be done. I'm not going to reflect on that too much right now and just be pleased with this milestone!
                        I had another thought -- with having what is essentially source code, is it possible to compile things to fit within the non-HP flash? From what I recall the HP software barely extended into the larger space as it is. Perhaps with some optimization and removal of unused functions it can work?

                        Comment


                          Originally posted by terra View Post
                          I had another thought -- with having what is essentially source code, is it possible to compile things to fit within the non-HP flash? From what I recall the HP software barely extended into the larger space as it is. Perhaps with some optimization and removal of unused functions it can work?
                          I would worry about performance and scheduling misses on the older HW with the slower clock speed.

                          Not saying it can't be made to work, just that I would be doing extensive performance analysis before being comfortable with the port, if I were implementing it myself. You really don't want to be missing deadlines on a system like this.
                          2002 Topasblau M3 - Coupe - 6MT - Karbonius CSL Airbox - SSV1 - HJS - Mullet Tune - MK60 Swap - E86 Front Triangulation - ZCP Rack - Nogaros - AutoSolutions - 996 Brembos - Slon - CMP - VinceBar - Koni - Eibach - BlueBus - Journal

                          2012 Alpinweiss 128i - Coupe - 6AT - Slicktop - Manual Seats - Daily - Journal

                          Comment


                            Originally posted by terra View Post

                            I had another thought -- with having what is essentially source code, is it possible to compile things to fit within the non-HP flash? From what I recall the HP software barely extended into the larger space as it is. Perhaps with some optimization and removal of unused functions it can work?
                            Yep this is 100% on my radar as something to investigate. I absolutely share heinzboehmer's concerns though - at that point we're talking about significant changes to software and I'm just not sure I can stomach that much risk, especially when it comes to other people using it, I wouldn't want to be directly or indirectly responsible for damage to other people's cars, let alone damage to other people.

                            That said, I do intend to at least experiment with it, and there are mechanisms within the OS to monitor system load. The 0401 software specifically has quite a lot of unnecessary code running, and also a lot of computationally expensive lookups to tables that are zeroed out, so there's definitely quite larger performance savings to be made.
                            2005 ///M3 SMG Coupe Silbergrau Metallic/CSL bucket seats/CSL airbox/CSL console/6 point RACP brace/Apex ARC-8s
                            Build Thread | Community Patch | MSS54 DS2 Tool

                            Comment


                              Originally posted by heinzboehmer View Post

                              I would worry about performance and scheduling misses on the older HW with the slower clock speed.

                              Not saying it can't be made to work, just that I would be doing extensive performance analysis before being comfortable with the port, if I were implementing it myself. You really don't want to be missing deadlines on a system like this.
                              The clock multiplier is set through software though isn't it? As far as I'm aware if one upgrades the flash ROM and flashes the CSL software, the DME is running at 25MHz (which all the CPUs are rated for I believe given the VFT25 part number). So theoretically CSL software compiled to fit on the smaller flash should still work? Or is the multiplier set within the bootloader?

                              I guess whether you have the 90ns or 70ns flash rom does become relevant tho.

                              I think potentially worth exploring nonetheless given how much more expensive HPs are on the used market these days.

                              Comment


                                Originally posted by terra View Post

                                The clock multiplier is set through software though isn't it? As far as I'm aware if one upgrades the flash ROM and flashes the CSL software, the DME is running at 25MHz (which all the CPUs are rated for I believe given the VFT25 part number). So theoretically CSL software compiled to fit on the smaller flash should still work? Or is the multiplier set within the bootloader?

                                I guess whether you have the 90ns or 70ns flash rom does become relevant tho.

                                I think potentially worth exploring nonetheless given how much more expensive HPs are on the used market these days.
                                Ah well that's fair if the 90ns rom can keep up. My thinking had been that without replacing the rom it would be necessary to run at 20MHz so had been thinking from that angle. Both approaches are worth experimenting with.
                                2005 ///M3 SMG Coupe Silbergrau Metallic/CSL bucket seats/CSL airbox/CSL console/6 point RACP brace/Apex ARC-8s
                                Build Thread | Community Patch | MSS54 DS2 Tool

                                Comment

                                Working...
                                X