Originally posted by bmwman91
View Post
Announcement
Collapse
No announcement yet.
E30 M42 to Motronic 1.7.3 Conversion Project
Collapse
X
-
URL: www.dsylva-tech.ca
-
Originally posted by Rasp View PostDont waste time its debug code.
Yes, all before that is "init" code, just after connect ECU to battery and before ignithion on start.
Originally posted by Rasp View PostActually $5-15 for DS1245Y on ebay, but there are offers more $100 :) (maybe original).
I think that is possible to rewrite table access function for work with external ram content, so about 15 tables we can edit online before ECU disconnected from battery. Its enought for engine tuning, but need to rewrite firmware, of course :)
Originally posted by MarkD View PostAlmost for sure this is just code used for testing and debug, to be used as a trigger for an oscilloscope and then measure an event happening after that trigger. Nothing to see here...
Comment
-
I'm now doing my code commenting in the IDA project in the nando folder of the Dropbox.
Honestly, some of the code is so badly optimized that I am thinking that it must have been written in some very rudimentary C or BASIC environment with zero optimization when it was translated into machine code. There are useless instructions everywhere which indicate that either nobody ever actually went through the assembly listing that the compiler generated, or if people were writing it directly in assembly, there were 500 different programmers and some large percentage of them really weren't very good. The latter case seems unlikely, so I am going with the first guess...written in a higher level language with a crappy compiler (it might have been "good" for the time 30 years ago, but it's junk now based on what I see).
Once I get into the subroutines that handle table lookups and stuff, I am going to make serious notes if/when I come across inefficient code. It sounds like the main loop gets bogged down at higher RPMs, and if there is room to speed it up I think that there might be some small benefit.
One example, and this is a really small one...there are plenty of others that waste more cycles.
mov A, #0
movx @R0, A
clr A
Comment
-
I saw that all over the place too! I thought I was just misunderstanding the code, since i'm not familiar with 8051 ASM - no wonder it didn't make sense to me. :p
I guess it makes sense as I've been looking at mostly modern DMEs which I suppose have very good compilers, because I don't recall seeing anything like that.
If we come up with a standard way to mark that code, I might be able to write a program that fixes it all automatically from a binary. What's the easiest way to replace that kind of code? no-op? can you just delete it and shift the bytes up, or will that mess up offsets etc? (obviously padding it with FFs at the end)
Comment
-
Originally posted by bmwman91 View PostI'm now doing my code commenting in the IDA project in the nando folder of the Dropbox.
Honestly, some of the code is so badly optimized that I am thinking that it must have been written in some very rudimentary C or BASIC environment with zero optimization when it was translated into machine code. There are useless instructions everywhere which indicate that either nobody ever actually went through the assembly listing that the compiler generated, or if people were writing it directly in assembly, there were 500 different programmers and some large percentage of them really weren't very good. The latter case seems unlikely, so I am going with the first guess...written in a higher level language with a crappy compiler (it might have been "good" for the time 30 years ago, but it's junk now based on what I see).
Once I get into the subroutines that handle table lookups and stuff, I am going to make serious notes if/when I come across inefficient code. It sounds like the main loop gets bogged down at higher RPMs, and if there is room to speed it up I think that there might be some small benefit.
One example, and this is a really small one...there are plenty of others that waste more cycles.
mov A, #0
movx @R0, A
clr A
You can read amount PL/M here:
And I bet they had teams of programmers writing varios functional blocks,which has to conform to well documented specific inputs and outputs so that hardly anyone could leave the company with all the source code, they probably only got to see their section. Obviously there would be a few people who had access to all of it.
I'm interested to have a look at the code, where is this code you mentioned in the source?
mov A, #0
movx @R0, A
clr A
I'd like to have a look at the other examples just out of curiosity.URL: www.dsylva-tech.ca
Comment
-
Originally posted by nando View PostI saw that all over the place too! I thought I was just misunderstanding the code, since i'm not familiar with 8051 ASM - no wonder it didn't make sense to me. :p
I guess it makes sense as I've been looking at mostly modern DMEs which I suppose have very good compilers, because I don't recall seeing anything like that.
If we come up with a standard way to mark that code, I might be able to write a program that fixes it all automatically from a binary. What's the easiest way to replace that kind of code? no-op? can you just delete it and shift the bytes up, or will that mess up offsets etc? (obviously padding it with FFs at the end)
Originally posted by MarkD View PostI can't imagine that they used BASIC. I'm quite sure they were using a mixture of assembly language and PL/M-51 back then.
You can read amount PL/M here:
And I bet they had teams of programmers writing varios functional blocks,which has to conform to well documented specific inputs and outputs so that hardly anyone could leave the company with all the source code, they probably only got to see their section. Obviously there would be a few people who had access to all of it.
I'm interested to have a look at the code, where is this code you mentioned in the source?
mov A, #0
movx @R0, A
clr A
I'd like to have a look at the other examples just out of curiosity.
The example I pasted above is from 0xAD28. Another good one is at 0x916E...see what it does in the call, and then promptly clears A after returning.
I'd believe that a bunch of different people were silo'ed and working on small chunks with only minimal information about what the broader context was. It sure looks like it, which could explain why (for example) things seem to be coded in such a way as to be "doubly sure" that A contains the proper value before it is used in various sections. Is it fair to assume that Bosch/BMW are extremely secretive about their algorithms since those comprise a large part of their secret sauce in making their cars run nicely?
Comment
-
Originally posted by MarkD View PostI'm quite sure they were using a mixture of assembly language and PL/M-51 back then.
Originally posted by bmwman91 View PostThe goal would be to remove those instructions entirely since they waste instruction cycles
Originally posted by bmwman91 View PostThe example I pasted above is from 0xAD28. Another good one is at 0x916E...see what it does in the call, and then promptly clears A after returning.
Originally posted by bmwman91 View PostI'd believe that a bunch of different people were silo'ed and working on small chunks with only minimal information about what the broader context was.
it does not look like M1.7.3 has a control signal for the Check Engine Light.
E36 non-US has not check engine light, its not required by OBD-I.Last edited by Rasp; 03-22-2018, 11:47 PM.
Comment
-
With respect to making "improvements" to the code, yes I agree that nothing should be touched until a more complete understanding of the code is achieved. And since you have already tried this, it may be that not much can be done since various timings are dependent on the number of instruction cycles between operations. For the precision stuff like ignition and fuel injection, I am assuming that the main way that timing is achieved is by the P1.0/INT3 interrupt coming from the crank position wheel...the interrupt function related to that is a MONSTER. It looks like Cthulhu in the IDA graph! Beyond using the crank wheel, there is probably some amount of dependence on the exact number of instruction cycles between events since that will have an effect on the true dwell / ignition timing and injection start time. So certainly great care must be taken there.
For the main loop, I of course need to understand it before touching it. It sounds like it runs at either 100Hz, or "best effort" if the RPM is high and the interrupt functions are using a lot of available cycles. The idea would be to remove "junk" instructions from the main loop so that it could execute more quickly at higher RPM when it is not able to maintain a 10ms period. I assume that it maintains that 10ms period by checking some timing constant against one of the timers to see if 10000 instruction cycles have completed: if yes, then it goes back to the start, otherwise it waits in a NOP loop or something until then. If instead Bosch programmed in about 10000 instructions worth of "stuff to do" so that is is not actually checking the timer and is barely able to keep up with itself, then more work would be needed to ensure that timing is maintained if "junk" is removed.
Back to your point though, maybe it is pointless to do this. The ECU seems to do a good job as it is. There's a saying that says, "if it isn't broken, do not fix it." That is probably the case here.
Originally posted by RaspI'm see that check-engine light code is exists in M1.7.3
Comment
-
I wouldn't bother trying to speed things up by removing instructions. There will be very little to be gained by removing them - you aren't going to suddenly get another 5 or 10% of CPU bandwidth available. I've already thought about how to get more CPU bandwidth for many years, and had been thinking of making a product based on my idea. It was to substitute a much faster processor for the one that is currently there.URL: www.dsylva-tech.ca
Comment
-
Originally posted by bmwman91 View PostFor the check engine light, since you have found the code related to it, do you know which Port#.# is switched in the code for this?
Comment
-
Originally posted by Rasp View PostCC150 20 pin, try to path it from chip to main plug, you do not publish PCB schematic so I'm cant do this. It used since M1.7 (maybe M1.1 I dont check this earlier) and has no modified.
S702.20 isn't connected to anything. Pin 47 is the only unused output it seems, with a bunch of not-installed transistors. S702.22 seems to be the control line for it.
Comment
-
Originally posted by bmwman91 View PostS702.20 isn't connected to anything.
Originally posted by bmwman91 View PostPin 47 is the only unused output it seems, with a bunch of not-installed transistors. S702.22 seems to be the control line for it.
Comment
Comment