The files provided along with this README are part of the Smart Card Detective
(SCD). The SCD is meant to provide an open framework for EMV research and
digital forensics, enabling users to analyze transactions.

The software is given under the BSD 2-clause license (FreeBSD):
http://www.opensource.org/licenses/bsd-license.php

VERSION
Current version of the software is 2.4.2
Last updated: February 2013.

See the CHANGELOG file for comments on what's new.
See the ISSUES file for comments on some current known issues.

REQUIREMENTS

In order to compile this project you need the avr-libc and avr-gcc tools.
Please use avr-libc version 1.7.0 or higher as the previous versions have
problems with the malloc functions. See http://www.nongnu.org/avr-libc/ for more
information.

To install all the necessary tools I recommend using the AVR GNU toolchains
provided by Atmel:
http://www.atmel.com/tools/atmelavrtoolchainforlinux.aspx
http://www.atmel.com/tools/ATMELAVRTOOLCHAINFORWINDOWS.aspx

On Windows you can try using AVR Studio:
http://www.atmel.com/tools/ATMELSTUDIO.aspx

However most of the testing is done under Linux, so I recommend it.


BUILD
Compile the project using the command "make all"

In order to program via JTAG or USB without root access you must create the following
rule files under /etc/udev/rules.d (ubuntu, probably similar on other distros):

45-atmel.rules:
    SUBSYSTEM=="usb", ACTION=="add", ATTR{idVendor}=="03eb", ATTR{idProduct}=="2104", MODE="0660", GROUP="plugdev" 
    SUBSYSTEM=="usb", ACTION=="add", ATTR{idVendor}=="03eb", ATTR{idProduct}=="2107", MODE="0660", GROUP="plugdev"

98-lufa-virtualserial.rules:
    SUBSYSTEMS=="usb", ACTION=="add", ENV{ID_MODEL_ID}=="2044", ENV{ID_VENDOR_ID}=="03eb", MODE="660", GROUP="plugdev"

99-dfu_programmer.rules:
    SUBSYSTEM=="usb", ACTION=="add", ATTR{idVendor}=="03eb", ATTR{idProduct}=="*", MODE="0660", GROUP="plugdev"

DEBUG/PROGRAM

I recommend using an AVR Dragon for programming and debugging your SCD.
The avrdude program is useful for programming.

Use the following commands to program:
    "make program-dragon": program the SCD using avrdude and the AVR Dragon.
    "make program-dragon-dfu": similar to "program-dragon" but include the bootloader so that you can later program the SCD via USB.
    "make program-dfu": program the SCD via USB using dfu-programmer (you need the bootloader preinstalled on the SCD).

Use the following commands to debug:
    "make avarice": allow debugging of the application using the SCD and AVR Dragon (next use "make debug").
    "make debug": connect avr-gdb to avarice (once avarice is running).
    "make debug-insight": similar to "make debug" but using the INSIGHT interface of GDB.

HARDWARE CHANGES IN VERSION 4 OF SCD

The version 4 of the SCD sold by Smart Architects has the smart card detector
switch inverted. If you have one of these boards (from 2012 onwards), then
leave the following line of the Makefile uncommented:
CFLAGS += -D INVERT_ICC_SWITCH

If you have the older versions then comment the line as follows:
# CFLAGS += -D INVERT_ICC_SWITCH

Then recompile and build the source code. Then program the SCD with the
modified code.


SET FUSES
For the first time using the board you might need to set up the fuses for correct operation of the SCD.
This can be done easily typing the following command:
    "make set-dragon-fuses"
as the name suggests, you need to use the AVR Dragon or similar JTAG programmer.

DOCUMENTATION
You can find the documentation in HTML format for the source code in the doc/ folder.
Point your browser to the doc/html/index.html file.

For more information about the software and how to get the SCD check the forum
of the Smart Card Detective at:
http://www.smartcarddetective.com/forum/

Copyright (C) Omar Choudary (omar.choudary@cl.cam.ac.uk)
http://cl.cam.ac.uk/~osc22/scd/

