Hi all,
I have searched multiple forums and guides for the past week but can't find a fix for my problem. Any suggestions would be much appreciated before I have lost all my hair! Sorry for long post but wanted to give what I thought may be useful info... Appreciate your thoughts and thanks for your time.
I recently purchased a Multiwii Pro flight controller with ATmega2560 micro controller. I am running Arduino 1.6.0 on Mac OS X 10.10.2.
I am new to Arduino and so initially I uploaded the basic "Blink" sketch to flash the on board LED. I then modified to turn off LED and re-uploaded. This was working fine and I could connect the board via USB and reprogram multiple times without any issue and see the light on or off.
I'm not sure what happened, but now I can only upload code to my board once upon initial connection (doesn't matter how long it's been connected for so long as I haven't accessed the chip since reconnect). Successful code upload Arduino IDE AVRDude output:
System wide configuration file is "/Applications/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf"
User configuration file is "/Users/InitialD/.avrduderc"
User configuration file does not exist or is not a regular file, skipping
Using Port : /dev/tty.usbserial-A502FUY2
Using Programmer : wiring
Overriding Baud Rate : 115200
AVR Part : ATmega2560
Chip Erase delay : 9000 us
PAGEL : PD7
BS2 : PA0
RESET disposition : dedicated
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
ByteDelay : 0
PollIndex : 3
PollValue : 0x53
Memory Detail :
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
eeprom 65 10 8 0 no 4096 8 0 9000 9000 0x00 0x00
flash 65 10 256 0 yes 262144 256 1024 4500 4500 0x00 0x00
lfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
efuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
lock 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00
Programmer Type : Wiring
Description : Wiring
Programmer Model: AVRISP
Hardware Version: 15
Firmware Version Master : 2.10
Vtarget : 0.0 V
SCK period : 0.1 us
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.04s
avrdude: Device signature = 0x1e9801
avrdude: reading input file "/var/folders/p6/kxthnfnd2ps6d_sm8bdzjsxr0000gn/T/build6895625350857975266.tmp/sketch_feb28a.cpp.hex"
avrdude: writing flash (1560 bytes):
Writing | ################################################## | 100% 0.44s
avrdude: 1560 bytes of flash written
avrdude: verifying flash memory against /var/folders/p6/kxthnfnd2ps6d_sm8bdzjsxr0000gn/T/build6895625350857975266.tmp/sketch_feb28a.cpp.hex:
avrdude: load data flash data from input file /var/folders/p6/kxthnfnd2ps6d_sm8bdzjsxr0000gn/T/build6895625350857975266.tmp/sketch_feb28a.cpp.hex:
avrdude: input file /var/folders/p6/kxthnfnd2ps6d_sm8bdzjsxr0000gn/T/build6895625350857975266.tmp/sketch_feb28a.cpp.hex contains 1560 bytes
avrdude: reading on-chip flash data:
Reading | ################################################## | 100% 0.39s
avrdude: verifying ...
avrdude: 1560 bytes of flash verified
avrdude done. Thank you.
When I try and upload a second sketch, I get the following timeout error:
System wide configuration file is "/Applications/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf"
User configuration file is "/Users/InitialD/.avrduderc"
User configuration file does not exist or is not a regular file, skipping
Using Port : /dev/tty.usbserial-A502FUY2
Using Programmer : wiring
Overriding Baud Rate : 115200
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
I have tried pressing the reset button whilst the Arduino is timing out but doesn't seem to help.
I have run AVRDude from the terminal so I can check exactly which instructions I am sending.
Could it be something to do with the onboard reset/memory lock? Checked my fuse settings against the ATmega 2560 data sheet and the Arduino boards.txt (and other users)
Me ATmega2560 Default boards.txt
LFuse: 0xFF 0xFF 0xFF
HFuse:0xD8 0X99 0xD8
EFuse: 0xFF 0x62 0xFD
The only difference which my chip appears to have vs boards.txt that came with Arduino is the Extended Fuse FF vs FD which I believe has an impact on brown-out detection but not sure this would be causing my issues. I have tried to change my fuse to match with instruction and it seems to work but when I reconnect chip, the fuses are all back to original values:
./avrdude -v -v -v -v -p m2560 -C /Applications/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf -D -c wiring -P /dev/tty.usbserial-A502FUY2 -U efuse:w:0xFD:m
Given the fuses wouldn't stay programmed, I then looked at my Lock bits and think this could be where the issue lies. I write to an intel hex file and see values which I believe just means 0x18 which i think is 00011000 in binary:
:0100000018E7
:00000001FF
From the Datasheet, my lock bits mean (LB2:1 = 00, BLB02:01 = 10):
"Further programming and verification of the Flash and EEPROM is disabled in Parallel and Serial Programming mode. The Boot Lock bits and Fuse bits are locked in both Serial and Parallel Programming mode.(1)"
"SPM is not allowed to write to the Application section."
Any thoughts on the issue? Could be something completely different and I'm barking up the wrong tree
Thanks again.