MAX32625PICO transmits UART data twice when built with GCC
- Dominant language
- C
- Stars
- 2.8k
- Forks
- 1.1k
- Avg merge
- 3d 12h
- Merged PRs (30d)
- 1
Description
Hello DAPLink team!
I've been tracking down an issue when using the MAX32625PICO. I have a local build of the FW, built from the 0257 release. I include a small change that makes the PICO use the DIP pins instead of the SWD header by default: https://github.com/bridadan/DAPLink/tree/debug_double_tx
I'm building with GCC: `python tools/progen_compile.py --toolchain make_gcc_arm max32625_if --clean`. And I'm using just the interface build since I don't want the MSD feature (though I've confirmed it also appears when the MSD is active using the `max32625_max32620fthr_if` project).
The issue is occasionally the PICO will transmit some UART data twice, even though I've only sent it once. Here's my test setup:
1. One PICO setup as a transmitter, another setup as a receiver (DIP P0_1 from the TX connected to DIP P0_0 on the RX)
2. A Saleae logic analyzer connected to the UART line to serve as a ground truth
3. Kernel level USB traffic snooping using the `usbmon` kernel module and wireshark for trace capture
Each PICO is being controlled by a Python script (present in my branch above):
- The transmitter is controlled by `serial_stress_test_tx.py`
- The receiver is controlled by `serial_stress_test_rx.py`
The transmitter and receiver are synchronized by first sending an `s` character (since I was having issues with data remaining in the buffer). Once that's done, the transmitter will transmit an integer followed by a `\n`. The integer increases by one each transmit. The receive will look for any transmissions that don't follow this sequence and it will print the line it received. This allows you to then match up the bad line with what was measured by the Saleae and the USB trace.
I've attached my Saleae capture (*.sal) and the Wireshark USB trace (*.pcapng) below. You can see that the line that includes `27` was transmitted twice by the PICO but it was only commanded once in the USB trace (filter with `usb.device_address==52` to only see messages sent to the PICO).

[double_tx_27.zip](https://github.com/ARMmbed/DAPLink/files/11149032/double_tx_27.zip)
The interesting thing with all of this is it _doesn't_ appear to be an issue on the released 0257 build using armcc. I don't have access to a copy of armcc so I can't verify it locally.
One thing I can say is I made some modifications to the firmware to try and figure out if its a bug in the UART driver or if its somewhere in the USB stack. I know that `uart_write_data()` is being called twice with the same contents (same length, same buffer), so that leads me to believe that the error is occurring before the UART driver. Hopefully that helps narrow it down, I'd appreciate any ideas or pointers!
Contributor guide
Research direction
Start by reproducing the GCC build with `python tools/progen_compile.py --toolchain make_gcc_arm max32625_if --clean`, using `serial_stress_test_tx.py` and `serial_stress_test_rx.py`. Trace the repeated calls to `uart_write_data()` and compare the Saleae capture with the USB trace, filtering with `usb.device_address==52`; done means one commanded line is transmitted once.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, python
- Domain
- embedded-iot
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100