I've written a boot loader for a Tiva TM4C1237. I use a Python program to test it. I have found that very specifically-sized combinations of USB OUT followed by IN transactions fail consistently.
I'm using a small Python program and pyusb to find the device by VID/PID and interactively send USB requests to test my Tiva firmware. I can send IN and OUT requests of various sizes to EP0. I have found that this combination of transactions fails consistently:
- An OUT transaction to EP0 of exactly any (1..n) multiple of max_packet_size bytes, followed by
- An IN transaction to EP0 of more than max_packet_size bytes.
Under those specific conditions, the OUT transaction succeeds, but the IN transaction that follows it will always fail. Deviating either transaction size by one byte will prevent the failure from occurring. After the failure occurs, subsequent IN transactions will frequently continue to fail, until at some point, the problem gets cleared and subsequent IN transactions will succeed.
Here are some specific numeric examples (max_packet_size is 64):
- These will all succeed, regardless of the IN size, because the OUT size is not a multiple of 64:
- OUT 63 bytes, IN 63 bytes: SUCCEEDS
- OUT 63 bytes, IN 64 bytes: SUCCEEDS
- OUT 63 bytes, IN 65 bytes: SUCCEEDS
- OUT 100 bytes, IN 63 bytes: SUCCEEDS
- OUT 100 bytes, IN 64 bytes: SUCCEEDS
- OUT 100 bytes, IN 65 bytes: SUCCEEDS
- OUT 129 bytes, IN 512 bytes: SUCCEEDS
- These will all succeed, regardless of the OUT size, because the IN size is not more than 64:
- OUT 64 bytes, IN 63 bytes: SUCCEEDS
- OUT 64 bytes, IN 64 bytes: SUCCEEDS
- OUT 128 bytes, IN 64 bytes: SUCCEEDS
- OUT 512 bytes, IN 64 bytes: SUCCEEDS
- These all fail, because the OUT is exactly n*64, where n=1,2,3,..., and the IN is more than 64:
- OUT 64 bytes, IN 65 bytes: FAILS
- OUT 64 bytes, IN 512 bytes: FAILS
- OUT 128 bytes, IN 100 bytes: FAILS
- OUT 512 bytes, IN 65 bytes: FAILS
Upon further investigation, I found that when the IN failure occurs, it happened because the USB interrupts did not occur.
Since the problem only occurs under very specific conditions of OUT followed by IN, I suspect the problem is not in my firmware.
I have prepared a minimal CCS project and the Python program that demonstrate the problem, but the forum does not allow me to attach those files, so I don't know how to make them available to others. I'm using CCS version 11, and TivaWare_C_Series-2.2.0.295.