- Embedded systems tend to lack a display, keyboard, and mouse with which to manipulate the microcontroller that you’re trying to program. So a host computer is used for this function, and typically communicates over a serial cable or more recently, Wi-Fi.
- Once a code is created, edited, and compiled for the embedded system on a host computer, there will be an executable (object) code that needs to be uploaded to the microcontroller in the embedded system.
- There, the code can be seen in action, can be tested, and the code debugged by making changes to the code on the host, recompiling, and running it again on the target MCU.
- But if we want to alter the contents of a register, memory, or the state of I/O to see what happens, then an in-circuit emulator can be used.
- An In-circuit emulator (ICE) is a debugging tool that allows us to access a target MCU for in-depth debugging. The function of emulator is 'debug the target firmware'.
- In-circuit emulation is rather rare in these days of high-performance, relatively low-cost processors because ICE needs to be invisible to the system, which is difficult to do with extremely fast, memory-intensive chips.
- ICE is the best tool for finding difficult bugs and can provide invaluable insight.
- The ICE is physically connected between the host computer and the target MCU. The debugger on the host establishes a connection to the MCU via the ICE.
- ICE allows a developer to see data and signals that are internal to the MCU, and to step through the source code (e.g., C/C++ on the host) or set breakpoints.
- Since the debugging is done via hardware, not software, the MCU’s performance is left intact for the most part, and ICE does not compromise MCU resources.
- This type of debugging is also referred to as source-level or run-time debugging, except ICE is as close to the real scenario as possible, as it’s not a simulation but a substitution of the target MCU with an emulation, or accurate mirror, of the target MCU in the ICE itself.
Disadvantages –
- The disadvantage of ICE debugging is that the ICE hardware must be physically connected to the MCU.
- Another disadvantage is that ICE devices come with a learning curve, especially if there will be complex debugging functions, for example, flagging when a register holds a specific value after a conditional branch is taken, etc.
Parts of hardware emulators:
i) Emulation device:
It is replica of target CPU which receives various signals from target board through device adapter connected to target board and performs the execution of firmware under the control of debug commands from debug application.
ii) Emulation memory:
It is a RAM. It is a replacement to EEPROM. Emulation memory acts as a trace buffer in debugging.
iii) Emulator control logic:
It is a logic circuit used for implementing complex hardware breakpoints, trace buffer trigger detection, trace buffer control.