# $Id: README,v 1.1 2006/04/19 00:56:51 cnguyen Exp $

Boot0 Code
----------

This is the first version of the boot0 code which will be executed out
of ROM at power-up.  Boot0 is responsible for reading the code for
boot1 from flash into SRAM, decrypting it, and verifying its hash.  
Boot0 consists of the following files:

boot0_sram1.s:  This is an assembler code file that contains the reset
		vector code that is first executed.   This code sets
		up a stack at the top of SRAM, and then jumps to the
		routine bootc() in the next source file.

bootc.c:	This is a C language source file that contains the
		remainder of the boot code.

		The outline of this code is as follows: This code
		first initializes the HW devices (aes, sha, flash, and
		eFuse).  Next it loads a 94KB chunk from the first 
		block on the flash device.  The block is decrpyted and 
		hashed.  The hash value is checked against an expected 
		hash value stored in the eFuse. If the hash check
		succeeds, then newly loaded code is executed.

		The aes key (bootKey) and iv (bootIv) are two
		byte arrays defined in external C files and will be 
		linked with the boot0 image.
       
The main routines in bootc.c are described below:

loadBoot1:	Load the next stage of the boot process.  This function 
		loads a 94KB "block" from the first block of the flash         
		device a page (2KB) at a time.  Each page is error-
		corrected, decrypted, and hashed.   The code takes
		advantage of overlap in the operation of read, decrypt
		and hash to set up a pipeline of operations, so as to
		make the operation of Boot0 faster.

		If the eFuse hash is 0 (as in bring-up), the boot code
		will skip the hash verification step.

checkEcc:	This function checks the computed ECC syndrome(s) with
		the ECC value(s) stored on flash for a single flash 
		page. If a single-bit error is discovered, it is repaired.  
		A double-bit error causes the boot process to fail. The
		argument 'buf' points to 'pageSize' bytes of flash page 
		data, 'spare' points to a 128-byte buffer that contains 
		the stored ECC values in the lower 64 bytes and the 
		computed ECC values in the upper 64 bytes.

readEfuse:	Read the expected hash value from Efuse.

The remaining routines in bootc.c are utility routines to set up the
devices required for boot0 to work, or to configure access by the
IOPto these devices.

# eof
