I have a PSoC4 BLE project that needs to do OTA updates to an external SPI based flash memory. It is using the CY84248FNI-BL483 device, which means it has a 256B page size for the internal flash. My external SPI based flash also has a 256B page size.
Updating the flash via the CySmart iOS app (which I downloaded the source code for and compiled locally installing an image to update), I choose the "stack and app" option for updating (for future reference, it fails if I choose app only, too). I can see via a UART that the flash all makes it to the external memory successfully (every page passes its checksum). I can also see that when the bootloader reboots, it checks the external flash and sees that the checksum of the entire image is valid.
I then get the UART output that says it is copying the external flash image to internal flash. When it is done, however, it checks the checksum of the copied app, and it fails. So it says the internal flash is invalid and the external flash is "loaded", so it schedules a reboot to copy it again, and this continues for eternity. The external image is always valid checksum, but the internal flash is saying the app is invalid.
For debug, I went even deeper into Bootloader.c of the bootloader (i.e. the generated code), and had it spit out the bytes it was using to calculate its checksum. I figured maybe a row was missing or something silly. But as I did this byte-by-byte dump, things look off. Right within the first page, there are bytes that are incorrect. Eventually, whole pages will have issues (like, things will by shifted by several bytes from the same row in external flash). However, I can't tell if I'm even really looking at the right thing at this point, or am just seeing bytes and concocting a pattern in my brain.
I built this project based upon the example "external_memory_interface" boot loader and bootloadable projects, which used I2C as the external interface, and run on the CY8CKIT-042 dev kit that has a 128B page size for the internal and external flash. I made the changes to move from I2C to SPI, and I'm sure those changes are correct, because as I said, each row is passing its checksum, and the entire image in external flash is valid (so it passed its checksum).
I'm thoroughly stumped here. I don't know if there is some clocking issue? Is there some other change that is needed that I'm not aware of due to the change from the example code on a 128B page size to a 256B page size? It's incredibly frustrating. It's not a hardware problem, because it fails the same way on every board (image copies to external flash successfully, passes checksum, fails after copying internal with a bad app checksum, reboot to copy it again).
Attached is the project.
Wavelet.cywrk_.Archive.zip 2.2 MB