Skip to content

[CH32V203] DFU download hangs on larger files with PMAOVR (PMA Overrun) interrupt #3573

@Devin-goBILDA

Description

@Devin-goBILDA

Operating System

Windows 11

Commit SHA

Release 0.20.0

Board

nanoCH32V203 & WeActStudio BluePill Plus CH32

Firmware

Here is a repo containing the bare dfu example found in examples/device/dfu that was slightly modified to work with MounRiver Studio II. https://github.com/Devin-goBILDA/CH32V203-TinyUSB-DFU-Issue.

This issue is reproducible with the stock examples/device/dfu example code running on a ch32v203.

What happened ?

I am in the process of creating a DFU bootloader with using both TinyUSB and a CH32V203. I setup TinyUSB with my MounRiver Studio II project and compiled the dfu example code found in examples/device/dfu. I then navigated to https://devanlai.github.io/webdfu/dfu-util/ in order to transfer few small files (512 bytes), that worked flawlessly! I then continued to setup my bootloader project and when it was finally time to send a relatively basic firmware file (roughly 9000-ish bytes) the transfer would hang. Upon using the debugger I noticed that every time it gets hung on a TU_BREAKPOINT in the dcd_stm32_fsdev.c.

Link to code in 0.20.0: dcd_int_handler

void dcd_int_handler(uint8_t rhport) {
  uint32_t int_status = FSDEV_REG->ISTR;

  /* Commented out Code */

  if (int_status & USB_ISTR_PMAOVR) {
    TU_BREAKPOINT();                           /* <- This is where is breaks */
    FSDEV_REG->ISTR = (fsdev_bus_t)~USB_ISTR_PMAOVR;
  }
}

Here is exactly where the PMAOVR is defined: USB_ISTR_PMAOVR

#define USB_ISTR_PMAOVR                      ((uint16_t)0x4000U)               /*!< DMA OVeR/underrun (clear-only bit) */

I am not super familiar with the lower level aspects of USB, but I would love to help in any way possible.

How to reproduce ?

  • Using MounRiver Studio II

    1. Clone this repo: https://github.com/Devin-goBILDA/CH32V203-TinyUSB-DFU-Issue
    2. Open the cloned repo in MounRiver Studio II
    3. Upload the firmware to your connected board (Default: WeActStudio BluePill Plus)
  • Only using the TinyUSB DFU Example

    1. Clone TinyUSB and set it up to work with the CH32V203 (Can use the nanoCH32V203 board that is in the hw folder)
    2. Configure the project to use the DFU example code found in examples/device/dfu
    3. Upload the firmware to the board

How to upload data and cause the crash

  1. Plug your MCU in via USB and go to https://devanlai.github.io/webdfu/dfu-util/
  2. Connect to the board, select EEPROM or FLASH (Both lead to the same outcome), select this file: Large File (10240 bytes).txt , then click "Download"
  3. While transferring the text file it will freeze and display this message "Error during DFU download: DFU GETSTATUS failed: ControlTransferIn failed: NetworkError: Failed to execute 'controlTransferIn' on 'USBDevice': A transfer error has occurred."

Note: I tested the dfu transfer with both dfu-util and the webdfu website, they both resulted in the same outcome.

Debug Log as txt file (LOG/CFG_TUSB_DEBUG=2)

Both debug logs ended in a DFU transfer failure. The bottom of the logs is the point at which the communication failed

Debug Log.txt
Debug Log (TU_BREAKPOINT Disabled).txt

Screenshots

Image

I have checked existing issues, discussion and documentation

  • I confirm I have checked existing issues, discussion and documentation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions