Skip to content
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

flip2: ATxmega32A4U DFU bootloader does not work even though Atmel FLIP 3.47 works fine. #1082

Closed
mcuee opened this issue Aug 21, 2022 · 7 comments
Labels
invalid This doesn't seem right

Comments

@mcuee
Copy link
Collaborator

mcuee commented Aug 21, 2022

I have got the DFU bootloader to work on a simple breakout board of ATxmega32A4U (from MCUzone).

When downloading application, Atmel FLIP 3.47 works fine. However avrdude does not seem to work.

PS C:\work\avr\avrdude_test\avrdude_bin> .\avrdude -c flip2 -p x32a4u -U application:w:flip2_demo_app.hex:i

avrdude.exe: AVR device initialized and ready to accept instructions

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

avrdude.exe: Device signature = 0x1e9541 (probably x32a4u)
avrdude.exe: NOTE: "application" memory has been specified, an erase cycle will be performed
             To disable this feature, specify the -D option.
avrdude.exe: erasing chip
avrdude.exe: reading input file flip2_demo_app.hex for application
avrdude.exe: writing 29166 bytes application ...

Writing | ############################                       
| 56% 0.31savrdude.exe: Error: DFU_DNLOAD failed: short write
avrdude.exe: Error: Failed to set memory page 0x0000
Writing | #############################                      
| 57% 0.32savrdude.exe: Error: DFU_DNLOAD failed: short write
avrdude.exe: Error: Failed to set memory unit 0x00 (Flash)
 ***failed;
avrdude.exe: Error: DFU_DNLOAD failed: short write
avrdude.exe: Error: Failed to write 0x0001 bytes at 0x0006
 ***failed;
avrdude.exe: Error: Failed to get DFU status: short read
avrdude.exe: Error: Failed to write 0x0001 bytes at 0x0078
 ***failed;
avrdude.exe: Error: DFU_DNLOAD failed: short write
avrdude.exe: Error: Failed to set memory page 0x0000
 ***failed;
avrdude.exe: Error: DFU_DNLOAD failed: short write
avrdude.exe: Error: Failed to set memory page 0x0000
 ***failed;
avrdude.exe: Error: DFU_DNLOAD failed: short write
avrdude.exe: Error: Failed to write 0x0001 bytes at 0x00A2
 ***failed;
avrdude.exe: Error: DFU_DNLOAD failed: short write
avrdude.exe: Error: Failed to set memory page 0x0000
 ***failed;
avrdude.exe: Error: DFU_DNLOAD failed: short write
avrdude.exe: Error: Failed to write 0x0001 bytes at 0x00A5
 ***failed;
avrdude.exe: Error: DFU_DNLOAD failed: short write
avrdude.exe: Error: Failed to write 0x0001 bytes at 0x0101
 ***failed;
avrdude.exe: Error: DFU_DNLOAD failed: short write
avrdude.exe: Error: Failed to set memory page 0x0000
 ***failed;
<CTRL-C>

After I program the demo application using Atmel FLIP 3.47, avrdude still failed to verify.

PS C:\work\avr\avrdude_test\avrdude_bin> .\avrdude -c flip2 -p x32a4u
 -U application:v:flip2_demo_app.hex:i

avrdude.exe: AVR device initialized and ready to accept instructions

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

avrdude.exe: Device signature = 0x1e9541 (probably x32a4u)
avrdude.exe: verifying application memory against flip2_demo_app.hex

Reading | #######################                            
| 46% 0.21savrdude.exe: Error: DFU_DNLOAD failed: short write
avrdude.exe: Error: Failed to set memory page 0x0000
Reading | ########################                           
| 47% 0.22savrdude.exe: Error: DFU_UPLOAD failed: short read
avrdude.exe: Error: Failed to read 0x0001 bytes at 0x0006
avr_read(): error reading address 0x0006
    read operation not supported for memory "application"
Reading | ################################################## | 100% 0.24s

avrdude.exe: failed to read all of application memory, rc=-2

avrdude.exe done.  Thank you.

@mcuee mcuee added the bug Something isn't working label Aug 21, 2022
@mcuee
Copy link
Collaborator Author

mcuee commented Aug 22, 2022

Microchip xmega DFU bootloader AN (FLIP2)
https://ww1.microchip.com/downloads/en/Appnotes/doc8429.pdf
http://www.atmel.com/Images/AVR1916.zip
Supposedly ASF has the DFU bootloader example as well.

