card_set_state(ch, ISO_S_WAIT_ATR) internally calls tc_etu_enable(),
so there's no need for the caller to do the same, too.
Change-Id: I2a2b4d64c40264623313a867957ffcefe57748f9
A function that is called to set the state should not in itself
contain logic to issue further state changes.
Let's shift the related block out to the end of card_emu_io_statechg(),
which is the only source of card_set_state() calls for the
WAIT_{POWER,CLK,RST} states anyway.
As an added benefit, the block of statements is now also executed if
there's no state change - something that was prevented by the
"if old == new" state guard at the top of card_set_state(). I believe
this may help us to cover more (non-standard) card activation sequences.
Change-Id: Ieefa1807099eb234cfd994bca83caaa0dcc919b6
We need to send zero-length packets on bulk endpoints whenever the
transfer size is exactly a multiple of the wMaxPacketSize.
See USB 2.0 Specification Section 5.8.3 titled "Bulk Transfer Packet
Size constraints."
Change-Id: Ice3842399d5a5c4a18383860f81074497c6e7c9b
Closes: OS#4331
When the Modem is asserting RST, the emulated card should set all
of its state back to default/initial values and release any buffers
it may still hold in its state.
Change-Id: I66eca6afe4ff7d900c5b75df1e3ec6d52f6ef214
Related: OS#4251
So far, we called card_emu_io_statechg() from interrupt context, which
was safe with the current code. However, as we want to trigger a more
comprehensive reset of data structures, including the flushing of
message queues, it is best to shift this processing from interrupt
context to main loop context.
Change-Id: I3983078396538f32bdff55611c41d2163be4d796
Related: OS#4251
Let's move all initialization of state that may change at runtime
to a separate function: card_handle_reset().
This has the advantage that the related function may also be called
at later/other instances, not just during initialization of card_emu.
Change-Id: I0954d192d001a3af5592010cc84a3a22aaf4b030
Related: OS#4251
We need at least one per IN/IRQ endpoint, as well as at least 3 for
every OUT endpoint. Plus some more depending on the application,
in case of cardem there could be one in uart_tx and one in uart_rx.
So for cardem, it should be 7 per slot, resulting 14 for dual-slot
devices like OWHW and QMOD.
Given that we have plenty of RAM available (utilization up from 49%
to 56% with this change), we can be on the comfortable size and
easily have 20 buffers for now.
Future MITM / triple-play applications likely need more.
Change-Id: I022ba3bb3e1f5fd0c364aafe1a23f8fd9b2d8499
Related: OS#4251
In Change-ID Ie15183f16b22193ffdaf01845db2eae4c7f43c17 we wanted
to limit the number of queue elements to 3, but actually implemented 4.
Change-Id: Ic5fb164f2dfd1c293c51bee8184fc34552267a54
Some boards like QMOD cannot simulate a virtual card insert signal
towards the modem (as the mPCIe connector doesn't have that signal).
In these situations, we were aborting processing of the related OUT
endpoint command and forgot to release the related memory.
Change-Id: I489097b7e332004e0f2beca0b22fa36d5d1d31b5
Related: OS#4251
This helps when debugging the firmware, as it shows the current
utliization of the 10-msgb-talloc pool.
Change-Id: Ib10c4396cd4c9c4a6257cf45886e367214787927
Related: OS#4251
As of Change-Id I1c8cca2f7f0f0070d7bf1ade676e035c45e4d5ab, a firmware
compiled without ALLOW_PEER_ERASE will not support resetting the hub or
writing to its EEPROM. Let's make sure to remove those options also
from the menu.
Change-Id: I3071332d85e6168947384ddc230298d3293e4668
If there are already three elements in the to-be-transmitted queue
for the EP, let's free the first element of the queue. This is a
clear indication that the USB host is not polling the endpoint
regularly. Maybe there's no host application running at all?
This should obsolete Change-Id Ie9ebdd2ff966f67c9afd1ed760f106558f0091ad
Change-Id: Ie15183f16b22193ffdaf01845db2eae4c7f43c17
Closes: OS#4251
the USB trace now respects the global setting.
the verbosity is also decreased, not showing USB activity unless
debugging.
this also saves some space.
the reset cause is now printed.
the strings increase the bootloader size, but it already exceeded
the 16 kB limit when trace level is set to info.
Change-Id: I9ba08d4bb4f188f6e7a202ea86acb7a42a2054f3
now both partitions (bootloader and application) use a commonly
defined memory location to shared the DFU state (which includes
the magic value to know which part to start), instead of using
a hard coded value.
the bootloader size has now also been restricted to 16 kB.
this limitation is enforced so to not be able to create larger
images, which could be corrupted when flashing the application.
bootloader and application flashing have been successfully tested
on qmod st12 and st34.
Change-Id: I204bed7e9391602672ed894decec1fc12e879275
this will help seeing how much free space is available for the
bootloader (which is restricted to 16 kB)
Change-Id: Ie74a1480c2f340765046be9bdfc3a8c4ba851e9b
There's no point in building a DFU loeader that is to be flashed
via DFU - nor is there really any need for regular cardem/trace
that can be flahsed directly without DFU. If anyone needs those,
they can still build them - but let's not confuse the average other
user.
Change-Id: I0abe86c6a942a59e5b2417d0532dffae654d7a18
Closes: OS#4087
"SIMtrace 2 compatible device" is pretty generic. Let's have the
actual board name inside the string descriptors, giving a more
user friendly experience in case users are issuing 'lsusb' and the
like.
Change-Id: Ibcc338b504bd2a1605e31d7f5eadb7161f547c6a
This string dates back to some very early naming; let's reflect how
we have been calling this in reality for quite some time now.
Change-Id: I5a7497188385706a1e924784073c619fa9bfdd60
The code in board_main_top() for QMOD blindly re-assigned some
members of the usb_strings[] array, writing to index 7 and 8.
However, that array only has those entries in the main firmware,
while in DFU that array has only 6 entries. Depending on whatever
the linker has decided to put in the next memory location after
that array, we would overwrite that very early during boot-up.
Change-Id: I59e4e1a54e819808d5a8259a6d14f4b970a90020
Related: OS#4302
when starting the DFU bootloader, but USB configuration (e.g.
enumeration) failed, the MCU restarted in the main application.
this occured after a DFU detach and were the USB host missed the
USB reset.
now after MCU reset, the bootloader is started again, since this
is what was requested to begin with.
the bootloader will always restart in the bootloader until USB
enumeration succeeded.
this boot loop can be stopped by unplugging/removing power from
the device.
Change-Id: I4062a7d8a7934af2119c169759b614dc45990651
the specification requires a reset duration of at least 10 ms.
reset is indicated by the device to the host by removing the
pull-up on D+ (host to device reset is a USB packet).
we used 20 ms, but on some setups (USB host, stack, hub, and load
dependent), this does not seem to be enough (no USB enumeration
was performed afterward, at least for the DFU bootloader).
increasing to 50 ms solved the issue on the affected setups.
instead of USB suspend, the more proper USB disconnect is used.
this mainly disables the pull-up provided by the USB peripheral.
USB activate is not required since the follow up initialisation
takes care of it.
Change-Id: If5ceb3b8f7a8f134d4439fdd138dd12b46589f97
This is the shortest and simplest ATR possible according to the
ISO 7816-3 spec.
It does not offer any non-default parameters (F, D, WI, ...)
Change-Id: I4ff41b5120bcadca652296f9d3691f7606be2bd2
this ATR does not encode any data and uses all defaults.
the lower default speed is also better handled by the hardware.
handling faster speeds is upcoming.
Change-Id: I5a4f2f94bea1a15aedbef5a6f2f49344387dc11d
monitoring the state changes of the VCC and nRST lines is required
to correctly detect warm and cold reset
Change-Id: I72099956332724f84226e1495fdc5a5b1a034695
else it's too nosy while debugging other components, not often
used, and break the flow since it does not and a line.
Change-Id: I8920ff7c33b4c9fb174bb31a29334a63fcbede43
the longer output is to fast and often incomplete.
the shorter version is enough to view the progress when not
debugging.
Change-Id: I97bb84da68d1f3bc14fb7c05400edf1748f55460
Make building the debian packages work again. I've verified that it
works in my own OBS namespace.
This patch also adds missing pkgconf variables in host/Makefile.am, so
libosmo-simtrace2.pc installs properly.
Related: OS#4283
Fixes: 964cda309d ("host: use autotools and split shared code to libosmo-simtrace2")
Change-Id: I2377de1e8b149520922217a1ab16f6e22fe6462a
Fixes:
simtrace2-sniff.c:113:4: error: format not a string literal and no format arguments [-Werror=format-security]
printf(flag_meanings[i].str);
Change-Id: I9793c680f070e724ce89272e9e489963c7516d52
on the QMOD board the VCC signal from the modem is measured using
an ADC (SIMtrace board just use card detect).
the threshold to consider VCC as activated was set to 2.8V, which
gives a bit of margin for the expected 3.0V.
still, we had one board where the voltage was 2.8V.
to be resilient against lower than expected voltages from
modems (or boards), we lowered the threshold to 2.5V.
this is still save for the SAM3S to correctly identify high/low
levels.
Change-Id: Iac2778903690045e4e63fef29f812205d00c28ed
when the reader sends APDU headers (e.g. after multiple reset),
messages are queued for USB transmission.
but if no host software is connected to SIMtrace in card emulation
mode, the USB message queue is not emptied, leading to the memory
getting full and preventing allocation for newer messages (e.g.
more recent APDU).
in this case the oldest queued message is now dropped to free some
memory.
Change-Id: Ie9ebdd2ff966f67c9afd1ed760f106558f0091ad