Clarifications on Flash Programming

Technical questions regarding the XTC tools and programming with XMOS.
Post Reply
jwegmanctmed
Junior Member
Posts: 4
Joined: Thu Sep 30, 2021 2:22 pm

Clarifications on Flash Programming

Post by jwegmanctmed »

Hello,

I'm looking to do remote firmware updates for my project over USB, and I'm having trouble figuring out exactly how this would work. I found the following post on this forum:

https://www.xcore.com/viewtopic.php?f=7&t=286

...and it has a lot of good information, but my slow brain is still missing something. The following app notes are helpful, but incomplete:

AN00154: Using flash memory for persistent storage. This example shows how to read data from a data partition.
AN00185: Boot an xCORE-200 device from QuadSPI flash memory. This app note explains how the xflash tool knows how to program the flash such that the XMOS will load its program from flash. On page 3 of the document, it shows how the flash is formatted in Figure 2. The figure shows:
  • A Flash loader (hardware protected)
  • A Factory image (also hardware protected)
  • Multiple regions labeled as 'Upgrade image'
  • A data region
This app note would seem to imply that you can place multiple loadable images into the flash, and then switch between them, which is obviously a common thing to do with microcontrollers. However, I'm missing how you actually do that programmatically. In the previous forum posting, I see how the poster finds the boot image and then seems to write to the region just beyond it. But what of the case of having multiple, bootable images? In an update case, I would want to:
  1. Write the new image from the running program.
  2. Reboot.
  3. If reboot fails, fall back to the previous image.
Am I trying to do something not possible with the current set of libraries, or if there something simple that I'm missing?

Thank you in advance,
Jake


RitchRock
XCore Addict
Posts: 186
Joined: Tue Jan 17, 2017 9:25 pm

Post by RitchRock »

Are you using the USB reference design firmware? If so, DFU is built-in. If you are trying to roll your own, I suggest you take a look at that code base to see how it was done.
jwegmanctmed
Junior Member
Posts: 4
Joined: Thu Sep 30, 2021 2:22 pm

Post by jwegmanctmed »

Hello,

Thank you for your question. That got me sleuthing on the tubes and I found all kinds of resources that XMOS has put out, albeit under the guise of audio development. It would be nice if they did a better job of compartmentalizing things in a way that made them easy to find and reconcile, but it's been this way for the last ten years, so I don't see them changing...
Slainte,
Jake
RitchRock
XCore Addict
Posts: 186
Joined: Tue Jan 17, 2017 9:25 pm

Post by RitchRock »

Can't argue with that assessment.

When I programmed my own DFU over ethernet, the AVB example and Part J Flash Programming in the Tools Guide were my go to resources: https://www.xmos.ai/download/Tools-User-Guide(6).pdf
mmar
Experienced Member
Posts: 122
Joined: Fri Jul 05, 2013 5:55 pm

Post by mmar »

Hi
you ask for function , that exist in first part
  • A Flash loader (hardware protected)
here standart xcode place loader , that detect factory and updates and start latest. When you need any switching you need rewrite and use custom loader.
But for only update not needed. Simply write to desired address bin file with upgrade.
Your point 3. is little more complicated, reboot to factory is real only when update image have any validity check for example AES ...
darasan
Newbie
Posts: 1
Joined: Fri Oct 29, 2010 8:10 am

Post by darasan »

Hi Jake,

If you want to be able to boot multiple firmware images, you need to write a custom bootloader. You can read how to do that here, it's quite straightforward:

https://www.xmos.ai/download/AN00109:-M ... .1rc1).pdf

Hope that helps,

Daire
Post Reply