Showing posts with label tamper tamper. Show all posts
Showing posts with label tamper tamper. Show all posts

Saturday, January 22, 2011

Helplessness, pity and kindness

Despite being partly a sociopath, a lunatic, misogynistic, a gloating bastard and a cynic that cannot hold back his happiness when the office is losing a valuable workday again for some reason I predicted, there is also a kind, loving and caring part of me that does all that for no reason but to know that someone was happy because of it.

Some time ago the doorbell rang and I expected some literally childish nuisance that needed PC related advice. Instead it was the female part of one of our neighbours. It's easy to make a list containing 20 items that each would qualify as a flaw in character about her. And although my girlfriend agrees she likes her to a good extent, which I only do to a rather small extend. When she told me, though, that they have pulled out their dishwasher to check if it does not work for the same reason as a year before, I saw a chance to support my reputation as a universal genius around the neighborhood in a quick and easy manner. And most of our neighbours are quite nice and you can always use a trump card if you need some good tools or a hand. Or a car with tow hitch.

The problem was soon analyzed and solved. The feet of the dishwasher weren't adjusted properly and pushing it back in this way was indeed impossible. Four minutes later it was screwed in its place again and I got big thanks and told what the problem was. What really made me pity her husband is the way she talks about him. I agree that he is the kind of guy that might have his best match with a rather dominant woman, but if my GF would talk about me in this way, especially when I was around, I'd give her a good amount of verbal backslaps. She described him as pretty much completely unhandy, incapable of solving the tiniest mechanical problems around the house and as acting impatient and dumb. ("When it doesn't work in a way he gets he tends to use force and break things.") Is there much more humiliating you can tell your neighbour about your husband when said neighbour obviously is, on top of everything else, the more intellectual, nerdy type and not your common handy man and of an age you'd expect a man of his age to act belittling towards his experience and skills just because of the age difference alone? I also bet this guy could achieve twice as much as he does now if he had his wife supporting him instead of dooming what he starts as a failure before he even moves his hand.

When I got told what the initial problem was they pulled the dishwasher out for, my greedy self was cringing. They had the same problem a year ago and paid the worth of a new machine for the repair. Now they wanted to exchange the same part and at least just pay the part's price, which would be acceptable. I told them that their problem is easily fixable for less than five bucks.
So soon the machine was back out again and she insisted to show me the instructions to disassemble the part . That gave me the chance to travel back in the early years of the century, with XGA flatscreens, something that seemed to be a slow Pentium IV and Windows XP running with way too less memory. Switching back to the Internet Explorer took the machine half a minute in which you could watch the GDI subsystem draw the window line by line. Of course the disk was rattling madly during swap file access and after maybe 15 seconds the fan started notably blowing. Netburst architecture at its best. The really sad part is that she uses this machine in her office and really works on it on a daily basis. If I would give such a thing to my GF to work with I would consider leaving her if she wouldn't slap me in the face immediately. And no, I do know money is not the issue.

After the half hour in her office was over, 5 minutes were scrolling to the line by line rendered PDF, 30 seconds contained possibly noteworthy information I wouldn't have minded being given, I took the machine apart and decided to also take off some dirty parts not mentioned in the instructions. An hour later everything except the one big part that needed inner cleaning with mild acid or vinegar was disassembled, cleaned and reassembled. In the meantime I heard not only more thanks than I had already gotten while being there, but also that the machines works like new again.


I tried to imagine how I would feel in such a situation if I would be unable to just take out some machine, take a close look to identify at least basic problems and disassemble easy mechanics. Of course, stuff like installing cables and wiring ethernet is not everybody's piece of cake and hardware diagnosis on laptops also is not something one must be able to do. Let alone resolder BGA chips with basic household tools on a two sided PCB. But how can you call yourself a man if a screwdriver and some tweezers are beyond what you can operate?
Yes, what makes a man manly has been defined quite differently during the last centuries and still is seemingly judged differently between men and women, but... WTF?

The lesson I learned from that is that I should be glad that I have two hands and am not just able to move them consciously, but also some mind that is able to transform eyesight into abstraction, apply transformations to abstractions and output the result as a series of hand movements.

