NUMBER 9
NOVEMBER 2010
Full
Speed
High
Speed Super
cranking up to superspeed 14
More nasty software bugs 9
Creating an event-flow tracer 23
Ganssle’s mailbox overflows 34
Solving the USB puzzle
USB solutions for embedded applications involve
numerous complex issues.
HCC-Embedded
COMPLETE USB SOLUTIONS
www.hcc-embedded.com • info@hcc-embedded.com
INTEGRITY RTOS has it.
No one else does.
Copyright © 2010 Green Hills Software, Inc. Green Hills, the Green Hills logo, and INTEGRITY are
trademarks of Green Hills Software, Inc. in the U.S. and/or internationally. All other trademarks are
the property of their respective owners.
www.ghs.com
Get Your Hands On What’s Next.
Scan
Mouser and Mouser Electronics are registered trademarks of Mouser Electronics, Inc. Other products, logos, and company names mentioned herein, may be trademarks of their respective owners.
T H E O F F I C I A L P U B L I C AT I O N O F T H E E M B E D D E D S Y S T E M S C O N F E R E N C E S A N D E M B E D D E D. C O M
COLUMNS
barr
code 9
Five more top causes of nasty
embedded software bugs
BY MICHAEL BARR
What do memory leaks, deadlocks, and
priority inversions have in common?
They’re all Hall of Famers in the pan-
EMBEDDED SYSTEMS DESIGN theon of nasty firmware bugs.
VOLUME 23, NUMBER 9
NOVEMBER 2010
break points 34
An accumulation of stuff
BY JACK G. GANSSLE
14
Catching up with the incoming
product announcements, Jack
Ganssle finds a few gems (and some
horror stories) to share..
DEPARTMENTS
Full
Speed #include 5
A matter of energy
High BY RON WILSON
Speed Super
Speed A recent panel discussion at ESC
Boston brought to light the many
complexities of measuring power
use in embedded systems.
ONLINE
Tracing is useful both during development and after the software
is released. This article explains the different parts required for www.embedded.com
realizing a tracing function and how to implement tracing of
state-based designs with minimal effort.
EMBEDDED SYSTEMS DESIGN (ISSN 1558-2493) print; (ISSN 1558-2507 PDF-electronic) is published 10 times a year as follows: Jan/Feb, March, April, May, June,
July/August, Sept., Oct., Nov., Dec. by the EE Times Group, 600 Harrison Street, 5th floor, San Francisco, CA 94107, (415) 947-6000. Please direct advertising and editorial
inquiries to this address. SUBSCRIPTION RATE for the United States is $55 for 10 issues. Canadian/Mexican orders must be accompanied by payment in U.S. funds with addi-
tional postage of $6 per year. All other foreign subscriptions must be prepaid in U.S. funds with additional postage of $15 per year for surface mail and $40 per year for
airmail. POSTMASTER: Send all changes to EMBEDDED SYSTEMS DESIGN, EE Times/ESD, PO Box #3609, Northbrook, IL 60065-3257, embedsys@omeda.com. For cus-
tomer service, telephone toll-free (847) 559-7597. Please allow four to six weeks for change of address to take effect. Periodicals postage paid at San Francisco, CA and additional
mailing offices. EMBEDDED SYSTEMS DESIGN is a registered trademark owned by the parent company, EE Times Group. All material published in EMBEDDED SYSTEMS
DESIGN is copyright © 2010 by EE Times Group. All rights reserved. Reproduction of material appearing in EMBEDDED SYSTEMS DESIGN is forbidden without permission.
INDUSTRIAL AEROSPACE SYSTEM ON A CHIP
THREADX: WHEN IT
REALLY COUNTS
When Your Company’s Success, And Your Job, Are On The Line -
You Can Count On Express Logic’s ThreadX® RTOS
Express Logic has completed 14 years simply must succeed. Its royalty-free
of successful business operation, licensing model helps keep your BOM low,
and our flagship product, ThreadX, T H R E A D and its proven dependability helps keep
has been used in over 800 million your support costs down as well. ThreadX
electronic devices and systems, repeatedly tops the time-to-market results
ranging from printers to smartphones, from single-chip reported by embedded developers like you. All the while,
SoCs to multiprocessors. Time and time again, when Express Logic is there to assist you with enhancements,
leading manufacturers put their company on the line, training, and responsive telephone support.
when their engineering team chooses an RTOS for their
next critical product, they choose ThreadX. Join leading organizations like HP, Apple, Marvell, Philips, NASA,
and many more who have chosen ThreadX for use in over 800
Our ThreadX RTOS is rock-solid, thoroughly field-proven, million of their products – because their products are too
and represents not only the safe choice, but the most important to rely on anything but the best. Rely on ThreadX,
cost-effective choice when your company’s product when it really counts!
Contact Express Logic to find out more about our ThreadX RTOS, FileX® file system, NetX™ Dual IPv4/IPv6 TCP/IP stack, USBX™
USB Host/Device/OTG stack, and our new PrismX™ graphics toolkit for embedded GUI development. Also ask about our TraceX®
real-time event trace and analysis tool, and StackX™, our patent-pending stack size analysis tool that makes stack overflows a
thing of the past. And if you’re developing safety-critical products for aviation, industrial or medical applications, ask Newnes
ThreadX, FileX, and TraceX are registered trademarks, and NetX, USBX, PrismX, StackX, and Certification Pack are trademarks of Express Logic, Inc.
All other trademarks are the property of their respective owners.
EMBEDDED SYSTEMS DESIGN
Director of Content/Media,
BY Ron Wilson #include
EE Times Group Events and Embedded
Ron Wilson
(415) 947-6317
ron.wilson@ubm.com
Managing Editor
A matter of energy
Susan Rambo
susan.rambo@ubm.com
Acquisitions/Newsletter Editor,
Embedded.com Site Editor
Bernard Cole
bccole@acm.org
O ur cover story in this issue
treats one aspect of an in-
creasingly important design
requirement: energy consumption. It
may sound like a pure hardware issue,
enough information. An audience
member at the panel warned that bat-
tery life depends not just on current-
drain and time but on details of the
current waveform: how high are the
Contributing Editors
Michael Barr, John Canosa, but software design is at least as signifi- current pulses, what is their duty cycle,
Jack W. Crenshaw, Jack G. Ganssle, cant as hardware for energy efficiency. and what is their impact on battery
Dan Saks, Larry Mittag
Once even rudimentary hardware pro- temperature, for example. Similar in-
Art Director
Debee Rommel visions—such as standby and sleep formation is necessary for selecting
debee.rommel@ubm.com modes—are in place, the responsibility regulators for AC-powered supplies.
Production Director falls on software developers at all levels System-level power-estimation
Donna Ambrosino
dambrosino@ubm-us.com
to use the modes effectively. A non- tools can help keep track of power
power-aware OS or careless applica- modes and use models. But they often
Subscriptions/RSS Feeds/Newsletters
www.eetimes.com/electronics-subscriptions tion code can negate anything the work with averages, not waveforms,
Subscriptions Customer Service (Print) hardware designers can accomplish. and are dependent on the accuracy of
Embedded Systems Design But you can’t manage what you the hardware models you plug in. One
PO Box # 3609
Northbrook, IL 60065- 3257 can’t measure, as the saying goes. A re- panelist (an FPGA vendor) suggested
embedsys@omeda.com ally interesting panel at ESC Boston that the most accurate power estima-
(847) 559-7597
this September explored the problems tions come from FPGA vendors’ tools,
Article Reprints, E-prints, and
Permissions of estimating and measuring power simply because a vendor can control
Mike O’Brien during design. Perhaps surprisingly, the hardware, power-management ar-
Wright’s Reprints
(877) 652-5295 (toll free) neither task is easy. chitecture, and much of the silicon IP.
(281) 419-5725 ext.117 The traditional approach is to sit Of course you can build a proto-
Fax: (281) 419-5712
www.wrightsreprints.com/reprints/index.cfm down with the IC datasheets, a guess type, load the software, and measure
?magid=2210 at the end-user’s use models, and a current through the actual supply
Publisher great deal of coffee, and build a spread- nodes. But because of those complex
David Blaza waveforms, even this approach can be
(415) 947-6929
sheet. But panelists pointed out that to-
david.blaza@ubm.com day, when the hardware may have very misleading. Current meters measure
Editorial Review Board complex internal power-management RMS or average current. And measur-
Michael Barr, Jack W. Crenshaw, mechanisms of its own, the datasheet ing current over a range of ten-thou-
Jack G. Ganssle, Bill Gatliff,
Nigel Jones, Niall Murphy, Dan Saks, numbers may be only a vague sugges- sand to one without disturbing the cir-
Miro Samek tion of reality. The typical operating cuit is a huge electrical problem. Just
power, for example, may represent the taking the measurements may require
average of a random scattering of very a complex test set up and perhaps a
large but randomly-spaced current programmable mixed-signal scope. It
spikes. The real shape of the complicat- may also require forcing the prototype
ed supply-current waveform will prob- into a single operating mode during
ably be highly software-dependent. the measurements.
Even if you could count on the av- So on the one hand, software has
erage or RMS figures being reasonably very significant influence over energy
Corporate—EE Times Group representative, they may not be consumption in embedded designs.
Paul Miller Chief Executive Officer
Felicia Hamerman
Brent Pearson
Group Marketing Director
Chief Information Officer
On the other hand, estimating or even
Jean-Marie Enjuto Financial Director Ron Wilson is the measuring that influence during the
Amandeep Sandhu Manager Audience Engagement
director of content/
Barbara Couchois Vice President Sales Ops
media, EE Times design is fraught. It is a nontrivial
Corporate—UBM LLC
Group Events and problem.
Marie Myers Senior Vice President, Embedded. You may
Manufacturing
Pat Nohilly Senior Vice President, Strategic
reach him at
Development and Business ron.wilson@ubm.com.
Administration
Ron Wilson, ron.wilson@ubm.com
Wind River embedded systems deliver the cutting-edge reliability and performance that fuel innovation.
Boeing’s 787 Dreamliner is taking flight with an innovative integrated modular avionics (IMA)-based Common Core System (CCS)
developed by GE Aviation and enabled by Wind River.
Our industry-leading VxWorks 653 partitioning operating system is the foundation for GE’s CCS, which serves as the Dreamliner’s
central nervous system by infallibly orchestrating the operation of over 70 applications supplied by over 15 Boeing suppliers.
VxWorks enables the asynchronous integration of multiple suppliers and allows for applications of different RTCA DO-178B safety
criticality levels to reliably run on a single shared computer platform.
It’s the kind of cutting-edge dependability and proven performance that’s made Wind River a trusted leading provider of
advanced embedded solutions for aerospace and defense.
Take your innovation to new heights. Contact us today for our Mission Critical Toolkit,
now available for a limited time at www.windriver.com/missioncritical/safety.
©2010 Wind River Systems, Inc. The Wind River logo is a trademark, and Wind River is a registered trademark of Wind River Systems, Inc. Other marks are the property of their respective owners.
parity bit
The MIPS benchmark can still be useful
G aurang Kavaiya (“Why MIPS is
just a number,” October, p. 16,
www.eetimes.com/design/embed-
ded/4209273/Why-MIPS-is-just-a-num-
ber) says “If generic C code is used, the
template how many MIPS it takes to
bit-bang an output pin to do something
as trivial as a PWM—because such a
function takes so little digital logic, it
would never occur to some of us that a
tially as one may overestimate the re-
quirement where a lower-cost MCU
might have sufficed but, by continually
assessing the execution profile during
development, one can get a better idea
MIPS requirement may increase by hardware-software trade-off should be of the final MIPS requirement.
three times.” That is a huge factor. The considered.In the context of a system- —Trevormh
Cengine prototype that I have in simu- level application, MIPS does not have to
lation running C statements and func- Some factors that aren’t so obvious.
tion calls has fmax about 200 Mhz and
takes two to four clock/CPU cycles per
C statement plus one cycle per opera-
tor in assignments and comparisons.
!To the end user, the only
relevant MIPS number is
MIPS is not the main problem, because,
now, languages, compilers, optimizers,
and processor cores are designed to
produce MIPS. The main problem is
Embedded memory blocks are operat-
ing in parallel and a new CPU archi-
tecture is used. [Determining millions
!the number of available,
unused MIPS when the sys-
the hierarchical memory that can have
an impact on the high level of perform-
ance required for some applications. No
of instructions per second (MIPS)] is a
complex problem for which there will
never be a single parameter to rate the
solution. One fundamental require-
!tem is running full blast
doing everything required.
compiler can manage this; solutions ex-
ist but are usually homemade. With
modern languages, when you write an
application, you describe the operations
ment comes down to response time. The be a mostly meaningless number be- not the operands. Often the operands
more things that are involved, the more tween 0 and several thousand. The rele- are just a variable declaration. The
complex the calculation. —KarlS vant number of MIPS is the number problems become more difficult when
left over after the MCU/SoC has ful- you have to share data in real-time mul-
To further complicate the equation, as filled all of its requirements—whether tiprocessing application. —global hawk
with programmable logic capabilities, that includes brushless DC motor con-
the internal hardware peripherals set trol, SPI communications, audio filter- Bottom line of the article: MIPS pa-
can have a pretty big impact too. For ing, video decoding, or whatever. To the rameter shows performance of CPU
example, hardware SPI, I2C, or PWM: customer or the end user, the only for ideal case of the full CPU load.
all of those can be implemented in soft- MIPS number that is relevant is the Most the real control tasks are too far
ware via bit-banging, but having hard- number of available, unused MIPS from this assumption due to peripher-
ware do all of the work can significantly when the system is running full blast als, SDRAM or DDRAM, cache, etc.
reduce the MIPS requirements. The and doing everything required of it. MIPS parameter is especially useful
choice of compiler can have an impact That is the resource available for the when comparing CPUs of the same ar-
too. How well does your compiler opti- customer to run his own apps or make chitecture. For example, if selecting
mize its code? Does it allow easy em- his own customizations. another MCU of Coldfire family with
bedding of inline assembly code? Food —Frank Eory a two-times faster clock, it’s reasonable
for thought to make an already complex to expect improving the FFT time
decision process even more so. Theoretical determination of the MIPS twice. Also MIPS parameter is useful
—Duane Benson requirement is for me seldomly useful. for estimating the CPU time of pure
What is more accurate is to get a practi- calculations, similar to digital filter.
It’s interesting how very differently soft- cal measure of certain critical execution —YevgeniT
ware designers and hardware designers profiles for a particular implementa-
think about this issue of MIPS and how tion. To this end the SDK’s are useful. We welcome your feedback. Letters to the
many are required for a particular ap- Once I have a good fit, I may apply editor may be edited. Send your comments to
Ron Wilson at ron.wilson@ubm.com or post a
plication. It may seem strange to a margin of 30% to 100% to the require- comment online, under the article you wish to
hardware designer, for example, to con- ment, this may be costly approach ini- discuss. We edit letters and posts for brevity.
>> Get to market faster with prototyping tools at ni.com/succeed 888 279 9833
©2010 National Instruments. All rights reserved. CompactRIO, LabVIEW, National Instruments, NI, and ni.com are trademarks of National Instruments.
Other product and company names listed are trademarks or trade names of their respective companies. 2412
By Michael Barr
barr code
Five more top causes of nasty embedded
software bugs
F inding and killing latent bugs in
embedded software is a difficult
business. Heroic efforts and ex-
pensive tools are often required to
trace backward from an observed
memory leaks whether we’re talking
about an embedded system or a PC
program. However, the long-run-
ning nature of embedded systems
combined with the deadly or spec-
crash, hang, or other unplanned tacular failures that some safety-
run-time behavior to the root cause. critical systems may have make this
In the worst scenario, the root cause one bug you definitely don’t want in
damages the code or data in a way your firmware.
that the system still appears to work Memory leaks are a problem of
fine or mostly fine—at least for a ownership management. Objects al-
while. located from the heap always have a
In an earlier column (“Five top creator, such as a task that calls
causes of nasty embedded software malloc() and passes the resulting
bugs,” April 2010, p.10, online at pointer on to another task via mes-
www.embedded.com/columns/ sage queue or inserts the new buffer
barrcode/224200699), I covered into a meta heap object such as a
what I consider to be the top five linked list. But does each allocated
causes of nasty embedded software object have a designated destroyer?
bugs. This installment completes the
top 10 by presenting five more nasty
firmware bugs as well as tips to find,
! What do memory leaks,
deadlocks, and priority
Which other task is responsible and
how does it know that every other
task is finished with the buffer?
fix, and prevent them.
!
Eventually, systems that leak even small Famers in the pantheon ship pattern or lifetime of each type
amounts of memory will run out of of heap-allocated object. Figure 1
free space and subsequently fail in of nasty firmware bugs. shows one common ownership pat-
nasty ways. Often legitimate memory tern involving buffers that are allo-
areas get overwritten and the failure isn’t registered until cated by a producer task (P), sent through a message
much later. This happens when, for example, a NULL queue, and later destroyed by a consumer task (C). To
pointer is returned by a failed call to malloc() and the the maximum extent possible this and other safe design
caller blindly proceeds to overwrite the interrupt vector patterns should be followed in real-time systems that use
table or some other valuable code or data starting from the heap.2
physical address 0x00000000.
Memory leaks are mostly a problem in systems that BUG 7: DEADLOCK
use dynamic memory allocation.1 And memory leaks are A deadlock is a circular dependency between two or more
tasks. For example, if Task 1 has already acquired A and is
blocked waiting for B while Task 2 has previously acquired
Michael Barr is the author of three books and over B and is blocked waiting for A, neither task will awake. Cir-
50 articles about embedded systems design, as cular dependencies can occur at several levels in the archi-
well as a former editor in chief of this magazine. tecture of a multithreaded system (for example, each task is
Michael is also a popular speaker at the Embedded
Systems Conference and the founder of embedded waiting for an event only the other will send) but here I am
systems consultancy Netrino. You may reach him concerned with the common problem of resource dead-
at mbarr@netrino.com or read more by him at locks involving mutexes.
www.embeddedgurus.net/barr-code.
Task P
Message queue
Task C
blocking for another mutex turns out to be a necessary con- gleton resource such as a global data area, heap object, or pe-
dition for deadlock. Holding one mutex is never, by itself, a ripheral’s register set. In the first part of this column (www.em-
cause of deadlock.3 bedded.com/columns/barrcode/224200699), I described two of
In my view, the practice of acquiring only one mutex at a the most common problems in task-sharing scenarios: race
time is also consistent with an excellent architectural practice conditions and non-reentrant functions. But resource sharing
of always pushing the acquisition and release of mutexes into combined with the priority-based preemption found in com-
the leaf nodes of your code. The leaf nodes are the device driv- mercial real-time operating systems can also cause priority in-
ers and reentrant libraries. This keeps the mutex acquisition version, which is equally difficult to reproduce and debug.
and release code out of the task-level algorithmics and helps to The problem of priority inversion stems from the use of an
minimize the amount of code inside critical sections.4 operating system with fixed relative task priorities. In such a
The second technique is to assign an ordering to all of the system, the programmer must assign each task it’s priority. The
mutexes in the system (for example, alphabetical order by mu- scheduler inside the RTOS provides a guarantee that the high-
tex handle variable name) and to always acquire multiple mu- est-priority task that’s ready to run gets the CPU—at all times.
texes in that same order. This technique will definitely remove To meet this goal, the scheduler may preempt a lower-priority
all resource deadlocks but comes with an execution-time price. task in mid-execution. But when tasks share resources, events
I recommend removing deadlocks this way only when you’re outside the scheduler’s control can sometimes prevent the
dealing with large bodies of legacy code that can’t be easily highest-priority ready task from running when it should.
refactored to eliminate the multiple-mutex dependency. When this happens, a critical deadline could be missed, caus-
ing the system to fail.
BUG 8: PRIORITY INVERSION At least three tasks are required for a priority inversion to
A wide range of nasty things can go wrong when two or more actually occur: the pair of highest and lowest relative priority
tasks coordinate their work through, or otherwise share, a sin- must share a resource, say by a mutex, and the third must have
a priority between the other two. The scenario is always as
Priority inversion. shown in Figure 2. First, the low-priority task acquires the
Priority shared resource (time t1). After the high priority task preempts
Inversion! low, it next tries but fails to acquire their shared resource (time
t2); control of the CPU returns back to low as high blocks. Fi-
nally, the medium priority task—which has no interest at all in
H the resource shared by low and high—preempts low (time t3).
At this point the priorities are inverted: medium is allowed to
use the CPU for as long as it wants, while high waits for low.
M There could even be multiple medium priority tasks.
The risk with priority inversion is that it can prevent the
high-priority task in the set from meeting a real-time deadline.
The need to meet deadlines often goes hand-in-hand with the
L
choice of a preemptive RTOS. Depending on the end product,
this missed deadline outcome might even be deadly for its
t t t time user!
1 2 3
Figure 2
RX Design Contest
you do with
n
ca
...
Zero-wait Flash
at will you d
Ethernet, USB, CAN
h
W
ow
ith...
t weapon...
re Over $110,000 in
Cash and Prizes
ec
Your s
Free to Qualified
Contestants,
the RX62N
Development Kit
Get details on how to enter, and the over $110,000 in cash and prizes.
www.renesasRulz.com/rx-contest
Renesas Partners participating in the RX Design Contest
!
embedded software developers being unaware of the proper
There is simply too little feedback from technique. There is simply too little feedback from non-repro-
non-reproducible deadline misses in the ducible deadline misses in the field to the original design
team—unless a death and a lawsuit forces an investigation.
prove that all deadlines will always be met. Note that the BUG 10: JITTER
method for doing this varies by the specific work-around. Some real-time systems demand not only that a set of dead-
lines be always met but also that additional timing constraints
Note that it’s safe to ignore the possibility of priority inver- be observed in the process. Such as managing jitter.
sions if you don’t have any tasks with consequences for missing An example of jitter is shown in Figure 3. Here a variable
deadlines. amount of work (blue boxes) must be completed before every
10 ms deadline. As illustrated in the figure, the deadlines are all
BUG 9: INCORRECT PRIORITY ASSIGNMENT met. However, there is considerable timing variation from one
Get your priorities straight! Or suffer the consequence of run of this job to the next. This jitter is unacceptable in some
missed deadlines. Of course, I’m talking here about the relative systems, which should either start or end their 10 ms runs
priorities of your real-time tasks and interrupt service rou- more precisely.
tines. In my travels around the embedded design community, If the work to be performed involves sampling a physical
I’ve learned that most real-time systems are designed with ad input signal, such as reading an analog-to-digital converter, it
hoc priorities. will often be the case that a precise sampling period will lead to
Unfortunately, mis-prioritized systems often “appear” to higher accuracy in derived values. For example, variations in
work fine without discernibly missing critical deadlines in test- the inter-sample time of an optical encoder’s pulse count will
CONTINUED ON PAGE 32
Figure 3
© Copyright 2010. Xilinx, Inc. XILINX, the Xilinx logo, Artix, ISE, Kintex, Spartan, Virtex, and other designated brands included herein are trademarks of Xilinx in the United
States and other countries. All other trademarks are the property of their respective owners.
cover feature
USB 3.0 offers new opportunities to boost battery life for both host and endpoint
functions thanks to comprehensive power management features that operate
autonomously at the hardware level.
High
Speed Super
Speed
as USB presents additional challenges. model was enhanced with the intro- market adoption. Table 1 outlines the
USB is one of the few peripheral buses duction of Link Power Management LPM entry and exit timing windows.
that allow different types of devices (LPM) in the EHCI specification 1.1.
with varying usage frequencies to at- The new LPM transaction is similar to USB 3.0: DESIGNED FOR POWER
tach simultaneously. Many of these the existing USB 2.0 suspend/resume EFFICIENCY
USB devices experience extended peri- capability, however—it defines a mech- Recognizing that continued adoption
ods of idle. In addition, developers anism for faster transition of a root of USB will require improved power
must contend with the growing popu- port from an enabled state (L0) to a efficiency, the USB Implementers Fo-
larity of devices that draw power or new sleep state (L1). Implementing rum (USB-IF) has made power man-
recharge batteries over USB. LPM requires changes at both the chip agement a cornerstone to its next gen-
The USB 2.0 power-management and software layers, which have slowed eration interface, SuperSpeed USB. For
backwards compatibility, USB 3.0 de- than offset by the improved efficiency of
vices are required to support both 2.0 3.0 data transfers. The USB-IF estimates
and 3.0 link speeds. USB 3.0 devices will the system power necessary to complete
maintain separate controllers and physi- a 20-MB superspeed data transfer will be
cal layers for high/full speed and super- 25% lower when compared with high-
speed links. To ensure power savings speed mode. This is possible because
gained while operating in USB 3.0 mode several architectural issues that ham-
are not lost when 3.0 hosts are connect- pered USB 2.0 power efficiency have
ed to legacy 2.0 devices, all USB 3.0 been enhanced in the USB 3.0 specifica-
ports (host and device) are now required tion below:
to support the LPM feature above when
operating at high/full speed. Correct
power-management operation in both
• Elimination of device polling by al-
lowing devices to asynchronously
signal when they need service from
the host.
!
The ability to use data streaming for
improved efficiency of 3.0 bulk transfers.
data transfers. • More efficient token/data/hand-
shake sequence.
13 W
12.5 W
Average system
System power
power using
high-speed
device
9.7 W
Average system
power using
superspeed
device
7.5 W
7W
Time
Figure 1
shows the power savings when using superspeed data transfer. These timers provide the flexibility to delay power state
Table 2 outlines the four power states in USB 3.0. Each transitions for specific applications, such as Blu-Ray disk
state incrementally lowers power use while increasing the al- writers, that could suffer usability problems if response la-
lowed exit latency. This method provides a more adaptive tency is introduced. The U1 and U2 inactivity timeout can
power-management model that uses timers and link-state be as long as 127 µs and 65 ms respectively. Sending an
awareness to reduce power use. Although the specifics of how LMP with the U1 inactivity timeout value between the
devices will lower their power draw are left to the vendor, range 0x01-0xFE also serves to implicitly enable the host
Table 2 outlines the link states defined by the USB 3.0 specifi- port to initiate U1/U2 transitions.
cation. 4. Host will inform the device of the U1/U2 System Exit La-
Most early 3.0 devices rely on inactivity timers to initiate tency using SET_SEL. Reporting System Exit Latency
entry into the U1 state. In the U1 state, these devices will typi- (SEL) allows the host to more intelligently manage power
cally reduce power to their SuperSpeed PHY. These devices will state transitions for periodic endpoints, such as isochro-
progressively lower power to other parts of the interface as the nous devices. SEL represents the total latency to transition
inactively period increases. In some cases, host ports will im- the entire path of links between the device and host from
mediately request transition to the most aggressive power sus- U1/U2 back to U0. It provides a mechanism for higher lay-
pend state (U3) during idle periods. This more rigid approach ers to reduce or even disable U1/U2 entry if system exit la-
to lowering power draw is generally initiated by higher layers
and is based on expected usage patterns for specific device
classes. USB 3.0 also preserves function-suspend features from
USB 2.0 allowing individual functions to be placed into a lower
power state. The remainder of this article explores the Super-
Speed power-management model and the power-state transi-
tions required by the USB 3.0 specification.
Keep dreaming.
Mouser and Mouser Electronics are registered trademarks of Mouser Electronics, Inc. Other products, logos, and company names mentioned herein, may be trademarks of their respective owners.
cover feature
Test tools capable of monitoring link state changes with independent been directed (by a higher layer) to initi-
timers in each state are essential for identifying timing violation ate a transition to U3 while a transition
to U1 or U2 has been initiated but not
yet completed, the host port should
complete the in-process transition to U1
or U2, then immediately return to U0
and request entry to U3.
Turn Key System Design ASIC Design Embedded Software Development FPGA & Board Design
Infotech Enterprises is an 8,000 employee Global Engineering Services company focused on providing “concept to
silicon and prototype” solutions for ASIC/FPGA Engineering and Embedded Software Development. Our comprehensive
and highly skilled design solution team has been serving the Hi-Tech Industry and the manufacturing OEM’s for 20 years.
We provide:
Innovative client centric solutions to meet current design requirements & roadmaps for future design trends
Reliable and cost effective services that combine global delivery with local interface
An impeccable track record of “first pass silicon success” over 200+ ASIC tapeouts
Australia | Canada | France | Germany | India | Japan | Malaysia | Netherlands | Norway | New Zealand |Sweden| Singapore | UAE | UK | USA
www.info t ech- enterprises.co m e n g i ne e r i ng @ i nf o t e ch - enterprises.com
feature
Tracing is useful both during development and after the software is released. Here is an
explanation of the different parts required for realizing a tracing function and how to
implement tracing of state-based designs with minimal effort.
In systems with real-time operating received, the task becomes ready and
systems (RTOSes), the individual state reads the event, for example, from a
machines typically run in its own task. message queue. The event is then
Tasks are generally constructed as processed from the state machine and
while () loops, and the task body real- eventually a state change happens. The
izes the state machine. After an event is task then waits for the next event. The
!
difference is that in the background a generated code is correct. You don’t
main loop executes the different state
In a non-RTOS design, have to worry about all the nitty gritty
machines one after the other. The state the difference is that in details of the realization of a state ma-
machines return immediately if an even- chine, such as handling history, han-
tually available event was processed. One
of the advantages of this design is that
the issues of task switching and re- ! the background a main
loop executes the differ-
dling hierarchical designs, placement of
entry/exit. If the machine does not do
what it should do, then most probably
source-sharing between RTOS tasks is
not relevant, as Listing 2 demonstrates.
In both designs, the individual state
machine can be coded by hand, such as
in C. But this is an error-prone task es-
! ent state machines one
after the other.
the model is not correct. To track down
the problem—especially in deeply em-
bedded real-time systems—typically
means to add a tracing mechanism that
allows you to see which events do fire.
pecially for hierarchical designs. In pecially if the model is not complete Here a code generator can support you
practice, a code generator can fully from the beginning and transitions or again by automatically generate trace
code that provides you with informa-
tion useful for debugging or testing.
Listing 2 State machine function in a non-RTOS system design. The trace data can be used both
during the development process and
1 void main(void){
after the software is released either on-
2
line or in a post mortem. The main ad-
3 …
vantage of dynamic analysis is that it
4 while(1){
can run in real-life production condi-
5 state_machine1(eventVar1);
tions. In practice, the information col-
6 state_machine2(eventVar2);
lection does disturb the system execu-
7 …
tion, but the disturbance may remain
8 }
extremely small, possibly negligible, in
9 }
many cases.
The Tracing Book on Wikipedia
1 void state_machine1(eventT event){
provides a good overview on the differ-
2 switch(state){
ent parts needed to realize a tracing
3 if(event==eventA){
function.2 Based on a small mobile ro-
4 // process transition
bot, these different parts are exemplary
5 ...
realized and discussed in the following
6 }
section of the article. Figure 1 shows
7 }
the hardware setup of the demo system.
m
Find it at
mathworks.com/accelerate
datasheet
video example
trial request
Run Matlab
Programs
in parallel
with
Parallel Computing Toolbox™
®
feature
Mobile robot used as demo to show the different parts needed for testing state machines.
PC side Target side
Communication link
Target
UDP
client
Target Event ids sent
com. via 868-MHz link
Wireless
USB interface
GUI + UDP server:
codegen.jar-S …
Figure 1
To log trace messages while the robot is be written to a trace buffer or sent serial link) to a PC; this second aspect
cruising, the connection to the moni- through the network (for example, a is called data collection and transfer.
toring PC was realized as wireless link.
Data providers are the basic mecha-
nisms to access the needed data, for ex- Listing 3 State machine with enabled tracing in line 6, 9, and 23.
ample by adding instructions to trace
the execution of some program section. 1 switch(instanceVar->stateVarEXPLORE){
2
!
3 case AHEAD:
Pullquote — please pull a 4
quote for this puillquote. 5 if(usDist<15){
6 behaviourTraceEvent(2U);
else
{
14 /* Intentionally left blank */
In state-based systems, an important 15 }
information to trace are the events 16 break;
causing a state transition. A state-ma- 17
chine tool can automatically create the 18 case TURN:
needed trace code. The code in List- 19 /* action code */
ing 3 shows trace code that was auto- 20 turned=turn(90,100);
matically inserted (lines 6, 9, 23) in the 21
generated cruising algorithm’s state 22 if(turned==1){
machine. Each event is uniquely identi- 23 behaviourTraceEvent(1U);
fied with an unsigned integer so the 24 /*Transition from TURN to IDLE4 */
overhead is minimized. In other words, 25 ...
no strings needs to be copied. 26 }
The event information must then
20 MHz - 40 MHz
100 MHz - 1 GHz
oscilloscope company.*
DC - 90 GHz Sampling
100 MHz - 1 GHz
!
1 const char* const behaviourTraceEvents[] = {
measure or identify inter- 2 “evTimeoutT0”,
esting properties or met- 3 “turned==1”,
!
4 “usDist<15”,
rics, such as number of 5 “usDist>30”,
processed events. 6 “evKey”
7 };
8
egnahc
means exploring new paths.
The entire range of key technologies and forward-looking innovations. Visit electronica
and the embedded Forum and experience their incomparable significance to the entire electronica 2010
industry—with today’s solutions for tomorrow’s applications.
embedded
Parallel event: hybridica. Trade fair for hybrid-component production. www.hybridica.de
With over 25% of all consumer electronic
devices in the world running on ARM processors,
the future may well be in your hands.
Are you ready?
Immerse yourself in Best-in-Class design strategies for the leading digital architecture – ARM.
NOVEMBER 9: Chip Design Conference
Conference: Centers around designing ICs using ARM cores. Learn from the best amongst the EDA,
foundries and hardware companies supporting the ARM architecture. Topics will span the gamut from
SoC architecture analysis and SoC IP to design, verification, reliability and yield. These sessions will
strengthen your hardware and chip design expertise.
Exhibition: Showcasing carefully selected tabletop exhibits from leading solutions providers, FRE
E
designed to make it easier for you to evaluate available support tools for chip design. SavEXPO PA
ou e $ SS
if y
NOVEMBER 10-11: Software & System Design Conference
pre 7
-reg 5
teris
Conference: The focus will be on designing systems and developing software around ARM-based hardware.
Learn about the latest ARM processors, roadmap and strategies. Optimize your ARM based design; through classes
taught by industry experts across the entire development chain from SoC, embedded, physical IP and EDA solutions to
software and tools.
Exhibition: theatre sessions, and a comprehensive exhibition hall, featuring the hottest new products to support the
entire ARM ecosystem. There will be giveaways, special events, and a few surprises too!
If your responsibilities span across both areas- we offer an all access pass to attend the entire conference, the
best value.
Take advantage of the only design conference dedicated to the ARM architecture and strengthen your
core design.
ENDNOTES:
1. Mueller, Peter. “State charts can provide
you with software quality insurance.” Em-
bedded.com, August 19, 2009, www.embed-
ded.com/219400531.
2. Tracing Book, Wikipedia.
http://lttng.org/tracingwiki/index.php/Trac- This Statement of Ownership will be printed in the November 2010 issue of this publication.
ingBook I certify that all information furnished on this form is true and complete. I understand that
anyone who furnishes false or misleading information on this form or who omits material or
3. Mueller, Peter. SinelaboreRT. SinelaboreRT
information requested on the form may be subject to criminal sanctions (including fines and
generates code from UML state charts. imprisonment) and/or civil sanctions (including civil penalties).
www.sinelabore.com.
4. Graphviz—Graph Visualization Software. Signature and Title of Editor, Publisher, Business
Manager, or Owner:
www.graphviz.org/
David Blaza, Publisher,
October 1, 2010.
ISR
10 ms 10 ms 10 ms
T
H
T
L
Figure 4
! system is to have someone perform a 3. In theory, the task that wants the mutex could starve while a series of
higher priority tasks take turns with the mutex. However, the rate mo-
thorough independent high-level review notonic analysis can be used to ensure this doesn’t happen to tasks
with deadlines that must be met.
Figure 4 shows how the interval of three different 10 ms 4. An additional benefit of this architectural pattern is that it reduces the
recurring samples might be impacted by their relative priori- number of programmers on the team who must remember to use and
ties. At the highest priority is a timer tick ISR, which executes correctly use each mutex. Other benefits are that each mutex handle
precisely on the 10 ms interval. (Unless there are higher priori- can be hidden inside the leaf node that uses it and that doing this al-
lows for easier switches between interrupt disables and mutex acquisi-
ty interrupts, of course.) Below that is a high-priority task
tion as appropriate to balance performance and task prioritization.
(TH), which may still be able to meet a recurring 10-ms start
5. One of the most famous priority inversions happened on Mars in
time precisely. At the bottom, though, is a low priority task
1997. Glitches were observed in Earth-based testing that could not
(TL) that has its timing greatly affected by what goes on at be reproduced and were not attributed to priority inversion until af-
higher priority levels. As shown, the interval for the low priori- ter the problems on Mars forced investigation. For more details,
ty task is 10 ms +/- approximately 5 ms. read Glenn Reave’s “What really happened on Mars?” account
(http://catless.ncl.ac.uk/Risks/19.54.html#subj6).
HIRE AN EXTERMINATOR 6. Barr, Michael and Dave Stewart. “Introduction to Rate Monotonic
As with any bug that’s difficult to reproduce, your focus Scheduling,” Beginner’s Corner, Embedded Systems Programming, Feb-
should be on keeping all five of these nasty bugs out of your ruary 2002. Available online at www.embedded.com/showArticle.jhtml?
system before they get in. For the particular bugs in this in- articleID=9900522.
stallment, the single best way to do that is to have someone 7. Barr, Michael. “Three-Things-Every-Programmer-Should-Know-
inside or outside your company perform a thorough inde- About-RMA,” Barr Code, Embedded.com, available at
pendent high-level review of the firmware architecture, look- www.eetimes.com/discussion/other/4206206/Three-Things-Every-
Programmer-Should-Know-About-RMA.
ing especially at task and ISR interactions and relative priori-
8. Barr, Michael. “Five top causes of nasty embedded software bugs,”
ties. Of course, coding standards and coding reviews are also
Embedded Systems Design, April 2010, p.10, available online at
helpful in picking up on some of these issues—as they were
www.embedded.com/columns/barrcode/224200699.
especially for the top five.8 ■
On Demand
Virtual Conferences
Embedded Linux
www.eetimes.com/linux EE Times, the leading resource for design decision makers in
the electronics industry brings to you a series of Virtual
Approaching Multicore Conferences. These fully interactive events incorporate online
www.eetimes.com/multicore learning, active movement in and out of exhibit booths and
sessions, vendor presentations and more. Because the
Advances in Power Management conference is virtual you can experience it from the comfort
www.eetimes.com/power
of your own desk. So you can get right to the industry
Digi-Key Symposium: information and solutions you seek.
Lighting and System Design
www.eetimes.com/lighting Why you should attend:
• Learn from top industry speakers
Maximizing the Flexibility of FPGAs
www.eetimes.com/FPGA • Participate in educational sessions in real time
• Easy access to EE Times library of resources
Medical Systems Design
www.eetimes.com/medical • Interact with experts and vendors at the Virtual Expo Floor
• Find design solutions for your business
Motor Control:
Intelligent Control Maximizes
Performance, Minimizes Power/Cost For sponsorship information, please contact:
www.eetimes.com/motor David Blaza, 415-947-6929 or david.blaza@ubm.com
An accumulation of stuff
I have a very strange job, if one were
to even try and glorify my efforts
with that three letter word. My com-
mute is 10 feet across the hallway, or 30
miles to Baltimore Washington Inter-
ter-Carr bearings; they’re bulky, with
the smallest being seven inches in di-
ameter and 3.8 inches thick. (See Fig-
ure 1.) Besides, one needs a bit of heft
so there’s room for the RJ-45 Ethernet
national. I work with people I never connection, which lets engineers moni-
see. Susan Rambo, for instance, has ed- tor the health of the bearing and un-
ited this column for years yet we’ve derstand loads imposed on it. Who
only been in each other’s presence four would have dreamed of an Internet-
or five times. I have never been given a enabled bearing?
charter or objective for these articles so The devices need only a 48-volt
have no idea if the powers that be— DC supply of power. They’re promot-
whoever they are—are infuriated or ed as being green due to the frictional
pleased with them. But frequent read- power savings, but one wonders how
ers realize that the subject matter is all much that is offset by the 48-volt
over the map, from opinions to book supply.
reviews to educational pieces about The thought of putting embedded
embedded systems engineering. smarts into something as boring as a
It’s rather unusual for me to write bearing is truly mind-bending.
about products. Who wants to be a
corporate shill parroting some press re- POWER STUFF
lease? But the PR people don’t seem to
understand this, and they send a daily
barrage of exciting news about new
! Catching up with the
incoming product
In unrelated news, Microchip intro-
duced yet another in their dizzingly-di-
verse families of PIC microcontrollers
version 4.1.2.c of the latest widget
(even fewer bugs than in 4.1.2.b!!!) or
breathless releases covering Joe Crony’s ! announcements, Jack
Ganssle finds a few
this year. The PIC18 “K22” series are
notable for their extremely low power
consumption. The most miserly parts
!
promotion to Executive Assistant Sub- consume just 75 microamps per mega-
Vice President. Most of it gets
gems (and some horror hertz at 1.8 volts. (Note that power
eTrashed, but occasionally something stories) to share. consumed in a digital circuit is propor-
grabs my attention and gets set aside. tional to V2F, where V is voltage and F
Sometimes for years. frequency. So, though these parts will
So here’s a potpourri of product controller inside the bearing! Sensors run at up to 5 volts, there’s quite a hit
announcements, ideas, and thoughts digitize the shaft’s position 15,000 on power consumption.) Sleep current
that have been piling up. I hope you times per second and feed that data is a miniscule 20 nanoamps, which is
find some of these as interesting into an on-board DSP. The processor so low it’s hard to measure.
as I do. drives a pulse-width modulator whose The company claims a “typical”
First there’s news in the bearing in- output goes to two high-power ampli- application can run for two decades on
dustry. Yep, bearings, those metallic fiers that control the magnetic field. a couple of AAs. That’s pretty close to
items that reduce rotational friction. A These are not your typical McMas- the self discharge rate of alkalines,
company called Synchrony (www.syn-
chrony.com) has introduced bearings
that hold the rotating shaft in position Jack G. Ganssle is a lecturer and consultant on embedded
development issues. He conducts seminars on embedded systems
with a magnetic field, essentially elimi- and helps companies with their embedded challenges.
nating friction and wear. That’s not Contact him at jack@ganssle.com.
new; what struck me is that their Fu-
sion line incorporates the required
!
for a peak of 30 mA with a capacity of space. Check it out here at
only about one milliamp-hour. But sol-
have a self-powered http://bit.ly/bnsdiR.
der it on to a board with a low-power embedded system.
PIC and a solar cell or piezoelectric DRAM STUFF
transducer and you’ll have a self-pow- How reliable are DRAMs? In the olden
ered embedded system. And that’s pret- against software standards (such as days, we assumed not-very and always
ty cool. MISRA and many others) as well as the had at the very least a parity bit associ-
deeper analysis of how the program will ated with each word, if not full error-
LIFECYCLE STUFF actually work: ranges of variable values, correcting code (ECC). An utterly fasci-
On another front, the folks at LDRA detecting unreachable code, and much nating—and horrifying—study by a
(www.ldra.com) gave me an indepth more. In dynamic analysis, the tool in-
demo of their products (and pizza) at struments your code to gather run-time
One of InfinitePowerSolutions’
the recent Embedded Systems Confer- information. Unit testing tools will
ence in Boston. I’ve been following build test harnesses with little user in- INFINERGY micro power modules.
LDRA for some time, both because of volvement. Couple these together and
their interesting products and since they the tools identify those hard-to-find
have some really smart people. I find it testing gaps.
hard to describe the Tool Suite as it’s Other LDRA tools manage require-
composed of a great number of individ- ments, a subject that induces narcolepsy
ual components that can work together in some developers, but which is be-
or alone (and they can be purchased in- coming much more important. Chang-
dividually). Their web site only hints at ing rules at the FDA and certification
the products’ capabilities. But these are requirements for avionics mean fewer of
software tools that, together, manage us can duck the thorny issues of, say, re-
pretty much the entire development quirements traceability. As this industry
lifecycle. matures, we will have to get more disci- Photo from the INFINERGY D-MPM 101-7A datasheet on
For instance, components can do plined at all aspects of building and www.infinitepowersolutions.com/product/infinergy.
Figure 2
!
and Wolf-Dietrich Weber, SIGMET- around.
RICS/Performance’09, June 15–19,
My takeaway: we need And that’s the rub. It satisfies an odd
2009, Seattle, WA. ACM 978-1-60558- mitigation strategies. niche—somewhere between a smart-
511-6/09/06) is available at phone and a laptop. Its size is one of its
www.cs.toronto.edu/~bianca/papers/sig- best features, but that size is too big for a
metrics09.pdf and is a must-read. takeaway is that we need mitigation pocket. I don’t care to wander around
Errors can be single-shot events strategies. Even if you could build a clutching anything, other than my wife.
like a bit corrupted by a cosmic ray or provably correct chunk of firmware, a On a business trip it would be nice as a
an all-out hardware failure. The au- watchdog timer is still needed to deal book reader, but the 3G versions are a bit
thors studied Google’s vast array of with these sorts of problems. High-rel expensive for that. Marybeth packs it in
servers over a couple of years and con- systems probably need serious ECC. It’s her purse most of the time, but for us
clude that error rates are 25,000 to wise to seed code with assertions that guys, unless we’re decked out with a
70,000 per Mbit per billion device are active at run time and that take re- man-purse, that’s not an option.
hours. Over 8% of the DIMMs they medial action. A friend brought his on a vacation
studied were effected by correctable er- The study shows that the funda- to Europe and was able to support his
rors; a typical DIMM has about 4,000 mental rule of computer program is customers without a laptop. There are
correctable errors per year. The error more important than ever: expect the pretty decent Office-like apps for it as
rate varies considerably by the hard- unexpected. well as SSH clients. The keyboard works
ware platform, leading the authors to extremely well, except accessing non-al-
think that some have better designs iSTUFF pha keys requires an extra keystroke, as
than others. They also conclude that Finally, I have to make a few com- on the iPhone. I doubt that it would
soft errors—like those from cosmic ments about this year’s non-embed- support any real development environ-
rays—are unlikely to be more common ded rage product, Apple’s iPad. It’s ment, though, and for real work I prefer
than hard errors. simply breathtaking. The display is so a big screen or three.
The numbers are scary and lead to crisp and clean it’s hard to imagine But it does fill a useful niche. And
many unanswered questions, like, does how the inevitable version two will did I mention the thing is just breath-
Google buy cheap chips? But my key improve on it. taking? ■
PCB Assembly
$50 in 3-Days
Advanced Assembly specializes in fast assembly for R&D prototypes, NPI, and low-
volume orders. We machine-place all SMT parts and carefully follow each board through
the entire process to deliver accurately assembled boards in three days or less.
aapcb.com/esd9
1.800.838.5650