Alternative DFU bootloader implementations.
https://github.com/kuro68k/xmega_dfu_bootloader (GPL v3)
https://github.com/ganzziani/Xproto-Watch-Bootloader (GPL v3)

Official PC host tool: Atmel FLIP (which supports flip1 and flip2)
https://www.microchip.com/en-us/development-tool/flip

Alternative host program other than avrdude
https://sourceforge.net/projects/dfu-programmer/

@MCUdude
Copy link
Collaborator

MCUdude commented Oct 3, 2022

I wonder if this has anything to do with the ATxmega32A4U being a device with less than 128kiB flash.
I have a hybrid Arduino UNO board with an ATxmega128A3U I can modify to piggyback a USB connector on, so I can check if flip2 works or not on this chip.

I've had a look at Xmega-based Xplained boards, and very few of them have a "native" USB connector intended for the flip2 bootloader. I have an STK600 that could be used for this, but the socket adapters are so freaking expensive that I can't justify buying one just to help out and potentially fix a single issue.
EDIT: STK600 socket adapters are also going obsolete, so they're also difficult to find

@mcuee
Copy link
Collaborator Author

mcuee commented Mar 26, 2023

I wonder if this has anything to do with the ATxmega32A4U being a device with less than 128kiB flash.
I have a hybrid Arduino UNO board with an ATxmega128A3U I can modify to piggyback a USB connector on, so I can check if flip2 works or not on this chip.

@MCUdude

I am going through the existing bug reports and this is one of them. Just wondering if you have got a chance to test on your side. Thanks. But I think this is not an important one to fix.

https://github.com/avrdudes/avrdude/issues?q=is%3Aopen+is%3Aissue+label%3Abug

@mcuee
Copy link
Collaborator Author

mcuee commented May 7, 2023

Unfortunately I can not get the USB bootloader working now for this device. Strange. The device can not be recognized by Windows 11 or Ubuntu Linux 20.04.

Edit: the bootloader can be recognized. I need to press the S2 button (PE0 pin) to go into bootloader pin.

dmesg log under Ubuntu 20.04 Linux.

[  695.703304] usb 3-1: new full-speed USB device number 24 using xhci_hcd
[  695.853035] usb 3-1: New USB device found, idVendor=03eb, idProduct=2fe4, bcdDevice= 0.04
[  695.853043] usb 3-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0

But it does not work at all under Linux.

mcuee@UbuntuSwift3:~/build/avr/avrdude_bin$ ./avrdude -c flip2 -p x32a4u -v

avrdude: Version 7.1-20230108
         Copyright the AVRDUDE authors;
         see https://github.com/avrdudes/avrdude/blob/main/AUTHORS

         System wide configuration file is /home/mcuee/build/avr/avrdude_bin/avrdude.conf
         User configuration file is /home/mcuee/.avrduderc
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : usb
         Using Programmer              : flip2
         AVR Part                      : ATxmega32A4U
         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
           ----------- -------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           fuse1                   0     0     0    0 no          1    1      0     0     0 0x00 0x00
           fuse2                   0     0     0    0 no          1    1      0     0     0 0x00 0x00
           fuse4                   0     0     0    0 no          1    1      0     0     0 0x00 0x00
           fuse5                   0     0     0    0 no          1    1      0     0     0 0x00 0x00
           lock                    0     0     0    0 no          1    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         50   50      0     0     0 0x00 0x00
           data                    0     0     0    0 no          0    1      0     0     0 0x00 0x00
           eeprom                  0     0     0    0 no       1024   32      0     0     0 0x00 0x00
           flash                   0     0     0    0 no      36864  256      0     0     0 0x00 0x00
           application             0     0     0    0 no      32768  256      0     0     0 0x00 0x00
           apptable                0     0     0    0 no       4096  256      0     0     0 0x00 0x00
           boot                    0     0     0    0 no       4096  256      0     0     0 0x00 0x00
           usersig                 0     0     0    0 no        256  256      0     0     0 0x00 0x00

         Programmer Type : flip2
         Description     : FLIP for bootloader using USB DFU protocol version 2 (AVR4023)
