HI,

No idea why this message did not make it through.

Resending with small updates.

------------------------------------------------

Hi,

it is time!


I am, right now, starting to implement the smart card mode for STM32 USART, starting with STM32H7, this will be portable to other STM32 chips I guess.

The UART mode will just configure the uart for smartcard shenanigans, eg, put it in working order for this mode.

Smart card contact protocols (T=0, T=1) will go into a user space app that manages readers, similar to pcsclite daemon in linux.


So the smart card mode of the stm32 usarts is just an activation of the proper registers, that will :

-wire the hardware as expected: enable the clock output, define one single full duplex IO line

-reconfigure the uart character framing, including parity generation and detection, which is a fundamental mechanism, required for protocol compliance testing.

The exchanges will still be made with the read() and write() primitives (protocol is a kind of IPC), so I am expecting to add just one IOCTL, like is done for LIN, single wire, and 485:


+#define TIOCSSMARTCARD  _TIOC(0x0038) /* Set Smart Card mode */

+#define TIOCGSMARTCARD  _TIOC(0x0039) /* Get Smart Card mode */


The parameter given to the IOCTL must be able to:

-ENABLE smart card mode with a bool parameter to enable or disable, default disabled

-START or STOP the clock signal

-Define the communication convention

-Define the communication speed in terms of ETU (clock pulses per bit, which is different from the baud rate and the industry standard way to define smart card comm speeds). This need to be modifiable, the speed is negotiated dynamically at card insertion.

-Define the character guard time, which is a delay between transmitted characters.

This will return a ENOTTY error if a particular uart does not support Smart Card mode.


The goal is to facilitate the upstreaming of this feature.

I know smart cards are unusual and quite niche, you can ask me as many questions as needed to understand smart card context, behaviour, and habits.

Does anyone have suggestion about this uart mode?

Thank you for your reading and comments

Sebastien

Reply via email to