Saturday, January 15, 2011

Let's bake power states!

So we now know what benefits undervolting might get us and how we do it with our precious Core or Core 2 CPU. We also know that the operating voltage changes all the time, as does the clock rate, and I hope why constantly adjusting voltage and clock is a good thing does not need a further explanation.
So how should this mechanism behave to not slow your system down and save power?

The short answer is you will likely never know the precise and correct answer but have to consider some things to avoid some pits lots of people fall into. Out of the box the power states and the rules for their transition are very well done. Chances are what you define yourself is worse, the question is just by how much.
Basically you want to rise the clock speed whenever the power consumption of the system as a whole integrated over time is smaller with a faster CPU that drains more power. This is obviously the case when your task is CPU bound, e.g. video rendering. Besides the CPU you also have the power drain of your running harddisk, the chipset, the memory, maybe your screen, the NICs and whatever else may be running. Let's say this takes 15W and your CPU takes another 10W running at half speed. The job takes x minutes to finish. Running the CPU at full speed, it uses 15W and the job takes roughly x/2 minutes. So in one case we have 25W for x minutes and in the other case we have 30W for x/2 minutes. So we end with 25*x Wminutes and 30*x*1/2 Wminutes, equaling 15*x Wminutes. Yes, this is very trivial but a lot of people do not understand this without a hammer.
If you thought about the numbers for CPU power draw used in this example you must come to the conclusion that the CPU runs way less efficiently on a lower clock rate. And this is actually true for most undervolted systems that are not overclocked. You can draw a diagram that correlates minimal power consumption for stable work and processing power and you will see it is not a line you get, but something curvy.
It will roughly look like this with power consumption being on the y-axis and processing power being on the x-axis, both assumed to be linear. The left end is intended to be a clock rate of about 0Hz, the right end something severely overclocked. The y-axis is not starting with 0, as even with basically no real clock the CPU will draw some power and need a certain minimum voltage to function at all.
The bottom line of this is that for every CPU there is a point from which you will need a lot more voltage and hence power to make it work faster. Go look for those overclocking freaks that reach 5GHz with some i7 and see what crazy voltages and cooling setups they use. Some of those systems have the CPU use 3 times the stock power and more. In terms of efficiency that is horrible, as they aren't running even twice as fast in some cases.
Around the point where the CPU needs rather suddenly a lot more voltage to operate faster, there will be a point where lowering the clock speed will not really reduce the necessary voltage for it to perform stable. Between those points, which are more intervals than points, there's the point of maximum efficiency, where you get a good speed for cheap power.
Although the diagram for each CPU will very roughly like the one above, where your stock speed is can barely be foreseen. And keep in mind stock speed usually has not the minimal power consumption as stock voltage might be way more than the CPU really needs. So you really have to figure out where on this curve you are with your own CPU. The one I talked about in the last post has its stock speed definitely in the left half of the diagram. Between lowest and highest clock there's only a tenth of a Volt more needed to keep it running stable! Keep in mind that P=U^2/R is not applying as a rule of thumb if you compare different clock speeds, though. The higher the clock rate, the more the electrical capacity of the CPU comes into play, wasting power.

Depending on how steep the needed increase in voltage is for your CPU, you should either make it aggressively increase clock speed or not so aggressively. But in general you do want it to clock up quite soon. For one because this makes the system more responsive and eliminates possible perform impacts on other hardware that might have to wait for the CPU to finish its work and also because highest efficiency is typically close to stock speed. There's another effect comping into play that you might call "the race to sleep". When the CPU has done its work, it very quickly enters a sleep state where the power consumption drops to something damn low. And it is more effective for it to work fast and sleep more than to work slower and sleep less.
If you have full load at half speed you need e.g. 10W. If you go full speed with half load you have 15W during the work times and let's say 1W during sleep. So you have 15/2+1/2W resulting in an 8W average. Yes, we leave out a lot of details here, assuming load drops to 50% and not figuring in any time for the sleep state entering, but the direction's the thing that's important.