avrdude: found VID=0x03eb PID=0x2fe4 at 003:024
avrdude dfu_dnload() error: DFU_DNLOAD failed: Input/output error
avrdude dfu_getstatus() error: unable to get DFU status: Input/output error
avrdude flip2_read_memory() error: unable to set memory unit 0x05 (signature)
avrdude: AVR device initialized and ready to accept instructions
avrdude avr_signature() error: unable to read signature data for part ATxmega32A4U, rc=-1
avrdude main() error: unable to read signature data, rc=-1

avrdude done.  Thank you.

@mcuee
Copy link
Collaborator Author

mcuee commented May 7, 2023

The bootloader works fine with dfu-programmer (https://github.com/dfu-programmer/dfu-programmer).

mcuee@UbuntuSwift3:~/build/avr/dfu-programmer$ dfu-programmer --version
dfu-programmer 1.0.0

mcuee@UbuntuSwift3:~/build/avr/dfu-programmer$ dfu-programmer atxmega32a4u erase
Checking memory from 0x0 to 0x7FFF...  Not blank at 0x1.
Erasing flash...  Success
Checking memory from 0x0 to 0x7FFF...  Empty.

mcuee@UbuntuSwift3:~/build/avr/avrdude_bin$ dfu-programmer atxmega32a4u flash flip2_demo_app.hex 
Checking memory from 0x0 to 0x71FF...  Empty.
0%                            100%  Programming 0x7200 bytes...
[>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>]  Success
0%                            100%  Reading 0x8000 bytes...
[>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>]  Success
Validating...  Success
0x7200 bytes written into 0x8000 bytes memory (89.06%).

@mcuee
Copy link
Collaborator Author

mcuee commented May 7, 2023

Hmm, now it works under Linux.

mcuee@UbuntuSwift3:~/build/avr/avrdude_bin$ ./avrdude -c flip2 -p x32a4u -e
avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e9541 (probably x32a4u)
avrdude: erasing chip

avrdude done.  Thank you.

mcuee@UbuntuSwift3:~/build/avr/avrdude_bin$ ./avrdude -c flip2 -p x32a4u -U application:w:flip2_demo_app.hex:i
avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e9541 (probably x32a4u)
avrdude: Note: application 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 flip2_demo_app.hex for application
         with 29166 bytes in 1 section within [0, 0x71ed]
         using 114 pages and 18 pad bytes
avrdude: writing 29166 bytes application ...
Writing | ################################################## | 100% 0.55 s 
avrdude: 29166 bytes of application written
avrdude: verifying application memory against flip2_demo_app.hex
Reading | ################################################## | 100% 0.21 s 
avrdude: 29166 bytes of application verified

avrdude done.  Thank you.

@mcuee
Copy link
Collaborator Author

mcuee commented May 7, 2023

It works under Windows as well, using the default libusb-win32 driver.

PS C:\work\avr\avrdude_test\avrdude_bin> .\avrdude -c flip2 -p x32a4u -U application:w:flip2_demo_app.hex:i
avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e9541 (probably x32a4u)
avrdude: Note: application 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 flip2_demo_app.hex for application
         with 29166 bytes in 1 section within [0, 0x71ed]
         using 114 pages and 18 pad bytes
avrdude: writing 29166 bytes application ...
Writing | ################################################## | 100% 0.61 s
avrdude: 29166 bytes of application written
avrdude: verifying application memory against flip2_demo_app.hex
Reading | ################################################## | 100% 0.49 s
avrdude: 29166 bytes of application verified

avrdude done.  Thank you.

PS C:\work\avr\avrdude_test\avrdude_bin> .\dfu-programmer atxmega32a4u erase
Checking memory from 0x0 to 0x7FFF...  Not blank at 0x1.
Erasing flash...  Success
Checking memory from 0x0 to 0x7FFF...  Empty.
PS C:\work\avr\avrdude_test\avrdude_bin> .\dfu-programmer atxmega32a4u flash .\flip2_demo_app.hex
Checking memory from 0x0 to 0x71FF...  Empty.
0%                            100%  Programming 0x7200 bytes...
[>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>]  Success
0%                            100%  Reading 0x8000 bytes...
[>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>]  Success
Validating...  Success
0x7200 bytes written into 0x8000 bytes memory (89.06%).

@mcuee mcuee added invalid This doesn't seem right and removed bug Something isn't working labels May 7, 2023
@mcuee mcuee closed this as completed May 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants