So I just recently finished a standalone pcb utilizing the atmega1280 chip. I have wrote all the code in the arduino IDE. I would like to be able to use the existing code I have written and upload it through AVR studio 4. Last night I uploaded the *.hex file in avr studio that was generated in the arduino IDE but nothing seemed to work correctly. The atmega1280 of course has no bootloader, but from what i've read as long as your using the MKII you shouldn't need the bootloader. The hex file that I uploaded programmed fine but nothing was working correctly. There's an lcd, buttons, buzzers, mosfets... all that jazz. So I decided to try the bootloader. I used the atmega1280 bootloader supplied with the arduino IDE files, but it bricked the chip (Changed the fuse settings) - probably from my lack of experience. The only way to recover would be to use a HVPP I suppose.
I'm going to build another board today, but i don't want a repeat of last night. Will the hex file work without the bootloader, I see in avrstudio all the pins are mapped using a different method, not using the pinMode(53, OUTPUT); could this be what the bootloader assists with or is the bootloader just for say using a USB instead of a programmer like the MKII.
I have done lots of research but no straight forward answers that I can find. Any help is greatly Appreciated.
Also whats the *.ELF file :(
Thanks a bunch
So far the only thing I could find was that the hex file generated doesn't work without the arduino bootloader, can anymore confirm? Would the ELF file work?
Do you specifically want to use Studio or just get away from the IDE?
Doesn’t matter what I use, I just need to be able to get the sketch that I wrote in the arduino IDE onto my new board. The arduino IDE I’d like to stay away from.
Doesn't matter what I use, I just need to be able to get the sketch that I wrote in the arduino IDE onto my new board. The arduino IDE I'd like to stay away from.
Try using AVRDUDE with command line control?
Thats the thing though, how will the 1280 be able to understand the programming from the arduino IDE. I can't seem to find a proper bootloader anywhere.. if that is what I need.
Thats the thing though, how will the 1280 be able to understand the programming from the arduino IDE.
There are a stack of bootloaders under the Arduino install folder, one is called ATmegaBOOT_168_atmega1280.hex so presuably that's the one to use.
You'll heed to ISP the BL into the chip (there is a sketch to use another Arduno I think but I've just used a programmer).
Once done you can use any editor and a makefile. I've been using Netbeans until yesterday but now think I prefer Notepad++ (after some recomendations on this forum) and a DOS window to run the makefile.
I can supply a makefile example if you get to that point.
Im in AVR studio right now. All im going to do is under the program → flash → input hex (bootloader file) same as you suggested, its listed in the arduino boards.txt…
Will the bootloader change any of my fuse settings? before I go ahead and hit program
Ok the bootloader is on, no problems, now if I upload the makefile in avr studio will it overwrite the bootloader?
Did you verify that the BL works, say by downloadeing blink from the IDE.
You don't "upload" the makefile you just run make and it executes commands based on the makefile contents.
So what it will do to your fuses etc depends on the makefile, where did you get it from?
I have done this type of thing plenty with a 328P and it works fine and no bootloader required. I write the code in Arduino IDE, click compile, the hex file can be unloaded using AvrStudio or Eclipse (I use a USBTinyISP). I do ensure the chips fuses are set correctly and the external oscillator is set as per the Arduino IDE. The AVR chips are set to 1Mhz internal (8MHz with divide by 8 ) by default when you buy them. Have you tried a simple blink just to be certain?
Here is a ref to the *.elf
So I changed the fuse bit settings for:
And its bricked, cannot enter programming mode. WTF!!!!!!!
mega.name=Arduino Mega (ATmega1280)
Also the bootloader file I used was in the C:\Users\metroexpress\Desktop\arduino-0022\hardware\arduino\bootloaders\atmega\ATmegaBOOT_168_atmega1280.hex
I've tried every combination of fuses in Studio and cannot get the same fuse values so therefore I don't know what exactly has been programmed. It's possible the SPIEN fuse has been cleared which will stop any further ISP programming.
One thing to check is your clock, is there a clock running on the board? If an external clock is selected with the fuses (which is should be) and there is none it won't program.
This is outside the scope of what I was talking about though, I understood that you had the boot loader successfully loaded and I was suggesting using a makefile to download a sketch.
It's possible to do what snowman suggests as well, but I haven't done so. I prefer to use the bootloader so I have less crap (ie the programmer) on my (very small) desk.
You have a programmer right? Which one?
SPIen is still enabled i think.
Ok the website to check fuse values are here
I changed the fuses from default to:
I'm using an avr isp mkII. There is a crystal on my board 16Mhz.
I just tried my 1280 with 16Mhz clock and your fuse settings(FFDAF5). I have up loaded with and without bootloader with Arduino IDE, Eclipse and AVRDude via command line and everything work as expected (using USBTinyISP). I sent different data to a LCD
I even changed the driver for the mkII and tried in the arduino IDE but i got
Binary sketch size: 46760 bytes (of a 126976 byte maximum)
avrdude: stk500v2_command(): command failed
avrdude: initialization failed, rc=-1
Double check connections and try again, or use -F to override
im very confused now lol, how in the world could it go from working perfectly to nothing that quick :-/
Ok so now, every time I try and plug it in, I get
mosi and sck lines appear to be shorted.
I've checked and checked there not shorted though, could it be pullups or something?.
So far I built 2 boards everything was fine until I changed the fuses to those settings. Now both boards are saying mosi and sck are shorted :-/
Problem solved, I used two 10uF caps on XTAL 1 and 2, changed to 22pF worked like a charm, thanks for all the help guys.