Let's start with a review of the electrical signals defined by the ISO standard.
Now let's talk a bit about the protocol on this I/O pin. Right after reset, the card sends a block of data called the Answer to Reset (ATR); this is documented in section 2.3.4 of the standard. The baud is specified as being the input clock frequency divided by exactly 372. The other parameters are: 8 bits, even parity and one stop bit.
Assuming we want to work at a baud of 9600 (fairly typical baud for PC serial ports), this means we need an input frequency of 3.5712 MHz. While there's crystals out there that provide this frequency, I don't have one and I don't have a signal generator either. So I had to improvise.
I had laying around an Altera UP2 development board with a 25.175 MHz crystal. This is an educational board with a CPLD and an FPGA (programmable logic chips); I also happened to have a working copy of Quartus usable to create designs for the chips. I basically used a binary counter as a frequency divider from the main 25.175 MHz clock. In the end, it looked something like this:
Don't be deceived by the large board; it's just an oversized clock generator.
At first, I tried using a divisor of 7, which adds up to a baud of (25.175 MHz / 7 / 372 = ) 9668. This is really close to 9600, and most serial port receivers tolerate a certain margin of error, but 9668 turned out to be too far off; data become garbled after the first few bytes. If I settled for an I/O baud of 1200 bps, the required clock for the smartcard would be only 0.4464 MHz. With a divisor of 56, I would get a baud of 1208 bps, which was close enough for the serial port. I was able to get an ATR:atr: read 8 bytes: atr: read 8 bytes: 3b b2 11 00 10 80 00 04
A quick Google search for this hex string quickly uncovered the identity of this smart card:
3B B2 11 00 10 80 00 04
Atmel memory card AT88SC0404C
http://www.atmel.com/dyn/resources/prod_documents/doc5210.pdf
Aha! Luckily, the datasheet is fairly explicit regarding the command set of the chip. But you'll have to wait until next time to see what happened when I started poking commands at it.
8 comments:
haha thats some crazy stuff i also have that in my building i was looking to start up something like that, i have the same system in my laundry room i was googling to mess around as well let me know how it turns out.
what you're doing is seriously cool man. please continue for us readers. altho i know what it's like - i have an infinite number of incomplete projects myself!
please continue!
If you figure this out you're my savior. I'm very ignorant to smart card technology, but nevertheless I shelled out 20$ for a reader/writer with the hope of never paying $10 for laundry again.
any updates on this at all? Where did you leave off or did you get this to work? any updates would be appreciated!
any success with this yet?
still checking back! any updates?!
It would be amaze balls if you figured this out! Let me know how it goes!
Post a Comment