Embed version number at specific location in spi flash.

Technical questions regarding the XTC tools and programming with XMOS.
jmag99
Active Member
Posts: 35
Joined: Tue Jul 20, 2010 9:45 pm

Embed version number at specific location in spi flash.

Post by jmag99 »

Is there any way to embed a code version number in the spi flash at a known location so that another processor can read the spi flash and get the version number of the code on the xmos processor? Ideally, I would like to be able to do this from within xde. Any ideas?


User avatar
Bianco
XCore Expert
Posts: 754
Joined: Thu Dec 10, 2009 6:56 pm

Post by Bianco »

Hello jmag99,

A SPI flash can be divided into a boot partition and a data partition using an XMOS specific format.
Using xflash you can write a binary file to the data partition. The application on the XMOS processor itself can also read or write from the data partition using libflash. A version number can be stored into this data partition.

It is also possible to store multiple boot images for one processor and a bootloader will pick the latest version. A version number will be stored with each boot image (in the boot partition). This way might be a bit more difficult, because to retrieve the version number, the application needs to understand the format of how data is stored in the boot partition.

Furthermore one should be careful that the second processor will not drive the SPI bus while the XMOS processor is accessing the SPI flash while booting.
jmag99
Active Member
Posts: 35
Joined: Tue Jul 20, 2010 9:45 pm

Post by jmag99 »

How would I find out about writing binary data using xflash? I do not see this in the xflash manual.
User avatar
Bianco
XCore Expert
Posts: 754
Joined: Thu Dec 10, 2009 6:56 pm

Post by Bianco »

Usage: xflash [options] file...

By default xflash will try to connect to a target in order to determine
which flash device is being used even when outputting only to file. To
prevent this connection supply the --noinq option.

Overall Options:
--factory [<node>] <file> [size]
Specify factory image for <node>.
--upgrade <id> <file> [size]
Specify upgrade image
--boot-partition-size <n>
Specify the size of the boot partition as <n> bytes
--data <file> Write the contents of <file> to data partition
--loader [<node>] <file> Use boot loader functions defined in <file> for node
<node>
--verbose Display information about program when loaded
--version Display the version of the programmer
--help Display this information
--idnum <num> When making a bootable image, override the identifier
code with <num>
--idstr <str> When making a bootable image, override the identifier
string with <str>

Target Options:
-l, --list-devices Display all devices connected to this machine
--id <id> Specify target adaptor ID (reported by -l)
--adapter-id <serial> Specify target adaptor by its serial number
--jtag-speed <n> Set the JTAG divider to <n>
--spi-spec <file> Enable support for the SPI device defined in <file>
--spi-div <n> Set the SPI clock divider to <n>
--noinq Do not connect to a target device

Security Options:
--key <keyfile> AES-encrypt images in boot partition
--disable-otp Disable OTP access after booting
--enable-otp Enable OTP access after booting

Programming Options:
-o <file> Place output <file> (disables programming)
--target-file <xn-file> Specify target platform from <xn-file>
--target <platform> Specify target platform from device path
--erase-all Erase all memory on the SPI device
--read-all Read contents of SPI memory (use with -o)
--write-all <file> Write contents of <file> to SPI device

Compatibility Options:
-992compat Make any upgrade images 9.9.2 compatible

For bug reporting instructions, please see:
http://www.xmos.com/support
jmag99
Active Member
Posts: 35
Joined: Tue Jul 20, 2010 9:45 pm

Post by jmag99 »

Thanks this helps. It keeps telling me that there is not enough space when I add the data file (which is 8 bytes long). I have defined the boot sector size, but I think by default the data partition size is 0. I don't see a way to change this.
User avatar
Bianco
XCore Expert
Posts: 754
Joined: Thu Dec 10, 2009 6:56 pm

Post by Bianco »

When you specify the boot partition size with a smaller size than the total available memory in the flash chip, the remaining space will be partitioned as the data partition.

You can run this example on your XMOS processor to check whether it is partitioned correctly:

http://github.xcore.com/repo_index/sw_f ... eadme.html