MCUdude / MegaCore

Arduino hardware package for ATmega64, ATmega128, ATmega165, ATmega169, ATmega325, ATmega329, ATmega640, ATmega645, ATmega649, ATmega1280, ATmega1281, ATmega2560, ATmega2561, ATmega3250, ATmega3290, ATmega6450, ATmega6490, AT90CAN32, AT90CAN64 and AT90CAN128
Other
374 stars 115 forks source link

Arduino IDE can't access AVR ISP mk2 #192

Closed cerickson888 closed 1 year ago

cerickson888 commented 1 year ago

I'm only able to access com ports but, as a true USB device, my programmer isn't assigned a port number. Can anyone suggest a way?

MCUdude commented 1 year ago

The AVRISPmkII isn't a serial device, but native USB. It doesn't have a COM port. Simply select it in the programmers menu and hold shift while pressing upload (Upload using programmer).

cerickson888 commented 1 year ago

Thanks for the advice. I read that shift+upload would flash a sketch onto the target via a programmer (erasing the bootloader) but the bootloader is what I'm trying to flash the target with. I'd like to be able to use it like a normal Arduino board.

This post seems to show a way for Arduino IDE to use a USB port. https://github.com/MCUdude/MegaCore/issues/172

 System wide configuration file is "C:\Users\syph3rd\AppData\Local\Arduino15\packages\MegaCore\hardware\avr\2.1.3/avrdude.conf"

 Using Port                    : usb
 Using Programmer              : atmelice_isp

But I don't know how to make that work.

MCUdude commented 1 year ago

If you want to burn the bootloader, select the settings you prefer in the tools menu, and click "Burn Bootloader". If you're getting an error, please post it here.

cerickson888 commented 1 year ago

Arduino: 1.8.19 (Windows Store 1.8.57.0) (Windows 10), Board: "ATmega1280, Yes (UART0), EEPROM retained, Arduino MEGA pinout, BOD 2.7V, LTO disabled, External 8 MHz"

avrdude: Version 6.3-20190619

     Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/

     Copyright (c) 2007-2014 Joerg Wunsch

     System wide configuration file is "C:\Users\A\Documents\Arduino\hardware\MegaCore-master\avr/avrdude.conf"

     Using Port                    : usb

     Using Programmer              : stk500v2

Error while burning bootloader.

avrdude: usbdev_open(): did not find any USB device "usb" (0x03eb:0x2104)

avrdude done. Thank you.

This report would have more information with "Show verbose output during compilation" option enabled in File -> Preferences.

it says " Using Programmer : stk500v2" but the selected programmer is "AVRISP mkII (MegaCore)".

cerickson888 commented 1 year ago

avrdude: Version 6.3-20201216Failed chip erase: uploading error: exit status 1

I tried Arduino IDE version 2.0.0 rc9.2 cuz I'm out of ideas but that didn't work either

MCUdude commented 1 year ago

This is most likely due to the AVRISPmkII using the incorrect driver. Instead of WinUSB, it has to be switched to libusb in order for it to work with Avrdude.

cerickson888 commented 1 year ago

avrdude: Version 6.3-20201216 Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/ Copyright (c) 2007-2014 Joerg Wunsch

     System wide configuration file is "C:\Users\A\Documents\Arduino\hardware\MegaCore-master\avr/avrdude.conf"

     Using Port                    : usb
     Using Programmer              : stk500v2

avrdude: usbdev_open(): Found AVRISP mkII, serno: 001D2C990079 AVR Part : ATmega128 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         4    12    64    0 no       4096    8      0  9000  9000 0xff 0xff
       flash         33     6   128    0 yes    131072  256    512  4500  4500 0xff 0xff
       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          4    0      0     0     0 0x00 0x00
       signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

     Programmer Type : STK500V2
     Description     : Atmel STK500 Version 2.x firmware
     Programmer Model: AVRISP mkII
     Hardware Version: 1
     Firmware Version Master : 1.24
     Vtarget         : 4.8 V
     SCK period      : 8.00 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e9702 (probably m128) avrdude: erasing chip avrdude: reading input file "0xff" avrdude: writing lock (1 bytes):

Writing | ***failed;
################################################## | 100% 0.06s

avrdude: 1 bytes of lock written avrdude: verifying lock memory against 0xff: avrdude: load data lock data from input file 0xff: avrdude: input file 0xff contains 1 bytes avrdude: reading on-chip lock data:

Reading | ################################################## | 100% -0.00s

avrdude: verifying ... avrdude: WARNING: invalid value for unused bits in fuse "lock", should be set to 1 according to datasheet This behaviour is deprecated and will result in an error in future version You probably want to use 0x3f instead of 0xff (double check with your datasheet first). avrdude: 1 bytes of lock verified avrdude: reading input file "0xff" avrdude: writing efuse (1 bytes):

Writing | ################################################## | 100% 0.00s

avrdude: 1 bytes of efuse written avrdude: verifying efuse memory against 0xff: avrdude: load data efuse data from input file 0xff: avrdude: input file 0xff contains 1 bytes avrdude: reading on-chip efuse data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ... avrdude: 1 bytes of efuse verified avrdude: reading input file "0b11000110" avrdude: writing hfuse (1 bytes):

Writing | ################################################## | 100% 0.00s

avrdude: 1 bytes of hfuse written avrdude: verifying hfuse memory against 0b11000110: avrdude: load data hfuse data from input file 0b11000110: avrdude: input file 0b11000110 contains 1 bytes avrdude: reading on-chip hfuse data:

Reading | ################################################## | 100% -0.00s

avrdude: verifying ... avrdude: 1 bytes of hfuse verified avrdude: reading input file "0b10111111" avrdude: writing lfuse (1 bytes):

Writing | ################################################## | 100% 0.01s

avrdude: 1 bytes of lfuse written avrdude: verifying lfuse memory against 0b10111111: avrdude: load data lfuse data from input file 0b10111111: avrdude: input file 0b10111111 contains 1 bytes avrdude: reading on-chip lfuse data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ... avrdude: 1 bytes of lfuse verified

avrdude done. Thank you.

***failed;
avrdude: WARNING: invalid value for unused bits in fuse "lock", should be set to 1 according to datasheet This behaviour is deprecated and will result in an error in future version You probably want to use 0x0f instead of 0xcf (double check with your datasheet first).

The driver seems to be working but still no joy.

MCUdude commented 1 year ago

failed; avrdude: WARNING: invalid value for unused bits in fuse "lock", should be set to 1 according to datasheet This behaviour is deprecated and will result in an error in future version You probably want to use 0x0f instead of 0xcf (double check with your datasheet first).failed; avrdude: WARNING: invalid value for unused bits in fuse "lock", should be set to 1 according to datasheet This behaviour is deprecated and will result in an error in future version You probably want to use 0x0f instead of 0xcf (double check with your datasheet first).

This doesn't matter. It has been fixed in the latest Avrdude release. However, I haven't updated MegaCore yet. Look at the output below from when I'm bootloading an ATmega128. Both the fuses and the bootloader is written, even though it fails when writing the lock bit. You can confirm that the bootloader is present and working by connecting an LED to pin PB7. It should flash twice every second if the bootloader is running.

