These are some the forum threads I have read before submitting this question:
This is the documentation I have studied:
- PSoC_Creator_Component_Author_Guide (chapter 10) - this is the only documentation I could find on "custom bootloader"
Here is the general idea:
- I am developing a product using PSOC5LP which has an external I2C EEPROM.
- This EEPROM is 2Mbit, but a large portion of the memory is used up for other things.
- I have converted the contents of the .cyacd file generated at compilation to a .bin file which will be used to perform an over-the-air update. This .bin file is 256 bytes per line, and will be written to EEPROM a page at a time (256 bytes/page). I will do my own checksumming and data integrity during the write process to EEPROM. I do not wish to use Cypress's checksum features, etc. The .bin file contains only firmware data, and nothing else.
- The importance of not writing additional .cyacd information to EEPROM is both due to minimization of overall data transferred over the air, as well as memory used in EEPROM.
- The data needs to be stored in EEPROM first, not in flash.
- The data needs to be stored as binary data only, without checksum information, etc. so it is aligned to each page in EEPROM.
In bootloaders I have used previously, you write data to flash memory, do any checksums, etc. as needed, verify the write completed, continue until all data is written to flash, and then reset the chip (and sometimes you may swap a flag to revert to previous code if there's a flash write error somewhere in the middle of the process).
I'm having difficulty understanding the process for implementing a custom bootloader to read data out of an I2C slave device, write it to flash, and reset the chip. All of the examples I have seen seem to indicate there's a host present somewhere sending commands and receiving responses. In my case, the PSOC5LP micro is the host, with an I2C master in the bootloader code taking data out of external memory and writing it to flash.
My understanding is that there are 5 functions that need to be implemented:
void CyBtldrCommStart(void) - this function starts the I2C master
void CyBtldrCommStop(void) - this function stops the I2C master
void CyBtldrCommReset(void) - this function resets data pointers (clear cached data, etc.)
cystatus CyBtldrCommWrite(uint8 *data, uint16 size, uint16 *count, uint8 timeOut) - this function would technically write data to a host, but what if the "host" is an EEPROM slave device ?
cystatus CyBtldrCommRead(uint8 *data, uint16 size, uint16 *count, uint8 timeOut) - this function reads data from EEPROM device -- I assume that Cypress state machine is going to write contents of data to flash here?
In my case, there is no concept of CyBtldrCommWrite, because the host would only be communicating with itself. Or maybe, I'm very confused.
I need some help in understanding the concept of reading from EEPROM, writing it to flash, and resetting the micro from a custom bootloader. Is this functionality supported within the bounds of these 5 functions?