We've been having this issue at work for weeks and neither us or the support guys at Atmel can think of a reason.
We are using the ATMEGA325P in a new design. During testing, we use JTAG (JTAGICE MKII) for realtime debugging on WinXP with AVR Studio 4.
During debugging, seemingly randomly, the AVR will suddenly refuse to connect to the JTAGICE. We then tried the ISP and found that it too refused to connect. We were able to confirm this after sending one of the chips to Atmel. They pulled it off the PCB for parallel programming and confirmed that the ISP and JTAG fuses had been disabled. This made sense since the last code would still run. This has happened several times now.
Our only clue so far is that our Programmer said he's seen the chip disable its own JTAG fuse before after ocassionaly freezing during debug. In that case, we used the ISP to restore JTAG.
I didn't think the chip could write to its own fuse locations from code so I would think it has to be happening during programming/debug maybe?
Sorry for the long read, but hopefully all the detail can help. Thanks for reading.