SOLVED: Busy wait longer than 3 seconds for fl_startImageAdd to finally return flash ready

Technical questions regarding the XTC tools and programming with XMOS.
Post Reply
susnak
Member
Posts: 13
Joined: Fri Apr 12, 2019 1:01 pm

SOLVED: Busy wait longer than 3 seconds for fl_startImageAdd to finally return flash ready

Post by susnak »

Dear all,
I am using the reference audio class implementation on a custom board with x208 and QSPI external flash.
With a new prototype, I started experiencing failed DFU updates. I narrowed it down to this piece of code in module_dfu/flash_interface.c
do
{
result = fl_startImageAdd(&factory_image, FLASH_MAX_UPGRADE_SIZE, 0); */
} while (result != 0);
which takes more than 3 seconds to finally break out of the busy wait. This also blocks Endpoint0.
I have an idea how to work around that, but first, I wanted to make sure whether this behavior is expected.
Cheers,
Zdenek

UPDATE: It turns out the USB current limiter on the custom board was active. After disabling it, it now seems to be working just fine.


User avatar
akp
XCore Expert
Posts: 578
Joined: Thu Nov 26, 2015 11:47 pm

Post by akp »

Glad you solved it. I had a similar problem with other code where I changed the FLASH_MAX_UPGRADE_SIZE from 128k to 256k. What takes time is all the sector erases. I interleaved the sector erase and page writes (i.e. if there's still a sector that needs to be erased, erase it, then do the page write. otherwise just do the page write).
susnak
Member
Posts: 13
Joined: Fri Apr 12, 2019 1:01 pm

Post by susnak »

The current limiter was just a part of the problem. It still takes more than 3s, but during that time, I return STATE_DFU_DOWNLOAD_BUSY in DFU_GetStatus. I also set some nonzero timeout and keep calling fl_startImageAdd from there.
My FLASH_MAX_UPGRADE_SIZE is only 64kB.
User avatar
akp
XCore Expert
Posts: 578
Joined: Thu Nov 26, 2015 11:47 pm

Post by akp »

Right, my problem was with the AVB in-system upgrade, not DFU, so a little different there, anyway.
susnak
Member
Posts: 13
Joined: Fri Apr 12, 2019 1:01 pm

Post by susnak »

I've run into this issue again with xu316 and 8MB qspi flash. This time around, fl_startImageAdd takes up to 20 seconds to become ready. My FLASH_MAX_UPGRADE_SIZE is now close to 2MB.
Does anyone know if there is a way how to speed this up?
Post Reply