AnsweredAssumed Answered

FLASHB, High Space Block programming

Question asked by mike stuart on Aug 15, 2018

Hi All, I have a question regarding flash programming on SPC5644A.

We have an existing bootloader implementation - this works fine to do any of the following:

  • erase any block in either FLASHA or FLASHB
  • Programming any block in FLASHA
  • Programming Low and Mid Space blocks in FLASHB

 

What I cannot do is program High Space blocks in FLASHB *correctly*.

For example program 32 bytes at address 0x00100000, the first High Space block in FLASHB, 512kB in size.

Programming is performed by 32bit word, in sets of 8 (the page size is 256bits). After a set of 8 words written, the EHV programming sequence is applied.

 

We write this test sequence at 0x00100000:

      0xAAAA5555,0x12345678,0xAAAA5555,0x12345678,

      0x98765432,0xFAFAFAFA,0x98765432,0xFAFAFAFA,

After the EHV cycle is finished, we read the flash at 0x00100000 and see this:

      0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,

      0xAAAA5555,0x12345678,0xAAAA5555,0x12345678,

      0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,

      0x98765432,0xFAFAFAFA,0x98765432,0xFAFAFAFA,

     

The exact algorithm is:

erase FLASHB High Space block 0 at 0x00100000 

set FLASHB mode to WRITE

Unlock FLASHB High Space block 0

Select FLASHB High Space block 0

Write Words:

int w;
uint32_t* FlashAddress = (uint32_t*)0x00100000;
const uint32_t* Data = mydata; // 32 bytes as above
for(w = 0; w < 8; w++) {
    *FlashAddress = *Data;
    FlashAddress++;
    Data++;
}
FLASHB->MCR.B.EHV = 1;
volatile uint8_t tmp = FLASHB->MCR.B.DONE;
while(tmp == 0) {
    tmp = FLASHB->MCR.B.DONE;
}
bool Result = FLASHB->MCR.B.PEG == 1;
FLASHB->MCR.B.EHV = 0;

set FLASHB mode to READ

 

There is something odd about addressing within these 256 bit pages in the High space blocks, any insights or advice would be amazing.

 

Thanks

Outcomes