The Challenge of Debugging Cache Coherency Problems

The following is an example of a cache-related embedded software bug that is a real challenge to solve for several reasons, not the least of which is the fact that the actual problem was masked in the debugger’s view of memory. One nasty bug that came up recently for us was the realization that we […]

Read More

So you want to be an independent contractor?

Today’s post is motivated by the events that happened yesterday in Austin, Texas. For my overseas visitors, a software engineer, Joe Stack, decided to fly his light aircraft into an office building that housed the regional offices of the IRS (the American tax office). He created tremendous damage and likely murdered at least one person, while killing […]

Read More

Firmware-Specific Bug #3: Missing Volatile Keyword

Failure to tag certain types of variables with C’s ‘volatile’ keyword, can cause a number of symptoms in a system that works properly only when the compiler’s optimizer is set to a low level or disabled. The volatile qualifier is used during variable declarations, where its purpose is to prevent optimization of the reads and […]

Read More

Firmware-Specific Bug #2: Non-Reentrant Function

Technically, the problem of a non-reentrant functions is a special case of the problem of a race condition.  For that reason the run-time errors caused by a non-reentrant function are similar and also don’t occur in a reproducible way—making them just as hard to debug.  Unfortunately, a non-reentrant function is also more difficult to spot in […]

Read More

Firmware-Specific Bug #1: Race Condition

A race condition is any situation in which the combined outcome of two or more threads of execution (which can be either RTOS tasks or main() plus an ISR) varies depending on the precise order in which the instructions of each are interleaved. For example, suppose you have two threads of execution in which one regularly increments a global variable […]

Read More

Embedded Software is the Future of Product Quality and Safety

Last year a friend had a St. Jude pacemaker attached to his heart. When he reported an unexpected low battery reading (displayed on an associated digital watch) to his doctor a month later, he learned this was the result of a firmware bug known to the manufacturer. The battery was fine and would last on the order […]

Read More

Efficient C Tip #11 – Avoid passing parameters by using more small functions

This is the eleventh in a series of tips on writing efficient C for embedded systems. Today’s topic will, I suspect, be slightly controversial. This post is based upon two basic observations: Passing parameters to functions is costly. Conditional branch instructions can be very costly on CPUs that have instruction caches (even with branch prediction). I don’t […]

Read More

Is GCC a ‘good’ compiler?

It seems that barely a month goes by when I’m not asked my opinion on compilers. Sometimes I’m simply asked what compilers I use, while other times I’m asked my opinion on specific compilers – with GCC being by far the most asked about compiler. I’ve resisted writing about this topic because quite frankly it’s […]

Read More

Goto heresy

Today’s post is prompted by an email I received from Michael Burns. With his permission I have reproduced his email below. Hi Nigel, What is your opinion on the usage of goto in C? Sometimes when a routine has many conditions [usually for error handling] I have used a do {..} while(0); loop with breaks […]

Read More