Bootloading an ATmega128 using AVRISPmkII and MightyCore ``` /Users/hans/Library/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/bin/avrdude -C/Users/hans/Documents/Arduino/hardware/MegaCore/avr/avrdude.conf -v -patmega128 -cstk500v2 -Pusb -e -Ulock:w:0xff:m -Uefuse:w:0xff:m -Uhfuse:w:0b11000110:m -Ulfuse:w:0b10111111:m avrdude: Version 6.3-20190619 Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/ Copyright (c) 2007-2014 Joerg Wunsch System wide configuration file is "/Users/hans/Documents/Arduino/hardware/MegaCore/avr/avrdude.conf" User configuration file is "/Users/hans/.avrduderc" User configuration file does not exist or is not a regular file, skipping Using Port : usb Using Programmer : stk500v2 avrdude: usbdev_open(): Found AVRISP mkII, serno: 000200124552 AVR Part : ATmega128 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 4 12 64 0 no 4096 8 0 9000 9000 0xff 0xff flash 33 6 128 0 yes 131072 256 512 4500 4500 0xff 0xff 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 4 0 0 0 0 0x00 0x00 signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00 Programmer Type : STK500V2 Description : Atmel STK500 Version 2.x firmware Programmer Model: AVRISP mkII Hardware Version: 1 Firmware Version Master : 1.24 Vtarget : 5.4 V SCK period : 1.00 us avrdude: AVR device initialized and ready to accept instructions Reading | ################################################## | 100% 0.00s avrdude: Device signature = 0x1e9702 (probably m128) avrdude: erasing chip avrdude: reading input file "0xff" avrdude: writing lock (1 bytes): /Users/hans/Library/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/bin/avrdude -C/Users/hans/Documents/Arduino/hardware/MegaCore/avr/avrdude.conf -v -patmega128 -cstk500v2 -Pusb -Uflash:w:/Users/hans/Documents/Arduino/hardware/MegaCore/avr/bootloaders/optiboot_flash/bootloaders/atmega128/16000000L/optiboot_flash_atmega128_UART0_115200_16000000L_B5_BIGBOOT.hex:i -Ulock:w:0xcf:m avrdude: Version 6.3-20190619 Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/ Copyright (c) 2007-2014 Joerg Wunsch System wide configuration file is "/Users/hans/Documents/Arduino/hardware/MegaCore/avr/avrdude.conf" Writing | ***failed; ################################################## | 100% 0.06s avrdude: 1 bytes of lock written avrdude: verifying lock memory against 0xff: avrdude: load data lock data from input file 0xff: avrdude: input file 0xff contains 1 bytes avrdude: reading on-chip lock data: Reading | ################################################## | 100% 0.00s avrdude: verifying ... avrdude: WARNING: invalid value for unused bits in fuse "lock", should be set to 1 according to datasheet This behaviour is deprecated and will result in an error in future version User configuration file is "/Users/hans/.avrduderc" User configuration file does not exist or is not a regular file, skipping Using Port : usb Using Programmer : stk500v2 You probably want to use 0x3f instead of 0xff (double check with your datasheet first). avrdude: 1 bytes of lock verified avrdude: reading input file "0xff" avrdude: writing efuse (1 bytes): Writing | ################################################## | 100% 0.00s avrdude: 1 bytes of efuse written avrdude: verifying efuse memory against 0xff: avrdude: load data efuse data from input file 0xff: avrdude: input file 0xff contains 1 bytes avrdude: reading on-chip efuse data: Reading | ################################################## | 100% 0.00s avrdude: verifying ... avrdude: 1 bytes of efuse verified avrdude: reading input file "0b11000110" avrdude: writing hfuse (1 bytes): Writing | ################################################## | 100% 0.00s avrdude: 1 bytes of hfuse written avrdude: verifying hfuse memory against 0b11000110: avrdude: load data hfuse data from input file 0b11000110: avrdude: input file 0b11000110 contains 1 bytes avrdude: reading on-chip hfuse data: Reading | ################################################## | 100% 0.00s avrdude: verifying ... avrdude: 1 bytes of hfuse verified avrdude: reading input file "0b10111111" avrdude: writing lfuse (1 bytes): Writing | ################################################## | 100% 0.00s avrdude: 1 bytes of lfuse written avrdude: verifying lfuse memory against 0b10111111: avrdude: load data lfuse data from input file 0b10111111: avrdude: input file 0b10111111 contains 1 bytes avrdude: reading on-chip lfuse data: Reading | ################################################## | 100% 0.00s avrdude: verifying ... avrdude: 1 bytes of lfuse verified avrdude done. Thank you. avrdude: usbdev_open(): Found AVRISP mkII, serno: 000200124552 AVR Part : ATmega128 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 4 12 64 0 no 4096 8 0 9000 9000 0xff 0xff flash 33 6 128 0 yes 131072 256 512 4500 4500 0xff 0xff 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 4 0 0 0 0 0x00 0x00 signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00 Programmer Type : STK500V2 Description : Atmel STK500 Version 2.x firmware Programmer Model: AVRISP mkII Hardware Version: 1 Firmware Version Master : 1.24 Vtarget : 5.4 V SCK period : 1.00 us avrdude: AVR device initialized and ready to accept instructions Reading | ################################################## | 100% 0.00s avrdude: Device signature = 0x1e9702 (probably m128) 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 "/Users/hans/Documents/Arduino/hardware/MegaCore/avr/bootloaders/optiboot_flash/bootloaders/atmega128/16000000L/optiboot_flash_atmega128_UART0_115200_16000000L_B5_BIGBOOT.hex" avrdude: writing flash (131072 bytes): Writing | ################################################## | 100% 0.00s avrdude: 131072 bytes of flash written avrdude: verifying flash memory against /Users/hans/Documents/Arduino/hardware/MegaCore/avr/bootloaders/optiboot_flash/bootloaders/atmega128/16000000L/optiboot_flash_atmega128_UART0_115200_16000000L_B5_BIGBOOT.hex: avrdude: load data flash data from input file /Users/hans/Documents/Arduino/hardware/MegaCore/avr/bootloaders/optiboot_flash/bootloaders/atmega128/16000000L/optiboot_flash_atmega128_UART0_115200_16000000L_B5_BIGBOOT.hex: avrdude: input file /Users/hans/Documents/Arduino/hardware/MegaCore/avr/bootloaders/optiboot_flash/bootloaders/atmega128/16000000L/optiboot_flash_atmega128_UART0_115200_16000000L_B5_BIGBOOT.hex contains 131072 bytes avrdude: reading on-chip flash data: Reading | ################################################## | 100% 0.00s avrdude: verifying ... avrdude: 131072 bytes of flash verified avrdude: reading input file "0xcf" avrdude: writing lock (1 bytes): Writing | ***failed; ################################################## | 100% 0.06s avrdude: 1 bytes of lock written avrdude: verifying lock memory against 0xcf: avrdude: load data lock data from input file 0xcf: avrdude: input file 0xcf contains 1 bytes avrdude: reading on-chip lock data: Reading | ################################################## | 100% 0.00s avrdude: verifying ... avrdude: WARNING: invalid value for unused bits in fuse "lock", should be set to 1 according to datasheet This behaviour is deprecated and will result in an error in future version You probably want to use 0x0f instead of 0xcf (double check with your datasheet first). avrdude: 1 bytes of lock verified avrdude done. Thank you. ```
cerickson888 commented 1 year ago

