Programming a Butterfly (ATMega169)
2006-03-08 by Chuck Hackett
I have successfully compiled the Atmel Butterfly demo program after converting it from CodeVision to WinAVR(gcc) ... (at least I'm now at the point where I just get warnings about 'char' types being used as array subscripts, etc. which I'll address later). I used AVRStudio to program the butterfly via JTAG with the Butterfly mounted on an ECROS Technologies Butterfly carried board. When I brought up AVRStudio and programmed the m169 I got the following from AVRStudio: ...... start .............. Loaded objectfile: C:\Documents and Settings\Charles Hackett\My Documents\AVR Stuff\Butterfly\Copy of Demo Application Source\main.elf JTAG ICE: Warning: Execution stopped on boot loader reset vector. JTAG ICE: Warning: Boot reset fuses are programmed, but the program entry function is located in the application section. Wrong boot reset fuses will probably cause erronous execution. JTAG ICE: Warning: If this is not an error, this check can be disabled in the 'Debug' section in the JTAG ICE options. ...... end .............. The Atmel hex file was running fine before I tried my version. Fuses are set as follows (to my knowledge these are 'as shipped'): JTAGEN (JTAG Enable) SPIEN (SPI Enable) BOOTSZ=00 (4096 words) BOOTRST (Boot Reset vector enabled) BODLEVEL=1 (Brownout 2.7v) CKSEL=0010, SUT=10 (2Mhz RC Osc.) Lock Bits are set as follows (to my knowledge these are 'as shipped'): Mode 1: No memory lock features enabled Application Protection Mode 1: No lock on SPM and LPM in Application Section Boot Loader Protection Mode 1: No lock on SPM and LPM in Boot Loader Section I am only somewhat familiar with compiling for and loading an 'application' to an AVR (ATMega16's and 128's). I am not at all familiar with the intricacies of boot loaders and would prefer to let that go for another day. I have looked at the application code, and from what I can tell, the only 'boot' stuff it has in it is a section of code that enables the Watchdog Timer and then enters an infinite loop waiting for the AVR to be reset and (I assume) enter the boot loader. I thought that, since I'm compiling the Atmel demo, that all would be well and that the application and boot loader would cooperate but I guess there is something about this setup I don't understand. So ... Since I am currently loading the Butterfly using the JTAG interface can I disable the boot loader but leave it in memory in case I want to use it later? To accomplish this do I just un-program the BOOTRST fuse? On the other hand: If I wanted to recover the memory for use in my application how would I go about it and how do I restore the boot loader at a later time? Thanks for your time in helping me along ... Cheers, Chuck Hackett "Good judgment comes from experience, experience comes from bad judgment" 7.5" gauge Union Pacific Northern (4-8-4) 844 http://www.whitetrout.net/Chuck