So you now have an idea about some of the mechanisms that you should consider when deciding how your power state transitions should be defined and you will likely not make the same mistake as a lot of those kids around the interwebs that force their undervolted CPUs to perform worse and less efficient than they could. And if you think the directions are very vague, then you are absolutely right. there's so much stuff going on in detail that your setup will be not ideal most of the time, no matter what you choose as parameters. And again the most benefit comes from choosing the right general direction of behaviour, not the last tenth of a volt or 5% of load you alter. Maybe I feel like writing something about stability testing later, as this is the key to really use undervolting and not just play with it.

Details about the Intel Core (2) and voltage signaling

So after the basics, we wanna take a close look at how all the voltage stuff works for the Intel Core (2) mobile CPUs. First, there's enough tools out there to undervolt via software and you want to use that way, whether you add some hardware modfications or not. Look for CrystalCPUid or other tools like that. Don't forget to disable the power control mechanisms in your OS if you want your own tool to do the work.

First off, we wanna know how the voltage crap functions on the hardware level, so we can fuck with it. Thankfully Intel does provide good documentation of their technology and you can get your hands easily on that. They do have a website. You can not just get the pinout of your CPU (mind the difference between socket P and M!) and also a table that and an explanation for the signaling of voltage levels. There's seven pins on the CPU for that which are labeled VID0 to VID 6. With those voltages between 1.5 and lower-than-you-could-possibly-want can be signaled and the scheme behind it is easy. Base voltage is 1.5V and every pin subtracts a certain voltage from that if its level is high. VID 6 equals 0.8V, VID5 equals 0.4V, VID4 equals 0.2V and so on. The resulting table is just binary counting downwards for the pins while the voltages mapped to that are decreasing by 0.8V/2^6 per step. So what you need to do is simply make sure these pins have the right signals running on them for the voltages you want. Of course, there's more to it than just connecting some of them to something else.

Restriction one is that you cannot pull them to ground. This has fried people's CPU in the past. You can only pull them up to Vcc. Second restriction is that you do not know all the possible voltage requests of your CPU, at least without a lot of equipment or maybe inside knowledge of what some very specific registers' data mean. They again differ from CPU to CPU, if only slightly. And there's a lot of voltage transitions happening between the power button and a software starting under windows, likely even between the power button and the first try to execute any easily customizable code. And as a third restriction, you can't easily change your hardwirings for the VID pins. So if you decide to hardwire the pin that lowers the voltage by 0.4V to Vcc, every voltage having this pin on low will be reduced by 0.4V, while all others will not be affected. If you alter the table mapping pin states to voltages, you will see that every second block of voltages that is 0.4V "high" is repeated in the 0.4V range above it. That's simply a logical consequence, as the table was just counting with the pin states and you have eliminated one of these bits. So you also lose half of the voltages you could possibly get. Depending on where those blocks lie you could even have not affected the voltage range you want to alter. And also you might make your CPU getting 0.4V less in some sleep state that has very low voltage anyways. Expect this to cause problems, severe problems!
Restriction four is that you only have a small amount of voltages you can set by software. Lower ones will simply not be accepted.

Your best bet is to wire either the 0.1 or 0.2V pin to VID0 or maybe VID1. This way both pins are connected by a logical OR. Whenever one of them is high, the other one will be too. Look at the table and figure out why this is beneficial besides the fact that you have a fifty-fifty chance of it severely affecting some voltage you do not want.

Ok, we now know how to figure out what happens when we connect some pin to some other pin. If you look at the pinout again, you will see that this is not getting easy. At least some of the pins are facing the outer side of the pin array and none are really far from each other, but they do not lay too conveniently. So grab an old ethernet wire, rip it apart and get some of the fine copper stuff. Don't forget to cut your socket a little to make up for the additional height of the wire. Yes, it does make a difference and you do not want your cooler to put mechanical stress on the die or not sit as flat as possible.

