0
votes

I am currently developing an NFC application for a very, very customized Linux kernel running in a POS device such as this TPS300 for contact-less NFC cards. It has inbuilt libraries for communicating with NFC cards. I have researched on NFC and have learnt about the NFC reset command, which is supposed to respond with an Answer to Reset. My question is, is that command carried out via the normal APDU command-respond method or is the reset a hardware-based command? Am asking this because the libraries mentioned above have no explicit reset command method for cards, or a program either, and I (up to this moment) have found no APDU command for resetting the NFC card. I only know of the hardware method, via a signal to the reset terminal of the NFC card. Is there an explicit APDU command for resetting the card or does the customized OS take care of the resetting for me? If the command exists, what is it? And how is it applied to contact-less NFC cards?

2

2 Answers

0
votes

In general, switching OFF the RF field and switching it ON should 'reset' the card. But, if you want more specific reset mechanism, then that will depend on the type of card supported in the OS, and the card in question. ISO14443-Part3 should help you out there.

0
votes

The ATR (Answer to Reset) is typically sought by issuing special commands to the NFC controller (reader). APDU is a term that's used to refer to command/response exchanges with the NFC card itself (PICC). To give you something to compare against check out the documentation of the ACR122U, one of the popular USB readers on the market. It leverages a PCSC USB driver (CCID) that's common to most operating systems (evolved from interfacing with Smart Card controllers) which makes it easy to use on Windows, Mac, or Linux. Here's a flowchart of it:

Communication flowchart of ACR122U

The PCSC interface has several commands, but it all starts with a reader API connect. For contact Smart Cards, this equates to setting a RESET line high. For contactless (NFC) cards, this equates to turning on the NFC field (RF energy pulse). If there is a card present, the connect call will return an ATR response.

Looking beneath the PCSC layer and into the CCID driver, you can see how the reader API connect call is constructed. Here's a snippet of code from the nfcpy project, an open source stack for NFC:

def reset_mode(self):
    if (self.ic, self.fw) == ("PN533", "1.48"):
        self.command(0x18, [1])
        self.write(array("B", [0, 0, 255, 0, 255, 0])) # ack
        time.sleep(0.010)

The PN533 is the NFC controller (from NXP) inside the ACR122U reader. Command 0x18 instructs the NFC controller to turn on the RF field and attempt to get an ATR response from any tag present. Once an ATR is found, then APDU exchanges can begin. Such as interrogating the card for its description info:

 rsp = self.dev.in_list_passive_target("106A", "");  // for NFC-A type cards

So to answer your questions explicitly:

  1. Is there an explicit APDU command for resetting the card or does the customized OS take care of the resetting for me? - In the case of PCSC, this is a reader API connect call. Talking directly to the NFC controller, there might be an instruction to do this like the in_list_passive_target command for the PN533.
  2. If the command exists, what is it? - Search through the Linux setup in your POS and see if there's a CCID driver or PCSC daemon running. If not, you'll need to find what driver is being used to talk to the POS NFC controller. With that you should be able to determine the equivalent command to power on the RF field.
  3. And how is it applied to contact-less NFC cards? - There are many types of NFC cards but getting an ATR is common across them all.