So I need to change/ compile a program written for the ICCV Avr compiler using Atmel Studio 6 using GCC. I no longer have access to the ICCV compiler. I've successfully done this with smaller programs before but I'm having issues with this larger and much more complex program. The major difference with this program is that I'm having to store some constant variables in the __flash named address space.
I've gotten the program to compile with no errors and few seemingly insignificant warnings (e.g. variable is used uninitialized in this function)but when I go into debug mode it seems like nothing is actually being written to program memory. When I pause the debugger the disassembly window pops up and it seems the program counter has gone out of bounds so when I scroll to the top I sometimes see "nop" despite seeing the placing for the functions at certain points in the non-existent assembly code or other times see some code with "??? memory out of bounds" seemingly randomly placed in the code. I can get the program to at least reach a breakpoint in the simulator.
After trying to debug just once I can't enter debug mode again until I go to the device programming window, set the "use external reset" then erase the memory on the chip. If I don't do this it will always say "unable to enter programming mode." Once I do erase the memory I can change the "use external reset" back to off and I can do whatever I want until I try to program the chip again.
There are no lock bits set and the jtagice fuse is set and the cksel bits are set correctly to the external clock so I don't think that has anything to do with it.
Details: Using JTAG mkII in programming an ATmega 640 using Atmel studio 6.1.2674 with AVR GCC 4.7.2
Any help would be greatly appreciated. There's no way I can post the entire code as there's 20+ files worth. If posting any portion of it would be helpful please let me know.