Menu

#183 TX_length limit ignored by stm32_run_raw_code()

none
New
nobody
None
Medium
Defect
2026-08-31
2026-08-28
Kari Hautio
No

TX_length is not obeyed by stm32.c:stm32_run_raw_code().

The run_raw_code function always uses maximum 256 byte transfers ignoring any lower limit set by the "-F" command line parameter.

This causes reset command to fail when using MCP2221 USB-I2C bridge on Linux (hardware bug limiting transfers to ~64 bytes.

Discussion

  • Tormod Volden

    Tormod Volden - 2026-08-30

    Thanks for the report. I have made a suggestion here: https://sourceforge.net/p/stm32flash/code/merge-requests/27/ Can you please try it out?

     
  • Kari Hautio

    Kari Hautio - 2026-08-31

    Due to the way the tx_size is handled you will need to do the same "-2 byte" adjustment in run_raw_code as in main.c:527 otherwise the write won't be 4 byte aligned.

    With the following change the code works in my setup (with -F 34:34).

            while (length > 0) {
                    w = length > ( stm->tx_frame_max - 2) ? ( stm->tx_frame_max - 2 ) : length;
                    if (stm32_write_memory(stm, address, pos, w) != STM32_ERR_OK) {
                            free(mem);
                            return STM32_ERR_UNKNOWN;
                    }
    
     
  • Tormod Volden

    Tormod Volden - 2026-08-31

    Right, thanks for correcting this. I have applied a fix mimicking the pattern in main.c.

     

Anonymous
Anonymous

Add attachments
Cancel