|
|
Subscribe / Log in / New account

Inside the Volkswagen emissions cheating

By Jake Edge
January 6, 2016

In an interesting presentation [video link] at the 32nd Chaos Communication Congress (32C3) held at the end of December, Daniel Lange and Felix Domke gave a detailed look into the Volkswagen emissions scandal—from the technical side. Lange gave an overview of the industry, the testing regime, and the regulatory side in the first half, while Domke presented the results of his reverse-engineering effort on the code in the engine electronic control unit (ECU), as well as tests he ran on his own affected VW car. The presentation and accompanying slides [PDF] provide far more detail than has previously been available.

Lange is a former BMW engineer who now runs his own consulting company. Domke is an independent security researcher who became curious about how the code inside his car was gaming the emissions testing.

Some background

The VW scandal has made such an impact partly because of the sheer number of cars affected, which is roughly 11 million worldwide, Lange said. While VW has sought to pin the blame on a small number of engineers, the fact that 1500 hard disks and USB drives were confiscated as part of the investigation is a good indicator that many more employees were actually involved.

[NEDC profile]

The "New European Driving Cycle" (NEDC) is the profile used for testing car emissions; a graph of it from the slides is seen at right. It shows the speed of the car over time as it is accelerated and decelerated during the test. A car is conditioned the day before the test by driving it fast on the autobahn, then it is put through this test regime on a dynamometer and the emissions are measured.

The profile is "very artificial", Lange said, as "nobody drives a car like this". As engineers get better and better at optimizing for the tests, the gap between the test results and real-world performance grows. Cars running on the street are getting better emissions due to this work as well, but less quickly than the test results. There are also a number of "borderline gray areas" that car makers exploit to improve performance in the tests, such as over-inflating the tires and altering wheel alignment. Essentially, engineers see the tests as an optimization problem and react accordingly.

The net result is that real-world emissions are 30 or more times higher than those in the tests. It has been known in the industry for quite some time that the tests are not really reflecting actual vehicle emissions, Lange said. It is not just VW vehicles, either, as many other vehicles show 30x less emissions in the tests than they do on the road.

Lange also noted that the automotive industry is particularly careful to document its entire development process. All software changes are tied to requirements documents and those documents are signed-off by multiple layers of management in the companies. So, unless there is a cover up, VW should be able to determine exactly who made the change and when it was done. It is "completely impossible" that some kind of rogue engineer simply inserted the cheating code into ECU, he said.

In addition, this not the first time a company has done this sort of thing. In 2000, BMW was caught doing something quite similar in the ECU of some motorcycles.

The engine ECU is typically provided by an outside company (Bosch in the VW cars) and runs proprietary code that contains a computer model of the engine. Car makers cannot change (or even see) that code, but the model is driven by some 20,000 variables that describe the engine and its functioning. There is just as much record-keeping in how and why those variables get changed as there is with other changes, so VW (or the investigators) should be able to see just how this all came about.

Reverse engineering

At that point, Domke took over (around the 40-minute mark in the video) to describe what he had found. He said that the cars affected are out there on the roads, so he should be able take one apart, get the firmware out of it, and see just what was going on. "The truth is in the code", he said.

In order to investigate, he needed an affected car and access to a dynamometer to run some tests. In addition, he needed an extra ECU that he could use to extract the firmware without damaging the car. As it turned out, he got a letter from VW that said his car was one of those affected, so he could use it for the testing.

He got a Bosch EDC17C46 ECU from eBay, applied 12V to it, and watched it boot. It complained about missing sensors and such, but it was executing code. It did not have exactly the same firmware as is in his car, but it was close. He then discovered a flaw that allowed him to extract the 2MB flash firmware image from the TriCore CPU on the board. That bug was effectively a zero-day, since he did not find anyone else reporting it, but it was not all that difficult to work out, he said.

He then disassembled the firmware, which looked quite a bit different than disassemblies of normal code. It looked somewhat like electronic schematics had been turned into code, rather than spaghetti-like output from other kinds of programs, he said. One thing he noticed is that the program is all data-driven and there is a large part of the firmware that is simply data. Those are the 20,000 variables used to change the model in the ECU for the specific engine in the vehicle.

Basically, an engine ECU takes input from the throttle and controls the air and fuel mixture that goes to the engine to produce the engine power requested. But there is a lot more than that these days. One of the things that ECUs control is the emissions systems—and that is where he looked to determine how the cheating was done.

By using the OBD-II port on the car, he was able to extract a wealth of information from the ECU. There is some status information that the manufacturer makes available directly, but access to almost any of the other parameters is available in developer mode—if you know the address. He tracked down various "A2L" files that map these parameters to addresses and, though he wasn't able to get the exact set for his car, he got enough information to be able to access the information he wanted.

As an example of the kinds of complicated processing the ECU does, he noted that there is a 12KB block of code that is used to ensure the tachometer always shows 780 RPM when the car is idling. Even though the engine is not that steady, car owners want to see that value hold steady at idle, so car makers effectively lie to satisfy them. Domke said that it is clear that lots of different kinds of cheating is going on in the ECU and noted that the speedometer doesn't really show the speed of the vehicle, just something related to it.

Emissions

He then moved on to the emissions system and, specifically, the selective catalytic reduction (SCR) system. The idea behind SCR is to reduce NOx (NO and NO2) emissions from diesel engines. It does so by using a solution of urea and water (called "AdBlue" in Germany) to change the NOx to nitrogen and water.

However, the right amount of AdBlue to use is important and hard to get right. Too little will still convert some of the NOx, which is better than nothing, but too much will produce ammonia, which is definitely not wanted. So the goal of the emissions system should be to eliminate as much NOx as possible without emitting much (if any) ammonia.

The SCR is also modeled in the ECU. It takes sensor readings and outputs from other models and produces an amount of AdBlue to use. Ideally, that would be the right amount to eliminate NOx, but emit no ammonia. There is also a separate monitoring function that will trigger an OBD-II error if the efficiency of the conversions is too low. That might cause a "check engine" condition so that the owner takes the car in for service.

It turns out that the standard SCR model does not work under all conditions (e.g. if the engine is too hot), so there is an alternative model that runs in parallel. It is a much simpler model, with fewer inputs, that has the goal of never adding too much AdBlue. There is code in the ECU that determines which model to use, and that code depends on the data provided by the car maker. In addition, the ECU stores information about which model is chosen at each ten-millisecond interval.

The conditions that determine which model is chosen are all ORed together to decide when to switch to the alternate model. Many of those conditions were impossible (e.g. air temperature greater than 3276.8°K or less than 0.1°K), but one was particularly strange since it always evaluated to true (engine temperature greater than -3276.8°K), which meant that the OR would evaluate to true, thus the alternative model should always be chosen.

That all seemed pretty strange to Domke, so he drove his car while recording which models it used. It turned out that around 20% of the time it was in a mode where it did no AdBlue injection at all since the engine was warming up. Most of the rest of the time, the engine used the alternate model, but, interestingly, there was still some small sliver of time where it used the standard SCR model.

He noted that this fit well with the usage of AdBlue by his car. For best conversion efficiency, you would expect to use 2.5L of AdBlue for 1000km of driving, but his car only used 0.6L over that distance.

He was puzzled about how the standard model was ever chosen, though, based on his earlier investigation. So he dug back in and found another set of criteria that is used in the model selection. These "unlock conditions" would force the ECU to use the standard model under a fairly odd set of conditions. The engine must be at 15°C or more and it must be running where the atmospheric pressure is more than that at 750m. But, most strangely, the driving profile must also fit within a set of seven linear "curves" that were defined in terms of minimums and maximums of distance-driven versus time-since-motor start.

[ECU curves + NEDC]

As might be guessed, converting the NEDC curves to that system results in a curve that neatly fits in between two of those defined in the ECU. When the car operates within those parameters, the standard model, with its much lower emissions, would be triggered. Part of the testing regime is that all cars are warmed to 20°C overnight before the test and, presumably, all of the testing centers are well below 750m in elevation. The slide showing the ECU lines with the converted NEDC curves overlaid (seen at right) was greeted with loud applause.

To verify his results, Domke put his car on the dynamometer while recording various parameters (e.g. SCR model used, AdBlue added) from the OBD-II. He followed the NEDC testing profile, then ran the car at a faster speed that was outside of that particular range. As might be expected, while he was NEDC-compliant, the standard model was chosen and quite a bit of AdBlue was used. Once he got out of that range, the car switched to using the alternative model and the AdBlue usage dropped to near zero. Presumably, the alternative model provides better driving performance, while pumping out far more emissions.

