Hi,
... DBUG12 ... "Can't Write Target Memory".
This has nothing to do with code for writing data to flash. Interesting that in your first post it didn't look like you aren't able to upload your code into your board. Check if your prm-file settings are compatible with dBug12, also if interrupt vectors are where dBug12 expects them to be. Serach box at the bottom of this page may help you.