Global Sources
EE Times-Asia
Stay in touch with EE Times Asia
EE Times-Asia > Controls/MCUs

"Divide and conquer" prevents errors on hosts and targets

Posted: 02 Dec 2002 ?? ?Print Version ?Bookmark and Share

Keywords:error prevention? embedded system? host error prevention? microprocessor? microcontroller?

Using traditional debugging techniques to remove errors in embedded microcontroller- and microprocessor-based systems development is a difficult task that requires time and effort. Fortunately, a better approach to error removal has evolved to meet the needs of software developers.

Error prevention - the process and practices for preventing bugs before they even occur - is crucial for the efficient and timely production of reliable embedded products. Error prevention in embedded systems is a two-stage, "divide and conquer" effort that prevents errors on both the host and target systems.

The first stage involves preventing errors on the host system. Starting embedded error prevention on the host is cost and time advantageous for several reasons. The large variety of analytical tools available for standard software-development platforms makes it easier to test and validate software on the host system. Code corrections can easily be made and validated immediately, saving valuable time. By ignoring the target, error prevention is focused on a software-only environment, instead of an environment where software and hardware are interconnected.

Error prevention on the host comprises two distinct phases. The first phase includes validation of coding constructs (static analysis). The consistent use of coding constructs, or industry-standard coding rules, ensures that erroneous or dangerous coding practices do not turn into debilitating errors when the code is compiled and run.

The best method of ensuring consistent use of coding standards is to use an advanced source code analysis tool that automatically enforces industry-standard and custom C and C++ coding rules. Such tools contain specially designed rules for embedded systems. These embedded coding standards can be expanded with extensions that allow a developer to graphically create their own company, personal, or target-specific embedded coding standards.

Software development is a difficult task, but the difficulties inherent in embedded systems development demand that developers do not take any chances with their code. Static analysis tools provide cost and time savings for embedded developers, along with the priceless knowledge that their coding constructs are fully validated. However, static analysis is only one part of a well-defined error prevention strategy. It is limited to finding C/C++ language errors and must be supplemented by unit testing at the function level.

The second phase of host error prevention is focused on unit testing, which examines the construction and functionality of the code to determine how well it works, and the reasons for any operational failures. This type of testing is valuable, but it is also dangerous. The manual creation of test harnesses, stubs and test cases is a complex and slow process, making unit testing a very difficult and time-consuming activity.

Unit testing is very important in embedded systems, as it enables developers to exercise code on the host system and analyze and fix errors before they reach the target platform. However, the benefits of unit testing are not limited to the host system. The same tool mechanisms can also automatically generate test cases that can be compiled directly into the instrumented executable and executed when testing the target system. This is stage two of a comprehensive embedded systems error prevention strategy, and it provides developers with direct and valuable insight into the design and behavior of the target system under actual operating parameters.

In stage two, the software and hardware come together on the target system. If the stage one practices were followed successfully, then approximately 70 to 80 percent of potential errors that could have been ported to the target will have been eradicated. The remaining errors will most likely be hardware-related, but to be sure that no preventable software errors remain, it is necessary to conduct unit tests on the software directly on the target system.

To conduct unit testing on the target, an executable of the validated and tested code is instrumented using a cross compiler. A small set of test cases from the unit-test session on the host is compiled into the executable. These test cases address specific input values and other expected data in order to examine the software within the actual operational environment.

The target runs all hard-coded tests and reports back to the host via a serial interface or a TCP/IP connection. Unit testing in small hard-coded clusters is repeated - the instrumented executable is recompiled - until all necessary unit tests have been compiled and executed on the target. Any necessary code modifications made at this stage are verified by regression testing, running the same series of hard-coded unit tests to verify the code changes.

- Adam Kolawa

Chief Executive Officer

Parasoft Inc.

Article Comments - "Divide and conquer" preve...
*? You can enter [0] more charecters.
*Verify code:


Visit Asia Webinars to learn about the latest in technology and get practical design tips.

Back to Top