The reason flash writing is locked maybe caused by overwriting this protected section of memory:
define block CFMPROTROM with size = 20 { section .cfmconfig };
define block FLASHX_POOL with alignment = __FLASHX_SECT_SIZE { section .flashx };
define block TEXTSECTION with alignment = 4 { section .text };
keep { section .cfmconfig };
keep { section .flashx };
in the icf file, there was a 20 words of CFMPROTROM reserved for flash protection.
For whatever reason, these positions were written over (wrong) and locked the flash. So out board could not be programed.
Since a RAM based program can still be downloaded and run, we tried to modify the registers and unlock the protection. I'm not exactly 100% sure what we dit but the chip is now recovered.
I want to look into this a bit more to understand what is going on..