Hi Harald
I made a bunch of changes that significantly improved my test scenario:
Before the changes, the LTE SIM card being traced on a USB modem would fairly consistently "restart" the simtrace board (I later found out that the WDT was kicking in). And the same sim card on a Galaxy SII phone would get corrupted data (ie., wireshark would no longer be able to follow the conversation)
The changes are as follow:
1) The req_ctx are loaded into a double-linked list for consistency (FIFO manner). Previously, in the old code when multiple req_ctx are ready for transmit to USB, the lowered numbered (which may be the most recently filled req_ctx) would always be transmitted first. Additionally, to simplify the queue, there is only a single sized req_ctx now, 1 kb. There are 19 of them allocated.
2) The debug ring buffer is now transmitted using Peripheral DMA. Receive is left alone. Also, the append/flush and AT..._PrintFrame is written to allow for re-entrance (via Interrupt handler). Additionally, debugp will always prefix a line number to help / assist in debugging.
3) The watch dog (wdt.c) is modified so I can see when the watch dog is activated (which it no longer does in my current test, so you can comment out the #define WDT_DEBUG line...)
4) Both the usb interrupt and the uart interrupt handlers first enable core interrupt so that the AIC can do interrupt nesting (I observed at least 1 uart overrun per DEBUGPCR prior to these changes)
5) Minor additional debugpcr in req_ctx_init and in udp_refill_ep to indicate where the req_ctx are and containing what data to assist debug
Please review and comment
Issues I will work on further:
1) The first APDU after the ATR is almost always broken up (I don't think it's due to my changes). And occasionally, the length byte (p3?) sometimes is missing (ONLY on this LTE sim card / MODEM).
2) I need the simtrace to transmit a complete APDU as soon as possible. It seems not consistent on when it sends out received data to the USB. Sometimes, I would see GSM AUTHENTICATE apdu without a response for quiet a while...
----
I would like to have an additional field (2 byte short) in the simtrace header (the beginning of the req_ctx to indicate the position of the first byte of an APDU, so that in the event the synchronization is lost, the pc side can recover, because it appears the firmware code tracks the state of the APDU so it should be able to indicate it.
Thanks
Best Regards