At the end of the talk, Domke did have something of disclaimer. He was not able to externally test the NOx emissions due to lack of equipment, for one thing. In addition, he made a "best effort" at understanding the code and what the model was doing, but could have made a mistake in there somewhere. But the dynamometer testing does match up well with what he found and it is all consistent with what VW has said in its various press releases on the matter.

Overall, it is an interesting "detective story" of sorts, but it also shows just how much is going on behind the scenes in our cars and other devices we rely on every day. Even in a highly regulated industry like automobiles, though, there is plenty of wiggle room for companies to try to outcompete other car makers—or to outfox regulators. It is unclear how widespread this kind of cheating is in the industry, but it seems likely we will hear about more of this kind of chicanery in coming years.


Index entries for this article
SecurityAutomotive
SecurityReverse engineering


to post comments

Inside the Volkswagen emissions cheating

Posted Jan 7, 2016 3:38 UTC (Thu) by luto (guest, #39314) [Link] (3 responses)

Does anyone know why VW did this? That is, what do they gain by having the car inject too little AdBlue under normal conditions?

Inside the Volkswagen emissions cheating

Posted Jan 7, 2016 7:36 UTC (Thu) by burki99 (subscriber, #17149) [Link]

If I remember the discussions correctly, it was a means to get the AdBlue refilling cycles in line with the regular service intervals of the car as a convenience for the customers. That of course leads to the question why they couldn't just increase the size of the tank.

Inside the Volkswagen emissions cheating

Posted Jan 7, 2016 8:43 UTC (Thu) by HybridAU (guest, #85157) [Link]

The story I heard around the office (and I'm not mechanically inclined at all so this could be completely wrong) was that adding the AdBlue also meant using a different air-to-fuel ratio and so by not using AdBlue the car would have better performance and more torque.

That meant VW cars would use less fuel (which is something customers can easily measure themselves, often talk about, and would influence purchases) and feel more powerful when taking them for a test drive and comparing with other cars in a similar range which (probably) do meet emissions standards. So the incentive may have been around sales.

Inside the Volkswagen emissions cheating

Posted Jan 8, 2016 0:22 UTC (Fri) by felixfix (subscriber, #242) [Link]

The best guess I have heard is that the CEO of VW was a well-known tyrant, unwilling to change course or listen to nay-sayers, and way back when this started, he had publicly promised VW could create clean diesels that would not need AdBlue. One of the troubles with AdBlue is that US laws require the pollution control system work for 100,000 miles without user servicing, so the AdBlue tank has to be big enough to last for the 10,000 mile service interval (2.5L/1000km is roughly one gallon per 1000 miles, so a 10,000 mile tank is getting close to the size of the fuel tank); the less AdBlue needed, the smaller the tank. If you can make the diesel run clean without needing any AdBlue, even better.

But as the self-assessed deadline approached and the engineers couldn't make their diesels run clean without AdBlue, they resorted to a one time, temporary fix of perverting the pollution control software, fully expecting it to be taken out soon. Unfortunately, they couldn't make their diesels run clean, and the CEO was not the type to lose face by admitting so, so the perverted software remained.

That certainly sounds plausible to me. Whether it's true or not will probably never be known publicly, even though the tyrant CEO is now gone.

Inside the Volkswagen emissions cheating

Posted Jan 7, 2016 6:14 UTC (Thu) by alonz (subscriber, #815) [Link] (21 responses)

I am wondering…

Domke […] noted that the speedometer doesn't really show the speed of the vehicle

Could speeders now claim that their car showed a completely different speed to the one they were ticketed for?

Inside the Volkswagen emissions cheating

Posted Jan 7, 2016 10:29 UTC (Thu) by andy_shev (subscriber, #75870) [Link] (7 responses)

Luckily there is GPS system that doesn't lie, does it?

Inside the Volkswagen emissions cheating

Posted Jan 7, 2016 12:53 UTC (Thu) by NAR (subscriber, #1313) [Link] (2 responses)

The GPS usually shows 5-10% slower values. It practically means that if the speed limit is 50 km/h and the driver tries to keep the speed around the 50 km/h value (e.g. driving at 48-51) showed by the speedometer, then he's safely below the speed limit.

Inside the Volkswagen emissions cheating

Posted Jan 8, 2016 21:11 UTC (Fri) by ken (subscriber, #625) [Link] (1 responses)

Are you sure about that? From googling around I get the impression that GPS generally has less than 1% error on speed.

Lying speedometers

Posted Jan 10, 2016 0:55 UTC (Sun) by giraffedata (guest, #1954) [Link]

You misread the comment. It says the GPS reading, which is presumed to be correct, is 10-15% slower than the speedometer reading. So the speedometer overstates the speed and you cannot break the speed limit by driving by the speedometer.

Inside the Volkswagen emissions cheating

Posted Jan 7, 2016 17:47 UTC (Thu) by ssam (guest, #46587) [Link] (3 responses)

GPS will generally overestimate distance travelled due to jitter on each position reading.

Inside the Volkswagen emissions cheating

Posted Jan 12, 2016 11:42 UTC (Tue) by javispedro (guest, #83660) [Link]

GPS does not use position for speed -- Doppler shift is used for instantaneous speed. But even when you use position samples to calculate speed/distance, simple statistics (e.g. Kalman) filter the jitter out and obtain readings that will be more than accurate for the "car speedometer" use case.

Inside the Volkswagen emissions cheating

Posted Jan 12, 2016 12:53 UTC (Tue) by Sesse (subscriber, #53779) [Link] (1 responses)

Only as long as you're driving reasonably straight. If you take a lot of turns (e.g., city driving), you'll get the opposite effect.

Inside the Volkswagen emissions cheating

Posted Jan 28, 2016 16:38 UTC (Thu) by mathstuf (subscriber, #69389) [Link]

I used GPS to track a side trail on the map but not OSM last week. It's also almost comical with hiking with moderate tree cover (90 second interval to balance between accuracy and battery life). There are two quarter mile offshoots I definitely didn't do (they cross the contour lines all wrong). Still need to load it up in a GPX editor to overlap with the map to see how much of the GPX is useful before submission though.

Inside the Volkswagen emissions cheating

Posted Jan 7, 2016 11:41 UTC (Thu) by JdGordy (subscriber, #70103) [Link]

That was the worrying takeaway for me too! Though I'm sure the penalties to the car companies for falsifying speedo reading is going to be MUCH worse than emissions cheating. Also, they couldnt really advertise "our car goes faster at 80km/h than a ferrari at 80km/h" can they? :)

Inside the Volkswagen emissions cheating

Posted Jan 7, 2016 14:51 UTC (Thu) by paulj (subscriber, #341) [Link] (9 responses)

EU rules are that the speedometer must _always_ read higher than true speed, I think, possibly by at least some small percentage (I don't quite remember). In part to ensure motorists can not argue their speedometer didn't tell them they were speeding. So it's probably related to that, and so I don't think you can, least not in the EU.

Is my vague memory and guess. ;)

Inside the Volkswagen emissions cheating

Posted Jan 7, 2016 15:35 UTC (Thu) by nybble41 (subscriber, #55106) [Link] (2 responses)

I don't know about the EU, but my speedometer here in the US seems accurate enough when compared to a GPS, at least at highway speeds. In any case, if it's commonly known that speedometers are required to read 5-10% higher than true speed, then motorists *could* well argue that they took this into account when interpreting the speedometer results, since the law is that your true speed can't be over the speed limit, not that your speedometer can't read over the speed limit. For example, if the law is that speedometers must read at least 5% over true speed, and yours said that you were 3% over the limit, you could argue that—knowing how speedometers must be calibrated by law—you had a reasonable expectation that your true speed was at least 2% under the limit, and that if that was not the case the issue must be with the speedometer and not the driver.

Inside the Volkswagen emissions cheating

Posted Jan 8, 2016 13:58 UTC (Fri) by NAR (subscriber, #1313) [Link]

Actually some drivers are more "clever", they also take into account the tolerance of the police - i.e. they start to fine only if the driver went substantially faster. For example in Hungary the some (most?) of the police only fines the driver if he went faster than 69 km/h on a road where the maximum allowed speed is 50 km/h. So a few drivers go at 68 km/h (according to their GPSs).

Interestingly there are also minimum speed limits, for example 100 km/h on motorway in left lane on some steep parts - there the driver might say that he was over the minimum limit according to the speedometer, but in fact was slower. I don't think anyone ever fined for this.

Inside the Volkswagen emissions cheating

Posted Jan 8, 2016 20:12 UTC (Fri) by anselm (subscriber, #2796) [Link]

IIRC, here in Germany the speedometer in a car may not display a speed that is less than the speed the car is actually travelling at, while in the other direction the maximum allowed tolerance is something like 10% of the highest speed printed on the speedometer scale. So if the highest speed on the scale is 200 km/h, the speedometer may display a speed that is up to 20 km/h faster than the actual speed. This leads to even small cars with wimpy engines having speedometers that go up to fairly impressive speeds which are way beyond what the car could actually reach – even, as we say “at full throttle, downhill with the wind at its back, and homesick”.

If you're cited for speeding, there is an automatic allowance for “manufacturing tolerances” that would let you get away with somewhat more than 50 km/h in a 50-km/h zone. Even so, you don't get to claim that your speedometer showed less than the actual speed of the car. Manufacturers calibrate the speedometers to display a higher speed on purpose, so people that drive such that the speedometer value matches the posted speed limit are actually safely below the speed limit.

Inside the Volkswagen emissions cheating

Posted Jan 7, 2016 17:02 UTC (Thu) by pjones (subscriber, #31722) [Link] (2 responses)

Starting with FMVSS 127 in 1983, new passenger cars for retail sale in the USA must be configured such that at 50 miles per hour: a) the speedometer cannot be wrong by more than 5%, and also b) the indicated speed must be higher than the actual measured speed. 127 has sense been supplanted by other regulations, but AIUI the rule is still the same.

If you look on VW and Mini web forums (merely the two vendors I've had cause to look at in the past), the first thing people notice when they hook phones and such up to OBD2 to display real time data is that GPS and OBD2 display the same speed more or less, but the speedometer readout is usually ~2.5mph faster when moving at speed.

I don't know if OBD2 is required to show the real measured speed or not, but on those vehicles it does.

Indeed

Posted Jan 8, 2016 13:03 UTC (Fri) by mchouque (subscriber, #62087) [Link]

On my car, the speedometer reports a value that is always higher by 4 km/h than what I read on the OBD bus.

Inside the Volkswagen emissions cheating

Posted Jan 9, 2016 18:45 UTC (Sat) by jdulaney (subscriber, #83672) [Link]

My speedo in my 1988 Ranger showed about 3 MPH over what my actual speed was, as measured by a combination of radar and timed distance. I corrected this, of course.

Inside the Volkswagen emissions cheating

Posted Jan 7, 2016 19:12 UTC (Thu) by jhhaller (guest, #56103) [Link] (1 responses)

Speedometers were typically driven by wheel rotation, so worn tires and under-inflated tires will show a higher speed than the same car with new tires which are overinflated or normal. Given that the air pressure rises as the tire gets warm, you will get different values for the same tire pressure and wear in the same trip. Presumably, the ECU could supply some correction for the pressure/temperature, particularly if equipped with a Tire Pressure Monitor as newer cars are. I'm not sure if any cars drive the speedometer by the GPS in cars with GPS (including those used just for showing a direction), but those could be somewhat more accurate, excluding the GPS wander factor which overestimates instantaneous distance traveled.

Inside the Volkswagen emissions cheating

Posted Jan 7, 2016 19:34 UTC (Thu) by pjones (subscriber, #31722) [Link]

Typically in the post-OBD2 world there's a Hall Sensor or an optical sensor in the wheel hub and it's counting axle rotation, and then the computer is using some method (who the hell knows if it's just multiplication or something more complex...) to arrive at a number. And then it's displaying a different number.

There certainly *are* GPS speedometers - they're common for kit cars, and google finds plenty of them for sale. It's worth noting those cars don't have to comply with the FCR/NHTSA/FMVSS requirements for a new retail consumer vehicle; they still have to have a speedometer to be street legal to get a VIN assigned, but the rule that says it must reflect a higher-than-measured value at 50MPH, AFAICS, does not apply. Emissions standards are also applied differently in many cases.

Inside the Volkswagen emissions cheating

Posted Jan 7, 2016 20:47 UTC (Thu) by mstone_ (subscriber, #66309) [Link]

IIRC, the permitted margin of error (permitted as in "massive fine for noncompliance") is +10%-.001%. If you were an engineer, how would you implement this given hardware with a margin of error something like +-2.5%? Most would implement it as "set it to read high" because that's a heck of a lot easier than re-designing the hardware to actually have a .001% margin of error.

Inside the Volkswagen emissions cheating

Posted Jan 7, 2016 20:48 UTC (Thu) by mstone_ (subscriber, #66309) [Link]

no, unless you want to amuse the court with the argument, "I was really going faster"

Inside the Volkswagen emissions cheating

Posted Jan 8, 2016 15:13 UTC (Fri) by kokada (guest, #92849) [Link]

AFAIK, this is proposital, since if the driver is overspeed he can't get out by saying "in my velocimeter I was below the maximum speed".

And it is not completely unrelated, it is off by 10% at maximum.

Inside the Volkswagen emissions cheating

Posted Jan 7, 2016 8:20 UTC (Thu) by nhippi (subscriber, #34640) [Link]

This is a great read. The article omits that older VW diesels didn't use AdBlue at all. The big story was that
VW cheated because they didn't want to install AdBlue injector, and instead claimed that they can meet emission guidelines without it. I take the structure of cheat was still the same on older VW's diesels.

Inside the Volkswagen emissions cheating

Posted Jan 7, 2016 10:44 UTC (Thu) by osma (subscriber, #6912) [Link] (2 responses)

Since the ECU was made by Bosch, does this mean that actually Bosch did the implementation of the cheat?

Inside the Volkswagen emissions cheating

Posted Jan 7, 2016 13:20 UTC (Thu) by pwfxq (subscriber, #84695) [Link]

Bosch were certainly aware of what VW were up to. There are leaked emails from Bosch telling VW what they were doing was wrong.

Inside the Volkswagen emissions cheating

Posted Jan 7, 2016 20:18 UTC (Thu) by pbonzini (subscriber, #60935) [Link]

Who knows, there may be legal (not "legal" in the software sense :)) reasons to use the basic model within some distance vs. time profile.

Inside the Volkswagen emissions cheating

Posted Jan 7, 2016 12:09 UTC (Thu) by stevem (subscriber, #1512) [Link]

Excellent reverse engineering work, and a great write-up of it!

Inside the Volkswagen emissions cheating

Posted Jan 8, 2016 11:17 UTC (Fri) by branden (guest, #7029) [Link] (3 responses)

Fascinating piece! Thanks, LWN!

Minor correction: kelvins are not degrees; they're just kelvins. So one would write, e.g., "273 K", not "273°K".

And I love the use of a signed 16-bit integer to represent decikelvins. :D

Why signed?

Posted Jan 8, 2016 16:59 UTC (Fri) by pr1268 (guest, #24648) [Link] (2 responses)

use of a signed 16-bit integer to represent decikelvins

Why signed? Recent scientific research notwithstanding, I don't think temperatures below 0 [d]K would ever be measured by this system.

Unless they were using negative values as error codes, etc. (Disclosure: I haven't [yet] read the documents linked above.)

Why signed?

Posted Jan 8, 2016 22:07 UTC (Fri) by pbonzini (subscriber, #60935) [Link]

In the slides there is a "> -3276.8" condition that is always true, so the only plausible interpretation is that temperature is stored in a signed 16-bit integer. Presumably the format (signed 16-bit integer) and unit of measure (decikelvin) is also documented in the A2L files.

Why signed?

Posted Jan 9, 2016 22:53 UTC (Sat) by mrkrad (guest, #106224) [Link]

It's likely the ecu represented the unplugging of a sensor as 0xffff or 0x0000 which in unsigned 16 bit would meet the guidelines of a impossible to reach degrees <-32768 degrees.

back in the days of old 8-bit ecu's a linear look-up-table's 1st result would be used as a failsafe when a sensor was unplugged to lock in a value (for say coolant to timing adjustment), allowing one to unplug the coolant temp sensor and manually set the distributor timing! Talking about 1st generation VW ecu's here. but bosch had their hand in the design as well back then!


Copyright © 2016, Eklektix, Inc.
This article may be redistributed under the terms of the Creative Commons CC BY-SA 4.0 license
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds