Mark, thanks.
Yes, I seem to be all over the map here just trying to solve my problem. Not starting a new development, we have working code for the product, but just as my customer was ready to start a large build, they asked for the security. I just seem to keep getting foiled however I try to implement this.
My goal is to find a way to secure the flash, i.e., set FTFA_FSEC in the flash security configuration field bit 0 to a 1. This, as you know, is loaded into the FSEC register at reboot. So I've been trying:
1. Setting the desired data in the startup file, just as Xiangjun Rong pointed out above. This is what has been thwarted by the debugger in kds. I have not been able to find configuration that changes the behavior of not allowing the protection to be set in the security configuration field (long word at 0x0408). I'll continue to look for that, but so far no luck.
2. My second approach to setting the protection to write code to directly write the field. I've pulled in just the routines I need from the KDSK 1.3 to erase a sector and then write the field. I simply do an init, an erase sector, and a program of the bytes in question. Trouble is, though the commands compile and complete with non-error return codes, the flash never changes. So now I'm wondering if the driver is just not operating properly or I'm missing some step necessary to write the flash.
I suspect that many have successfully protected the flash in this environment, just hoping to find someone who has done it successfully and can point me to something that works.