Hey I am currently working on a program that uses the IAP functions and also having problems with programming sector0. Check out the thread here:
IAP via JTAG on LPC1754 #3
It would seem that there is some behavior in sector0 that is not documented, and I am also still waiting on an explanation.
That said, are you making sure to erase the sector before trying to perform the write?
EDIT
I got a response back from the very helpful @Carlos_Mendoza
To program sector0 you need to follow these steps:
1) Relocate interrupt table to RAM by writing new address to VTOR (0xE000ED04)
a)So copy the data in flash from 0x0-0x1F to your new RAM location. Remember that from 0x10000000-0x100001FF is used by the IAP, so relocate it to 0x10000200 or higher.
2) Erase sector0 with erase sector IAP command.
a) I found it necicary to reset the core after an erase before I could send another IAP command.
3) Program secotr0 with copy ram to flash command
a) Check that data includes 2s comp checksum at 0x1C
4) Restore VOTR to 0x0
5) Power cycle
/EDIT
Best Regards,
Peter