I use "mc68hc908lk24" and connect it with "EEPROM" through "IIC" and i want to make bootloader to Read bin file from EEPROM and load it to its Flash.
Hello, and welcome to the forum.
I notice that you are attempting to use a device from the now obsolete HC908 family. A member from the later MC9S08 family would be a better choice.
What do you mean by a "bin file" - do you mean a "binary image"? In this case, the EEPROM contents would need to represent the image of the full 24576 bytes of flash memory, minus the amount occupied by the bootloader code.
Alternatively, the EEPROM could contain the program data in S19 format. This could occupy more EEPROM space, since the binary data is represented by two ASCII characters per byte, and there are additional overheads for start address, number of bytes, and the checksum for each line. But only the flash areas that actually contain code would need to be programmed. The bootloader would need to translate each S19 line into binary data, but this should be a relatively simple process.
The bootloader will need to redirect all the interrupt vectors to a secondary vector table within the user flash area, usually immediately below the bootloader.
I am not sure how you would intend the bootloader should operate. Following a reset, it would need to determine whether an EEPROM device was present, and then do a byte-by-byte comparison of the EEPROM code with the flash code. Only if there were any differences would the EEPROM data be written to flash. With S19 format, the contents of the unused flash would not need to be tested.
The bootloader would make use of monitor ROM routines to erase and program the flash memory.
Retrieving data ...