Hi,
I have a PCB that I made with an Atemega4808.
I used a JTAG2UPDI to load the MegaCoreX bootloader onto it, and after that I've used a simple usb2serial for uploading code onto it.
This worked fine for a long time.
Today I wanted to update my code, but just cant make that.
Trying a normal upload I only get a pop up saying "request "upload" failed"
Trying to born bootloader with the JTAG2UPDI I get this errors:
avrdude: AVR device initialized and ready to accept instructions
avrdude warning: bad response to enter progmode command: RSP_ILLEGAL_MCU_STATE
avrdude warning: bad response to enter progmode command: RSP_ILLEGAL_MCU_STATE
avrdude error: bad response to read memory command: RSP_ILLEGAL_MCU_STATE
avrdude error: unable to read byte at address 0x0000
avrdude error: read operation not supported for memory signature
avrdude error: unable to read signature data for part ATmega4808, rc=-2
avrdude error: unable to read signature data, rc=-2
avrdude error: bad response to leave progmode command: RSP_ILLEGAL_MCU_STATE
avrdude done. Thank you.
Failed chip erase: uploading error: exit status 1
The 4808 is still running is last uploaded code, I can see it's output over the serial monitor.
Any ideas how to solve this?
Can the 4808 be fully reset using High-Voltage UPDI Programming? and if it can, what is the best tutorial for that?
Thanks
Hi @ZoharML.
The output from the failed "Burn Bootloader" attempt that you shared seems significant, but in case it might provide additional clues that will be useful to the forum helpers, I'm going to ask you to also provide the full verbose output from an upload attempt:
This procedure is not intended to solve the problem. The purpose is to gather more information.
Please do this:
- Select File > Preferences... (or Arduino IDE > Settings... for macOS users) from the Arduino IDE menus.
The "Preferences" dialog will open.
- Uncheck the box next to Show verbose output during:
☑ compile in the "Preferences" dialog.
- Check the box next to Show verbose output during: ☐ upload.
- Click the "OK" button.
The "Preferences" dialog will close.
- Attempt an upload, just as as you did before when you encountered that 'request "upload" failed' error.
- Wait for the upload to fail.
- You will see an "Upload error: ..." notification at the bottom right corner of the Arduino IDE window. Click the "COPY ERROR MESSAGES" button on that notification.
- Open a forum reply here by clicking the "Reply" button.
- Click the
<CODE/> icon on the post composer toolbar.
This will add the forum's code block markup (```) to your reply to make sure the error messages are correctly formatted.
- Press the Ctrl+V keyboard shortcut (Command+V for macOS users).
This will paste the error output from the upload into the code block.
- Move the cursor outside of the code block markup before you add any additional text to your reply.
- Click the "Reply" button to post the output.
@ptillisch , this is very strange, but I already have the verbose upload set.
To be on the safe side, I did a reboot, turned the versobe option off, turned them on again.
The upload (terminal if off), only gives the error pop up:
Clicking the "Copy error messeges" gets the compiler text:
Sketch uses 44757 bytes (91%) of program storage space. Maximum is 49152 bytes.
Global variables use 2104 bytes (34%) of dynamic memory, leaving 4040 bytes for local variables. Maximum is 6144 bytes.
I'm still using V2.3.3
Keep getting strange for me...
I've tried again to upload the code with the USB2Serail interface, and this time it worked on both the problematic card and a copy of it:
avrdude: Version 7.1-arduino.1
Copyright the AVRDUDE authors;
see https://github.com/avrdudes/avrdude/blob/main/AUTHORS
System wide configuration file is D:\Users\Zohar\Docs\Arduino\Shared_Arduino15\packages\MegaCoreX\hardware\megaavr\1.1.2\avrdude.conf
Using Port : COM3
Using Programmer : arduino
Overriding Baud Rate : 115200
AVR Part : ATmega4808
RESET disposition : dedicated
RETRY pulse : SCK
Serial program mode : yes
Parallel program mode : yes
Memory Detail :
Block Poll Page Polled
Memory Type Alias Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- -------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
fuse0 wdtcfg 0 0 0 0 no 1 1 0 0 0 0x00 0x00
fuse1 bodcfg 0 0 0 0 no 1 1 0 0 0 0x00 0x00
fuse2 osccfg 0 0 0 0 no 1 1 0 0 0 0x00 0x00
fuse4 tcd0cfg 0 0 0 0 no 1 1 0 0 0 0x00 0x00
fuse5 syscfg0 0 0 0 0 no 1 1 0 0 0 0x00 0x00
fuse6 syscfg1 0 0 0 0 no 1 1 0 0 0 0x00 0x00
fuse7 append 0 0 0 0 no 1 1 0 0 0 0x00 0x00
fuse8 bootend 0 0 0 0 no 1 1 0 0 0 0x00 0x00
fuses 0 0 0 0 no 9 10 0 0 0 0x00 0x00
lock 0 0 0 0 no 1 1 0 0 0 0x00 0x00
tempsense 0 0 0 0 no 2 1 0 0 0 0x00 0x00
signature 0 0 0 0 no 3 1 0 0 0 0x00 0x00
prodsig 0 0 0 0 no 61 61 0 0 0 0x00 0x00
sernum 0 0 0 0 no 10 1 0 0 0 0x00 0x00
osccal16 0 0 0 0 no 2 1 0 0 0 0x00 0x00
osccal20 0 0 0 0 no 2 1 0 0 0 0x00 0x00
osc16err 0 0 0 0 no 2 1 0 0 0 0x00 0x00
osc20err 0 0 0 0 no 2 1 0 0 0 0x00 0x00
data 0 0 0 0 no 0 1 0 0 0 0x00 0x00
userrow usersig 0 0 0 0 no 64 64 0 0 0 0x00 0x00
eeprom 0 0 0 0 no 256 64 0 0 0 0x00 0x00
flash 0 0 0 0 no 49152 128 0 0 0 0x00 0x00
Programmer Type : Arduino
Description : Arduino for bootloader using STK500 v1 protocol
Hardware Version: 3
Firmware Version: 9.0
avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e9650 (probably m4808)
avrdude: reading input file D:\Temp\WinTemp\arduino\sketches\7323C0E8D0863F184F68F1E8147E4490/Car_Keeper.ino.hex for flash
with 44517 bytes in 1 section within [0x200, 0xafe4]
using 348 pages and 27 pad bytes
avrdude: writing 44517 bytes flash ...
Writing | ################################################## | 100% 11.28s
avrdude: 44517 bytes of flash written
avrdude done. Thank you.
I don't know why it worked now, but not yesterday. 
I still cannot burn new bootloader. I did made some test in the past with one of these PCB's trying to lock the option to unload code from it.
How can I fully reset the 4808?
What Is the correct way to lock the 4808 so code could not be read out of it, but new code could be uploaded?
I think I found the source of the upload not working:
I had the "bootloader" option set to "none" and not "optiboot (UART0 default pins)" 
I think that some kind of a more infomative error like "could not communitacte with boad, have you set the bootloader" could have helped me find the cause of this.
I'm still stuck without the option to burn the bootloader that probebly have some locked security bits. how can I restore the 4808 to default?
Thanks for taking the time to post an update with your solution! I'm glad it is working now.
The Tools > Bootloader menu is produced by arbitrary "custom board options" that are configured by the MegaCoreX platform. Arduino IDE doesn't know anything about what this menu does, so it bespoke error messages regarding possible misconfiguration of the menu can't be implemented in the Arduino IDE codebase.
In theory, it would be possible for such an error message to be implemented in the MegaCoreX platform. This would be a bit complex because the current message is coming from the general purpose AVRDUDE uploader tool that is used by MegaCoreX, so the only way MegaCoreX could provide a bespoke error message would be by creating a wrapper around AVRDUDE which adds the bespoke message to the output produced by the avrdude command when appropriate. MegaCoreX is a hobby project so the resources available for adding enhancements like that are limited.