Commit Graph

87 Commits

Author SHA1 Message Date
Christina Quast
6032e796b9 string descr 0 is language identifier 2015-02-27 15:22:25 +01:00
Christina Quast
33864fa36c Set default trace level to FATAL
Because to compile with a debug trace level you can simply type:
colormake TRACE_LEVEL=5
2015-02-27 13:41:34 +01:00
Christina Quast
fb524b9bb3 Function pointer struct in main for run,init 2015-02-27 13:39:45 +01:00
Christina Quast
1edf350c34 MITM code and run and init decl in header 2015-02-27 13:33:52 +01:00
Christina Quast
f5462b47bd Change Makefile to compile simtrace firmware 2015-02-25 18:47:45 +01:00
Christina Quast
6f856337e2 Merge branch 'master' of ssh://git.admin.sysmocom.de/christina/simtrace
Conflicts:
	sam3s_example/.gitignore
2015-02-25 18:46:48 +01:00
Christina Quast
d2b05f014c comment changed 2015-02-25 18:44:24 +01:00
Christina Quast
0ae0314f6b Add usb config changed callback func 2015-02-25 18:43:46 +01:00
Christina Quast
10b2e5accc Consistent config num enum for main.c and usb.c 2015-02-25 18:40:15 +01:00
Christina Quast
54d0c1fca8 USB enum works again, No CCID conf 2015-02-25 16:04:25 +01:00
Christina Quast
1161b27e7d main while loop: wait for USB 2015-02-25 14:15:57 +01:00
Christina Quast
968b974cbe Moved usb descriptors and funcs into single file 2015-02-25 14:10:12 +01:00
Christina Quast
c0aa769a35 Redundant functions in phone and sniffer moved
File simtrace_iso7816.c is like a library for iso specific functions.
The next step will be to use the atmel softlib functions instead.
2015-02-25 14:02:01 +01:00
Christina Quast
c02571ebe2 basic structure for main while loop with all configs 2015-02-24 19:09:55 +01:00
Christina Quast
27c643d297 Sniffer functionality and sniffer bus board config 2015-02-24 19:09:08 +01:00
Christina Quast
a90eefa865 sniffer functions 2015-02-24 17:52:29 +01:00
Christina Quast
995e0d1319 git ignore memory librariers 2015-02-24 17:39:57 +01:00
Christina Quast
566d3f9e4a Made ohone functions extern in header file 2015-02-24 17:39:03 +01:00
Christina Quast
01bbdc3d52 device descriptor phone added 2015-02-24 17:38:45 +01:00
Christina Quast
f554950742 device descriptor sniffer, MITM 2015-02-24 14:27:08 +01:00
Christina Quast
32906bb919 simtrace main with phone as clk master 2015-02-24 11:35:19 +01:00
Christina Quast
5bcac5df4d ignore unused atmel libs 2015-02-20 14:42:44 +01:00
Christina Quast
1d410aabf3 ignore unused atmel libs 2015-02-20 14:42:11 +01:00
Christina Quast
b440c62140 clk calculation: updated max mul val 2015-02-20 14:40:07 +01:00
Christina Quast
49ba6bc1ba Fixed change usb config bug
In the standard atmel lib only one configuration was possible.
On a GETDESCRIPTOR request the board would always return the full buffer
with both configurations.

The USB driver requests each configuration one after another, using the
configuration index number.
The atmel lib did not support more than one USB configuration.
2015-02-20 14:35:36 +01:00
Christina Quast
6255ccca84 USB driver send standard configuration
One configuration, one Interface, two endpoints (bulk in and out)

We don't need to configure Endpoint 0 which is always the control
endpoint and configured before any descriptor requests take place.

