AnsweredAssumed Answered

S32K144: Read 1s All Blocks command

Question asked by David Gabbay on Jan 22, 2020
Latest reply on Feb 26, 2020 by Daniel Martynek

I run the "Read 1s All Blocks" command over a S32K144 block (0x800B) which I know it's all erased (I checked it with a customized function as depicted below).
When I issued the command (see below) the return MGSTAT0 bit in register FSTAT is set, suggesting that Read-1s fails.

I run this command with all 3 Margin levels which return the same result.


int  chk_block_earesed(u32 addr, int Margin_level)
int rc;

addr &= ~(PROG_SEC_SIZE-1);
FTFC->FSTAT= 0x70;
FTFC->FCCOB[3]= 0x00; /* (RD1BLK) Read 1s Block command */
FTFC->FCCOB[2]= (addr>>16)&0xff ;
FTFC->FCCOB[1]= (addr>> 8)&0xff ;
FTFC->FCCOB[0]= 0x00 ; /* address [2:0] = 000 */
FTFC->FCCOB[7]= Margin_level ;

rc= (int)FlashCommandSequence();
rc= (int)(FTFC->FSTAT & 0x7f);
return rc;


The stand alone-function (assembler, to speed-up the loop) is:

check if a given block is all-one
int DG_isAll_One(uint32_t addr, int16_t byte_size);
note: byte_size must be N*4
note: addr must be aligned to 4
r2= cur loop fetch addr
r3= loop-cnt
r4= temp fetch
r5= result

Author: David Gabbay
.align 2
.globl DG_isAll_One
.weak DG_isAll_One
.type DG_isAll_One, %function

lsrs r3, r1, #2 /* div by 4 */
bgt all_1s_cont /* do the job if valid size */
blx lr /* return if not valid size */

push {r4-r5,lr} /* save non-volatile reg */
orr r2,r0,r0 /* make r2 loop_addr */
ldr r5,[r2] /* get 1st operand */
b all_1s_lp

add r2,0x4
ldr r4,[r2]
and r5,r5,r4

subs r3,r3,1 /* chk loop-cnt */
bgt all_1s_lp /* continue if */
mvns r0,r5 /* set result */

pop {r4-r5,pc} /* restore reg + return to caller */



I decided to use this command because I had encountered issues (always the same address out of many) when I tried to program the p-flash.