Harald Welte
2ad0ca15a8
host_communication: Fix TRACE_ERROR syntax
2016-02-29 10:07:16 +01:00
Harald Welte
43f7949fe0
card_emu: Add TRACE_DEBUG once TPDU header is sent to USB
2016-02-29 10:06:54 +01:00
Harald Welte
b086ab0242
owhw: Fix GPIO for USIM1_RST (24, not 23!) and enable SET_USIM1_PRES
2016-02-29 10:05:53 +01:00
Harald Welte
9dbc46e799
mode_cardemu: Proper enabling/disabling of USART IRQ sources
...
we always have to disable all intrerrupts that we don't want to be
enabled
2016-02-29 10:05:10 +01:00
Harald Welte
ba0c688103
owhw: Make owhw/board.h the default for now
...
I will re-introduce simtrace2 hardware support later
2016-02-28 19:32:36 +01:00
Harald Welte
4dc3db7beb
req_ctx: Use only 10 small buffers, and no large ones
2016-02-28 19:32:01 +01:00
Harald Welte
203ea19227
req_ctx: Use the linked lists between req_ctx to ensure ordering
...
It is important we send the buffers in-order, and not re-order
them between the main program and the USB host.
2016-02-28 19:31:24 +01:00
Harald Welte
bd71768e5f
mode_card_emu: connect the update_fidi() callback
2016-02-28 19:30:05 +01:00
Harald Welte
2a6d3afd6c
re-introduce req_ctx buffers into the host communication
2016-02-28 19:29:14 +01:00
Harald Welte
29f8f0e5d4
improvements in req_ctx debugging
2016-02-28 12:44:30 +01:00
Harald Welte
2fb5996d30
owhw: fix GPIO definitions (output low level by default)
2016-02-28 12:34:26 +01:00
Harald Welte
8c49636127
card_emu.c: avoid re-defining update_fidi() symbol
2016-02-27 16:24:09 +01:00
Harald Welte
390760a006
add board/owhw.c
2016-02-27 16:23:46 +01:00
Harald Welte
54a7cec7bd
Add card_emu_target.c to bind card_emu.c code into target firmware
2016-02-27 16:23:14 +01:00
Harald Welte
17db2f1112
card_emu: Fix PTS checksum verification
...
If the checksum doesn't match, the card should not apply any Fi/Di
changes, not respond anything and simply expect the next TPDU.
2016-02-26 09:48:57 +01:00
Harald Welte
4ba66d0098
implement forwarding of PTS/PPS from emulator to host PC + test case
2016-02-26 09:40:34 +01:00
Harald Welte
86d047b8f4
card_emu_test: Verify content of emulator->reader bytes
2016-02-25 00:26:17 +01:00
Harald Welte
0ef96d5735
card_emu: Ensure the length is properly set on a TPDU header rctx
2016-02-25 00:09:17 +01:00
Harald Welte
0ab6fcd173
card_emu_tests: Verify context of USB request contexts
...
when the emulator has received some data, don't just check that
we see it coming up on teh USB side, but actually also check
the content of those messages
2016-02-25 00:08:22 +01:00
Harald Welte
c043e64ef1
card_emu_tests: move test cases into functions
2016-02-24 23:26:55 +01:00
Harald Welte
eef6c2a46c
card_emu_test: Add test for card-TX (reader-RX) APDU
2016-02-24 22:19:03 +01:00
Harald Welte
f16b618755
card_emu: Fix the length checks for transmit beyond rctx->tot_len
2016-02-24 22:18:46 +01:00
Harald Welte
22cdf2af59
card_sim: fix passing handle to tc_etu_*() functions
2016-02-24 22:18:11 +01:00
Harald Welte
6bf8c12b13
update card_emu_tests to recent card_emu changes
2016-02-24 21:04:08 +01:00
Harald Welte
042f0d366b
tc_etu: Add explicit enable/disable functions
...
We don't want the tc_etu to call into card_emu at all times,
e.g. while clock is applied, but RST is not yet present.
Rather, we want to explicitly enable it once RST is released
2016-02-24 21:01:50 +01:00
Harald Welte
855ba9e168
card_emu: Ensure TX happens synchronously before state changes
...
we cannot first chage the state and then transmit the byte
asynchronously later, this introduces race conditions. Do it
in-line by explicit calls to the UART Tx function.
2016-02-24 21:00:46 +01:00
Harald Welte
849269f4cc
add OWHW board.h file
2015-11-30 12:16:53 +01:00
Harald Welte
2d3371ed65
split board.h into generic part and simtrace-specific part
2015-11-30 11:59:03 +01:00
Harald Welte
61bb30e4ea
card_emu: Correctly handle SW after reader -> card data phase
2015-11-14 23:44:14 +01:00
Harald Welte
84ec252ff4
card_emu_test: test APDUs with both Rx and Tx data phase
2015-11-14 23:05:13 +01:00
Harald Welte
4d8046743e
card_emu: Fix state transitions for both Rx and Tx data phase
...
We now use the P3 value to determine how many characters to
receive (in case of Reader->Card payload phase).
2015-11-14 23:05:13 +01:00
Harald Welte
b5288e8ac4
card_emu: Introduce new flush_rx_buffer() function and use it
2015-11-14 23:05:13 +01:00
Harald Welte
e7194abb9e
card_emu: Ensure to re-set PTS state when coming out of reset
2015-11-14 23:05:10 +01:00
Harald Welte
52922ffa32
card_emu: Properly handle end of a procedure-byte carrying REQ_CTX
...
how we proceed changes depending on whether we should continue to
receive or transmit...
2015-11-14 20:59:56 +01:00
Harald Welte
05b41c62f6
card_emu: fix set_tpdu_state()
...
* don't enter a state we are already in
* enable the UART receiver not only when waiting for CLA, but also
generally when we're waiting for more data from the reader
2015-11-14 20:58:48 +01:00
Harald Welte
2935b3c479
card_emu: detect end of TX data from CEMU_DATA_F_FINAL
...
When the USB host software sets this flag, we terminate the
TPDU transmission after the last character in this frame and
transition again to the WAIT_TPDU state.
2015-11-14 20:00:14 +01:00
Harald Welte
b436286ed6
card_emu_tests: extend first TPDU test to sending PB + SW in response
2015-11-14 19:02:33 +01:00
Harald Welte
836990d244
req_ctx: Fix compiler warnings
2015-11-14 17:38:04 +01:00
Harald Welte
d79dc4f6f2
card_emu: Implement get_byte_pts()
2015-11-14 13:33:10 +01:00
Harald Welte
4c473dad30
card_emu: Fail with assert in case next_tpdu_state from wrong state
2015-11-14 13:32:05 +01:00
Harald Welte
612d65ad62
card_emu: Make update_fidi() void
2015-11-14 13:30:43 +01:00
Harald Welte
16cf408a49
card_emu.c: More comments about data structures
2015-11-11 19:02:48 +01:00
Harald Welte
9d3e38242c
initial commit of more code towards card emulation
...
I couldn't help but to spend my sunday on working towards card
emulation, including
* various state machines in the target about ISO7816 states
* tc_etu timer import from simtrace1
* req_ctx import from simtrace1 (needs renaming and simplifiation)
* USB protocol description as cardemu_prot.h
* some host-based testing code to test the state machines
The code seems to work fine throughout card reset, sending ATR and
receiving the TPDU header of the first APDU, up to the point where it
marks the TPDU header as to-be-transmitted over th bulk-in endpoint.
Sending the ATR must be done inside the firmware for timing
requirements.
From that point onwards, the host needs to respond at the very least
with a procedure byte, and some indication whether or not the card
emulator should continue to transmit data (card->reader), or receive
data (reader->card).
The code is intentionally not hooked up yet with the USB logic nor with
the UART. I want host-based testing completed before doing that.
2015-11-09 00:50:54 +01:00
Harald Welte
f64f68871e
move ARRAY_SIZE() definition to utils.h
2015-11-08 21:31:48 +01:00
Harald Welte
30a53f823a
Move Fi/Di calculation functions to separate C file
2015-11-08 14:29:55 +01:00
Harald Welte
6d44c1fdd3
USB: Add manufacturer name string descriptor
...
... and use indexed array initializers for more safety/clarity
2015-11-07 19:01:30 +01:00
Harald Welte
8a5b580a72
CCID usb descriptor: We support 3V only, not 5V.
2015-11-07 18:53:43 +01:00
Harald Welte
ec4fe2358b
Mark more local functions as static
2015-11-07 18:48:26 +01:00
Harald Welte
844db577f2
change to own USB vendor/device ID
...
we shouldn't re-use the vendor/device ID usd by simtrace1, as the
protocol is incompatible and applications for simtrace 1 don't work with
simtrace2. Also, there's a different processor architecutre in the
hardware.
2015-11-07 18:38:04 +01:00
Harald Welte
beb729391b
USB descriptors: call it SIMtrace 2 and add spaces to strings
2015-11-07 18:35:41 +01:00
Harald Welte
8d6a5d8f89
move USBDDriverCallbacks_ConfigurationChanged() to main.c
...
This alows us to mark simtrace_config as static variable and keep all
code related to this variable local to main.c
2015-11-07 18:27:05 +01:00
Harald Welte
d4c1421c91
conf_func: Mark const and static.
...
const saves RAM, and static avoids namespace pollution.
2015-11-07 18:25:46 +01:00
Harald Welte
fefd571701
conf_func: Use named struct initializers and named array subscripts
...
As part of this, we also do away with the '-1' based array subscripts
2015-11-07 18:25:19 +01:00
Harald Welte
15d72cc631
add some comments on the conf_func members
2015-11-07 18:19:06 +01:00