Design Article
What is power debugging?
Tomas Hedqvist, IAR Systems
5/27/2010 9:54 AM EDT
Today, many embedded systems are powered by battery or via a signal cable. We see them in almost any market segment; medical, consumer electronics, home automation and many more. A common design goal for all these systems is that the power consumption must be low. Convenience, environmental awareness and costs are all contributing factors in choosing products that do not require us to constantly change the battery.
The design goals of low power consumption and a long battery lifetime have traditionally been the domain of hardware developers. As more battery-powered applications become controlled by a microcontroller, the hardware manufacturers present products with functionality and characteristics that contribute to lower power consumption and hence longer battery lifetime.
But in an active system, power consumption does not only depend on the design of the hardware, but also of how it is used. Of course, how it is used is determined by the system software.
The software developers’ domain on the other hand has always been to develop applications that are as efficient as possible and use as little memory as possible. In low-power systems power consumption is a third dimension that needs to be taken into account. However, the lack of proper tools has prevented power consumption to become an integrated part of the software development process.
Recently an innovative technology that achieves just what has been missing, integrating the system's power consumption in the development of software for embedded systems, has been announced by IAR Systems. The term used to describe this approach is what is called 'power debugging'.
How does power debugging work?
By correlating a system's momentary power consumption with its software, a dynamic analysis tool that shows how the software affects and steers the power consumption is obtained. This is the fundamental approach for how to provide insight into how power consumption can be minimized.
In embedded systems, peripheral devices often account for much of the power consumption. As software controls how they are used, regardless of whether they are integrated into the microcontroller or not, it also controls the system's power consumption. By exercising better control of the hardware, system power consumption can be reduced. Because of this it is also important to consider the whole system and not just the processor when correlating power consumption to the software. In other words, there is more to be done to minimize power consumption than simply trying to spend as much time as possible in an inactive CPU state.
The technology for power debugging is based on the ability to sample the power consumption and correlate each sample with the program's instruction sequence and hence with the source code. One difficulty is to achieve high precision with sampling. Ideally you could sample the power consumption with the same frequency the system clock uses, but system capacity will reduce the reliability of such measurements. Simply put, the measured power consumption will be ‘smeared’ in relation to what is actually being consumed by the CPU and peripherals.
In practice this is not a problem though. As from the software developer's perspective it is more interesting to correlate the power consumption with the source code and various events in the program execution than with individual instructions, so the resolution needed is much lower than one sample per instruction. For example, it is more interesting to see how a particular function call affects power consumption than to see instruction by instruction how power consumption changes.
Next: Power profiling




Dan at ECS
5/27/2010 12:56 PM EDT
Good point in general, but not always so easy to apply/implement.
For example, suppose task 1 (running from t1 to t2) reads button switches. In this case, it might make sense to only apply a voltage across the switch(es) when they are to be read. When not reading the switches, there is no need to drive them. Fine. So starting at T2, we could switch off the voltage, and then only re-apply the voltage again at T3. (of course there are settling times, etc...)
But with other peripherals (ADCs, ethernet MACs, etc.) we can't just arbitrarily switch off power -- we might corrupt an ADC reading, or miss a packet on the wire, etc.
When I worked on low-power handset firmware architecture, we spent a tremendous amount of time up-front, considering all interactions with the user, hardware ramp-up/ramp-down timings, power-up (and down) sequencing, etc... These are definitely situations where up-front planning and design can yield enormous benefits. Some of the sequences were so complicated and intricate, if they hadn't been anticipated and accounted for up-front, it would have been nearly impossible to accomodate them later.
I've also been involved with a couple of complicated projects where low-power was retrofitted into the product, and the process in both cases was very painful.
Not criticizing the article at all, it makes a very good point that is very often overlooked, but the issue is much bigger than simply turning off peripherals when they're not in use by the currently running task.
Sign in to Reply
marklev
11/30/2010 5:02 AM EST
Interesting article. For security folks, power analysis methods are also a source of major vulnerabilities -- there have been many papers written about the attack and countermeasure methods (e.g., Google "differential power analysis").
I wonder if the statistical methods of differential power analysis attacks could probably be applied to debugging.
Sign in to Reply
AdamSch73
7/5/2011 3:50 PM EDT
@marklev: yes, smartcard hackers (or lets call them security experts) like to use power analysis in order to do side channel attacks on cryptographic algorithms
@Dan at ECS: I see your point, but the real value is that you can actually measure and correlate current consumption with your code which helps you to continuously focus on energy (or "power") consumption while designing/implementing your software. Consider this almost like TDD.
And also, in evaluation/prototyping phase, you have so many options on different peripherals, it takes a lot of time to experiment which hardware/software implementation gives you the best result on an application.
Sign in to Reply