Site Tools


projects:3dprinting:anycubic_i3_mega:replacing_atmega2560

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
projects:3dprinting:anycubic_i3_mega:replacing_atmega2560 [2020/03/12 07:34] – [Flashing with avrdude] adminprojects:3dprinting:anycubic_i3_mega:replacing_atmega2560 [2022/02/04 12:40] (current) – [Install avrdude] admin
Line 1: Line 1:
 ====== Replace Atmega2560 at Trigorilla board ====== ====== Replace Atmega2560 at Trigorilla board ======
-You need to make sure that you can flash the arduino bootloader again onto the chip.+If the Atmega2560 is broken, gives for example wrong temperature readings ((See for example here: [[https://forum.vellemanprojects.eu/t/replaced-atmega-2560-because-of-damaged-adc-input-t2-heatbed/10954]])), this is most likely caused by electrostatic discharge, destroying one or more input pins.
  
-For this you need an programmer like the AVR Dragon.+With the right equipment, removing the Atmega2560 and soldeering a new one should be pretty straightforward. Once done, you need to make sure that the arduino bootloader is in place.
  
-This is the wiring connection for the AVR Dragon to the Trigorilla ISP connector:+For this you need a programmer like the [[https://www.microchip.com/DevelopmentTools/ProductDetails/PartNO/ATAVRDRAGON|AVR Dragon]]. The connection typically would look like: 
 + 
 +^  Connecting trigorilla ISP to AVR Dragon ISP  ^ 
 +|  {{:projects:3dprinting:anycubic_i3_mega:img_20200312_102818.jpg?400}} 
 + 
 +This is the wiring connection between an AVR Dragon and a Trigorilla ISP connector:
 ^   AVR Dragon ISP (pin)  ^  Trigorilla ISP connector (pin)  ^ ^   AVR Dragon ISP (pin)  ^  Trigorilla ISP connector (pin)  ^
 |  1: MISO  |  1: D50 (Mega2560 pin 22)  | |  1: MISO  |  1: D50 (Mega2560 pin 22)  |
Line 13: Line 18:
 |  6: GND  |  6: GND  | |  6: GND  |  6: GND  |
  
-To flash the bootloader, download and install avrdude:+(Pin marking is given on the silk-screen) 
 + 
 +For flashing the bootloader, download and install avrdude:
  
 ==== Download avrdude ==== ==== Download avrdude ====
Line 23: Line 30:
  
 <code bash> <code bash>
-gunzip -avrdude-6.3.tar.gz | tar xf - +# Dependencies 
-cd avrdude-6.0+sudo apt-get update 
 +sudo apt-get install build-essential bison flex automake libelf-dev libusb-1.0-0-dev libusb-dev libftdi-dev libftdi1 
 + 
 +mkdir -p $HOME/SOMEWHERE/apps/avrdude 
 +cd !$ 
 +wget http://download.savannah.gnu.org/releases/avrdude/avrdude-6.4.tar.gz 
 +tar xzf avrdude-6.4.tar.gz 
 +# See here https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#Word-Designators 
 +# for an explanation about word designaters in bash 
 +cd !$:r:r
 ./configure ./configure
 make make
-su root -c 'make install'+sudo make install
 </code> </code>
  
Line 42: Line 58:
   sudo udevadm control --reload-rules && udevadm trigger   sudo udevadm control --reload-rules && udevadm trigger
 ==== Flashing with avrdude ==== ==== Flashing with avrdude ====
-Steps and information below basically follow the description from [[https://haarer.github.io/arduino,bootloader/2018/03/25/building-an-arduino-mega-2560-bootloader.html|here]].+Steps and information below basically follow the description from [[https://haarer.github.io/arduino,bootloader/2018/03/25/building-an-arduino-mega-2560-bootloader.html|here]] and [[https://www.ladyada.net/learn/avr/avrdude.html|here]].
  
 === Download bootloader === === Download bootloader ===
Line 49: Line 65:
 Original bootloader: Original bootloader:
  
-  arduino-1.8.5/hardware/arduino/avr/bootloaders/stk500v2/Mega2560-prod-firmware-2011-06-29.hex+  ../arduino-1.8.5/hardware/arduino/avr/bootloaders/stk500v2/Mega2560-prod-firmware-2011-06-29.hex
      
 or the newer one that fixes the WDT and the !!! problems((See for more info: https://forum.arduino.cc/index.php?topic=168642.0)):  or the newer one that fixes the WDT and the !!! problems((See for more info: https://forum.arduino.cc/index.php?topic=168642.0)): 
Line 60: Line 76:
  
 === 1. Unlock fuses, erase, verify === === 1. Unlock fuses, erase, verify ===
 +The original command would be:
 +
   avrdude -p m2560 -c dragon_isp -P usb -Ulock:w:0x3F:m -Uefuse:w:0xFD:m -Uhfuse:w:0xD8:m -Ulfuse:w:0xFF:m -e -v   avrdude -p m2560 -c dragon_isp -P usb -Ulock:w:0x3F:m -Uefuse:w:0xFD:m -Uhfuse:w:0xD8:m -Ulfuse:w:0xFF:m -e -v
 +But this command will cause avrdude to show an error at the verification step((See here: [[http://www.engbedded.com/fusecalc]])). To prevent this error, it is recommended to change this command into:
 +
 +  avrdude -p m2560 -c dragon_isp -P usb -Ulock:w:0xFF:m -Uefuse:w:0xFD:m -Uhfuse:w:0xD8:m -Ulfuse:w:0xFF:m -e -v
 +
 +The reason is that only the lowest 3 bits from the lockbits are used. The other bits don't return any sensible value and causes avrdude to indicate an error. Ideally you would need to use a logical AND to filter for the lowest 3 bits.
  
 === 2. Write the bootloader, set the lock fuse, verify === === 2. Write the bootloader, set the lock fuse, verify ===
   avrdude -p m2560 -c dragon_isp -P usb -Uflash:w:stk500boot_v2_mega2560.hex:i -Ulock:w:0x0f:m -v   avrdude -p m2560 -c dragon_isp -P usb -Uflash:w:stk500boot_v2_mega2560.hex:i -Ulock:w:0x0f:m -v
  
 +Similarly as in step 1, to prevent an error with the fuse setting at the verification step, change this command in:
 +
 +  avrdude -p m2560 -c dragon_isp -P usb -Uflash:w:stk500boot_v2_mega2560.hex:i -Ulock:w:0xcf:m -v
 +
 +==== Problems ====
 +
 +=== verification error, first mismatch at byte 0x0000 ===
 +If you get an error like the following with avrdude:
 +
 +<code bash>
 +...
 +Reading | ################################################## | 100% 0.05s
 +
 +avrdude: verifying ...
 +avrdude: verification error, first mismatch at byte 0x0000
 +         0xcf != 0x0f
 +avrdude: verification error; content mismatch
 +...
 +</code>
 +
 +You may have to change the fuse setting verification step((See here: [[http://www.engbedded.com/fusecalc]])). See above for the change.
 ===== Further information ===== ===== Further information =====
   * [[https://learn.sparkfun.com/tutorials/installing-an-arduino-bootloader/all]]   * [[https://learn.sparkfun.com/tutorials/installing-an-arduino-bootloader/all]]
projects/3dprinting/anycubic_i3_mega/replacing_atmega2560.1583994848.txt.gz · Last modified: 2020/03/12 07:34 by admin