% python usb_enum.py
Found device
  CONFIGURATION 2: 100 mA ==================================
   bLength              :    0x9 (9 bytes)
   bDescriptorType      :    0x2 Configuration
   wTotalLength         :   0x20 (32 bytes)
   bNumInterfaces       :    0x1
   bConfigurationValue  :    0x2
   iConfiguration       :    0x2 SOME
   bmAttributes         :   0x80 Bus Powered
   bMaxPower            :   0x32 (100 mA)
    INTERFACE 0: Vendor Specific ===========================
     bLength            :    0x9 (9 bytes)
     bDescriptorType    :    0x4 Interface
     bInterfaceNumber   :    0x0
     bAlternateSetting  :    0x0
     bNumEndpoints      :    0x2
     bInterfaceClass    :   0xff Vendor Specific
     bInterfaceSubClass :    0x0
     bInterfaceProtocol :    0x0
     iInterface         :    0x1 SIMTRACE~~~~~
      ENDPOINT 0x1: Bulk OUT ===============================
       bLength          :    0x7 (7 bytes)
       bDescriptorType  :    0x5 Endpoint
       bEndpointAddress :    0x1 OUT
       bmAttributes     :    0x2 Bulk
       wMaxPacketSize   :   0x40 (64 bytes)
       bInterval        :    0x0
      ENDPOINT 0x82: Bulk IN ===============================
       bLength          :    0x7 (7 bytes)
       bDescriptorType  :    0x5 Endpoint
       bEndpointAddress :   0x82 IN
       bmAttributes     :    0x2 Bulk
       wMaxPacketSize   :   0x40 (64 bytes)
       bInterval        :    0x0
2015-02-10 20:45:08 +01:00
Christina Quast
7188a126d5 Removed unused defines for USB operation in sniffer.c 2015-01-30 19:22:23 +01:00
Christina Quast
0a6025aeb6 Sniffer prints sends received data over uart0
But only when you program the chip. At some point it stops printing
the received bytes because the interrupt is not triggered anymore.
I do not know yet how and why this happens.

Even after restarting the board this state is maintained.
2015-01-30 18:10:29 +01:00
Christina Quast
ba62278b83 sniffer: Bus enables connect. between SIM and phone 2015-01-30 16:42:49 +01:00
Christina Quast
b455427413 Add tag INPUT to input CLK and IO lines
CLK_SIM, I/O_SIM, CLK_PHONE, I/O_PHONE: Each of these lines connect
two pins of the microcontroller. Therefore they should NEVER be
configured as output line simultaneously. Otherwise the uC might get
destroyed.
2015-01-30 16:28:45 +01:00
Christina Quast
b70efc0766 Receiver interrupt enabled
Serial smartcard reader sends data which should be processed.
In the USART1 IRQ a status variable is set to show that data has
arrived, which should be checked for in the main function.
2015-01-29 18:05:32 +01:00
Christina Quast
c8bf9f112a Fixed address bug in phone_test.c main
The second argument for PIO_Configure is the list size,
which can be determined using the macro PIO_LISTSIZE.
You should pass the list (which is an array of pins) to it.
Refrain from passing the ADDRESS of the list to it, otherwise
the pin configuration is never applied and you find yourself
debugging for 3 days.

In other words:
It's working, don't touch it or it will break again!
2015-01-29 17:39:23 +01:00
Christina Quast
0ff91d0833 Fixed types for ATR buffer etc 2015-01-28 18:04:58 +01:00
Christina Quast
f6264fac95 Added inttypes.h include directive in board.h
For now the inttypes.h of the development computer is used.
Which is a bad state. The reason is

