I'm currently integrating Arduino IDE to my project as it's an excellent GUI. My project uses an ATmega8535 so I have to adapt a bootloader to make it work with Arduino. I've chosen Optiboot, so far I've successfully compiled it, but there are some constants that I'm not completely sure about, it doesn't work yet so it's work in progress.
There's one thing I've never understood about Arduino IDE and it really annoys me: how does Ardiuno IDE send a new program to the AVR via the Optiboot bootloader? I've gone through all the Optiboot code and generally all makes sense, but what is happening on the Arduino IDE end when I click "upload"? Mind you I use a simple FTDI that appears as /dev/usb... in the "serial port" menu list.
My theory is that when I click "upload" Ardunio IDE tries to send the compiled program via the serial interface and waits for a reset to do so, is that right?
So far I've always gotten this error when I try to upload:
java.lang.NullPointerException
at processing.app.debug.AvrdudeUploader.uploadViaBootloader(AvrdudeUploader.java:88)
at processing.app.debug.AvrdudeUploader.uploadUsingPreferences(AvrdudeUploader.java:67)
at processing.app.Sketch.upload(Sketch.java:1706)
at processing.app.Sketch.exportApplet(Sketch.java:1662)
at processing.app.Sketch.exportApplet(Sketch.java:1634)
at processing.app.Editor$DefaultExportHandler.run(Editor.java:2346)
at java.lang.Thread.run(Thread.java:680)
I get that whether I have my AVR connected (with faulty bootloader) or not, so it's not very explicit, it's like Arduino doesn't even try, or I have another problem, or I completely misunderstood the whole thing.
Arduinos are constructed so that the DTR line resets them. This way opening the serial interface triggers a reset on the Arduino and it's bootloader is started. If you haven't made your circuitry to do the same you may have to hit the reset button manually to start the bootloader in the right moment.
pylon:
Arduinos are constructed so that the DTR line resets them. This way opening the serial interface triggers a reset on the Arduino and it's bootloader is started. If you haven't made your circuitry to do the same you may have to hit the reset button manually to start the bootloader in the right moment.
Sure, I understand that, but let's say my bootloader is faulty and it won't work: when I try to program it shouldn't Arduino IDE tell me it's waiting for reset or something? It won't get it and it won't be able to program it, but it should try at least. The error code above doesn't tell me anything really.
Never mind everybody, I found the issue: the problem was the implementation of the new board in the boards.txt file. For some obscure reason I decided to set "myboard.upload.protocol=uart", once I set it to "myboard.upload.protocol=arduino" I got some compilation errors and now it's failing upload like it should.
avrdude: stk500v2_ReceiveMessage(): timeout
I'm still not absolutely sure about the stk500v2 protocol for Optiboot.