It seems that xflash always erases the data partition, how can I avoid this?
xflash --version
Community_14.2.0 (build 11257, May-12-2016)
Code is loaded to xCORE-200 MC Audio board using:
xflash --id 0 --boot-partition-size 0xF0000 bin\2i2o2xxxxxx\whatever_2i2o2xxxxxx.xe
SW can read/write data partition, boot itself, and data is still there after power cycle.
But after repeating xflash command, the data partition is erased i.e. all 0xFF.
The xflash --erase-all option is not being used.
It tried --no-erase-all, but xflash does not accept that.
Using xflash -v (verbose) option shows a suspicious "-D ERASE_ALL_FIRST=1" define:
XFlash_Programmer_Program::DoProgram
XFlash_Programmer_Program::GenerateSource
XFlash_Programmer_Program::IssueCompileCommand :xcc -w -Xmapper --dontenablesodlinks -O2 -lquadflash -x xc "fp-6ce4f476" -x xn "target-xn-v0-9ce72226" -D VERBOSE=1 -D MONITOR=1 -D ERASE_ALL_FIRST=1 -o "fp-c2a02c26"
XFlash_Utils::BuildRunCommand : xrun --io --id 0 fp-c2a02c26
Site 0 has finished successfully.
XFlash_Programmer_Program::IssueResetCommand : xgdb --batch-silent --ex "connect --id 0" --ex "reset mode-pins nointerrupt" --ex "q"
xflash erases data partition?
-
- Member
- Posts: 10
- Joined: Fri Jun 17, 2016 10:04 am
-
- Member++
- Posts: 22
- Joined: Thu Apr 10, 2014 9:39 am
Hello,
This is the expected behaviour of the command.
Can you specify the contents of the data partition when you re-flash the firmware using --data option?
This is the expected behaviour of the command.
Can you specify the contents of the data partition when you re-flash the firmware using --data option?
-
- Member
- Posts: 10
- Joined: Fri Jun 17, 2016 10:04 am
Then why is there an --erase-all option?Choughtosh wrote:This is the expected behaviour of the command.
This doesn't make any sense.
I don't specify a --data option.Choughtosh wrote:Can you specify the contents of the data partition when you re-flash the firmware using --data option?
I expect xflash to erase/write the necessary sectors needed for .xe file, and leave the rest of the flash alone.
-
- Respected Member
- Posts: 275
- Joined: Fri Mar 12, 2010 6:03 pm
It's also useful to be able to erase the flash to make sure an older version of your program doesn't start instead of latest debug version that you download over JTAGsnap wrote:Then why is there an --erase-all option?
-
- Experienced Member
- Posts: 74
- Joined: Mon Dec 16, 2013 12:14 pm
XFLASH will erase the entire device when it is instructed to program a new factory image. This is in effect a factory reset! If you are using a data partition you will need to also specify the partitions using the option --boot-partition-size and also specify what data if any to put into the data partition (--data). Note that if you do not specify the --boot-partition-size option then there is no data partition, all flash memory is treated as the boot partition.
If you need to preserve the data partition, then you must perform an upgrade. In this case you are writing to flash memory an upgrade image to be booted instead of the default factory image providing there is adequate room in the boot partition to store the upgrade image. See the section 'Perform an in field upgrade' in the Design and manufacture systems with flash memory document.
If you need to preserve the data partition, then you must perform an upgrade. In this case you are writing to flash memory an upgrade image to be booted instead of the default factory image providing there is adequate room in the boot partition to store the upgrade image. See the section 'Perform an in field upgrade' in the Design and manufacture systems with flash memory document.
-
- Member
- Posts: 10
- Joined: Fri Jun 17, 2016 10:04 am
So the default behaviour is --erase-all?colin wrote:XFLASH will erase the entire device when it is instructed to program a new factory image.
Then why does --erase-all option exist?
And why is there not an option to override the default behaviour? (e.g. --no-erase-all)
-
- XCore Legend
- Posts: 1126
- Joined: Thu May 27, 2010 10:08 am
YesSo the default behaviour is --erase-all?
Looks like a vestige from earlier versions. If you add -save-temps to the command line and look at the "fp-???????" file, you can see the source of the flash programming agent. In older versions, I think the call to fl_eraseAll() was guarded by the define ERASE_ALL_FIRST. This still would not have helped though because it would have erased nothing.Then why does --erase-all option exist?
Same reason that any software doesn't support a particular feature. There has been no demand and/or priority to add the feature and verify it.And why is there not an option to override the default behaviour? (e.g. --no-erase-all)
I think the closest you can get without rolling your own, is to use the --data <file>, but first doing an --read-all -o <file> and a bit of binary file hackery with a script to chop off the boot partition, leaving just the data. Something like
Code: Select all
dd bs=1 skip=<boot partition size in bytes> if=whole_flash.bin of=data_partition.bin
Beware that read all takes a long time though on big flashes.
-
- Member
- Posts: 10
- Joined: Fri Jun 17, 2016 10:04 am
Already been there: --read-all takes >7 minutes, which obviously is unacceptable.infiniteimprobability wrote:first doing an --read-all and a bit of file hackery with a script to chop off the boot partition first. Read all takes a long time though on big flashes.
I will find another way to circumvent xflash.
-
- XCore Legend
- Posts: 1126
- Joined: Thu May 27, 2010 10:08 am
Oh, OK - was just trying to think of ideas for you.Already been there
For speed, I would recommend a small program that reads the data partition and dumps it to a file using fileio (although it's fileio that is the bottleneck - at least you won't be reading/writing the whole flash). Then do your flash, and run a small program to write it back in.
The data partition functions in quadflash.h will provide simple access to data flash with the added bonus of protecting against writing over the boot partition
Code: Select all
/**
* Returns the size of the data partition in bytes.
* \return The size in bytes.
*/
unsigned fl_getDataPartitionSize(void);
/**
* Reads data from the data partition.
* \param offset The offset from the start of the data partition in bytes.
* \param size The number of bytes to read.
* \param dst Array to fill with data.
* \return 0 on success, non zero on failure.
*/
int fl_readData(unsigned offset, unsigned size, unsigned char dst[]);
/**
* Returns the buffer size required for fl_writeData() with the given
* parameters.
* \param offset The offset from the start of the data partition in bytes.
* \param size The number of bytes to write.
* \return Buffer size on success, 0 if writing is not possible.
*/
unsigned fl_getWriteScratchSize(unsigned offset, unsigned size);
/**
* Write data to the data partition. If not writing a whole number of sectors
* a scratch buffer is required. The minimum size of the required buffer can be
* determined by calling fl_getWriteScratchSize().
* \param offset The offset from the start of the data partition in bytes.
* \param size The number of bytes to write.
* \param src The data to write.
* \param buffer A scratch buffer.
* \return 0 on success, non zero on failure.
*/
int fl_writeData(unsigned offset, unsigned size, const unsigned char src[],
unsigned char buffer[]);
/* Page level functions. */
/**
* Returns the page size in bytes of the connected flash device.
* \return Page size.
*/
unsigned fl_getPageSize(void);
/**
* Returns the number of pages in the data partition.
* \return Number of pages.
*/
unsigned fl_getNumDataPages(void);
/**
* Write to the nth page in the data partition. The sector containing the page
* must have been erased previously.
* \param n The page number to write.
* \param src The data to write.
* \return 0 on success, non zero on failure.
*/
int fl_writeDataPage(unsigned n, const unsigned char src[]);
/**
* Read the nth page in the data partition.
* \param n The page number to read.
* \param dst The array to fill with data.
* \return 0 on success, non zero on failure.
*/
int fl_readDataPage(unsigned n, unsigned char dst[]);
/* Sector level functions. */
/**
* Returns the number of sectors in the data partition.
* \return The number of sectors.
*/
unsigned fl_getNumDataSectors(void);
/**
* Returns the size in bytes of the n-th sector in the data partition.
* \param n The sector number.
* \return The size in bytes.
*/
unsigned fl_getDataSectorSize(unsigned n);
/**
* Erases the n-th sector in the data partition.
* \param n The sector number.
* \return 0 on success, non-zero on failure.
*/
int fl_eraseDataSector(unsigned n);
/**
* Erases all sectors in the the data partition.
* \return 0 on success, non-zero on failure.
*/
int fl_eraseAllDataSectors(void);