Search code examples
nfcacr122lib-nfc

NFC Reader ACR122U and libnfc.driver.acr122_usb Unable to write to USB (Result too large)


I try to use an ACR122 USB NFC-Reader on Mac OSX Mojave 10.14.6 with libnfc and I've got a "Unable to write to USB (Result too large)" error when I try to use the command LIBNFC_LOG_LEVEL=3 nfc-list:

info    libnfc.config   Unable to open file: /usr/local/etc/nfc/libnfc.conf
debug   libnfc.config   key: [device.allow_autoscan], value: [false]
info    libnfc.config   Unknown key in config line: device.allow_autoscan = false
debug   libnfc.config   key: [device.allow_intrusive_scan], value: [false]
info    libnfc.config   Unknown key in config line: device.allow_intrusive_scan = false
debug   libnfc.config   key: [device.log_level], value: [3]
info    libnfc.config   Unknown key in config line: device.log_level = 3
debug   libnfc.general  log_level is set to 3
debug   libnfc.general  allow_autoscan is set to true
debug   libnfc.general  allow_intrusive_scan is set to false
debug   libnfc.general  0 device(s) defined by user
nfc-list uses libnfc 1.7.1
debug   libnfc.driver.acr122_usb    device found: Bus 020 Device 020 Name ACS ACR122
debug   libnfc.general  1 device(s) found using acr122_usb driver
debug   libnfc.driver.acr122_usb    3 element(s) have been decoded from "acr122_usb:020:020"
debug   libnfc.driver.acr122_usb    TX: 62 00 00 00 00 00 00 01 00 00
error   libnfc.driver.acr122_usb    Unable to write to USB (Result too large)
debug   libnfc.general  Unable to open "acr122_usb:020:020".
nfc-list: ERROR: Unable to open NFC device: acr122_usb:020:020

When I started troubleshooting I had an "Unable to Claim USB Interface" error, which other people had as well. So I tried the following things from this stackoverflow question and this github issue I found:

  1. install libnfc with brew install libnfc --> Got the "Unable to Claim..." error.
  2. Using sudo -> No change
  3. Disable the PC/SC daemon -> Did not do anything
  4. Editing /usr/libexec/SmartCardServices/drivers/ifd-ccid.bundle/Contents/Info.plist -> Did not help
  5. Uninstall libnfc, compile the project myself and disable ifreader. I tried to build it with both drivers acr122_usb and acr122_pcsc -> Got now a "Unable to write to USB (Result too large)" error instead.
    • Compile with: autoreconf -iv && ./configure --with-drivers=acr122_usb && make clean && make && make install
    • sudo launchctl remove com.apple.ifdreader
    • sudo launchctl stop com.apple.ifdreader

After troubleshooting now I'm stuck with the error and have no idea how to solve the problem. The readers light is not blinking red anymore, but from the error the device is clearly connected to the computer and available.

As a side node: I connect the reader over a USB Hub, since the reader has no USB C cable, but that shouldn't be a problem. Has anyone had the same problem or another approach I could try?


Solution

  • Your step 4, editing /usr/libexec/SmartCardServices/drivers/ifd-ccid.bundle/Contents/Info.plist worked for me and it is the only clean solution I could find.

    Here a short description what you need to do:

    • disable 'System Integrity Protection'
    • removes 3 matching lines (with the same array index!) from the the 3 arrays ifdFriendlyName, ifdVendorID and ifdProductID of the plist /usr/libexec/SmartCardServices/drivers/ifd-ccid.bundle/Contents/Info.plist
    • enable 'System Integrity Protection'

    The three lines in my case were the entry number 370:

    • ifdFriendlyName="ACS ACR122U PICC Interface"
    • ifdVendorID=0x072F
    • ifdProductID=0x2200

    Detailed step by step description:

    1. unplug your NFC card reader
    2. shut down OSX
    3. hold down the keys <cmd>+<R> on the keyboard while starting your Mac to enter recovery mode
    4. in the recovery mode open a Terminal Window using the 'Utility' menu
    5. execute the command csrutil disable
    6. reboot your Mac normally
    7. open a Terminal window and execute the following commands:

      sudo -i
      cd /usr/libexec/SmartCardServices/drivers/ifd-ccid.bundle/Contents
      cp Info.plist Info.plist.orig
      patch -l -p0 <<EOF
      --- Info.plist.orig 2019-12-07 20:26:36.000000000 +0100
      +++ Info.plist  2019-12-07 20:26:40.000000000 +0100
      @@ -471,7 +471,6 @@
              <string>0x1050</string>
              <string>0x1050</string>
              <string>0x1050</string>
      -       <string>0x072F</string>
              <string>0x09C3</string>
              <string>0x03EB</string>
              <string>0x0A5C</string>
      @@ -864,7 +863,6 @@
              <string>0x0405</string>
              <string>0x0406</string>
              <string>0x0407</string>
      -       <string>0x2200</string>
              <string>0x0008</string>
              <string>0x6016</string>
              <string>0x5800</string>
      @@ -1257,7 +1255,6 @@
              <string>Yubico Yubikey 4 OTP+CCID</string>
              <string>Yubico Yubikey 4 U2F+CCID</string>
              <string>Yubico Yubikey 4 OTP+U2F+CCID</string>
      -       <string>ACS ACR122U PICC Interface</string>
              <string>ActivCard ActivCard USB Reader V2</string>
              <string>ATMEL VaultIC460</string>
              <string>Broadcom Corp 5880</string>
      EOF
      
    8. reboot your Mac normally

    9. plug in your NFC card reader
    10. test if the nfc utils are now working, e.g. by calling nfc-scan-device
    11. shut down OSX
    12. hold down the keys <cmd>+<R> on the keyboard and then start your Mac to enter recovery mode
    13. open a Terminal Window using the 'Utility' menu
    14. execute the command csrutil enable
    15. reboot your Mac normally

    @anderssonjohan was giving the correct answer in his post, but the plist file he posted was inconsistent because he only removed one line instead of three.