<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-1176501985869191402</id><updated>2024-09-09T21:25:33.076-07:00</updated><title type='text'>ECU Hacking 101</title><subtitle type='html'>I&#39;ve been reverse-engineering ECUs since 2001.  This blog is to share what I&#39;ve learned about Honda and Mazda ECUs and to provide you with tips and advice if you would like to hack your own ECU.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://ecuhacking101.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1176501985869191402/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://ecuhacking101.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>J. Wong</name><uri>http://www.blogger.com/profile/09137114208904793879</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>17</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1176501985869191402.post-5921431846568558369</id><published>2017-07-06T09:05:00.000-07:00</published><updated>2017-07-06T09:05:56.084-07:00</updated><title type='text'>I&#39;m back!</title><content type='html'>Hi, Everyone,&lt;br /&gt;
&lt;br /&gt;
It has been way too long since I&#39;ve posted anything on this blog. &amp;nbsp;Too many other things going on. &amp;nbsp;However, a couple of weeks ago I made the mistake of trying to read the EEPROM on my ECU. &amp;nbsp;I don&#39;t mean the large flash (29F200), but the little L56R (sometimes its a 93C56 - they are basically equivalent) next to the microcontroller. &amp;nbsp;This little guy holds immobilizer related information.&lt;br /&gt;
&lt;br /&gt;
Sadly, I wasn&#39;t successful, and worse yet, when I reinstalled the ECU, my car wouldn&#39;t start! &amp;nbsp;I don&#39;t know if I damaged the ECU somehow, but my guess was that I had inadvertently modified the contents of the EEPROM and the immobilizer system wasn&#39;t happy about it. &amp;nbsp;When I say &quot;immobilizer system&quot; I mean the ECU&amp;nbsp;+ immobilizer, as they work together.&lt;br /&gt;
&lt;br /&gt;
So what to do? &amp;nbsp;I figured that restoring the contents of the 93C56 was pretty much out of the question, since I had probably already scrambled it and I had no copy of the original data. &amp;nbsp;Plus I&#39;d have to desolder it to reprogram it anyway, which I didn&#39;t feel like doing.&lt;br /&gt;
&lt;br /&gt;
My only other option was to try to figure out how to bypass the immobilizer. &amp;nbsp;Long story short (and with the details intentionally omitted!), I was able to do this with just firmware mods (no hardware changes necessary, other than unplugging the immobilizer). &amp;nbsp;Yup, I can now start my car with no immobilizer. &amp;nbsp;Not the best solution security-wise, but it sure beats having to buy a new ECU/immobilizer/keys/etc.&lt;br /&gt;
&lt;br /&gt;
Do you have an immobilizer issue? &amp;nbsp;Here are some things you can try:&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;If the ECU went bad and needs to be replaced, buy a used one of the same type, then swap out the little EEPROM with the one from the original ECU. &amp;nbsp;&lt;i&gt;Yes, you will have to desolder/solder a small surface mount IC.&lt;/i&gt;&amp;nbsp; I highly recommend making a copy of the contents of this EEPROM while you&#39;re at it, just in case. &amp;nbsp;From the immobilizer&#39;s point of view, the entire &quot;identity&quot; of the ECU resides in that EEPROM, so as far as it&#39;s concerned, after the chip swap, the replacement ECU will look just like the original one.&lt;/li&gt;
&lt;li&gt;If the ECU is good and the immobilizer needs to be replaced, this is a bit more involved. &amp;nbsp;First, buy a used (known good) immobilizer. &amp;nbsp;Make sure you can read the serial number on it. &amp;nbsp;Then, you&#39;ll need a way of getting the code word from the serial number. &amp;nbsp;There are programs out there that can do this. &amp;nbsp;Most are not free, but I know of at least one where the &quot;demo&quot; mode will do this for free! &amp;nbsp;It will be an 8 digit number. &amp;nbsp;You&#39;ll have to program this into the EEPROM. &amp;nbsp;I&#39;m still looking for a way to do this without having to desolder the chip. &amp;nbsp;&lt;b&gt;There must be a way, because the manufacturer does it&lt;/b&gt;&amp;nbsp;- but until I find it, you&#39;ll have to remove the chip and program it that way. &amp;nbsp;If you are actually going to do this, let me know and I can help you out with the details. &amp;nbsp;Once the EEPROM&#39;s copy of the code word is made to match the immobilizer, then the new immobilizer &lt;i&gt;should &lt;/i&gt;work with the ECU. &amp;nbsp;You&#39;ll have to reprogram your keys, too (you can find the procedure online). &amp;nbsp;Caveat - I haven&#39;t tried this myself, so YMMV.&lt;/li&gt;
&lt;li&gt;If both ECU and immobilizer are replaced, and you don&#39;t have a matching set, do the same as if you replaced just the immobilizer, as I don&#39;t know how to change the code word in the immobilizer, or if it&#39;s even possible.&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
Anyway, I hope you never have a problem with your immobilizer system, and I&#39;m glad my car came with one, but if you do, just know that there are cheaper ways to get up and running again than replacing the ECU/immobilizer/keys/locks.&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://ecuhacking101.blogspot.com/feeds/5921431846568558369/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ecuhacking101.blogspot.com/2017/07/im-back.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1176501985869191402/posts/default/5921431846568558369'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1176501985869191402/posts/default/5921431846568558369'/><link rel='alternate' type='text/html' href='http://ecuhacking101.blogspot.com/2017/07/im-back.html' title='I&#39;m back!'/><author><name>J. Wong</name><uri>http://www.blogger.com/profile/09137114208904793879</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1176501985869191402.post-9207933734703449103</id><published>2014-02-19T22:27:00.000-08:00</published><updated>2014-02-19T22:28:53.348-08:00</updated><title type='text'>Hello again</title><content type='html'>Recently, I got an email from someone asking about the Miata ECU project. &amp;nbsp;It turned out that he works very close by where I work, so we met and talked over coffee. &amp;nbsp;I&#39;d been so busy with other things (life, basically) that I hadn&#39;t really done anything with the project in a long time. &amp;nbsp;That in itself really didn&#39;t (and doesn&#39;t) bother me, but our meeting made me realize that others have taken an interest in the project, and that I&#39;ve been remiss in keeping up this blog. &amp;nbsp;It&#39;s received a little over 10,000 page views, including over 500 last month, even though it&#39;s been over 2 years since I&#39;ve written a project-related post. &amp;nbsp;So I do feel like I owe you some new posts.&lt;br /&gt;
&lt;br /&gt;
While I really have not done much in the last year or so, there is a lot that I&#39;ve already learned over the past couple of years that I haven&#39;t shared, so just catching everyone up will take up quite a few posts.&lt;br /&gt;
&lt;br /&gt;
I left off with a series of posts about OBD modes. &amp;nbsp;I think next time, I&#39;ll just wrap up the remaining supported modes, so we can move on to more interesting topics. &amp;nbsp;If you have suggestions for topics of particular interest you&#39;d like me to cover, please leave a comment!</content><link rel='replies' type='application/atom+xml' href='http://ecuhacking101.blogspot.com/feeds/9207933734703449103/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ecuhacking101.blogspot.com/2014/02/hello-again.html#comment-form' title='13 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1176501985869191402/posts/default/9207933734703449103'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1176501985869191402/posts/default/9207933734703449103'/><link rel='alternate' type='text/html' href='http://ecuhacking101.blogspot.com/2014/02/hello-again.html' title='Hello again'/><author><name>J. Wong</name><uri>http://www.blogger.com/profile/09137114208904793879</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>13</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1176501985869191402.post-3778040451707927774</id><published>2012-05-29T23:52:00.000-07:00</published><updated>2012-05-29T23:52:06.157-07:00</updated><title type='text'>Shameless Panhandling</title><content type='html'>Hello, again! &amp;nbsp;I haven&#39;t posted for some time now, as you can see. &amp;nbsp;I am still working on the reverse engineering project, when I have time. &amp;nbsp;My latest crazy idea has been to port the code to C# so I can run and debug it on my PC. &amp;nbsp;It&#39;s never going to actually run my car, but it is useful to be able to run it and trace the program flow, instead of just staring at static code. &amp;nbsp;It also gives me a perverse sense of nerd joy knowing that I&#39;m probably the only one that&#39;s ever run the NB code in C#. &amp;nbsp;:P&lt;br /&gt;
&lt;br /&gt;
Anyway, I&#39;m writing today to (shamelessly) ask you to please click on an ad or two if you find any of this stuff interesting. &amp;nbsp;It won&#39;t cost you anything, and it may net me a penny or two. &amp;nbsp;To give you an idea of how little money we&#39;re talking about, to date the blog has been viewed about 2,000 times, and I&#39;ve made less than $2 from the ads. &amp;nbsp;So it&#39;s obviously not going to make me any real money, but think of it as your way of encouraging me to continue sharing with you what I&#39;m finding out about the NB ECU. &amp;nbsp;Thanks! &amp;nbsp;And thank you especially for the handful of readers that have left an encouraging note. &amp;nbsp;That&#39;s a great motivator for me!</content><link rel='replies' type='application/atom+xml' href='http://ecuhacking101.blogspot.com/feeds/3778040451707927774/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ecuhacking101.blogspot.com/2012/05/shameless-panhandling.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1176501985869191402/posts/default/3778040451707927774'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1176501985869191402/posts/default/3778040451707927774'/><link rel='alternate' type='text/html' href='http://ecuhacking101.blogspot.com/2012/05/shameless-panhandling.html' title='Shameless Panhandling'/><author><name>J. Wong</name><uri>http://www.blogger.com/profile/09137114208904793879</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1176501985869191402.post-7254018679605646391</id><published>2012-01-14T00:45:00.000-08:00</published><updated>2012-01-14T00:45:56.158-08:00</updated><title type='text'>NB Miata - OBD Mode 13</title><content type='html'>Happy Friday the 13th! &amp;nbsp;Are you superstitious? &amp;nbsp;I&#39;m not - especially not about the number 13. &amp;nbsp;Speaking of which, we&#39;re talking about OBD Mode 13 today. &amp;nbsp;OK, so 13 in this case is actually a hexadecimal number, but anyway...&lt;br /&gt;
&lt;br /&gt;
The ECU subroutines that handle Mode 13 are also shared with Modes 3 and 7. &amp;nbsp;It appears that, while the request messages for Modes 3 and 7 do not (actually, cannot) contain a PID, Mode 13 messages &lt;i&gt;can &lt;/i&gt;contain extra bytes after the mode number. &amp;nbsp;I wish I could tell you what they are used for, if anything, but at this point, I don&#39;t know.&lt;br /&gt;
&lt;br /&gt;
What I can tell you is that mode 13 reports the same DTCs as Mode 3, &lt;i&gt;plus&lt;/i&gt;:&lt;br /&gt;
&lt;br /&gt;
P0605 - Internal Control Module ROM Error&lt;br /&gt;
P1602 - Immobilizer / ECM Communication Error&lt;br /&gt;
P1603 - ID Number Unregistered&lt;br /&gt;
P1604 - Code Word Unregistered&lt;br /&gt;
P1621 - Immobilizer Code Words Do Not Match&lt;br /&gt;
P1622 - Immobilizer ID Does Not Match&lt;br /&gt;
P1623 - Immobilizer Code Word/ID Number Write Failure&lt;br /&gt;
P1624 - Vehicle anti-theft system malfunction&lt;br /&gt;
P1631 - Alternator Regulator #2 Control Circuit&lt;br /&gt;
P1633 - Generator Control System - over charge&lt;br /&gt;
P1634 - Generator Control System - no charge&lt;br /&gt;
&lt;br /&gt;
I could be wrong about the meaning of the last three. &amp;nbsp;But what you can see from looking at the rest of the list is that they represent a class of errors that have more to do with the system electronics than the engine, so they are different. &amp;nbsp;I&#39;m particularly interested in how the immobilizer works, and will post more about it later.&lt;br /&gt;
&lt;br /&gt;
It&#39;s been about 9 months since I have looked at the code, so it will take me a little bit of time to get back to where I was, but if I recall correctly, there may be some additional requirements that must be met in order to access Mode 13 (such as placing a jumper somewhere or something). &amp;nbsp;As I get back into analyzing the code, I will update this post with any additional info I find.&lt;br /&gt;
&lt;br /&gt;
Next up, Mode 14.&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://ecuhacking101.blogspot.com/feeds/7254018679605646391/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ecuhacking101.blogspot.com/2012/01/nb-miata-obd-mode-13.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1176501985869191402/posts/default/7254018679605646391'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1176501985869191402/posts/default/7254018679605646391'/><link rel='alternate' type='text/html' href='http://ecuhacking101.blogspot.com/2012/01/nb-miata-obd-mode-13.html' title='NB Miata - OBD Mode 13'/><author><name>J. Wong</name><uri>http://www.blogger.com/profile/09137114208904793879</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1176501985869191402.post-2851853225018571475</id><published>2011-12-20T23:23:00.000-08:00</published><updated>2011-12-20T23:23:46.864-08:00</updated><title type='text'>Season&#39;s Greetings</title><content type='html'>Hi to everyone who&#39;s stumbled across this blog!&amp;nbsp; As so often happens in life, you sometimes get busy doing other stuff and all of a sudden a few months have gone by.&amp;nbsp; I was very surprised to see that there have been a lot more views than I expected since I last posted.&amp;nbsp; I will resolve to continue posting in 2012!&amp;nbsp; See you in the new year.</content><link rel='replies' type='application/atom+xml' href='http://ecuhacking101.blogspot.com/feeds/2851853225018571475/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ecuhacking101.blogspot.com/2011/12/seasons-greetings.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1176501985869191402/posts/default/2851853225018571475'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1176501985869191402/posts/default/2851853225018571475'/><link rel='alternate' type='text/html' href='http://ecuhacking101.blogspot.com/2011/12/seasons-greetings.html' title='Season&#39;s Greetings'/><author><name>J. Wong</name><uri>http://www.blogger.com/profile/09137114208904793879</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1176501985869191402.post-1585753580505865562</id><published>2011-04-12T22:29:00.000-07:00</published><updated>2011-04-12T22:29:55.450-07:00</updated><title type='text'>NB Miata - OBD Mode 8</title><content type='html'>Today&amp;nbsp;I&#39;m going to talk about Mode 8.&amp;nbsp; It&#39;s been a while since I posted, partly because I have been busy with other things, and partly because I was hoping to have a more complete picture of what Mode 8 does.&amp;nbsp; Unfortunately, it&#39;s still mostly a mystery to me.&amp;nbsp; But at least I can tell you what I know.&lt;br /&gt;
&lt;br /&gt;
In general Mode 8 is used to control some on-board system, sometimes to create conditions necessary to test a component or subsystem.&amp;nbsp; In my ECU, here&#39;s the quick summary:&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;In the NB Miata, it only applies to OBD-II vehicles.&amp;nbsp; Any other flavor will simply respond to a Mode 8 request with an error reply.&lt;/li&gt;
&lt;li&gt;Only two PIDs are supported:&amp;nbsp; 00 and 01.&lt;/li&gt;
&lt;li&gt;The request message &lt;u&gt;must&lt;/u&gt; be 11 bytes long, so must be zero-padded.&amp;nbsp; And the extra bytes &lt;u&gt;cannot&lt;/u&gt; be anything other than zero.&lt;/li&gt;
&lt;li&gt;PID 0 is just a PIDs supported request.&amp;nbsp; Since&amp;nbsp;I&#39;m telling you now that&amp;nbsp;only 0 and 1 are supported, this is no longer of any use to you.&lt;/li&gt;
&lt;li&gt;If a PID 1 request is sent and bit 0 of 10055 is set at the time, then the ECU will set bit 0 of 108ED and respond with an affirmative OBD reply.&lt;/li&gt;
&lt;/ol&gt;I &lt;em&gt;think&lt;/em&gt; that&amp;nbsp;the request&amp;nbsp;is only honored&amp;nbsp;if the engine is not running at the time, but I&#39;m not 100% sure if that&#39;s the case.&amp;nbsp; Anyway, while it may seem like a lot of trouble just to set one bit in memory,&amp;nbsp;setting that bit&amp;nbsp;has a pretty significant ripple effect.&amp;nbsp; I&#39;m not sure I&#39;ve discovered all of the secondary effects, and I&#39;m pretty much in the dark about what the ultimate purpose is, but it appears to temporarily put the ECU in an altered state, and there are literally dozens of places in the the code that are ultimately affected.&amp;nbsp; Some of the affected subroutines are related to the short term fuel trim, but there are many others that I still have no idea what they are used for.&lt;br /&gt;
&lt;br /&gt;
I hope to eventually unravel the complete story.&amp;nbsp; In the meantime, if you are willing to try, you can see if you can get your car to accept a Mode 8 PID 1 command and see if you can tell how your car&#39;s behavior changes.&amp;nbsp; I doubt very much that&amp;nbsp;Mazda would build in a test that could potentially damage your car, but of course I can&#39;t guarantee it, so proceed at your own risk.&lt;br /&gt;
&lt;br /&gt;
Next time, Mode 9?&amp;nbsp; Sorry, but the NB Miata doesn&#39;t support Mode 9.&amp;nbsp; In fact, the next higher supported mode is Mode 13.</content><link rel='replies' type='application/atom+xml' href='http://ecuhacking101.blogspot.com/feeds/1585753580505865562/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ecuhacking101.blogspot.com/2011/04/nb-miata-obd-mode-8.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1176501985869191402/posts/default/1585753580505865562'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1176501985869191402/posts/default/1585753580505865562'/><link rel='alternate' type='text/html' href='http://ecuhacking101.blogspot.com/2011/04/nb-miata-obd-mode-8.html' title='NB Miata - OBD Mode 8'/><author><name>J. Wong</name><uri>http://www.blogger.com/profile/09137114208904793879</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1176501985869191402.post-2320856087872902160</id><published>2011-02-22T22:00:00.000-08:00</published><updated>2011-02-22T22:00:59.125-08:00</updated><title type='text'>NB Miata - OBD Mode 7, and Mode 3 update</title><content type='html'>Mode 7 is similar to Mode 3, in that it does not take any PIDs, and reports on DTCs.&amp;nbsp; They are so similar, in fact, that they share the same subroutines to generate responses to requests.&amp;nbsp; However, while Mode 3 responds by reporting active DTCs, Mode 7 reports &lt;em&gt;pending&lt;/em&gt; DTCs - that is, problems that have been detected but have not yet risen to the level of severity of an active DTC.&lt;br /&gt;
&lt;br /&gt;
Another key difference between the two is that they support a slightly different set of DTCs.&amp;nbsp; When I first&amp;nbsp;listed&amp;nbsp;the DTCs in the Mode 3 post, I thought that Mode 3 could report all of them.&amp;nbsp; However, upon closer inspection, it turns out that only a subset of them will ever show up in a Mode 3 response.&amp;nbsp; Similarly, the Mode 7 DTCs are a subset of the Mode 3 DTCs.&lt;br /&gt;
&lt;br /&gt;
Rather than re-list the DTCs that are associated with Mode 7, I&#39;ll just list the numbers.&amp;nbsp; You can refer to the previous Mode 3 post for more info.&lt;br /&gt;
&lt;br /&gt;
Mode 7 DTCs&lt;br /&gt;
P0011, P0012, P0031, P0032, P0037, P0038, P0101, P0106, P0111, P0116, P0121, P0125, P0126, P0128, P0131, P0132, P0133, P0134, P0138, P0140, P0171, P0172, P0300, P0301, P0302, P0303, P0304, P0401, P0402, P0420, P0421, P0442, P0451, P0443, P0452, P0453, P0455, P0461, P0462, P0463, P0464, P0480, P0500, P0506, P0507, P0550, P0703, P0704, P0706, P0715, P0725, P0741, P0742, P0751, P0752, P0756, P0757, P0850, P1450, P1496, P1497, P1498, P1499, P1512, P1518, P1569, P1570&lt;br /&gt;
&lt;br /&gt;
Mode 3 DTCs&lt;br /&gt;
(the above list), plus: P0010, P0102, P0103, P0107, P0108, P0112, P0113, P0117, P0118, P0122, P0123, P0222, P0223, P0327, P0328, P0335, P0340, P0505, P0720, P0743, P0753, P0758, P1562, P1601&lt;br /&gt;
&lt;br /&gt;
Finally, there are a few other modes that report DTCs, and have their own subset of DTCs.&amp;nbsp; More on these later.&amp;nbsp; Up next:&amp;nbsp; Mode 8.</content><link rel='replies' type='application/atom+xml' href='http://ecuhacking101.blogspot.com/feeds/2320856087872902160/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ecuhacking101.blogspot.com/2011/02/nb-miata-obd-mode-7-and-mode-3-update.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1176501985869191402/posts/default/2320856087872902160'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1176501985869191402/posts/default/2320856087872902160'/><link rel='alternate' type='text/html' href='http://ecuhacking101.blogspot.com/2011/02/nb-miata-obd-mode-7-and-mode-3-update.html' title='NB Miata - OBD Mode 7, and Mode 3 update'/><author><name>J. Wong</name><uri>http://www.blogger.com/profile/09137114208904793879</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1176501985869191402.post-6922237412306687760</id><published>2011-02-20T03:25:00.000-08:00</published><updated>2011-02-20T03:27:57.381-08:00</updated><title type='text'>NB Miata - OBD Mode 6, part 1</title><content type='html'>There is some interest in Mode 6 because the information it provides can sometimes give &quot;early warning&quot; of problems, and also because it tends to be poorly documented (unless you pay for access to the information).&amp;nbsp; Here&#39;s what I&#39;ve been able to piece together from looking at the code.&amp;nbsp; Although I prefer not to post before I think I fully understand a mode, in this case I decided to just write up what I&#39;ve found so far, because it may be a while before I figure it out completely.&amp;nbsp; Until then,&amp;nbsp;perhaps this partial explanation may prove useful to someone.&lt;br /&gt;
&lt;br /&gt;
Mode 6 supports the following TIDs (the request should only be the mode and the TID, with no other data bytes, which means a total request length of 6 bytes when you include the header and checksum byte):&lt;br /&gt;
00 - TIDs supported 01-20 (they are: 01, 02, 03, 04, 05, 06, 11, and 20)&lt;br /&gt;
20 - TIDs supported 21-40 (they are: 21, 22, 31, 32, and 40)&lt;br /&gt;
40 - TIDs supported 41-60 (only&amp;nbsp;41)&lt;br /&gt;
01 - for component ID (CID) 11, the test value stored at 10F56 needs to be less than 422&lt;br /&gt;
02 - for CID 11, the test value stored at 10D46 needs to be less than 62&lt;br /&gt;
03 - for&amp;nbsp;CID 11, the test value stored at 10D4A needs to be less than 50&lt;br /&gt;
04 - for&amp;nbsp;CIDs 01 and 02, the test value stored at 10970 needs to be greater than zero&lt;br /&gt;
05 - for CID 01, the test value stored at 10972 needs to be greater than zero&lt;br /&gt;
06 - for CID 01, the test value stored at 10974 needs to be greater than zero&lt;br /&gt;
11 - for CID 11, the test value stored at 10F5A needs to be greater than 40&lt;br /&gt;
21 - for CID 00, the test value stored at 10F6A needs to be less than the limit value stored at 10F6E&lt;br /&gt;
22 - for CID 00, the test value stored at 10F6C needs to be less than the limit value stored at 10F70&lt;br /&gt;
31 - for CID 00, the test value stored at 10F72 needs to be less than the limit value stored at 10F74&lt;br /&gt;
32 - for CID 00, the test value stored at 10F76 needs to be greater than the limit value stored at 10978&lt;br /&gt;
41 - for CID 00, the test value stored at 10F5C needs to be less than the limit value stored at 10F5E and greater than the limit store at 10F60&lt;br /&gt;
&lt;br /&gt;
I got a little help&amp;nbsp;by comparing the format of the reply message&amp;nbsp;that the code&amp;nbsp;puts together&amp;nbsp;to the ISO 15031-5 spec.&amp;nbsp;&amp;nbsp;However, I don&#39;t yet know what each test value represents.&amp;nbsp; I also don&#39;t know what components CIDs 0, 1, 2 and 11 refer to.&amp;nbsp; I don&#39;t even know what the limit values are in some cases (although you could determine this pretty easily by simply plugging a scantool into the car and sending the appropriate Mode 6 requests).&amp;nbsp; If anyone has this information and would like to share, please post a comment.&amp;nbsp; I should eventually be able to figure it out on my own from looking at the code, but&amp;nbsp;I would definitely appreciate it if&amp;nbsp;someone could save me the time by telling me what the above tests are all about.&lt;br /&gt;
&lt;br /&gt;
Next time, Mode 7, which is very similar to Mode 3.</content><link rel='replies' type='application/atom+xml' href='http://ecuhacking101.blogspot.com/feeds/6922237412306687760/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ecuhacking101.blogspot.com/2011/02/nb-miata-obd-mode-6-part-1.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1176501985869191402/posts/default/6922237412306687760'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1176501985869191402/posts/default/6922237412306687760'/><link rel='alternate' type='text/html' href='http://ecuhacking101.blogspot.com/2011/02/nb-miata-obd-mode-6-part-1.html' title='NB Miata - OBD Mode 6, part 1'/><author><name>J. Wong</name><uri>http://www.blogger.com/profile/09137114208904793879</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1176501985869191402.post-845664385289423328</id><published>2011-02-17T23:46:00.000-08:00</published><updated>2011-02-20T00:47:37.079-08:00</updated><title type='text'>NB Miata - OBD Mode 5</title><content type='html'>If you thought Mode 4 was simple, Mode 5 is, in some ways,&amp;nbsp;even simpler.&amp;nbsp; At least a Mode 4 request causes something to happen.&amp;nbsp; Mode 5 requests only return information, and that information never changes!&lt;br /&gt;
&lt;br /&gt;
Mode 5 is meant to return information that is used for oxygen sensor monitoring.&amp;nbsp; In the NB, only the following TIDs are supported:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;00xx - this is the TIDs supported TID.&amp;nbsp; It must be two bytes, but the second byte can be anything.&amp;nbsp; The reply tells you that only TIDs 1 and 2 are supported&lt;/li&gt;
&lt;li&gt;0101 - returns the rich-to-lean threshold voltage for O2 sensor 1&lt;/li&gt;
&lt;li&gt;0102 - returns the rich-to-lean threshold voltage for O2 sensor 2&lt;/li&gt;
&lt;li&gt;0201 - returns the lean-to-rich threshold voltage for O2 sensor 1&lt;/li&gt;
&lt;li&gt;0202 - returns the lean-to-rich threshold voltage for O2 sensor 2&lt;/li&gt;
&lt;/ul&gt;What makes this mode so uninteresting is that all you can do is request the above threshold voltages.&amp;nbsp; What&#39;s more, they are all the same (0.445V) and never change.&amp;nbsp; Yawn.&lt;br /&gt;
&lt;br /&gt;
Next up, Mode 6.</content><link rel='replies' type='application/atom+xml' href='http://ecuhacking101.blogspot.com/feeds/845664385289423328/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ecuhacking101.blogspot.com/2011/02/nb-miata-obd-mode-5.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1176501985869191402/posts/default/845664385289423328'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1176501985869191402/posts/default/845664385289423328'/><link rel='alternate' type='text/html' href='http://ecuhacking101.blogspot.com/2011/02/nb-miata-obd-mode-5.html' title='NB Miata - OBD Mode 5'/><author><name>J. Wong</name><uri>http://www.blogger.com/profile/09137114208904793879</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1176501985869191402.post-4688973390687964852</id><published>2011-02-05T09:48:00.000-08:00</published><updated>2011-02-05T09:48:47.072-08:00</updated><title type='text'>NB Miata - OBD Mode 4</title><content type='html'>This is a very simple mode.&amp;nbsp; There are no PIDs.&amp;nbsp; A mode 4 message tells the ECU to clear all DTCs.&lt;br /&gt;
&lt;br /&gt;
Under the hood, the way it works is as follows.&amp;nbsp; There are a slew of subroutines that periodically monitor the car&#39;s health and set DTCs as necessary.&amp;nbsp;&amp;nbsp;If you send a mode 4 message (with no PID - if you send a PID, it won&#39;t work), the ECU sets a bit (108E7, bit 2) to let these subroutines know that they should clear their associated DTCs.&amp;nbsp; At the same time this bit is set, a countdown timer at 1094E is set to 30.&amp;nbsp; When it counts down to zero, the &quot;clear DTCs&quot; bit is cleared, and the system returns to normal operation.&amp;nbsp; I haven&#39;t yet worked out how long the ECU takes to countdown from 30 to 0.&lt;br /&gt;
&lt;br /&gt;
Last time I said that I would post some details on the immobilizer system.&amp;nbsp; I have been working on it, a lot, and have learned a lot, too, but I don&#39;t feel like I have enough of the big picture to share yet.&amp;nbsp; So, maybe next time.&amp;nbsp; Otherwise, the next post will be on OBD Mode 5.</content><link rel='replies' type='application/atom+xml' href='http://ecuhacking101.blogspot.com/feeds/4688973390687964852/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ecuhacking101.blogspot.com/2011/02/nb-miata-obd-mode-4.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1176501985869191402/posts/default/4688973390687964852'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1176501985869191402/posts/default/4688973390687964852'/><link rel='alternate' type='text/html' href='http://ecuhacking101.blogspot.com/2011/02/nb-miata-obd-mode-4.html' title='NB Miata - OBD Mode 4'/><author><name>J. Wong</name><uri>http://www.blogger.com/profile/09137114208904793879</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1176501985869191402.post-3696146348764924039</id><published>2011-01-19T02:27:00.000-08:00</published><updated>2011-02-22T22:07:15.944-08:00</updated><title type='text'>NB Miata - OBD Mode 3 and DTCs</title><content type='html'>&lt;em&gt;Update:&amp;nbsp; 2/22/11&lt;/em&gt;&lt;br /&gt;
&lt;em&gt;I originally thought that Mode 3 could report any of the DTCs listed below.&amp;nbsp; This is incorrect.&amp;nbsp; The list below is actually the &lt;u&gt;complete list&lt;/u&gt; of all DTCs the ECU can generate, but&amp;nbsp;only &lt;u&gt;some&lt;/u&gt; of the DTCs in the list are associated with Mode 3 (see my Mode 7 post for the list).&amp;nbsp; The other DTCs are associated with other modes.&amp;nbsp; More on these later.&lt;/em&gt;&lt;br /&gt;
&lt;br /&gt;
OBD Mode 3 is used to return Diagnostic Trouble Codes (DTCs).&amp;nbsp; It does not support any PIDs - a mode 3 request only consists of the mode (other than the 3 header bytes and final checksum byte).&amp;nbsp; If any DTCs are active, the DTCs are returned as two-byte binary-coded-decimal numbers, in groups of three DTCs at a time.&lt;br /&gt;
&lt;br /&gt;
I&#39;m still trying to understand the details of how the code works that determines which DTCs are set and when, but for this post I&#39;ll just list the possible DTCs this ECU can report.&amp;nbsp; I&#39;ll post more details on OBD Mode 3 at a later time.&lt;br /&gt;
&lt;br /&gt;
All possible DTCs (see &lt;a href=&quot;http://www.obd-codes.com/trouble_codes/&quot;&gt;http://www.obd-codes.com/trouble_codes/&lt;/a&gt;&amp;nbsp;for details)&lt;br /&gt;
&lt;br /&gt;
P0010 - &quot;A&quot; Camshaft Position Actuator Circuit (Bank 1)&lt;br /&gt;
P0011 - &quot;A&quot; Camshaft Position - Timing Over-Advanced or System Performance (Bank 1) &lt;br /&gt;
P0012 - &quot;A&quot; Camshaft Position - Timing Over-Retarded (Bank 1) &lt;br /&gt;
P0031 - HO2S Heater Control Circuit Low (Bank 1 Sensor 1) &lt;br /&gt;
P0032 - HO2S Heater Control Circuit High (Bank 1 Sensor 1) &lt;br /&gt;
P0037 - HO2S Heater Control Circuit Low (Bank 1 Sensor 2)&lt;br /&gt;
P0038 - HO2S Heater Control Circuit High (Bank 1 Sensor 2)&lt;br /&gt;
P0101 - Mass Air Flow Circuit Range/Performance Problem&lt;br /&gt;
P0102 - Mass&amp;nbsp;Air Flow Circuit Low Input&lt;br /&gt;
P0103 - Mass&amp;nbsp;Air Flow Circuit High Input&lt;br /&gt;
P0106 - Manifold Absolute Pressure/Barometric Pressure Circuit Range/Performance Problem&lt;br /&gt;
P0107 - Manifold Absolute Pressure/Barometric Pressure Circuit Low Input&lt;br /&gt;
P0108 - Manifold Absolute Pressure/Barometric Pressure Circuit High Input&lt;br /&gt;
P0111 - Intake Air Temperature Circuit Range/Performance Problem&lt;br /&gt;
P0112 - Intake Air Temperature Circuit Low Input &lt;br /&gt;
P0113 - Intake Air Temperature Circuit High Input&lt;br /&gt;
P0116 - Engine Coolant Temperature Circuit Range/Performance Problem&lt;br /&gt;
P0117 - Engine Coolant Temperature Circuit Low Input&lt;br /&gt;
P0118 - Engine Coolant Temperature Circuit High Input&lt;br /&gt;
P0121 - Throttle Position Sensor/Switch A Circuit Range/Performance Problem&lt;br /&gt;
P0122 - Throttle Position Sensor/Switch A Circuit Low Input&lt;br /&gt;
P0123 - Throttle Position Sensor/Switch A Circuit High Input&lt;br /&gt;
P0125 - Insufficient Coolant Temperature for Closed Loop Fuel Control&lt;br /&gt;
P0126 - Insufficient Coolant Temperature for Stable Operation&lt;br /&gt;
P0128 - Coolant Thermostat (Coolant Temperature Below Thermostat Regulating Temperature)&lt;br /&gt;
P0131 - 02 Sensor Circuit Low Voltage (Bank I Sensor I)&lt;br /&gt;
P0132 - 02 Sensor Circuit High Voltage (Bank I Sensor 1)&lt;br /&gt;
P0133 - 02 Sensor Circuit Slow Response (Bank 1 Sensor 1)&lt;br /&gt;
P0134 - 02 Sensor Circuit No Activity Detected (Bank I Sensor 1)&lt;br /&gt;
P0138 - 02 Sensor Circuit High Voltage (Bank I Sensor 2)&lt;br /&gt;
P0140 - 02 Sensor Circuit No Activity Detected (Bank 1 Sensor 2)&lt;br /&gt;
P0171 - System too Lean (Bank 1)&lt;br /&gt;
P0172 - System too Rich (Bank 1)&lt;br /&gt;
P0222 - Throttle/Petal Position Sensor/Switch B Circuit Low Input&lt;br /&gt;
P0223 - Throttle/Petal Position Sensor/Switch B Circuit High Input&lt;br /&gt;
P0300 - Random/Multiple Cylinder Misfire Detected&lt;br /&gt;
P0301 - Cylinder 1 Misfire Detected&lt;br /&gt;
P0302 - Cylinder 2 Misfire Detected&lt;br /&gt;
P0303 - Cylinder 3 Misfire Detected&lt;br /&gt;
P0304 - Cylinder 4 Misfire Detected&lt;br /&gt;
P0327 - Knock Sensor 1 Circuit Low Input (Bank I or Single Sensor)&lt;br /&gt;
P0328 - Knock Sensor 1 Circuit High Input (Bank I or Single Sensor)&lt;br /&gt;
P0335 - Crankshaft Position Sensor A Circuit Malfunction&lt;br /&gt;
P0340 - Camshaft Position Sensor Circuit Malfunction&lt;br /&gt;
P0401 - Exhaust Gas Recirculation Flow Insufficient Detected&lt;br /&gt;
P0402 - Exhaust Gas Recirculation Flow Excessive Detected&lt;br /&gt;
P0420 - Catalyst System Efficiency Below Threshold (Bank 1)&lt;br /&gt;
P0421 - Warm Up Catalyst Efficiency Below Threshold (Bank 1)&lt;br /&gt;
P0442 - Evaporative Emission Control System Leak Detected (small leak)&lt;br /&gt;
P0443 - Evaporative Emission Control System Purge Control Valve Circuit&lt;br /&gt;
P0451 - Evaporative Emission Control System Pressure Sensor Range/Performance&lt;br /&gt;
P0452 - Evaporative Emission Control System Pressure Sensor Low Input&lt;br /&gt;
P0453 - Evaporative Emission Control System Pressure Sensor High Input&lt;br /&gt;
P0455 - Evaporative Emission Control System Leak Detected (gross leak)&lt;br /&gt;
P0461 - Fuel Level Sensor Circuit Range/Performance&lt;br /&gt;
P0462 - Fuel Level Sensor Circuit Low Input&lt;br /&gt;
P0463 - Fuel Level Sensor Circuit High Input&lt;br /&gt;
P0464 - Fuel Level Sensor Circuit Intermittent&lt;br /&gt;
P0480 - Cooling Fan I Control Circuit Malfunction&lt;br /&gt;
P0500 - Vehicle Speed Sensor Malfunction&lt;br /&gt;
P0505 - Idle Control System Malfunction&lt;br /&gt;
P0506 - Idle Control System duty cycle Lower Than Expected&lt;br /&gt;
P0507 - Idle Control System&amp;nbsp;duty cycle&amp;nbsp;Higher Than Expected&lt;br /&gt;
P0550 - Power Steering Pressure Sensor Circuit Malfunction&lt;br /&gt;
P0605 - Internal Control Module Read Only Memory (ROM) Error&lt;br /&gt;
P0703 - Torque Converter/Brake Switch B Circuit Malfunction&lt;br /&gt;
P0704 - Clutch Switch Input Circuit Malfunction&lt;br /&gt;
P0705 - Transmission Range Sensor Circuit malfunction (PRNDL Input)&lt;br /&gt;
P0706 - Transmission Range Sensor Circuit Range/Performance&lt;br /&gt;
P0715 - Input/Turbine Speed Sensor Circuit Malfunction&lt;br /&gt;
P0720 - Output Speed Sensor Circuit Malfunction&lt;br /&gt;
P0725 - Engine Speed input Circuit Malfunction&lt;br /&gt;
P0741 - Torque Converter Clutch Circuit Performance or Stuck Off&lt;br /&gt;
P0742 - Torque Converter Clutch Circuit Stuck On&lt;br /&gt;
P0743 - Torque Converter Clutch Circuit Electrical&lt;br /&gt;
P0751 - Shift Solenoid A Performance or Stuck Off&lt;br /&gt;
P0752 - Shift Solenoid A Stuck On&lt;br /&gt;
P0753 - Shift Solenoid A Electrical&lt;br /&gt;
P0756 - Shift Solenoid B Performance or Stock Off&lt;br /&gt;
P0757 - Shift Solenoid B Stuck On&lt;br /&gt;
P0758 - Shift Solenoid B Electrical&lt;br /&gt;
P0850 - Neutral switch input circuit problem &lt;a href=&quot;http://foxed.ca/rx7manual/2003mazdarx8/esicont/en/srvc/html/BHE010200800W01.html&quot;&gt;http://foxed.ca/rx7manual/2003mazdarx8/esicont/en/srvc/html/BHE010200800W01.html&lt;/a&gt;)&lt;br /&gt;
P1449 - Evaporative Check Solenoid Circuit (&lt;a href=&quot;http://www.aboutautomobile.com/DTC/P1449&quot;&gt;http://www.aboutautomobile.com/DTC/P1449&lt;/a&gt;)&lt;br /&gt;
P1450 - Unable to Bleed Up Fuel Tank Vacuum (this and the rest can be found at aboutautomobile.com)&lt;br /&gt;
P1487 - Exhaust Gas Recirculation Check Solenoid Circuit&lt;br /&gt;
P1496 - EGR Stepper Motor 1 Control Circuit Low/High&lt;br /&gt;
P1497 - EGR Stepper Motor 2 Control Circuit Low/High&lt;br /&gt;
P1498 - EGR Stepper Motor&amp;nbsp;3 Control Circuit Low/High&lt;br /&gt;
P1499 - EGR Stepper Motor&amp;nbsp;4 Control Circuit Low/High&lt;br /&gt;
P1512 - Intake Manifold Runner Control Circuit (IMRC) Bank 1 stuck closed&lt;br /&gt;
P1518 - IMRC stuck open&lt;br /&gt;
P1562 - PCM backup + terminal voltage low&lt;br /&gt;
P1569 - IMRC circuit malfunction&lt;br /&gt;
P1570 - IMRC circuit malfunction&lt;br /&gt;
P1601 - ECM/TCM Serial Communication Error&lt;br /&gt;
P1602 - Immobilizer/ECM Communication Error&lt;br /&gt;
P1603 - ID Number Unregistered&lt;br /&gt;
P1604 - Code word Unregistered&lt;br /&gt;
P1608 - PCM Internal Circuit&lt;br /&gt;
P1621 - Immobilizer Code Words Do Not Match&lt;br /&gt;
P1622 - Immobilizer ID Does Not Match&lt;br /&gt;
P1623 - Immobilizer Code Word/ID Number Write Failure&lt;br /&gt;
P1624 -Vehicle anti-theft system malfunction&lt;br /&gt;
P1631 - Alternator Regulator #2 Control Circuit&lt;br /&gt;
P1633 - Generator Control System - over charge&lt;br /&gt;
P1634 - Generator Control System - no charge&lt;br /&gt;
&lt;br /&gt;
I&#39;m interested in&amp;nbsp;analyzing the code behind the immobilizer-related DTCs.&amp;nbsp; I&#39;ll take a look and maybe post what I find next time.</content><link rel='replies' type='application/atom+xml' href='http://ecuhacking101.blogspot.com/feeds/3696146348764924039/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ecuhacking101.blogspot.com/2011/01/nb-miata-obd-mode-3-and-dtcs.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1176501985869191402/posts/default/3696146348764924039'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1176501985869191402/posts/default/3696146348764924039'/><link rel='alternate' type='text/html' href='http://ecuhacking101.blogspot.com/2011/01/nb-miata-obd-mode-3-and-dtcs.html' title='NB Miata - OBD Mode 3 and DTCs'/><author><name>J. Wong</name><uri>http://www.blogger.com/profile/09137114208904793879</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1176501985869191402.post-6681668736706340485</id><published>2011-01-09T23:50:00.000-08:00</published><updated>2011-01-09T23:50:58.385-08:00</updated><title type='text'>NB Miata, OBD Mode 2</title><content type='html'>Today&#39;s post is pretty brief, as I&#39;m planning to do one post per OBD Mode, and there&#39;s not a lot to say about Mode 2.&lt;br /&gt;
&lt;br /&gt;
OBD Mode 2 is similar to Mode 1.&amp;nbsp; However, whereas Mode 1 is used to obtain current diagnostic data, Mode 2 PIDs return freeze frame data.&amp;nbsp; That is, they report the state of the engine when the last DTC occurred.&lt;br /&gt;
&lt;br /&gt;
For the NB, the following Mode 2 PIDs are supported (a few less than Mode 1):&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;00 - PIDs supported (01-20)&lt;/li&gt;
&lt;li&gt;02 - Freeze DTC&lt;/li&gt;
&lt;li&gt;03 - Fuel system status&lt;/li&gt;
&lt;li&gt;04 - Calculated engine load value&lt;/li&gt;
&lt;li&gt;05 - Engine coolant temperature&lt;/li&gt;
&lt;li&gt;06 - Short term fuel % trim - Bank 1&lt;/li&gt;
&lt;li&gt;07 - Long term fuel % trim - Bank 1&lt;/li&gt;
&lt;li&gt;0C - Engine RPM&lt;/li&gt;
&lt;li&gt;0D - Vehicle speed&lt;/li&gt;
&lt;/ul&gt;&lt;strong&gt;PID 00 - PIDs supported (01-20)&lt;/strong&gt;&lt;br /&gt;
The subroutine that creates the reply message is at address 2885C.&lt;br /&gt;
Return value indicates that 02-07, 0C-0D are supported.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;PID 02 -&amp;nbsp;Freeze DTC&lt;/strong&gt;&lt;br /&gt;
The subroutine that creates the reply message is at address 28870.&lt;br /&gt;
Returns the DTC which the freeze data is associated with.&amp;nbsp; If there is no DTC, it returns 0.&lt;br /&gt;
If the byte at RAM location 10EF4 is non-zero, it means there is a DTC.&lt;br /&gt;
The Freeze DTC value is stored as a word at RAM location 10F28.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;PID 03 - Fuel system status&lt;/strong&gt;&lt;br /&gt;
The subroutine that creates the reply message is at address 28886.&lt;br /&gt;
The freeze frame data for fuel system status is stored in a byte at RAM location 10F21.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;PID 04 - Calculated engine load value&lt;/strong&gt;&lt;br /&gt;
The subroutine that creates the reply message is at address 28894.&lt;br /&gt;
The byte at RAM location 10F18 is proportional to calculated freeze frame engine load value.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;PID 05 - Engine coolant temperature&lt;/strong&gt;&lt;br /&gt;
The subroutine that creates the reply message is at address 288A4.&lt;br /&gt;
The byte at RAM location 10F20 is proportional to (freeze frame engine coolant temperature + 40 degrees C).&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;PID 06 - Short term fuel % trim - Bank 1&lt;/strong&gt;&lt;br /&gt;
The subroutine that creates the reply message is at address 288B4.&lt;br /&gt;
The&amp;nbsp;word at RAM location 10F1C is&amp;nbsp;related to&amp;nbsp;short term fuel % trim.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;PID 07 - Long term fuel % trim - Bank 1&lt;/strong&gt;&lt;br /&gt;
The subroutine that creates the reply message is at address 288C4.&lt;br /&gt;
The&amp;nbsp;word at RAM location 10F1E is&amp;nbsp;related to&amp;nbsp;long term fuel % trim.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;PID 0C - Engine RPM&lt;/strong&gt;&lt;br /&gt;
The subroutine that creates the reply message is at address 288D4.&lt;br /&gt;
The&amp;nbsp;word at RAM location 10F1A is&amp;nbsp;proportional to RPM.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;PID 0D - Vehicle speed&lt;/strong&gt;&lt;br /&gt;
The subroutine that creates the reply message is at address 288E4.&lt;br /&gt;
The&amp;nbsp;byte at RAM location 10F1F is&amp;nbsp;proportional to vehicle speed.</content><link rel='replies' type='application/atom+xml' href='http://ecuhacking101.blogspot.com/feeds/6681668736706340485/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ecuhacking101.blogspot.com/2011/01/nb-miata-obd-mode-2.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1176501985869191402/posts/default/6681668736706340485'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1176501985869191402/posts/default/6681668736706340485'/><link rel='alternate' type='text/html' href='http://ecuhacking101.blogspot.com/2011/01/nb-miata-obd-mode-2.html' title='NB Miata, OBD Mode 2'/><author><name>J. Wong</name><uri>http://www.blogger.com/profile/09137114208904793879</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1176501985869191402.post-621329049954087705</id><published>2011-01-08T14:05:00.000-08:00</published><updated>2011-01-09T23:51:29.454-08:00</updated><title type='text'>NB Miata Specifics, OBD Mode 1</title><content type='html'>So far,&amp;nbsp;I&#39;ve given you some general guidelines for&amp;nbsp;extracting your ECU&#39;s firmware image and some suggestions for how to begin analyzing it.&amp;nbsp; I&#39;ll just mention a few other analysis tips, and then I want to switch gears to talk about the specifics of what I&#39;m learning about the NB Miata ECU.&lt;br /&gt;
&lt;br /&gt;
So, a few other analysis tips:&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;Try to find out which variables and functions are called most often.&amp;nbsp; These are likely to be the most important.&lt;/li&gt;
&lt;li&gt;Note&amp;nbsp;where a variable is referenced.&amp;nbsp; The subroutines that share common variables are related.&lt;/li&gt;
&lt;li&gt;Take special note of where variables are modified.&amp;nbsp; Often a variable that is referenced in a dozen or more places is only set in one place; therefore the&amp;nbsp;code that sets this variable influences all of the other routines.&lt;/li&gt;
&lt;/ol&gt;Now, on to the Miata.&amp;nbsp; The first thing I want to talk about is the OBD modes it supports.&amp;nbsp; Today, I&#39;ll only talk about Mode 1.&lt;br /&gt;
&lt;br /&gt;
Mode 1 provides information about the current state of the engine.&amp;nbsp; The &#39;01 NB supports the following Mode 1 PIDs:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;00 - PIDs supported (01-20)&lt;/li&gt;
&lt;li&gt;01 - Monitor status since DTCs cleared&lt;/li&gt;
&lt;li&gt;03 - Fuel system status&lt;/li&gt;
&lt;li&gt;04 - Calculated engine load value&lt;/li&gt;
&lt;li&gt;05 - Engine coolant temperature&lt;/li&gt;
&lt;li&gt;06 - Short term fuel % trim - Bank 1&lt;/li&gt;
&lt;li&gt;07 - Long term fuel % trim - Bank 1&lt;/li&gt;
&lt;li&gt;0C - Engine RPM&lt;/li&gt;
&lt;li&gt;0D - Vehicle speed&lt;/li&gt;
&lt;li&gt;0E - Timing advance&lt;/li&gt;
&lt;li&gt;0F - Intake air temperature&lt;/li&gt;
&lt;li&gt;10 - MAF air flow rate&lt;/li&gt;
&lt;li&gt;11 - Throttle position&lt;/li&gt;
&lt;li&gt;13 - Oxygen sensors present&lt;/li&gt;
&lt;li&gt;14 - Bank 1, Sensor 1: O2S Voltage, Short term fuel trim&lt;/li&gt;
&lt;li&gt;15 - Bank 1, Sensor 2: O2S Voltage, Short term fuel trim&lt;/li&gt;
&lt;li&gt;1C - OBD standards this vehicle conforms to&lt;/li&gt;
&lt;li&gt;20 - PIDs supported (21-40)&lt;/li&gt;
&lt;li&gt;21 - Distance traveled with MIL on&lt;/li&gt;
&lt;/ul&gt;For details on how each reply message is encoded, see &lt;a href=&quot;http://en.wikipedia.org/wiki/OBD-II_PIDs#Modes&quot;&gt;http://en.wikipedia.org/wiki/OBD-II_PIDs#Modes&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
You can get all of the above info with any generic OBD scantool.&amp;nbsp; But the following additional details can only be determined from looking at the code:&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;PID 00 - PIDs supported (01-20)&lt;/strong&gt;&lt;br /&gt;
The subroutine that creates the reply message is at address 285A6.&lt;br /&gt;
Return value indicates that 01, 03-07, 0C-11, 13-15, 1C and 20 are supported.&amp;nbsp; However, PIDs 15 and 20 will only be indicated as supported if the ECU&amp;nbsp;is configured to conform to OBD-II as defined by CARB or to EOBD (Europe).&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;PID 01 - Monitor status since DTCs cleared&lt;/strong&gt;&lt;br /&gt;
The subroutine that creates the reply message is at address 285D8.&lt;br /&gt;
The subroutine that counts active DTCs is at 2866A.&amp;nbsp; Not all DTCs are counted:&amp;nbsp; only the ones that match a specified set of categories.&amp;nbsp; More on this later.&lt;br /&gt;
If the 5th bit of RAM location 104C1 is set, this means the check engine light (MIL) is on.&amp;nbsp; Alternatively, if the 1st and 3rd bits of 10000 are 0 and the 4th bit of 104C2 is 1, that also means the MIL is on.&lt;br /&gt;
If the ECU&amp;nbsp;is configured to conform to OBD-II as defined by CARB, the following tests are available:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Misfire&lt;/li&gt;
&lt;li&gt;Fuel System&lt;/li&gt;
&lt;li&gt;Components&lt;/li&gt;
&lt;li&gt;Catalyst&lt;/li&gt;
&lt;li&gt;Evaporative System&lt;/li&gt;
&lt;li&gt;Oxygen Sensor&lt;/li&gt;
&lt;li&gt;Oxygen Sensor Heater&lt;/li&gt;
&lt;li&gt;EGR System&lt;/li&gt;
&lt;/ul&gt;Otherwise, if the ECU&amp;nbsp;is configured to conform to EOBD, the following tests&amp;nbsp;are available:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Misfire&lt;/li&gt;
&lt;li&gt;Fuel System&lt;/li&gt;
&lt;li&gt;Components&lt;/li&gt;
&lt;li&gt;Catalyst&lt;/li&gt;
&lt;li&gt;Oxygen Sensor&lt;/li&gt;
&lt;li&gt;Oxygen Sensor Heater&lt;/li&gt;
&lt;/ul&gt;Otherwise, only the Fuel System test is available.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;PID 03 - Fuel system status&lt;/strong&gt;&lt;br /&gt;
The subroutine that creates the reply message is at address 286D2.&lt;br /&gt;
If the 2nd bit of 10190 is&amp;nbsp;0, the fuel system&amp;nbsp;is open loop due to engine load OR fuel cut due to deacceleration.&lt;br /&gt;
Otherwise&amp;nbsp;if the 4th bit of 1028E is 0, the fuel system is open loop due to insufficient engine temperature.&lt;br /&gt;
Otherwise&amp;nbsp;if the first bit of 1028E is 0, the fuel system is open loop due to system failure.&lt;br /&gt;
Otherwise if the 2nd bit of 0104E6 is 0, the fuel system is closed loop, using oxygen sensor feedback to determine fuel mix.&lt;br /&gt;
Otherwise the fuel system is closed loop, using at least one oxygen sensor but there is a fault in the feedback system.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;PID 04 - Calculated engine load value&lt;/strong&gt;&lt;br /&gt;
The subroutine that creates the reply message is at address 286E2.&lt;br /&gt;
The byte at RAM location 100D8 is proportional to calculated engine load value.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;PID 05 - Engine coolant temperature&lt;/strong&gt;&lt;br /&gt;
The subroutine that creates the reply message is at address 286F2.&lt;br /&gt;
The byte at RAM location 100FF is proportional to (engine coolant temperature + 40 degrees C).&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;PID 06 - Short term fuel % trim - Bank 1&lt;/strong&gt;&lt;br /&gt;
The subroutine that creates the reply message is at address 28702.&lt;br /&gt;
The&amp;nbsp;word at RAM location 10296 is&amp;nbsp;related to&amp;nbsp;short term fuel % trim.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;PID 07 - Long term fuel % trim - Bank 1&lt;/strong&gt;&lt;br /&gt;
The subroutine that creates the reply message is at address 28712.&lt;br /&gt;
The&amp;nbsp;word at RAM location 102D8 is&amp;nbsp;related to&amp;nbsp;long term fuel % trim.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;PID 0C - Engine RPM&lt;/strong&gt;&lt;br /&gt;
The subroutine that creates the reply message is at address 28722.&lt;br /&gt;
The&amp;nbsp;word at RAM location 10078 is&amp;nbsp;proportional to RPM.&amp;nbsp; This variable is almost certainly used with fuel and timing lookup tables.&amp;nbsp; I haven&#39;t located them yet, but I hope to soon.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;PID 0D - Vehicle speed&lt;/strong&gt;&lt;br /&gt;
The subroutine that creates the reply message is at address 28732.&lt;br /&gt;
The&amp;nbsp;byte at RAM location 10141 is&amp;nbsp;proportional to vehicle speed.&lt;br /&gt;
The subroutine at 29F8E is used to calculate vehicle speed, and could probably be modified to account for different wheel/tire sizes.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;PID 0E - Timing advance&lt;/strong&gt;&lt;br /&gt;
The subroutine that creates the reply message is at address 28744.&lt;br /&gt;
The&amp;nbsp;byte at RAM location 103BE is related to timing advance.&amp;nbsp; This variable is likely calculated from lookup tables.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;PID 0F - Intake air temperature&lt;/strong&gt;&lt;br /&gt;
The subroutine that creates the reply message is at address 28764.&lt;br /&gt;
The&amp;nbsp;byte at RAM location 1013B is proportional to intake air temperature.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;PID 10 - MAF air flow rate&lt;/strong&gt;&lt;br /&gt;
The subroutine that creates the reply message is at address 28774.&lt;br /&gt;
The word at RAM location 100CC is proportional to MAF air flow rate.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;PID 11 - Throttle position&lt;/strong&gt;&lt;br /&gt;
The subroutine that creates the reply message is at address 28780.&lt;br /&gt;
Throttle position % is stored in the byte at RAM location 10102.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;PID 13 - Oxygen sensors present&lt;/strong&gt;&lt;br /&gt;
The subroutine that creates the reply message is at address 2878C.&lt;br /&gt;
If the ECU&amp;nbsp;is configured to conform to OBD-II as defined by CARB or to EOBD (Europe), it will report Bank 1 Sensors 1 and 2 present.&lt;br /&gt;
Otherwise, only Bank&amp;nbsp;1 Sensor 1 is reported as present.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;PID 14 - Bank 1, Sensor 1: O2S Voltage, Short term fuel trim&lt;/strong&gt;&lt;br /&gt;
The subroutine that creates the reply message is at address 287A4.&lt;br /&gt;
The reply &quot;A&quot; byte&amp;nbsp;is proportional to the byte at&amp;nbsp;RAM location 10160.&lt;br /&gt;
The reply &quot;B&quot; byte is a function of the word at RAM location 10296 (same as in PID 06).&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;PID 15 - Bank 1, Sensor 2: O2S Voltage, Short term fuel trim&lt;/strong&gt;&lt;br /&gt;
The subroutine that creates the reply message is at address 287C2.&lt;br /&gt;
The reply &quot;A&quot; byte&amp;nbsp;is proportional to the byte at&amp;nbsp;RAM location 10172.&lt;br /&gt;
The reply &quot;B&quot; byte is #FF.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;PID 1C - OBD standards this vehicle conforms to&lt;/strong&gt;&lt;br /&gt;
The subroutine that creates the reply message is at address 287DA.&lt;br /&gt;
If the 4th bit of 10000 is set, this vehicle conforms to OBD-II as defined by the CARB.&lt;br /&gt;
Otherwise, if the 2nd bit of 10000 is set, this vehicle conforms to&amp;nbsp;EOBD (Europe).&lt;br /&gt;
Otherwise, this vehicle is not meant to comply with any OBD standard.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;PID 20 - PIDs supported (21-40)&lt;/strong&gt;&lt;br /&gt;
The subroutine that creates the reply message is at address 287F4.&lt;br /&gt;
If the ECU&amp;nbsp;is configured to conform to OBD-II as defined by CARB or to EOBD (Europe), it will report that PID 21 is supported.&amp;nbsp; Otherwise, none.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;PID 21 - Distance traveled with MIL on&lt;/strong&gt;&lt;br /&gt;
The subroutine that creates the reply message is at address 28826.&lt;br /&gt;
The word at RAM location 104DE is the number of km traveled with the MIL on.&lt;br /&gt;
&lt;br /&gt;
Whew - OK, that&#39;s all for Mode 1.&amp;nbsp; Next time I&#39;ll describe Mode 2.&amp;nbsp; The ECU supports standard modes 1-8 and a little over a dozen other non-standard modes, and I plan to describe all of them, in order.</content><link rel='replies' type='application/atom+xml' href='http://ecuhacking101.blogspot.com/feeds/621329049954087705/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ecuhacking101.blogspot.com/2011/01/nb-miata-specifics.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1176501985869191402/posts/default/621329049954087705'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1176501985869191402/posts/default/621329049954087705'/><link rel='alternate' type='text/html' href='http://ecuhacking101.blogspot.com/2011/01/nb-miata-specifics.html' title='NB Miata Specifics, OBD Mode 1'/><author><name>J. Wong</name><uri>http://www.blogger.com/profile/09137114208904793879</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1176501985869191402.post-6368727035500307558</id><published>2010-12-31T08:46:00.000-08:00</published><updated>2010-12-31T08:46:24.771-08:00</updated><title type='text'>Reverse engineering strategies</title><content type='html'>OK, so now you have this massive assembly language listing staring you in the face.&amp;nbsp; How do you go about reverse engineering it?&amp;nbsp; This reminds me of a saying/joke a friend of mine told me:&amp;nbsp; &lt;i&gt;How do you eat an elephant?&amp;nbsp; One bite at a time.&lt;/i&gt;&amp;nbsp; So grab your knife and fork and get ready for a really big meal, because this is going to take a long time.&amp;nbsp; All of the automated analysis has been done by your disassembler, so now it&#39;s up to you to figure out what this code actually &lt;b&gt;does&lt;/b&gt;.&amp;nbsp; But that&#39;s the fun of it, right? :)&lt;br /&gt;
&lt;br /&gt;
Still, you have to start somewhere.&amp;nbsp; Should you just start from the first instruction and go from there?&amp;nbsp; That&#39;s pretty much what I did the first time.&amp;nbsp; &lt;i&gt;Don&#39;t make the same mistake&lt;/i&gt;.&amp;nbsp; Reverse-engineering code is kind of like putting together a puzzle, except you don&#39;t know what the final picture will look like, at least not exactly.&amp;nbsp; But in the case of an ECU, you do know some things that have to be there.&amp;nbsp; You know what sensors and actuators it&#39;s talking to (O2 sensor, MAP and/or MAF sensor, coolant temperature sensor, injectors, etc).&amp;nbsp; For OBDII cars, you also know that it&#39;s got to support certain standard Modes and PIDs, as well as Diagnostic Trouble Codes.&amp;nbsp; And, you should know something about the design of your microcontroller, such as where the reset vector and interrupt vectors are located, and what special function registers control the ADC and serial ports.&lt;br /&gt;
&lt;br /&gt;
In the case of the NB Miata, I originally thought that it would be much harder to reverse-engineer, since OBDII compliance meant that it had to support a lot more diagnostic functions than earlier cars, which I assumed would make the code much more difficult to figure out.&amp;nbsp; &lt;b&gt;In fact, the opposite is true&lt;/b&gt;.&amp;nbsp; The reason is that, since so many diagnostic functions are &lt;i&gt;mandated by law&lt;/i&gt; to work a certain way, all you need to do is to find the code that is responsible for processing and responding to OBD commands to figure out how this information is stored in the ECU.&amp;nbsp; For example, take Mode $01, PID $05, Engine Coolant Temperature.&amp;nbsp; SAE J1979 requires that the response contains a byte that corresponds to the car&#39;s engine coolant temperature in degrees Celsius, plus 40.&amp;nbsp; So if you find the code that generates the response, you now know which memory location holds the engine coolant temperature.&lt;br /&gt;
&lt;br /&gt;
So what would be the most likely place to find code that allows the microcontroller to communicate with the outside world?&amp;nbsp; Perhaps through a serial port?&amp;nbsp; That&#39;s a very logical guess.&amp;nbsp; &lt;b&gt;And, in the case of the Miata, it&#39;s also correct&lt;/b&gt;.&amp;nbsp; By searching the code for any references to serial ports, and looking at the functions pointed to by the serial port interrupt vectors, it took very little time to find the code that generated responses to not only Mode 1 PID 5 but all OBD commands (including the non-standard, proprietary ones).&lt;br /&gt;
&lt;br /&gt;
Once you know which memory locations hold important information (such as coolant temperature, RPM, ignition timing, etc), start looking at all the functions that reference those variables.&amp;nbsp; For example, if you examine the functions that deal with ignition timing, you are likely to find that one or more of them refer to a lookup table (LUT) that is used to determine the timing.&amp;nbsp; These are the tables that most &quot;performance chips&quot; modify, along with the fuel LUTs.&lt;br /&gt;
&lt;br /&gt;
So, if you&#39;re reverse-engineering firmware from any OBDII compliant car, I would say that the absolute best place to start is to try to locate the code that generates the reply messages.&amp;nbsp; Once you find it and figure out how each response is generated, you will have established a pretty significant beachhead from which you can venture out further in your understanding of the inner workings of your ECU.&amp;nbsp; Happy trails!</content><link rel='replies' type='application/atom+xml' href='http://ecuhacking101.blogspot.com/feeds/6368727035500307558/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ecuhacking101.blogspot.com/2010/12/reverse-engineering-strategies.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1176501985869191402/posts/default/6368727035500307558'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1176501985869191402/posts/default/6368727035500307558'/><link rel='alternate' type='text/html' href='http://ecuhacking101.blogspot.com/2010/12/reverse-engineering-strategies.html' title='Reverse engineering strategies'/><author><name>J. Wong</name><uri>http://www.blogger.com/profile/09137114208904793879</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1176501985869191402.post-5224677053674967713</id><published>2010-12-31T08:04:00.000-08:00</published><updated>2010-12-31T08:04:31.811-08:00</updated><title type='text'>Some disassembly required</title><content type='html'>&lt;i&gt;(Happy New Year&#39;s Eve! &amp;nbsp; Before I talk about reverse-engineering strategies, I thought I would explain to the uninitiated what a disassembler is, and recommend a good one.&amp;nbsp; If you already know what a disassembler is and have a favorite, you can skip this post.)&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
Once you&#39;ve successfully read out the firmware image from your ECU, you still only have a bunch of bytes.&amp;nbsp; In order to make any sense out of it, you&#39;re going to have to change it into a more human-readable form:&amp;nbsp; assembly language.&amp;nbsp; You &lt;i&gt;could &lt;/i&gt;try doing this manually, by looking up what instruction each byte corresponds to in the user manual for your ECU&#39;s microcontroller.&amp;nbsp; You could, but that would be crazy.&amp;nbsp; It would take forever.&amp;nbsp; The right way is to use a disassembler, which is a program that does this (and usually a lot more) for you.&lt;br /&gt;
&lt;br /&gt;
When I started with the Honda CRX, I was lucky that its ECU used an 8051.&amp;nbsp; It&#39;s such a popular micro that there are free disassemblers available to download.&amp;nbsp; The Integra, however, uses a much less common chip from Oki Semiconductor (66207), so I wasn&#39;t able to disassemble it until someone else (another Honda ECU hacker, I assume) wrote a disassembler for it.&amp;nbsp; For the NB Miata, although I don&#39;t know the exact micro it&#39;s using, I at least know it&#39;s from the Motorola MC68HC16 family, and that&#39;s common enough that disassemblers exist for it.&amp;nbsp; There are certain registers (memory locations with special functions) that are specific to the particular variant found in the NB that the disassemblers don&#39;t know about, but for the most part the assembly code they generate is quite usable.&lt;br /&gt;
&lt;br /&gt;
So earlier I mentioned that most disassemblers do more than just transform bytes into assembly language instructions.&amp;nbsp; What else do they do?&amp;nbsp; A lot!&amp;nbsp; Take &lt;b&gt;IDA Pro&lt;/b&gt;, for example.&amp;nbsp; This is probably one of the most well-known and best disassemblers out there.&amp;nbsp; It&#39;s also freakin&#39; expensive, so for most of us, we can only afford the free version.&amp;nbsp; But even that is still really powerful.&amp;nbsp; For example, the assembly language listing it generates is not just a text file, but it groups code into functions and subroutines, and you can follow the jump instructions by simply clicking on them.&amp;nbsp; It also compiles lists of all functions, subroutines and variable names used, which can be renamed so that as you figure out what each one is for, you can rename it to something more meaningful.&amp;nbsp; You can also specify which parts of your firmware image are instructions and which parts are data tables (or blank), so the disassembler translates it properly.&amp;nbsp; In the expensive version, IDA Pro can also draw subroutines is flowcharts, which I&#39;m sure makes untangling them even easier.&amp;nbsp; I wish they had a cheaper version that had some of the Pro features in it.&amp;nbsp; I would definitely consider buying it.&amp;nbsp; Still, anyone interested in reverse-engineering binary code (whether it&#39;s from an ECU, any other firmware or even PC programs) should at least check out their free version.&amp;nbsp; The Pro version supports many more processors than the free version, but sometimes people write modules that support other processors for the free version (including the one that works for the Miata, fortunately!).</content><link rel='replies' type='application/atom+xml' href='http://ecuhacking101.blogspot.com/feeds/5224677053674967713/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ecuhacking101.blogspot.com/2010/12/some-disassembly-required.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1176501985869191402/posts/default/5224677053674967713'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1176501985869191402/posts/default/5224677053674967713'/><link rel='alternate' type='text/html' href='http://ecuhacking101.blogspot.com/2010/12/some-disassembly-required.html' title='Some disassembly required'/><author><name>J. Wong</name><uri>http://www.blogger.com/profile/09137114208904793879</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1176501985869191402.post-7751620471431848834</id><published>2010-12-09T02:06:00.000-08:00</published><updated>2010-12-09T02:06:15.975-08:00</updated><title type='text'>Preparation:  Gather your tools and information</title><content type='html'>The obvious first step to hacking your car&#39;s ECU is to locate it, and remove it without damaging it.&amp;nbsp; This usually involves a Google search or just looking around your car, and then removing a few nuts, bolts and/or screws.&amp;nbsp; A flat head screwdriver helps to remove the wiring harness from the ECU.&amp;nbsp; It&#39;s probably prudent to ground yourself so you don&#39;t damage the ECU with static discharge, as well as disconnecting the car battery first.&amp;nbsp; (I usually don&#39;t do either, but don&#39;t say I didn&#39;t warn you).&lt;br /&gt;
&lt;br /&gt;
Once the ECU is out of the car, you&#39;ll need to open it up.&amp;nbsp; At least in the case of the Civic, Integra and Miata, all you need is a Phillips screwdriver.&amp;nbsp; Most ECUs are pretty basic - a PCB enclosed in a metal box, with a large connector for the wiring harness.&amp;nbsp; You&#39;ll probably need to remove the PCB from the case in order to work on it.&amp;nbsp; If you have an anti-static mat (such as this one from Fry&#39;s &lt;a href=&quot;http://www.frys.com/product/2807074&quot;&gt;http://www.frys.com/product/2807074&lt;/a&gt;), you might want to use it.&amp;nbsp; Take a look at the board.&amp;nbsp; Take pictures.&amp;nbsp; Pay special attention to the largest ICs.&amp;nbsp; Two of them are probably going to be the microprocessor and a memory chip.&amp;nbsp; If you&#39;re lucky, the part numbers will be easily readable.&amp;nbsp; If you&#39;re not so lucky, all you will have to go on is the package type and pin count.&amp;nbsp; Either way, you&#39;ll be going back to Google to find out all you can about these two components.&lt;br /&gt;
&lt;br /&gt;
Auto manufacturers aren&#39;t in the business of making their own microcontrollers and custom memory ICs, so it&#39;s likely these will be commonly available parts, and it won&#39;t be hard to find information on them.&amp;nbsp; On the other hand, when you build thousands or millions of ECUs, you can probably afford to use some ASICs.&amp;nbsp; For example, in the CRX ECU (commonly referred to as the PM6), an 8051 microcontroller is used, along with a standard 27C256 EPROM.&amp;nbsp; However, the particular variant of 8051 implements a non-standard opcode - why, I don&#39;t know.&amp;nbsp; In addition, the PM6 has an important IC on it that you won&#39;t find a datasheet for anywhere.&amp;nbsp; That made some of the inner workings of the ECU a mystery, but a great deal could still be learned from disassembling the 8051 program on the EPROM.&lt;br /&gt;
&lt;br /&gt;
Anyway, once you identify your ECU&#39;s microprocessor and memory, you&#39;ll want to look for the necessary software tools to disassemble the program.&amp;nbsp; But of course you need to access the program first, which for ECUs that are more than about 5-10 year old&amp;nbsp;usually means physically removing the memory chip and reading it with an EPROM programmer.&amp;nbsp; You can probably reprogram most newer ECUs without even removing them from the car, but I&#39;m talking about the older ones at the moment.&lt;br /&gt;
&lt;br /&gt;
It&#39;s usually pretty easy to find an EPROM programmer that will be able to read the particular memory chip you have.&amp;nbsp; Ebay is full of them.&amp;nbsp; I got one from mcumall.com that works well and was reasonably priced.&amp;nbsp; There may be even better deals out there.&amp;nbsp; The harder part is non-destructively removing the chip from the PCB.&amp;nbsp; For older&amp;nbsp;ECUs, where the memory chips are through-hole mounted, a desoldering tool like this one works well (&lt;a href=&quot;http://www.radioshack.com/product/index.jsp?productId=2062731&quot;&gt;http://www.radioshack.com/product/index.jsp?productId=2062731&lt;/a&gt;).&amp;nbsp; In the Miata, however, the flash memory is a surface mount part.&lt;br /&gt;
&lt;br /&gt;
I have to admit that the idea of desoldering a surface mount part kind of scared me, but in fact it&#39;s actually easier than desoldering through-hole components!&amp;nbsp; Check out this video, for example:&amp;nbsp; (&lt;a href=&quot;http://www.youtube.com/watch?v=FTQqjggeklo&quot;&gt;http://www.youtube.com/watch?v=FTQqjggeklo&lt;/a&gt;).&amp;nbsp; It really is that easy, and reattaching is a snap, too.&amp;nbsp; Still, you should practice a couple of times on similar components on scrap boards before you try it on the real thing.&amp;nbsp; And you &lt;u&gt;will&lt;/u&gt; need a multimeter so you can verify that you don&#39;t have any open or short circuits after you&#39;re done.&lt;br /&gt;
&lt;br /&gt;
In addition to the ChipQuik kit, you&#39;ll need a good (i.e., temperature-controlled) soldering iron such as a Weller, with a screwdriver- or hoof-shaped tip, plenty of Q-tips and rubbing alcohol to clean off the PCB after the chip is removed, and of course solder to reattach the SMD.&lt;br /&gt;
&lt;br /&gt;
Next time, I&#39;ll talk about what to do with the firmware image once it&#39;s been copied off the EPROM (and this applies to both newer and older ECUs):&amp;nbsp; how to disassemble it, and&amp;nbsp;some strategies to consider&amp;nbsp;when reverse-engineering the code.</content><link rel='replies' type='application/atom+xml' href='http://ecuhacking101.blogspot.com/feeds/7751620471431848834/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ecuhacking101.blogspot.com/2010/12/preparation-gather-your-tools-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1176501985869191402/posts/default/7751620471431848834'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1176501985869191402/posts/default/7751620471431848834'/><link rel='alternate' type='text/html' href='http://ecuhacking101.blogspot.com/2010/12/preparation-gather-your-tools-and.html' title='Preparation:  Gather your tools and information'/><author><name>J. Wong</name><uri>http://www.blogger.com/profile/09137114208904793879</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1176501985869191402.post-7660696352185771305</id><published>2010-12-04T15:59:00.000-08:00</published><updated>2010-12-04T15:59:03.429-08:00</updated><title type='text'>So you want to hack your ECU.  Where do you start?</title><content type='html'>I&#39;ve been reverse engineering automotive engine control units (ECUs) since 2001.&amp;nbsp; Recently, an acquaintance encouraged me to write a blog about it.&amp;nbsp; At first, I wasn&#39;t sure if anyone would really be interested about the internal details of ECUs, but then I thought, why not.&amp;nbsp; So if you&#39;re reading this, I assume you are the curious type, are interested in cars and electronics, and aren&#39;t afraid to use a soldering iron.&amp;nbsp; I plan to write about how I got into ECU hacking, the basics of how to do it, such as what tools you need, and some of what I&#39;ve learned along the way.&amp;nbsp; So let&#39;s start from the beginning.&lt;br /&gt;
&lt;br /&gt;
I wasn&#39;t always interested in cars.&amp;nbsp; In fact, growing up I never really thought of them as anything more than a form of transportation until one singular experience changed everything for me - playing Gran Turismo.&amp;nbsp; I know, it sounds kind of silly, and it is, but that&#39;s really the reason why I got excited about cars, and why, in 2001, I bought a used Honda 1991 CRX Si (which had seen better days), bought a used Jackson Racing supercharger, which I&amp;nbsp;installed&amp;nbsp;myself to save money, and, finally, decided to crack open the CRX&#39;s ECU to see if I could hack it myself, because the only other option at the time was to pay someone else about $1000 to do it.&amp;nbsp; So, what started out mainly as an attempt to go fast cheaply has turned into a long-term hobby, and since that time, I have had&amp;nbsp;almost as much fun working on my cars and hacking their ECUs as I&#39;ve had driving them.&lt;br /&gt;
&lt;br /&gt;
In 2001, the conventional wisdom was that Honda ECUs couldn&#39;t be hacked, except by the few commercial outfits that were charging an arm and a leg for their services.&amp;nbsp; But hey, if they could do it, why couldn&#39;t I?&amp;nbsp; I decided to open up my ECU and see.&amp;nbsp; What I found was a pleasant surprise:&amp;nbsp; My CRX&#39;s ECU was powered by an 8051 microcontroller and used a standard 28-pin EPROM.&amp;nbsp; It&#39;d be hard to come up with a more common combination of parts.&amp;nbsp; There were plenty of 8051 code disassemblers that could be downloaded for free, as well as datasheets.&amp;nbsp; I was fortunate enough to have access to an EPROM programmer, so all I had to was desolder the EPROM, read it and disassemble it.&amp;nbsp; If you&#39;re interested, you can read more about it here:&amp;nbsp; &lt;a href=&quot;http://forum.pgmfi.org/viewtopic.php?f=2&amp;amp;t=7&amp;amp;start=0&quot;&gt;http://forum.pgmfi.org/viewtopic.php?f=2&amp;amp;t=7&amp;amp;start=0&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Since the CRX, I&#39;ve owned a supercharged &#39;93 Civic Si, a supercharged &#39;94 Integra GS-R and now a 2001 Mazda Miata, and I&#39;ve hacked the ECU in each one.&amp;nbsp; I&#39;ve also gone from having no kids to 4, so I don&#39;t have as much free time to devote to this as I used to, but I will try to post regularly about what you need to do to hack your own ECU, from the ground up, including what hardware and software tools you&#39;ll need and where to find them.&amp;nbsp; Stay tuned.</content><link rel='replies' type='application/atom+xml' href='http://ecuhacking101.blogspot.com/feeds/7660696352185771305/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ecuhacking101.blogspot.com/2010/12/so-you-want-to-hack-your-ecu-where-do.html#comment-form' title='25 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1176501985869191402/posts/default/7660696352185771305'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1176501985869191402/posts/default/7660696352185771305'/><link rel='alternate' type='text/html' href='http://ecuhacking101.blogspot.com/2010/12/so-you-want-to-hack-your-ecu-where-do.html' title='So you want to hack your ECU.  Where do you start?'/><author><name>J. Wong</name><uri>http://www.blogger.com/profile/09137114208904793879</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>25</thr:total></entry></feed>