[Bug Report] Feature test - EMV Reader
Describe the bug: Hello, @andreock @emericklaw I'm trying the feature with Bruce Beta/Dev version "8e9f2a4". I'm using a PN532 V3, red, from Elechouse via I2C on the Cardputer ADV. The PN532 (I2C) is also configured in the Cardputer's PIN configuration.
There's a chance I'm using the wrong firmware version; if so, please let me know.
I have a number of cards here at home and I tested most of them. The result was:
A few Visa card models:
Visa Unknown PAN Unknown issue date Unknown valid to date
[Serial Log]
Selected: RFID
Selected: Read EMV
Found finish
Success AID
Found finish
Other Visa card models:
Failed to read EMV Card.
[Serial Log]
Selected: RFID
Selected: Read EMV
Found finish
Can't get aidFeliCa
Success AID
Can't read card
Some MasterCard card models:
MasterCard Unknown PAN Unknown issue date Unknown valid to date
[Serial Log]
Selected: RFID
Selected: Read EMV
Found finish
Success AID
Found finish
Can't get PDOL
Found finish
Can't get AFL
Can't get AFL ID
The detail is about a single MasterCard I have. It starts reading, shows "MasterCard", then nothing appears below, and Bruce immediately restarts. I imagine that perhaps this card can read the content, but the data might be incorrect. I will investigate further.
[Serial Log]
Selected: RFID
Selected: Read EMV
Found finish
Success AID
Found finish
Can't get PDOL
Found finish
Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled.
Guru Meditation Error: Core 0 panic'ed (Unhandled debug exception).
Debug exception reason: Stack canary watchpoint triggered (IDLE0)
Core 0 register dump:
PC : 0x40056f60 PS : 0x00060036 A0 : 0x82181e49 A1 : 0x3fcc5d50
A2 : 0x3fcc5d70 A3 : 0x3c32e9a8 A4 : 0x00000060 A5 : 0x3fcc5da0
A6 : 0x3c2d472b A7 : 0x3c2d4734 A8 : 0x00000000 A9 : 0x00000000
A10 : 0x00060020 A11 : 0x3fcc5fcf A12 : 0x42180e8a A13 : 0x3fcc5ed0
A14 : 0x00000038 A15 : 0x3fca2140 SAR : 0x0000000c EXCCAUSE: 0x00000001
EXCVADDR: 0x8d8d8d91 LBEG : 0x40056f5c LEND : 0x40056f72 LCOUNT : 0x00000002
Backtrace: 0x40056f5d:0x3fcc5d50 0x42181e46:0x3fcc5d60 0x42181c2a:0x3fcc5df0 0x42181c56:0x3fcc5e10 0x422a6a17:0x3fcc5e30 0x42181be9:0x3fcc5e60 0x40376955:0x3fcc5eb0 0x4037d9a4:0x3fcc5ed0 0x42180e87:0x3fcc5f90 0x42181362:0x3fcc5fb0 0x421813b3:0x3fcc5ff0 0x422a65a2:0x3fcc6010 0x4038644b:0x3fcc6030 0x40385319:0x3fcc6050
ELF file SHA256: e94bf443b
In general, of the more than 20 cards I tested, none of them were readable.
I performed a new test, now with the PN532 connected via I2C to the top of the Cardputer ADV, and I changed the SDA and SCL pins in BrucePinfs.conf. When trying to read any card, it gives the same results, but the keyboard stops working; the only button that works is G0 (the top button). When I test with that MasterCard that was restarting the Cardputer, I receive the following information:
[17:49:16] Scanning I2C bus...
[17:49:16]DEBUG: Found I2C device at address 0x18
[17:49:16]DEBUG: Found I2C device at address 0x34
[17:49:16]DEBUG: Found I2C device at address 0x69
[17:49:16]DEBUG: Found 4 I2C devices
[17:49:16]DEBUG: Attempting to initialize TCA8418 at address 0x34
[17:49:16]Image from SD
[17:49:16]Selected: RFID
[17:49:25]Selected: Read EMV
[17:49:25][ 94443][E][esp32-hal-i2c-ng.c:252] i2cWrite(): bus is not initialized
[17:49:25][ 94450][E][esp32-hal-i2c-ng.c:354] i2cWriteReadNonStop(): bus is not initialized
[17:49:25][ 94457][E][Wire.cpp:520] requestFrom(): i2cWriteReadNonStop returned Error -1
[17:49:25][ 94464][E][esp32-hal-i2c-ng.c:354] i2cWriteReadNonStop(): bus is not initialized
[17:49:25][ 94471][E][Wire.cpp:520] requestFrom(): i2cWriteReadNonStop returned Error -1
[17:49:32]Found finish
[17:49:32]Success AID
[17:49:32]Found finish
[17:49:32]Can't get PDOL
[17:49:33]Found finish
[17:49:33]Found finish
[17:49:33]Can't parse AFL data
[17:49:50]Selected: Save
hi, thanks for the testing. VISA is unreadable at the moment since I didn't try to understand the protocol yet. I have two mastercard EMV at home and both are working. Can you give me the AID of your cards? You can add a print at https://github.com/pr3y/Bruce/blob/dev/src/modules/rfid/emv_reader.cpp#L83 or use https://play.google.com/store/apps/details?id=com.github.devnied.emvnfccard&hl=en-US(not open source)
AID is not a sensible information, it's just the identifier of your card vendor. I think that your mastercard doens't implement PDOL like VISA so I need to understand the messages exchange without PDOL to get them work.
When trying to read any card, it gives the same results, but the keyboard stops working; the only button that works is G0 (the top button).
Some devices (ADV is one of them) have an I2C bus specific for its hardware (keyboard and IMU on ADV, PN532, Gauge and Power chip on T-Embed) that must be kept running no matter what... So we need to (somehow) have an I2C bus specific for it (Wire1, for example) and use the other (Wire0) for the second bus, and know which to use depending on the pins selected..
I have some ideas in mind, but need to align them better
Little update on this issue: At the moment I fixed the PDOL reading but I'm rewriting the whole EMV reader to be more general and works for all cards that doesn't require authentication or obfuscate data
@IncursioHack I wrote a new function to parse VISA card since it handle the data differently than MasterCard, can you try to build and test from my branch: https://github.com/andreock/Bruce/tree/emv_enhancement ? For the others MasterCard that is not working for you, I will try to write a more generic read function but I don't have any card to test it since mine works.