bugAVR Downloader/UploaDEr - Bugs: bug #60863, avrftdi programming error probably...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #60863: avrftdi programming error probably caused by multiple, consecutive empty pages

Submitter:  Martin Thierer <thierer>
Submitted:  Wed 30 Jun 2021 06:41:27 PM UTC
   
 
Category:  None Severity:  3 - Normal
Priority:  5 - Normal Item Group:  None
Status:  Fixed Privacy:  Public
Assigned to:  joerg_wunsch Originator Name:  Martin Thierer
Open/Closed:  Closed Release:  6.3
Programmer hardware:  avrftdi Device type:  m32u4

Sun 07 Nov 2021 04:00:43 PM UTC, comment #1: 

I decided your patch to skip empty pages makes sense, applied in r1462.

Joerg Wunsch <joerg_wunsch>
Group administrator
Wed 30 Jun 2021 06:41:27 PM UTC, original submission:  

I get consistent programming errors when flashing the Arduino "Caterina" bootloader to an atmega32u4 with the avrftdi driver. The first 16 bytes of the bootloader (at byte address 0x7000) are not programmed.

Flashing the same file with avrdude using either an usbasp or an usbtiny programmer works fine.

This seems to be caused by the many empty (0xff filled) pages, which are only guarded by a usleep(m->max_write_delay) in avrftdi_flash_write() because polling doesn't work for them.

1. Using a delay instead of polling is what the datasheet suggests (28.8.1 / 4.) and the delay of 4.5ms is correct, so it's not obvious why it doesn't work. My best guess is that libftdi or the chip itself buffer the data and make ftdi_write_data() return while data is still transferred to the MCU, causing the delay to start early. Increasing the delay 10x fixes the problem for me, but I don't consider that the correct solution.

2. I wonder why empty pages are "programmed" in the first place? Even if the flash wasn't erased I can't see that making a difference? Or does it? As a proof of concept I modified avrftdi_flash_write() to skip empty pages (see attached patch) and that fixes the problem for me, too.

Martin Thierer <thierer>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attached Files

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by joerg_wunsch (Posted a comment)
  • -email is unavailable- added by thierer (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-11-07 joerg_wunsch StatusNone Fixed
        Assigned toNone joerg_wunsch
        Open/ClosedOpen Closed
    2021-06-30 thierer Attached File- Added ftdi-skip-empty-pages.patch, #51631

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code