Fri Jul 12 12:19:16 EDT 2013

SIMtrace board

Board arrived, so probably best to use it for dev.

I don't have a lot of time to get this working.  What shortcuts to
take?  Main trouble is understanding the currently working code.  It
seems more complex than necessary.

First, set up tagging. (cscope)

The mainloop calls

CCID_SmartCardRequest() -> CCID_Read() -> USBD_Read() 

There are 2 USBD_Read() : USBD_UDP.c & USBD_UDPHS.c
simtrace uses USBD_UDP.c

Passed in is a callback:

Where is this called?  USBD_Read() just schedules a transfer.

Endpoint interrupt handler eventually calls UDP_EndOfTransfer() which
invokes the callback.


- Check if card driver works from python pc/sc bindings.
- Use the 0xFF apdu approach.

Does it use TPDU or APDU?  What's the difference?  Minor it seems..
can it be ignored for now?

Depends on features, which are set in configurationDescriptorsFS

Top row was added by Harald, bottom row was in the original example.
SIMtrace only does TPDU-level exchanges.

It seems both APDU/TPDU are handled in PCtoRDRXfrBlock()

Transfer (request + reply) is done by ISO7816_XfrBlockTPDU_T0()

USB reply is handled by RDRtoPCDatablock();

This mentions the ESCAPE command is supported:

but this mentions they need to be explicitly enableD:

Is it supported in pysc?
Doesn't look like.
It seems more trouble than it's worth.. let's use the CLA=FF approach.

From the code, it seems the card sends an ack before the command's
data payload is sent.  Makes no sense..

Yes in apdu_split.c there is an ack byte that's parsed.
ISO7816-3 3.5.b - Structure and processing of commands:
After transmission of such 5 byte header, the interface device waits for a procedure byte.

- Embedding in CLA=FF should work
- Problem: low level code is bound to a single serial port