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:44] 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 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 ==== ==== Problems ====
  
 === verification error, first mismatch at byte 0x0000 === === verification error, first mismatch at byte 0x0000 ===
 +If you get an error like the following with avrdude:
 +
 <code bash> <code bash>
-avrdude -p m2560 -c dragon_isp -P usb -Uflash:w:stk500boot_v2_mega2560.hex:i -Ulock:w:0x0f:m -v +...
- +
-avrdude: Version 6.3, compiled on Mar 11 2020 at 23:44:01 +
-         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/ +
-         Copyright (c) 2007-2014 Joerg Wunsch +
- +
-         System wide configuration file is "/usr/local/etc/avrdude.conf" +
-         User configuration file is "$HOME/.avrduderc" +
-         User configuration file does not exist or is not a regular file, skipping +
- +
-         Using Port                    : usb +
-         Using Programmer              : dragon_isp +
-avrdude: usbdev_open(): Found AVRDRAGON, serno: 00A200007476 +
-JTAG ICE mkII sign-on message: +
-Communications protocol version: 1 +
-M_MCU: +
-  boot-loader FW version:        255 +
-  firmware version:              7.33 +
-  hardware version:              1 +
-S_MCU: +
-  boot-loader FW version:        255 +
-  firmware version:              7.33 +
-  hardware version:              7 +
-Serial number:                   00:a2:00:00:74:76 +
-Device ID:                       AVRDRAGON +
-         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        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 no          1    0      0  9000  9000 0x00 0x00 +
-           hfuse          0            0 no          1    0      0  9000  9000 0x00 0x00 +
-           efuse          0            0 no          1    0      0  9000  9000 0x00 0x00 +
-           lock                      0 no          1    0      0  9000  9000 0x00 0x00 +
-           calibration    0            0 no          1    0      0         0 0x00 0x00 +
-           signature      0            0 no          3    0      0         0 0x00 0x00 +
- +
-         Programmer Type : DRAGON_ISP +
-         Description     : Atmel AVR Dragon in ISP mode +
-         Vtarget         : 4.9 V +
-         SCK period      : 4.00 us +
- +
-avrdude: AVR device initialized and ready to accept instructions +
- +
-Reading | ################################################## | 100% 0.15s +
- +
-avrdude: Device signature = 0x1e9801 (probably m2560) +
-avrdude: safemode: hfuse reads as D8 +
-avrdude: safemode: efuse reads as FD +
-avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed +
-         To disable this feature, specify the -D option. +
-avrdude: erasing chip +
-avrdude: reading input file "stk500boot_v2_mega2560.hex" +
-avrdude: writing flash (261406 bytes): +
- +
-Writing | ################################################## | 100% 0.00s +
- +
-avrdude: 261406 bytes of flash written +
-avrdude: verifying flash memory against stk500boot_v2_mega2560.hex: +
-avrdude: load data flash data from input file stk500boot_v2_mega2560.hex: +
-avrdude: input file stk500boot_v2_mega2560.hex contains 261406 bytes +
-avrdude: reading on-chip flash data: +
- +
-Reading | ################################################## | 100% 0.00s +
- +
-avrdude: verifying ... +
-avrdude: 261406 bytes of flash verified +
-avrdude: reading input file "0x0f" +
-avrdude: writing lock (1 bytes): +
- +
-Writing | ################################################## | 100% 0.06s +
- +
-avrdude: 1 bytes of lock written +
-avrdude: verifying lock memory against 0x0f: +
-avrdude: load data lock data from input file 0x0f: +
-avrdude: input file 0x0f contains 1 bytes +
-avrdude: reading on-chip lock data: +
 Reading | ################################################## | 100% 0.05s Reading | ################################################## | 100% 0.05s
  
Line 170: Line 105:
          0xcf != 0x0f          0xcf != 0x0f
 avrdude: verification error; content mismatch avrdude: verification error; content mismatch
- +...
-avrdude: safemode: hfuse reads as D8 +
-avrdude: safemode: efuse reads as FD +
-avrdude: safemode: Fuses OK (E:FD, H:D8, L:FF) +
- +
-avrdude done Thank you.+
 </code> </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.1583995444.txt.gz · Last modified: 2020/03/12 07:44 by admin