OTA in never ending loop of copying firmware from external memory

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
JoBe_1971641
Level 1
Level 1

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.

0 Likes
1 Solution
JoBe_1971641
Level 1
Level 1

Looks like I got it working.  I really have no idea how I got it working.  I swear I didn't change anything.  But after a couple of fits of clean-and-builds, it started working.

View solution in original post

0 Likes
2 Replies
himam_31
Employee
Employee
50 likes received 25 likes received 10 likes received

Hello,

   

We have another project with SPI NOR flash link:https://github.com/cypresssemiconductorco/PSoC-4-BLE/tree/master/100_Projects_in_100_Days/Project051.... Please have a look at the project.

   

Thanks,

   

Hima

0 Likes
JoBe_1971641
Level 1
Level 1

Looks like I got it working.  I really have no idea how I got it working.  I swear I didn't change anything.  But after a couple of fits of clean-and-builds, it started working.

0 Likes