I really appreciate you taking the time to help me out with this. I suppose it's just something to do with the programmer I'm using so I'll buy another one and hope for the best.. image

MCUdude commented 1 year ago

No worries! It might be something with your programmer, I don't know. The cheapest and most reliable AVR programmer is probably the USBasp. I'll recommend getting this one!

cerickson888 commented 1 year ago

I just received a new AVRISP mk2 (original not a copy) and it showed-up as a com port device right away allowing me to "Get Board Info" from Arduino IDE. However, it shows-up in Device Manager under "Other Devices" and does not have a driver installed. I searched for one online but couldn't find one. The AVRISP mk2 appeared in Zadig as "USB Serial" so I tried replacing the driver with libusbK but that just resulted in one less com port device in system. Any suggestions?

MCUdude commented 1 year ago

The original AVRISPmkII is not a UAB to a serial device, so it should not show up as a COM port. I have an original one myself, so I can confirm. Are you 100% sure it is a genuine one?

If you use the libusbk driver, it should work with Avrdude if you have a working AVRISPmkII programmer.

cerickson888 commented 1 year ago

I realize this is totally not your problem so I'm going to stop bugging you about it. For what it's worth, I'm in Shenzhen where I buy almost everything from Taobao. You're supposed to be able to get authentic stuff from jd.com but, maybe not.

Not a hardcore embedded guy but I used PIC's back when they required a UV eraser, AVRs well before Arduino was popular, STM's cuz they're cheap enough for production.. never had this much trouble just trying to code a chip. Ironically, I wanted to run Arduino on a Atmega128 to make things easier i.e. even with 53 io's I still have to mux the inputs but at least I can drive 12 motors directly. Pluss most of the LSM6DS3 libraries are written for Arduino. eh, some way some how.. :)

mcuee commented 1 year ago

Just FYI, there are many AVRISP mkii clones from Taobao/AliExpress and some of them are not working well at all. For example, I have one from AliExpress which uses firmware USB and it will not work at all under Windows, even though it seems to work under Linux. Then I have another one from Taobao which is also problematic under Windows/Linux.

As for the driver, you may have to install Atmel Studio to get the proper driver. Zadig should work though (either WinUSB driver or libusbk driver).