Harald Welte
67415e3385
HACK: Add EEPROM writing at boot of SAM3 on qmod
...
This is not for production use, but just for hardware verification
2016-09-01 20:57:56 +02:00
Harald Welte
73d697d788
i2c-bitbang: increase speed to ~110kHz
2016-09-01 18:58:41 +02:00
Harald Welte
0aea9fff28
Fix reading SDA in I2C bit-banging code
...
We need to use pin_sda_in, not pin_sda to read the PIO Input.
2016-09-01 18:39:12 +02:00
Harald Welte
c6ae98c53a
i2c_bitbang: Change logic when to use i2c_delay()
2016-09-01 11:57:09 +02:00
Harald Welte
226b40aba4
WIP: bit-banging I2C support for EEPROM access on QMOD
...
for now, it just continuously reads the EEPROM bytes and dumps them to
the serial console for testing.
2016-08-21 19:33:24 +02:00
Harald Welte
fd9c041ec8
fix TRACE_ENTRY line termination (LF -> CRLF)
2016-03-20 18:20:14 +01:00
Harald Welte
622b6be774
Fix ADC based VCC detection
...
* we need to actually return the voltage
* we need to use the correct register name for the CIDR
2016-03-20 18:19:18 +01:00
Harald Welte
3bafe43376
dynamically dispatch USART IRQs
...
The different modes (configurations) will have different interrupt
handlers, so we need to dispatch them via config_func_ptrs
2016-03-20 18:19:12 +01:00
Harald Welte
dde112e71c
print instance/channel number in all trace messages
...
When debugging issues related to two concurrent SIM card emulations,
it is vital to know to which USART a message relates.
2016-03-20 16:42:11 +01:00
Harald Welte
8ee15dbc2a
read SAM3S unique serial number at start and print it
2016-03-20 16:00:39 +01:00
Harald Welte
28772ebcdc
ADC: Make errata work-arounds depend on run-time detection of chip version
2016-03-20 15:44:52 +01:00
Harald Welte
cf1c19abe0
src_simtrace/main: debug/trace logging improvements
2016-03-20 15:18:18 +01:00
Harald Welte
04e37a8481
firmware/main: Disable the rotor unless TRACE_DEBUG
2016-03-20 15:18:03 +01:00
Harald Welte
53079bbbac
debug/tracing updates
2016-03-20 14:58:35 +01:00
Harald Welte
c58bba0833
wait for UART Tx completion before switching baud rate at PTS
2016-03-20 14:57:53 +01:00
Harald Welte
c8beefbf85
wait for transmitter to be done before receiving
...
At higher speeds, it seems we are turning off the transmitter before we
are enabling the receiver. Unfortunately the TXEN bit in the uart mode
register is read-only, so we don't really know if the transmitter is
enabled or not. It seems we can simply keep transmitter + reciver
running at the same time, and use the TXEMPTY bit as reliable means to
determine if we're busy transmtting.
2016-03-20 14:40:47 +01:00
Harald Welte
903d63a1e0
card_emu: Alwasys update state before enabling UART Rx/Tx
...
The UART Rx/Tx irq might hit us before we actually reach the line that
changes the state. So always update the state before enabling UART
Rx/Tx.
2016-03-20 13:38:39 +01:00
Harald Welte
52d554657c
card_emu: Avoid PTS related race-condition
...
We should not set the new Fi/Di values before we actually transmitted
the PTSS PCK at the old baud rate first.
2016-03-20 13:38:05 +01:00
Harald Welte
ccb8a22037
card_emu: Avoid PTS related race-condition
...
We should not set the new Fi/Di values before we actually transmitted
the PTSS PCK at the old baud rate first.
2016-03-20 13:37:11 +01:00
Harald Welte
a929f218d2
card_emu: Differentiate between TRACE_{DEBUG/ERROR/INFO}
2016-03-20 13:36:42 +01:00
Harald Welte
07872b6cdd
VCC/ADC: finish implementing VCC detection via ADC
...
... however, keep it disabled due to ADCVREF not being connected on
OWHWv1/v2.
2016-03-20 11:45:36 +01:00
Harald Welte
6dcacf3efe
OWHW: fix operation with second modem/UART
...
We can now enable CARDEMU_SECOND_UART in owhw/board.h, as it no
longer interferes with operation of the first port (USIM1). Whether
the second port actuall works still remains to be tested at this point.
2016-03-20 10:06:05 +01:00
Harald Welte
419eb8acf2
WIP: Use ADC to determine VCC voltage
2016-03-20 10:04:03 +01:00
Harald Welte
ff16065047
implement CEMU_USB_MSGT_DT_GET_STATUS
...
card_emu can now report its current satus upon request.
2016-03-19 21:59:06 +01:00
Harald Welte
2315e6ba07
ensure git version ends up in firmware image
2016-03-19 21:37:55 +01:00
Harald Welte
b26d0038f6
split/segment multiple commands from single USB transfer
...
UDP end-points are streams, so when we receive data on the OUT
endpoint callback, the buffer might contain several commands. When
dispatching the messages, split (segment) them again before dispatching
them to their respective handlers.
2016-03-19 13:33:02 +01:00
Harald Welte
d295b92192
ensure usb_msg_hdr contains raw message length
...
we want to ensure that the length of every (current or future) message
can be determined by looking at cardemu_usb_msg_hdr.msg_len, rather than
having a length that is relative to the respective specific command.
2016-03-18 21:01:36 +01:00
Harald Welte
b8f9450c18
shrink ringbuffer size to 128 bytes
...
We only use it to implemet a software FIFO between the UART Rx IRQ
and the code that processes it. 1k is way too large for that.
2016-03-18 10:33:31 +01:00
Harald Welte
9f240b6d34
use irq-safe version of llist operations between USB callback and main
2016-03-18 10:32:56 +01:00
Harald Welte
da15ca01bf
mode_cardemu: mask the USART status register with mask register
...
otherwise it might be reacting on stale bits in CSR, which actually are
no longer able to cause any interrupts.
2016-03-17 21:14:04 +01:00
Harald Welte
3d27c84635
host_comm: Fix race condition in handling OUT USB transfers
2016-03-17 20:07:45 +01:00
Harald Welte
250cd2c062
host_communication: set rctx->tot_len after receiving USB transfer
2016-03-17 18:19:39 +01:00
Harald Welte
5820ea9327
dispatch_usb_command: Ensure list consistency + avoid mem leaks
...
When iterating over the queue of req_ctx, make sure to unlink each
buffer before processing it. And during processing, ensure all buffers
are reelased back to the memory management.
2016-03-16 22:22:57 +01:00
Harald Welte
0eaa992682
cardem: Add support for USB host based set/clear of card_insert
...
This way the application on the USB host can control whether the
emulator should emulate that the card be inserted or not. We change the
reset-default back to 'not inserted' (GPIO output 0) and wait for the
application to explicitly request this by issuing
CEMU_USB_MSGT_DT_CARDINSERT.
2016-03-16 22:22:57 +01:00
Harald Welte
7abdb51f8f
ringbuffer: Make ring buffer access irq-save
...
We have to temporarily disable nterrupts when performing rinbuffer
operations, as the ring buffer is used both from IRQ as well as process
context.
2016-03-16 22:22:54 +01:00
Harald Welte
7dd3dfd992
convert all src_simtrace code to kernel coding style
...
Let's use the Osmocom standard, based on the Linux kernel standard:
tab-indent and 8-charracter tab width.
2016-03-16 20:45:10 +01:00
Harald Welte
1605564489
ensure USB config numbers always start from 1
...
Depending on which features (and thus USB configurations) are included
in the firmware, we need to re-define the ordering of the configuration
numbers, as the Atmel USBD driver simply assumes that configurations are
numbered 1..N without any gaps in the sequence.
2016-03-16 20:45:10 +01:00
Harald Welte
072daddf98
main.c: Only call the configure() function of a configuration if it exists
2016-03-16 20:45:10 +01:00
Harald Welte
40901a0f14
various printf/debug output improvements
...
... among those is a rotor (\|/-) that is printed by the main loop,
so one can observe if the main loop is still executing or the system
is somehow stuck.
2016-03-16 20:45:09 +01:00
Harald Welte
57b3a250d4
Add Card-Emulation for second UART/USIM to USB descriptors
2016-03-16 20:45:09 +01:00
Harald Welte
13e8202c81
mode_cardem: Prepare for full support of second UART/USIM
...
So far we have only been working with a single UART/USIM. Let's
make things more data structure driven and pass around handles to
the data structures rather than hardcoding...
2016-03-16 20:45:09 +01:00
Harald Welte
06b27f64a2
mode_cardemu: Implement CEMU_USB_MSGT_DT_SET_ATR
...
This way the host PC can set the ATR of the emulated card
2016-03-16 20:45:09 +01:00
Harald Welte
ebb80eda19
introduce 'main' queue between USB receive and UART TX
...
In order to handle other USB commands like GET_STATUS, SET_ATR
or GET_STATS, we introduce an intermediary queue. The USB receive
completion call-back puts the command on that intermediate 'main'
queue. From that intermediate queue, the are further
dispatched/processed according to their mesage type.
2016-03-16 20:45:09 +01:00
Harald Welte
ad43440d93
card_emu: Fix various compiler warnings by switch/default/break
2016-03-16 20:45:09 +01:00
Harald Welte
a0cf200695
host_communication: keep track of number of pending/queued req_ctx
2016-03-02 10:35:51 +01:00
Harald Welte
acd48c51f2
HACK: always use the USART interrupt handler of mode_cardemu()
...
This must be fixed in a way that the per-configuration interrupt
handler is called, depending on the USB configuration that is set.
2016-03-02 10:34:24 +01:00
Harald Welte
fcdd660fb1
card_emu: Don't de-reference a NULL variable
2016-03-02 10:33:58 +01:00
Harald Welte
12d4bdfbb1
mode_cardemu: Process RX interrupts before TX
...
It's always more important to pull out a received character from
the receive holding register to avoid the risk of overflow, so let's
do that first.
2016-03-02 10:31:03 +01:00
Harald Welte
dda7355306
card_emu: Only transmit NULL byte from the right state
...
The reader cannot accept a waiting time extension at any time. Rather,
it can only accept it if it is currently waiting for a procedure byte.
2016-03-02 10:29:55 +01:00
Harald Welte
f1697e2dd9
card_emu: Only allocate a new buffer if needed in send_tpdu_header()
2016-03-02 10:28:54 +01:00