If you are as lucky as I was, your CPU will run on 0.825V instead of something around 1.2V.  How much of a difference that makes is easy to describe. If you just stress the CPU (and the chipset) the fan will stay really quiet instead of running at top speed and power consumption will drop by about 20W. Yes, from the level of a standard voltage CPU to the level of some insanely expensive Low Voltage one - while running at a speed the LV versions aren't even available at. Thereotically, assuming the CPU behaves like a normal resistor, the resulting power consumption should be about 45% of the original one. And this rule of thumb seems to apply well as such.

If you think about doing this yourself, keep in mind it all depends on luck for a big part of the way. Try with software only first and see how far you can get, then decide if you wanna void your warranty and risk that. If you did drill holes into your CPUs ten years ago, though, this is not going to be the question. Yes, drilling holes, as explained here: http://www.cpu-central.com/dualceleron/
And yes, I of course did that back then.

The basic ideas about undervolting

Have you ever heard about undervolting? Sure you have, and likely either complete bullshit or just some dribble of people who only use the popular software and go for trial and error, without having the slightest idea what is really happening.

Basically undervolting is a fancy, pseudo-1337 term for just lowering the voltage for some component, usually CPU or GPU. It got cool after overvolting, which is just increasing that voltage, which often helps to achieve higher clock rates via overclocking. So if this is not making your e-penis longer, what's the point, especially with CPUs? What does it really do anyway?
Well, you might remember R=U/I, P=U*I and P=U^2/R. This says basically that half the voltage results in half the current and a quarter of the power consumption, hence a quarter of the heat that has to be disposed.

For normal PCs neither heat nor power consumption are too interesting. Unless you have a stock heatsink that's terribly weak and noisy, heat is not a real concern, as it is with power. A normal PC has a puny average load level and while the CPU is idle there's not really a noteworthy difference you could make. When it comes to servers and laptops, though, this stuff can make a huge difference.
I have a quite sexy virtualization architecture around the house that is powered by a severely overclocked AND undervolted quadcore and the power consumption under load drops by about 30W. So instead of roughly 95W the CPU only guzzles down 65W. If the load level of my server wouldn't be puny for most of the time, too, this would save some money.
If you want to build a very tiny and silent PC, having to dispose of the heat is usually a problem. 30W less is a huge difference here and actually you can run into a situation where undervolting makes a system stable. The reason for this is just insufficient cooling capacities for normal operation, though. With fans that adjust their speed to temperature, though, it can also make the difference between the system becoming noisy under load or not.
If you have a laptop, it can obviously affect battery life quite a bit. For manufacturers the heat that needs to be disposed is also a concern and the noise argument comes into play again, I did it for the battery life, though.

What voltage a specific CPU needs to work properly is different and varies for every single one. There's datasheets that tell you under what conditions your CPU is guaranteed to work properly and they involve a lot of conditions. The most important ones are temperature, voltage and clock speed. In case you don't know, I can tell you that chip fabrication ends with lots of dead CPUs that go from the wafer to the dust bin after the initial test, because they simply do not work. Over time with a new fabrication process their number decreases as the process gets optimized. Especially towards the end of the lifecycle there's a good chance there's more CPUs coming out that could be sold as high clocking or low voltage ones than there are customers for. So they simply try to fill the quota of expensive, rarely gotten chips and the rest gets labeled worse than they could technically perform. Another thing is that not every single CPU is tested for all the shit in the datasheet in exact detail. It's cheaper to analyze how the limitations are working together and add a bit of headroom for the ones that are fit to select chips by.
So you have a good chance that your off-the-shelve CPU can do more than it is labeled for. And also you can optimize the working conditions for it.

Problem with all this is that you have to test the results, know what knob to adjust and test for stability afterwards. Having a gut feeling for that helps immensely. And maintaining stability is a key issue, as an occasionally crashing system is just defective, no matter at what speed it runs. If you want to go to the extreme by adjusting things like the reference levels of the gunning transceiver logic on your motherboard, you can waste as much time as you want and usually 80% of the benefits come after 20% of the time you invest in tuning.

