Embedded Systems Firmware Demystified

Chapter 4: Assembly Required

Overview

This chapter explains how MicroMonitor handles basic system startup. Here you will learn how the system initializes the execution context, including stack, exception handlers, and important state information.

This startup code is critically important: if it s not right, nothing else will work right. It is also notoriously machine-dependent. To get this part of the monitor right, you must:

  • come to terms with the system s memory map;

  • identify some means of distinguishing between a power cycle and warm restart;

  • master the machine exception handlers;

  • learn how to save the entire processor state;

  • correctly disable any cache;

  • initialize and manipulate a communications port.

Thus, the startup code involves many machine-specific details and until you get them all correct, you won t have enough working machine to support any code-based debugging. Even so, a great deal of the structure can be coded in relatively machine-independent C. This chapter details the high-level portions of this structure and explains what considerations the lower-level board support code must address. Along the way, I ll point out some of the more important design tradeoffs you ll need to consider to adapt the code to your own projects.

Just After Reset

The code executed immediately out of reset must be written in assembly language. The reset code should be written so that it can be executed either as a result of a real reset or powerup of the hardware or as a result of a firmware-invoked restart. (These two types of system startups are commonly referred to as

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Emergency Stop Switches
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.