I am trying to use the arduino mega with a ethernet shield and trying to upload a sketch using ethernet on the mega. I am using a uno as a ISP. I am following this link to do this - http://www.freetronics.com/pages/how-to-upload-a-sketch-to-your-arduino-via-a-network. I downloaded the 0.3beta version of tftp bootloader for that.
I burnt the ISP sketch on uno, made the connections to the mega, but got errors while trying to burn the bootloader using the IDE.
avrdude: ser_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
In the bootloader code, I changed the spi pin numbers to match the ones on mega and replaced the hex file, but that didnt work. There was also a suggestion to put a 10mfd cap between reset and ground on uno but that also didnt work...
Any idea as to what do i need to do to make it work.
Did I get your approach correctly? You want to program a TFTP bootloader to an Arduino Mega2560 by taking an Arduino UNO with an ISP sketch applied?
In this case you haven't wired it correctly. The UNO must have the possibility to reset the Mega2560, so the Mega's reset pin has to be connected to a GPIO pin on the UNO (example with two UNOs: http://arduino.cc/en/Tutorial/ArduinoISP)
thanx, the burning the bootloader was successful. The link i am following says once its done, the led connected to pin 9 and gnd should blink at 1hz... for me it just stays on, though the ide says burning was successful.
I also changed the IP address for the gateway, arduino and the subnet mask in the net.c file and copied the hex file in the arduino tree for the bootloader, to match my current setup. My router is at 192.168.0.1, pc at 192.168.0.5 and the arduino at 192.168.0.10. I changed my router setup to hardcode the ip address for the shield mac address. After doing all this, when I ping the arduino from the pc, I get the destination host unreachable.
The compiled bootloader is for an ATmega328 and not for an ATmega2560. You have to compile the package yourself and install it in the appropriate folder. Have you done that? Post the modified Makefile.
I hadnt changed the makefile. I changed the device id to atmega2560. rest of the file is the same, do I need to change anything else in there. I tried the whole thing again, led still doesnt blink (led and resistor work otherwise), I can burn the bootloader, but cannot ping the mega.
Makefile:
# Name: tftp.c
# Author: Denis PEROTTO, from work published by Arduino
# Copyright: Arduino
# License: GPL http://www.gnu.org/licenses/gpl-2.0.html
# Project: eboot
# Function: tftp implementation and flasher
# Version: 0.1 tftp / flashing functional
# Important make targets:
# install : flash bootloader using AVR ISP MkII
# disasm : output disassembly of bootloader
# readback : read back flash contents to read.hex
#DEVICE = atmega328p
DEVICE = atmega2560
CLOCK = 16000000
PROGRAMMER = -c usbtiny -P usb
OBJECTS = main.o net.o tftp.o validate.o debug.o
APPOBJECTS = app.o
# 2Kword boot block
FUSES = -U efuse:w:0x05:m -U hfuse:w:0xd8:m -U lfuse:w:0xff:m
#FUSES = -U efuse:w:0x05:m -U hfuse:w:0xd9:m -U lfuse:w:0xff:m
LDFLAGS = -Ttext=0x7000
# 1Kword boot block
#FUSES = -U efuse:w:0x05:m -U hfuse:w:0xda:m -U lfuse:w:0xff:m
#LDFLAGS = -Ttext=0x7800
# 512 word boot block
#FUSES = -U efuse:w:0x05:m -U hfuse:w:0xdc:m -U lfuse:w:0xff:m
#LDFLAGS = -Ttext=0x7C00
# 256 word boot block
#FUSES = -U efuse:w:0x05:m -U hfuse:w:0xde:m -U lfuse:w:0xff:m
#LDFLAGS = -Ttext=0x7E00
# Extended Fuse Byte:
# 0x05 = 0 0 0 0 0 1 0 1
# \---+---/ \-+-/
# | +------ BODLEVEL Brownout detect at 2.5 to 2.9V
# +-------------- Unused
#
# High Fuse Byte:
# 0xD8 = 1 1 0 1 1 0 0 0 <-- BOOTRST Reset to bootloader
# ^ ^ ^ ^ ^ \+/
# | | | | | +------- BOOTSZ 2Kword bootloader, 0x3800-0x3FFF, reset at 0x3800
# | | | | +---------- EESAVE EEPROM erased in chip erase
# | | | +------------ WDTON Watchdog timer off
# | | +-------------- SPIEN SPI programming enabled
# | +---------------- DWEN DebugWIRE disabled
# +------------------ RSTDISBL External Reset enabled
#
# Low Fuse Byte:
# 0xFF = 1 1 1 1 1 1 1 1
# | | \+/ \--+--/
# | | | +------- CKSEL Low power crystal, 16Kck delay
# | | +------------- SUT 65ms delay
# | +---------------- CKOUT No clock out
# +------------------ CKDIV8 No divide by 8 prescaler
AVRDUDE = avrdude $(PROGRAMMER) -p $(DEVICE)
# Compiler options to shrink bootloader size
#
CCOPT = -Os
CCOPT += -mno-interrupts #Interrupts will not be supported in code
CCOPT += -mshort-calls
CCOPT += -fno-inline-small-functions
CCOPT += -fno-split-wide-types
CCOPT += -Wl,--relax
# do not use cause great instability??
#CCOPT += -nostartfiles
# These optimisations have no effect, so turned off
#
#CCOPT += -mtiny-stack
#CCOPT += -ffreestanding
#CCOPT += -fpack-struct
#CCOPT += -fno-jump-tables
COMPILE = avr-gcc -Wall $(CCOPT) -DF_CPU=$(CLOCK) -mmcu=$(DEVICE)
OBJCOPY = avr-objcopy
OBJDUMP = avr-objdump
# symbolic targets:
all: main.hex
%.o: %.c
$(COMPILE) -c $< -o $@
%.o: %.S
$(COMPILE) -x assembler-with-cpp -c $< -o $@
# "-x assembler-with-cpp" should not be necessary since this is the default
# file type for the .S (with capital S) extension. However, upper case
# characters are not always preserved on Windows. To ensure WinAVR
# compatibility define the file type manually.
%.s: %.c
$(COMPILE) -S $< -o $@
%.bin: %.elf
rm -f $@
$(OBJCOPY) -j .text -j .data -O binary $< $@
%.hex: %.elf
rm -f $@
$(OBJCOPY) -j .text -j .data -O ihex $< $@
# Programming targets - which are set up for a TinyUSB programmer
flash: main.hex
$(AVRDUDE) -U flash:w:main.hex:i
quickflash: main.hex
$(AVRDUDE) -V -U flash:w:main.hex:i
fuse:
$(AVRDUDE) $(FUSES)
# Xcode uses the Makefile targets "", "clean" and "install"
install: flash fuse
quickinstall:quickflash fuse
clean:
rm -f *.hex *.elf *.bin *.o
# Bootloader
#
main.elf: $(OBJECTS)
$(COMPILE) -o main.elf $(OBJECTS) $(LDFLAGS)
# Targets for code debugging and analysis:
disasm: main.elf
$(OBJDUMP) -d main.elf
map: main.elf
$(OBJDUMP) -h main.elf
cpp:
$(COMPILE) -E main.c
readback:
$(AVRDUDE) -U flash:r:read.hex:i
tried with the new fuses. still same result. No led blink on pin 9... no ping.
I also see that when the bootloader is being burnt, the uno tx light is blinking rapidly, but no such luck on the mega, the rx is not lighting. so i guess the data is not making it to the mega. though avrdude reports success.
I also updated the boards.txt with relevant values in the /usr/share/arduino/hardware/arduino-tftpboot/boards.txt file but no impact.
I also see that when the bootloader is being burnt, the uno tx light is blinking rapidly, but no such luck on the mega, the rx is not lighting. so i guess the data is not making it to the mega. though avrdude reports success.
This is the expected behavior because the UNO is using the USART interface to communicate with the PC while the UNO and the Mega communicate using the SPI interface which doesn't have an LED to check data is transmitted (it would be much to fast anyway).
I ask my question again: How do you check that the generated file was transfered to the Mega2560 and not any other? Have you activated the debug information during upload?
Edit: Did you also change SS_PIN in net.h? Pin 10 is on PB4 on the Mega and not PB2 as on the UNO.
But looks like the issue is that the SS pin 53 isnt connected to anything. For uno, its pin 10, but that is also the reset pin on uno in the ISP program. Should i change the reset pin to something else in Arduino ISP sketch and connect 53 on mega to 10 on uno?
Not sure I understand your question. the system connected is mega to uno. the debug output is on while doing the upload.
output from upload, its quite big and i had to trim it. Let me know if you need to see the whole output and I will send it across by some other way.
avrdude -v -v -v -v -patmega2560 -cstk500v1 -P/dev/ttyACM0 -b19200 -e -Uefuse:w:0xfd:m -Uhfuse:w:0xd8:m -Ulfuse:w:0xFF:m
avrdude: Version 5.11.1, compiled on Jul 19 2012 at 01:16:45
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2009 Joerg Wunsch
System wide configuration file is "/etc/avrdude/avrdude.conf"
User configuration file is "/home/vikas/.avrduderc"
User configuration file does not exist or is not a regular file, skipping
Using Port : /dev/ttyACM0
Using Programmer : stk500v1
Overriding Baud Rate : 19200
avrdude: Send: 0 [30] [20]
avrdude: Send: 0 [30] [20]
avrdude: Send: 0 [30] [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]
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 :
Programmer Type : STK500
Description : Atmel STK500 Version 1.x firmware
Hardware Version: 2
Firmware Version: 1.18
Topcard : Unknown
Vtarget : 0.0 V
Varef : 0.0 V
Oscillator : Off
SCK period : 0.1 us
avrdude: AVR device initialized and ready to accept instructions
avrdude: Device signature = 0x1e9801
avrdude: reading input file "0xfd"
avrdude: writing efuse (1 bytes):
avrdude: 1 bytes of efuse written
avrdude: verifying efuse memory against 0xfd:
avrdude: load data efuse data from input file 0xfd:
avrdude: input file 0xfd contains 1 bytes
avrdude: reading on-chip efuse data:
avrdude: verifying ...
avrdude: 1 bytes of efuse verified
avrdude: reading input file "0xd8"
avrdude: writing hfuse (1 bytes):
avrdude: 1 bytes of hfuse written
avrdude: verifying hfuse memory against 0xd8:
avrdude: load data hfuse data from input file 0xd8:
avrdude: input file 0xd8 contains 1 bytes
avrdude: reading on-chip hfuse data:
avrdude: verifying ...
avrdude: 1 bytes of hfuse verified
avrdude: reading input file "0xFF"
avrdude: writing lfuse (1 bytes):
avrdude: 1 bytes of lfuse written
avrdude: verifying lfuse memory against 0xFF:
avrdude: load data lfuse data from input file 0xFF:
avrdude: input file 0xFF contains 1 bytes
avrdude: reading on-chip lfuse data:
avrdude: verifying ...
avrdude: 1 bytes of lfuse verified
avrdude: Send: Q [51] [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]
avrdude done. Thank you.
avrdude -v -v -v -v -patmega2560 -cstk500v1 -P/dev/ttyACM0 -b19200 -Uflash:w:/usr/share/arduino/hardware/arduino-tftpboot/bootloaders/arduino-tftpboot/arduino-tftpboot-bootloader-m328.hex:i
avrdude: Version 5.11.1, compiled on Jul 19 2012 at 01:16:45
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2009 Joerg Wunsch
System wide configuration file is "/etc/avrdude/avrdude.conf"
User configuration file is "/home/vikas/.avrduderc"
User configuration file does not exist or is not a regular file, skipping
Using Port : /dev/ttyACM0
Using Programmer : stk500v1
Overriding Baud Rate : 19200
avrdude: Send: 0 [30] [20]
avrdude: Send: 0 [30] [20]
avrdude: Send: 0 [30] [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]
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 :
Programmer Type : STK500
Description : Atmel STK500 Version 1.x firmware
Hardware Version: 2
Firmware Version: 1.18
Topcard : Unknown
Vtarget : 0.0 V
Varef : 0.0 V
Oscillator : Off
SCK period : 0.1 us
avrdude: AVR device initialized and ready to accept instructions
avrdude: Device signature = 0x1e9801
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude: reading input file "/usr/share/arduino/hardware/arduino-tftpboot/bootloaders/arduino-tftpboot/arduino-tftpboot-bootloader-m328.hex"
avrdude: writing flash (32086 bytes):
Writing | ############################################avrdude: Send: U [55] . [00] 8 [38] [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]
avrdude: Recv: . [10]
# | 100% 20.22s
avrdude: verifying ...
avrdude: 32086 bytes of flash verified
avrdude: Send: Q [51] [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]
avrdude done. Thank you.
Have you really name your bootloader compiled for the ATmega2560 "arduino-tftpboot-bootloader-m328.hex"?
I am using pin 53 for SS, so its set to 0. Here're the settings in net.h
You cannot use pin 53 for the SS because the Ethernet Shield is using pin 10 for that.
For uno, its pin 10, but that is also the reset pin on uno in the ISP program. Should i change the reset pin to something else in Arduino ISP sketch and connect 53 on mega to 10 on uno?
The UNO is not connected to the Ethernet Shield and is not running the TFTP-Bootloader so it's not relevant. You don't have to change anything in the wiring, you have to change the software appropriately.
I had been looking all over the Internet for a solution to the same dilemma. As I understand it, one must have an AVR ISP MkII programmer in order to burn any bootloader to the mega2560 because of its large memory. The UNO ISP sketch isn't able to address the extended memory of the 2560.
Is this correct?
I really do not want to spend the $30 that they cost (or whatever it is). Anyone in Phoenix have one I could barrow for, uhh, idk, 10 minutes?
JoeyPhxAZ:
I had been looking all over the Internet for a solution to the same dilemma. As I understand it, one must have an AVR ISP MkII programmer in order to burn any bootloader to the mega2560 because of its large memory. The UNO ISP sketch isn't able to address the extended memory of the 2560.
Is this correct?
I really do not want to spend the $30 that they cost (or whatever it is). Anyone in Phoenix have one I could barrow for, uhh, idk, 10 minutes?
HI JoeyPhxAZ!!!
Have you find a solution to upload your sketch over tftp on your Arduino Mega 2560.
I find a solution for it, but I cannot Upload sketch over 28 Kb of size...
Tnk!