If you didn't get it from above, Intel is selling CPUs that meet certain power requirements quite a bit below of those of standard CPUs. For a way higher price of course. Usually no problem on desktops, laptops come with a certain range of voltages you can force by software that stop your undervolting urge quite soon, especially with the slower CPUs. And that's where real nerds are separated from kids. Or maybe just crazy idiots from sane people.

Two fucking bytes can make a difference

Don't we all love the crazy shenanigans that some vendors make us deal with?
The concept of building just a single piece of hardware and selling it for different prices by locking features is nothing new. Ask for the Siemens HiPath series and what it costs to use the basic hardware with all it can do. Even without additional hardware you easily pay 10k bucks for some small sized company if you want IP based telephony and you do not have a single phone to plug in yet.

What Intel and some notebook vendors have done (again!) now is not a thing for all of us people who like to play around with their hardware. No, this time there's no sexual innuendo intended.
Some time ago I bought myself a new Wifi card for a new toy i have for some time already. You'll hear about that toy and what I have done to it soon, too. Well, exchanging a miniPCIe card in a laptop is usually nothing challenging or complicated. It's the old in-and-out-game, getting drivers and then being happy - usually. But if the card you wanna push in as some intel Wifi Link 5100 or 5300 you might face some challenges. Google for "Code 10" and intel wifi link, then you'll see there's a lot of people who wonder why those things do not work in their units. The usual, completely useless, answer is, that it worked like a charm for some others. Why that is you seldomly hear, but there actually is a "special version" of those cards made for IBM/Lenovo and HP/Compaq. Those things simply won't work like they should, likely even in units from these brands because they are known to use BIOS whitelisting. And unless they sell you their version of the Wifi cards explicitly for your model, it will likely not be whitelisted. And if they sell it to you expect the price to be at least twice what the card would cost as a normal, not brand specific version. And I guess that's the only thing this is about, being able to force their customers to pay unreasonable prices by artificially restricting their stuff from working together with standard hardware.

Of course, I got such a crippled Wifi card and was pissed like hell after I found out about this. Curious as I am, I at least wanted to know what the actual difference is and if I could give my oversized soldering iron a shot in turning this thing from crippled to normal. I found nothing about any such mod, not even later when I knew how it all worked. Soon enough I found out that the same thing already happened some time ago with the Intel 2200BG miniPCI card and that there was a fix. Intel just used a different set of hardware ID and subsys ID for the specially crafted kind and those were saved in the EEPROM of those cards. Google soon confirmed my suspicion about this being at least one difference this time, too. I didn't find a single post or anything about this where someone suspected or stated that, though, but only a lot of diagnosis logs from people with a laptop that showed this difference clearly and consistent. So why not do what had been a success in the past and change the EEPROM with ethtool and some linux live disc?
Because it does not work. I tried my standard Knoppix and also mint linux, which was quite newly released, and ethtool does not support dumping the EEPROM from those cards. By chance I stumbled upon some GoogleCode project that was developing a tool for axactly what I wanted: dumping and writing the EEPROMs of Intel Wifi cards. It's here: http://code.google.com/p/iwleeprom/
As I did not find anything better, I decided to check this out, second meaning intended. Compiling worked as wonderfully as dumping the ROM. In some old fashioned hex editor I immediately saw what I wanted to see...

PCIVEN_8086&DEV_4237&SUBSYS_12118086 and PCIVEN_8086&DEV_4232&SUBSYS_12018086 are the 2 ID sets of the Wifi link 5100, the earlier being the IBM/HP one, the latter being the sane one. Now look for yourself.
Oh yes, as simple and obvious as one could wish. And soon after that even the MAC address is stored, which is why I chose to delete this. If you wonder why the words are seemingly swapped google big and little endian.

Ok, altering this was dead simple and guess what happened after writing this thing back to the wifi card. Yes, it worked. Goodbye crappy Atheros card, hello 802.11n. Now I can finally have sufficient network speed while in bed on the second floor and forwarding in some video file won't take ten VLC ten seconds to cache data.

If you know who had the idea to ask for a crippled version of the wifi cards to rip off customers at IBM/HP or who has agreed with that deal on Intel's side, please greet them from me and smack them in the face heavily.