-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unable to burn bootloader for mega2560 #200
Comments
The error message is pretty self-explanatory, isn't it? |
yeah but it work fine with the standard mega2560 boards if i switch between the two, this only fails on the megacore |
Can you turn on verbose upload under the IDE settings, and paste the entire output here? |
The difference between the official Arduino boards and MegaCore in terms of uploading is that MegaCore uses Avrdude 7.1, while The standard Arduino boards use Avrdude 6.3 |
This is the standard mega flashing the bootloader
|
and this is the MegaCore
|
So why is 7 failing but 6 works OK |
can we get megacore to point to 6 for avrdude ? |
Ah, you're using the AVRISPmkii! There is a bug in the programmers.txt file that I fixed a while ago on the other Arduino cores I host. I'll have to release a new version that fixes this soon, but meanwhile, you can easily fix this yourself. Find the programmers.txt file in the boards manager installation and find the following line: avrispmkii.program.extra_params= and replace it with: avrispmkii.program.extra_params=-Pusb |
so it should look like this ? avrispmkii.name=AVRISP mkII |
progress but not just there thet, we now have the following errors "C:\Users\Peter\AppData\Local\arduino15\packages\MegaCore\tools\avrdude\7.1-arduino.1/bin/avrdude" "-CC:\Users\Peter\AppData\Local\arduino15\packages\MegaCore\hardware\avr\2.2.2/avrdude.conf" -v -patmega2560 -cstk500v2 -Pusb -e -Ulock:w:0xff:m -Uefuse:w:0xfd:m -Uhfuse:w:0b11010110:m -Ulfuse:w:0xf7:m avrdude: Version 7.1-arduino.1
avrdude usbdev_open() error: cannot open device: Permission denied avrdude done. Thank you. Failed chip erase: uploading error: exit status 1 |
What happens if you replace the entire avrispmkii section with this? (replaced stk500v2 with avrispmkii)
|
Away from my pc for a couple of hours. My dog want walking and is not gonna take a pass LOL I’ll try this when I get back thanks a lot for your help
Cheers Pete
… On 24 Apr 2023, at 16:31, Hans ***@***.***> wrote:
What happens if you replace the entire avrispmkii section with this?
(replaced stk500v2 with avrispmkii)
avrispmkii.name=AVRISP mkII
avrispmkii.communication=usb
avrispmkii.protocol=avrispmkii
avrispmkii.program.protocol=avrispmkii
avrispmkii.program.tool=avrdude
avrispmkii.program.extra_params=
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.
|
Nope unfortunatly that did not work either |
Try pasting the following command in Windows command prompt: This first:
And then this:
And post the output of each command here. I'm trying to figure out why Avrdude 6.3 works while Avrdude 7.1 doesn't. |
I have modified my avrdude.cfg and programmers.txt files, can you send my some virgin copies so we are both singing from the same hymn sheet PLZ |
Dont wory i grabbed them from the repository |
and this is the second ...... C:\Windows\System32>"C:\Users\Peter\AppData\Local\arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude" "-CC:\Users\Peter\AppData\Local\arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf" -v -patmega2560 -csvrispmkii -Pusb avrdude: Version 6.3-20190619
avrdude: Can't find programmer id "svrispmkii" Valid programmers are: |
and the first ...... C:\Windows\System32>"C:\Users\Peter\AppData\Local\arduino15\packages\MegaCore\tools\avrdude\7.1-arduino.1/bin/avrdude" "-CC:\Users\Peter\AppData\Local\arduino15\packages\MegaCore\hardware\avr\2.2.2/avrdude.conf" -v -patmega2560 -csvrispmkii -Pusb avrdude: Version 7.1-arduino.1
avrdude programmer_not_found() error: cannot find programmer id svrispmkii Valid programmers are: |
OK, there is a typo in both commands, and that's my fault.
You'll have to do your part to get the command to actually run. It looks like a copy/paste mistake to me. |
First one .......
Second one .........
|
Sooooooo Second one works ~~~~~ what's with the "Permission denied" message on the first one. |
It's most likely a driver issue. I'm not sure why. Avrdude 7.1 should provide better compatibility, not worse. @mcuee do you have any idea what going on here? Here's what you can do:
|
OK with the WinUSB driver loaded here is the first command result C:\Windows\System32>"C:\Users\Peter\AppData\Local\arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude" "-CC:\Users\Peter\AppData\Local\arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf" -v -patmega2560 -cavrispmkii -Pusb avrdude: Version 6.3-20190619
avrdude: usbdev_open(): Found AVRISP mkII, serno: 000200216512
avrdude: AVR device initialized and ready to accept instructions Reading | ################################################## | 100% 0.02s avrdude: Device signature = 0x1e9801 (probably m2560) avrdude: safemode: lfuse reads as FF avrdude done. Thank you. C:\Windows\System32>"C:\Users\Peter\AppData\Local\arduino15\packages\MegaCore\tools\avrdude\7.1-arduino.1/bin/avrdude" "-CC:\Users\Peter\AppData\Local\arduino15\packages\MegaCore\hardware\avr\2.2.2/avrdude.conf" -v -patmega2560 -cavrispmkii -Pusb avrdude: Version 7.1-arduino.1
avrdude: usbdev_open(): found AVRISP mkII, serno: 000200216512
avrdude: AVR device initialized and ready to accept instructions avrdude done. Thank you. and here is the second command C:\Windows\System32>"C:\Users\Peter\AppData\Local\arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude" "-CC:\Users\Peter\AppData\Local\arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf" -v -patmega2560 -cavrispmkii -Pusb avrdude: Version 6.3-20190619
avrdude: usbdev_open(): did not find any USB device "usb" (0x03eb:0x2104) avrdude done. Thank you. C:\Windows\System32> |
That seems about right. WinUSB will only work with Avrdude 7.1. But which USB driver was previously selected that did work with Avrdude 6.3 but not with Avrdude 7.1? |
So the WinUSB (v6.1.7600.16385) drivers work with the avrdude: Version 7.1-arduino.1 but i need to use the libusb-win32 (v1.2.7.3) drivers with avrdude: Version 6.3-20190619 |
The thing is that Avrdude 7.1 should work both libusb and WinUSB. I'm not sure why libusb-win32 doesn't work for you. As a last test, can you try using libusbK, and see if this works with both 6.3 and 7.1? |
It does not they seem to be mutualy exclusive :( |
Now that i have it uploadig and flashing the bootloader using the arduino IDE my next trick it to get it working through platformio do you have a platformIO files that you know works with this combination of drivers and MCU ? |
So, libusbK does work with both, or none? But on Windows, WinUSB is the preferred driver, since Microchip Studio 7 or MPLAB X will work with the WinUSB driver, and not libusb.
Yes, See https://github.com/MCUdude/MegaCore/blob/master/PlatformIO.md for details This should, however, suit your needs, given that your ATmega2560 is running at 16 MHz. ; PlatformIO template configuration file for MegaCore
; https://github.com/MCUdude/MegaCore/
;
; Build options: build flags, source filter
; Hardware options: oscillator type, BOD, UART number, EEPROM retain
; Upload options: custom upload port, speed, and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options
; https://github.com/MCUdude/MegaCore/blob/master/PlatformIO.md
; https://docs.platformio.org/page/projectconf.html
; https://docs.platformio.org/en/latest/platforms/atmelavr.html
[platformio]
default_envs = Upload_UART ; Default build target
; Common settings for all environments
[env]
platform = atmelavr
framework = arduino
; TARGET SETTINGS
; Chip in use
board = ATmega2560
; Clock frequency in [Hz]
board_build.f_cpu = 16000000L
; BUILD OPTIONS
; Comment out to enable LTO (this line unflags it)
build_unflags = -flto
; Extra build flags
build_flags =
; SERIAL MONITOR OPTIONS
; Serial monitor port defined in the Upload_UART environment
monitor_port = ${env:Upload_UART.upload_port}
; Serial monitor baud rate
monitor_speed = 9600
; Run the following command to upload with this environment
; pio run -e Upload_UART -t upload
[env:Upload_UART]
; Serial bootloader protocol
upload_protocol = arduino
; Serial upload port
upload_port =
; Get upload baud rate defined in the fuses_bootloader environment
board_upload.speed = ${env:fuses_bootloader.board_bootloader.speed}
; Run the following command to upload with this environment
; pio run -e Upload_ISP -t upload
[env:Upload_ISP]
; Custom upload procedure
upload_protocol = custom
; Avrdude upload flags
upload_flags =
-C$PROJECT_PACKAGES_DIR/tool-avrdude/avrdude.conf
-p$BOARD_MCU
-PUSB
-cavrispmkii
; Avrdude upload command
upload_command = avrdude $UPLOAD_FLAGS -U flash:w:$SOURCE:i
; Run the following command to set fuses
; pio run -e fuses_bootloader -t fuses
; Run the following command to set fuses + burn bootloader
; pio run -e fuses_bootloader -t bootloader
[env:fuses_bootloader]
board_hardware.oscillator = external ; Oscillator type
board_hardware.uart = uart0 ; Set UART to use for serial upload
board_bootloader.speed = 115200 ; Set bootloader baud rate
board_hardware.bod = 2.7v ; Set brown-out detection
board_hardware.eesave = yes ; Preserve EEPROM when uploading using programmer
upload_protocol = avrispmkii ; Use the USBasp as programmer
upload_flags = ; Select USB as upload port and divide the SPI clock by 8
-PUSB
-B8 Use Use Use |
It's OK i have it working in visual code and platformIO [platformio] bla bla bla [env:Upload_ISP] |
thanks so much for your help, please drop a note back here if you ever figure out why those drivers are not behaving as expected. |
Let me try libusb0.sys to see I can reproduce the issue or not. Take note the latest version of libusb0.sys is 1.2.7.3. There are known issues of libusb0.sys 1.2.6.0 with avrdude. As mentioned by Hans, the preferred driver for AVRISP mkII is WinUSB, since Microchip Studio 7 or MPLAB X will work with the WinUSB driver, and not libusb0.sys. If you really want to use both Arduino's version of avrdude 6.3 (using libusb-win32 library, only working with libusb0.sys and libusbK.sys but not WinUSB) and 7.1 (using libusb-1.0 + libusb-compat-0.1 library, working well with WinUSB and libusbK.sys but not so well with libusb0.sys), then it is recommended that you use libusbK driver. The official avrdude 7.1 Windows binary is using avrdude-libusb which supports all three drivers. So there is another option to switch to that binary. It has some issues but may not really impact the use in MegaCore or other Arduino Core. |
I do not have the ATmega2560 with me right now, so I tested with ATmega328P and I can not reproduce the issue using MiniCore (with MCUdude/MiniCore@6d77019), all three drivers work fine. I will test MegaCore later and I believe it will be fine as well. Run log with libusb0.sys 1.2.6.0 driver. Arduino run log with libusb0.sys 1.2.6.0 driver
|
@BainesBunch
|
@mcuee I suspect he used the libusb driver that was bundled with Arduino IDE (libusb0.dll, found in Arduino/hardware/tools/avr/bin). My (work) computer says this is version 1.2.6.0: |
No issues with ATmega2560 either with MegaCore (with 12e390c fix).
|
@BainesBunch Once I rename
|
Please also read libusb Wiki here. Yes I agree it is rather complicated but that is the reality to use libusb under Windows. FYI: I am the non-developer admin of libusb, libusb-win32 and libusbK project, as well as avrdude project, mainly on testing and supporting side, as I can not code. |
I think the issue can be closed. |
avrdude: Version 7.1-arduino.1
Copyright the AVRDUDE authors;
see https://github.com/avrdudes/avrdude/blob/main/AUTHORS
avrdude ser_open() error: cannot open port /dev/ttyS0: The system cannot find the path specified.
avrdude main() error: unable to open programmer stk500v2 on port /dev/ttyS0
avrdude done. Thank you.
Failed chip erase: uploading error: exit status 1
The text was updated successfully, but these errors were encountered: