2013-07-11 06:19 AM
Hello,
is F4 Flash write can be random or only sequential? I've tryed to doFLASH_Unlock();
FLASH_EraseSector(FLASH_Sector_8, VoltageRange_3);
for(i=0, EEAddr=EEA;i<32;i++){
FLASH_ProgramWord(EEAddr, ParArray[i]);
EEAddr+=4;
}
FLASH_Lock();
and all works fine, but when I try to do this:
FLASH_Unlock();
FLASH_EraseSector(FLASH_Sector_8, VoltageRange_3);
for(i=1, EEAddr=EEA+4;i<32;i++){
FLASH_ProgramWord(EEAddr, ParArray[i]);
EEAddr+=4;
}
FLASH_ProgramWord(EEA, ParArray[0]);
FLASH_Lock();
the 1st word, that I've tried to write at the end, does not writes.
1st 4 bytes are still ''FF''.
So, write to flash should be sequential?
2013-07-12 08:29 AM
Nobody knows?
2013-07-12 08:53 AM
Nobody knows?
Why do people say this in forums, honestly it's like yelling into a vacuum. In space no one can hear you scream. As far as my experience goes you can write flash in a sparse/random fashion, providing the location you're writing is blank. There may be additional impediments wrt to the bit width of the flash lines, which I suppose are 64 or 128 bits here. Experiment, that's what I'd have to do to confirm either way.2013-07-12 09:00 AM
>As far as my experience goes you can write flash in a sparse/random fashion, providing the location you're writing is blank.
So, why the second code does not works? I making the Firmware Upgrade, and I wish to write all code, except the 1st aplication's word - the starting word of the Vector Table, that Bootloader check before jump to application. And only in case of susscessfuly writing of application - to program the 1st word. But, this word remains 0xFFFFFFFF. The same thing in a parameters section of flash (this code was shown) - I want to program at first the words from [1] to [31], and only after this - [0]. Not works. From [0]to[31] - works.2013-07-12 01:30 PM
just a note, the files generated by Keil for flash load are NOT sequential.
Erik2013-07-12 01:34 PM
stupid website decalres error even when post posted
Erik2013-07-12 03:18 PM
So, why the second code does not works?
I'm not convinced it fails, it's working for me, I think you're doing something else wrong. Do the write or erase signal a failure?void FlashBackward(void)
{
int i;
unsigned long EEA = 0x08080000;
unsigned long EEAddr;
static unsigned long ParArray[32] = {
0x00010203,0x04050607,0x08090A0B,0x0C0D0E0F,
0x10010203,0x14050607,0x18090A0B,0x1C0D0E0F,
0x20010203,0x24050607,0x28090A0B,0x2C0D0E0F,
0x30010203,0x34050607,0x38090A0B,0x3C0D0E0F,
0x40010203,0x44050607,0x48090A0B,0x4C0D0E0F,
0x50010203,0x54050607,0x58090A0B,0x5C0D0E0F,
0x60010203,0x64050607,0x68090A0B,0x6C0D0E0F,
0x70010203,0x74050607,0x78090A0B,0x7C0D0E0F };
FLASH_Unlock();
FLASH_EraseSector(FLASH_Sector_8, VoltageRange_3);
for(i=1, EEAddr=EEA+4; i<32; i++)
{
FLASH_ProgramWord(EEAddr, ParArray[i]);
EEAddr += 4;
}
FLASH_ProgramWord(EEA, ParArray[0]);
FLASH_Lock();
for(i=0; i<32; i++)
{
printf(''%08X '',*((unsigned long *)(EEA + 4 * i)) );
if ((i % 8) == 7)
putchar('
');
}
for(i=0; i<32; i++)
{
if (*((unsigned long *)(EEA + 4 * i)) != ParArray[i])
printf(''FAIL @ %2d
'', i);
}
}
2013-07-13 01:46 AM
> the files generated by Keil for flash load are NOT sequential.
What does it means?! >I'm not convinced it fails, it's working for me, I think you're doing something else wrong. Very interesting! I show all the code, that not works! Will try to check again. > Do the write or erase signal a failure? I didn''t checked.2013-07-13 03:55 AM
> the files generated by Keil for flash load are NOT sequential.
What does it means?!
I'll let Erik confirm, but what I think he means is that things like HEX files do not have to have contiguous linear streams of data. They can be sparse (have gaps leaving 0xFF in the ROM, or whatever), and the records do not have to be in any particular order. Object files are often generated in this way because it's much easier for the LINKER to emit data in small blocks and in an interleaved manner. The two fold benefit being that it doesn't have to hold an entire memory image of the application, which has to be managed as it grows, and also it eliminates several passes over the data to get the placement order and sequencing done. The point being that it's safer to assume HEX files are randomly ordered, than linear/sequential, and that if the flash failed under such conditions more people would have tripped over it.
2013-07-14 12:40 AM
I do not use .hex file to firmware upgrade, I use encripted .bin for firmware and nonencripted for ''eeprom''.