It should be fixed by creating a stdint.h in the Baselib, which
defines types like uint32_t, etc., or by entirely replacing the Baselibs
with the newlib.
2015-01-28 17:58:30 +01:00
Christina Quast
f833b5dbd3 Merge branch 'master' of ssh://git.admin.sysmocom.de/christina/simtrace 2015-01-27 15:37:36 +01:00
Christina Quast
97632e6309 Fixed format symbol bug in pmc.c 2015-01-27 15:36:56 +01:00
Christina Quast
061fa6e817 Fixed format symbol error in pio_it.c 2015-01-27 15:31:02 +01:00
Christina Quast
7f52340611 Format string fix for iso7816_4.c 2015-01-27 15:24:31 +01:00
Christina Quast
23c001303c Fixed format symbol (makro) for inttypes
"%u" becomes "%" PRIu32 for uint32_t, etc.
2015-01-27 15:17:37 +01:00
Christina Quast
87d141ec59 Reanabled some compiler warnings 2015-01-27 14:56:33 +01:00
Christina Quast
d20f26d293 Makefile: Disable unused variable warnings 2015-01-27 14:40:31 +01:00
Christina Quast
79c2b72c7a Fix address evaluates always as true warnings
This was an example of a compiler warning when the switch -Waddress was passed:

atmel_softpack_libraries/usb/device/core/USBD.c: In function 'USBD_RequestHandler':
atmel_softpack_libraries/usb/device/core/USBD.c:149:14: warning: the address of
    'USBDCallbacks_RequestReceived' will always evaluate as 'true' [-Waddress]
     else if (USBDCallbacks_RequestReceived) {

The test for existense of USBDCallbacks_RequestReceived is removed since there
is always a default implementation of these function.
2015-01-27 14:32:47 +01:00
Christina Quast
f9890d91d3 Fix address evaluates always as true warnings
This was an example of a compiler warning when the switch -Waddress was passed:

atmel_softpack_libraries/usb/device/core/USBD.c: In function 'USBD_RequestHandler':
atmel_softpack_libraries/usb/device/core/USBD.c:149:14: warning: the address of
    'USBDCallbacks_RequestReceived' will always evaluate as 'true' [-Waddress]
     else if (USBDCallbacks_RequestReceived) {

The test for existense of USBDCallbacks_RequestReceived is removed since there
is always a default implementation of these function.
2015-01-27 14:27:38 +01:00
Christina Quast
2021077a66 changed TRACE_WARN into TRACE_WARNING in iso7816_4.c 2015-01-27 11:19:27 +01:00
Christina Quast
f7c28e0b0b phone: on reset by smartcardreader send ATR
Every time the reset line is pulled low, simtrace sends an ATR
packet over USART1.
The USART1 is slave in this configuration.
2015-01-23 20:57:52 +01:00
Christina Quast
ea103826fa test for phone I/O pin 2015-01-21 14:00:45 +01:00
Christina Quast
e8119112cb IRQ when phone RST line triggered
When the SIM card adapter, which is usually plugged into a phone,
is plugged into a CCID reader instead, the CCID reader triggers
the reset line of the RST line and therefore a PIO interrupt.
The reader then waits for an ATR from the smartcard,
which should be send next.
2015-01-20 20:15:04 +01:00
Christina Quast
8d0f4a6675 Pass ISO7816_GetChar return val to higher layers
The return value of ISO7816_GetChar is 0 in case of a timeout
when trying to retrieve values, and status of US_CSR otherwise.

Proper handling of this return value is not yet implemented though.
With the naive approach of just not sending the ATR if it could not
be read the simtrace firmware did not work together with pcsc_scan
AT ALL.
2015-01-15 14:53:38 +01:00
Christina Quast
99de4e5753 There is no ASCII in ATR messages.. 2015-01-15 14:49:42 +01:00
Christina Quast
f6bf349a53 CCID: Change cold to warm rst on PCtoRDRIccPowerOn
Before this change pcsc_scan would always receive garbage
from the stack when the reset button was pressed on the
simtrace board. Because the return value of ISO7816_GetChar
is never checked anywhere. If there is a timeout in this function,
the non-initialized local variable values which happen to be
lying around on the stack are inserted into the ATR message
and send to the host.

This only helps mitigating the symptoms but does not remove
the reason for the behavior. On the other hand, is it really
feasable to check the return value on EVERY call to
ISO7816_GetChar..?
2015-01-15 14:42:04 +01:00