Magic Smoke

At this point I’ve worked on enough hardware projects at a few companies to have a good idea of trends in the industry. One of the first things I learned while doing factory support and validation at Palm was how incredible it is that anything electronic is built by anyone within the madness that is the hardware design and fabrication supply chain. But more to my next point, I also was amazed by how many things in hardware are as hackish as you’d expect in zero hour software patches for products on their ship day.

One of my favorite stories along these lines comes from one of the first products I worked on. When you are building a device with a radio and battery there are a number of compliance tests you need to pass, with most of them coming from the FCC or CTIA. Generally you assemble a preproduction unit, make some custom firmware, and then ship them off to a 3rd party testing house who would run tests and send a report back that you could use as needed. However, especially in the case of CTIA, some defined tests were vague in that one testing house could interpret the spirit of a test to be different from another testing house. It was a frustrating process to see something that passed before fail in a new round, but you eventually got the hang of it and began to assume the worst case for each test. But on the product I am referring to, there was a very specific test we could not pass. If I remember correctly, one of the requirements was that if you had a charger plugged in and shut the device off it needed to stay off and not charge the battery past a certain safe threshold.

The test itself was fairly mundane, but the Power Management IC (PMIC) provided to use by the chip vendor had a design flaw. Essentially, if power was applied to the voltage lines the PMIC would boot the main cpu and the device would boot, thus failing the test. This meant that if the charger was attached and the user shut the device off it would immediately restart and boot back into the main OS no matter what we tried when it came to configuring the PMIC. In the end, the only solution I could come up was to have the device effectively ‘pretend’ it was off. If the system was shutdown from Linux with the charger attached it would write a specific value into the retention ram. When the bootloader came up it would check for that value and if it saw it it would not boot Linux. It also would power down the display, radio and other peripherials in the device and begin charging the battery. If the battery hit 95% charged it would physically disconnect it via the charging FET interface. Otherwise, in this state it would for all intents and purposes appear completely off and would only be powering itself via the usb charger. But if the user pressed the power button for ~1 second it would detect it and boot to Linux as if the device was booting cold in the first place. If the charger was ever pulled then the device would completely power off and the value in memory would be gone, so the next boot would be a proper cold boot anyway. This passed every test and to date I’m still not entirely sure whether the testers would have cared if they realized how much we were cheating on that specific part. I like to think that because it was mostly about battery safety that they wouldn’t mind, but I really have no idea.

The more time I spend working on hardware the more I discover this sort of thing isn’t that uncommon. But on the plus side, it’s at least satisfying to come up with clever solutions to things you’re told are impossible.