K60/K20 flash programming - reg access to ftfl

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

K60/K20 flash programming - reg access to ftfl

1,242 Views
richyankee
Contributor II

I am working on a fw updater for the internal flash on two boards, one based on a K60 and the other a K20.  IAR embedded workbench is the toolset.

On the K20 board - bare metal <no operating system> The first thing that happens when I attempt to execute a flash command (I have tried read 1s section and erase) is that when I write to the FSTAT (0x40020000) to cause command execution (parameters previously written to the FCCOB registers), from a RAM copy of the flash command execution code), the processor goes to a hard fault handler.

I thought this was due to having interrupts enabled in the FCNFG register (and not having installed an interrupt handler for it), but this is not the case.(The IE bits in FCNFG are == 0)

I decide to observe the flash operations on the K60 board (running MQX) to verify that I had the method and sequence of operations correct, so I rebuilt the bsp with flashx driver and added an _io_open(), _io_write() and_io_read() for the flash driver in my main.

The flash driver successfully erases a sector, programs 0x800 bytes (using 32-bit flash writes) and all looks good.

The surprise to me is that when I add a few lines of register writes/reads to the main (to verify that I can set the values in the ftfl registers), the writes do not work at all on the first three regs (FSTAT, FCNFG, FSEC). In this environment, there is no bus error or fault occurring, just that the writes do not have effect.

I'm not sure what I missed here, because the other  registers in that space are writable (FCCOBn).

Thank,

Rich

Labels (1)
0 Kudos
1 Reply

398 Views
mjbcswitzerland
Specialist V

Hi

Don't know what is happening but maybe check:

- all interrupts are disabled when executing the actual Flash command

- check bus speeds to be sure than no clocks (bus, Flash etc.) are out of range

- clear any previous flash errors before starting a new command sequence

- check that previous previous flash commands have completed before executing a new one

Regards

Mark

www.uTasker.com

0 Kudos