Specifications

Developer’s Serial Bootloader, Rev. 13
Master applications user guides
Freescale Semiconductor62
int read_blk(unsigned adr, int len, BYTE *dest)
int prg_blk(unsigned a, int len)
The actual implementation is straightforward and follows the rules described in Interpreting MCU
commands.
9.6.7 Main programming loop
The core of the bootloaders programming capabilities is implemented in the function int
prg_area(unsigned start, unsigned end)
. The function of this routine is to read data from an image
and split the data into appropriately sized blocks (minimum erase/write block sizes). Then the erase block
and write block routines are called, in that order.
The routine also prints the progress information to the standard I/O (for example, block boundary
addresses and progress indicator).
One additional auxiliary function, int prg_mem(void), is included. It retrieves the lowest and highest
memory addresses that must be programmed because those addresses are used for calling the int
prg_area(unsigned start, unsigned end)
function.
9.6.8 CRC calculation
The new version of bootloader protocol add option to secure serial communication protocol by
CRC-CCITT check. So the PC source code contains a few basic primitive functions to support this
possibility:
void CRC_AddByte(unsigned short *pCrc, unsigned char data)
void CRC_AddWord(unsigned short *pCrc, unsigned short data)
void CRC_Add3Bytes(unsigned short *pCrc, unsigned long data)
void CRC_AddLong(unsigned short *pCrc, unsigned long data)
void CRC_AddByteArray(unsigned short *pCrc, unsigned char* data, int size)
void CRC_AddString(unsigned short *pCrc, unsigned char* str)
void CRC_ResetCRC(unsigned short *pCrc, unsigned short seed)
unsigned short CRC_GetCRC(unsigned short *pCrc)
9.6.9 Final unhook
Function int unhook(void) sends out the Quit command.
10 Master applications user guides
The bootloader binary code (S19 file) is loaded in the MCU like any other regular 8-bit MCU (using
MON08 serial programmer or other, for HCS08 using BDM interface). Then the MCU is soldered, or
socketed, in the application.
Using the bootloader preprogrammed into the MCU, the user can download the 8-bit MCU user
application code via SCI interface using the bootloader utility.