Commit Graph

285 Commits

Author SHA1 Message Date
Harald Welte 43281fe37e Fix returned data in case of command TPDU
When Lc>0 (command TPDU), our response always copied the command
data in front of the response (which is a SW of 2 bytes in this case).

This of course confuses the hell out of users.  The response to a Lc>0
TPDU should be just the two-bytes status word.

Introduce the use of msgb->l4h for the point in the buffer from where
we receive data from the card.  all bytes before l4h are transmitted
to the card.

Change-Id: Ie3fc7437d39dc330b9f2b7d7960ad2560b6be4b7
2020-07-30 20:32:02 +02:00
Joachim Steiger 3ae39cab62 switch to using 'usbrelay' and more generic,inexpensive relay board
Change-Id: I292e3fd8127d393838b11db7fb058eb638524abc
2020-03-17 12:25:38 +01:00
Joachim Steiger 25d4d3f185 generic improvements for the testsbed
* fix run-tests so it can return != 0
* bail out if prepare fails
* add more sanity checks to prepare
* generalize usb-ids, paths
* add test for flashing from application mode
* add test reading simcards via pysim

Change-Id: I246224e29e5936b4fe40cf7d7a5ff83c9940d121
2020-03-03 13:46:30 +01:00
Joachim Steiger 685f3d8cd9 Implement CI scripts for testing the resulting binary on hardware for jenkins
Change-Id: I3ddd2b9afda0e15883603566259c6e58571d2bc8
2020-02-25 13:22:46 +00:00
Eric Wild 240d00936a dfu: proper product name for dfu runtime descriptor
dfu-util -l says
Found Runtime: [1d50:60e3] ver=0002, devnum=72, cfg=1, intf=1,
path="1-2", alt=0, name="UNKNOWN", serial="12345"
Found Runtime: [1d50:6141] ver=0000, devnum=71, cfg=1, intf=3,
path="1-3", alt=0, name="DFU (Runtime)", serial="6789"

One is a simtrace2, one is the octsim - let's make flashing less
exciting by at least telling the user which one is the octsim...

Change-Id: Ifa37c63c97824ce42b3476f53626323cb40b879e
2020-02-10 10:27:01 +00:00
Eric Wild 1571e7500f usb dfu header cleanup
Let's stick to one set of headers, the hand-crafted usb descriptor structs
are prettier than the asf define galore.

Change-Id: I689d7122872b28444b6c5343df3bac0c30f23b1d
2020-02-10 10:26:55 +00:00
Eric Wild f659ae8386 git version appended to the product usb string descriptor
Change-Id: I4a9d010c9025cf8c14ebaf42de048b9a172c7786
2020-02-10 10:26:49 +00:00
Eric Wild 922aba5463 support DFU detach to switch from fw to bootloader
This makes flashing a bit more convenient, because pushing the button is
not required. It can be disabled using make DISABLE_DFU_DETACH=1.

Change-Id: I04d05054d1c0e3988b8eafd93c6524f4a0489cb7
2020-02-10 10:26:44 +00:00
Harald Welte e7b3aa9823 Add DFU runtime descriptor
Change-Id: I031c2353248873735698c845f591537779eee995
2020-02-10 10:02:36 +00:00
Harald Welte ce9378d15c Implement serial number string descriptor in CTRL EP callback
Change-Id: I910eca1db4baa375bf604110301a0bde25ffcb26
2020-02-06 16:22:32 +00:00
Eric Wild 50c8816b8f PC_to_RDR_ResetParameters fix
Change-Id: I1d89a704727baa0fd1d14eb6f17809c69cc0df67
2020-01-28 16:15:43 +01:00
Eric Wild 56a5055b45 PC_to_RDR_SetDataRateAndClockFrequency support
Change-Id: I96bb11ac7dff0880c56bd4592e9fde900f55f7a1
2020-01-28 16:07:23 +01:00
Kevin Redon e0605051ed reserve RAM for DFU magic
this changes the linker script so the first word (smallest unit
since the data needs to be 4 baty aligned) is not reserved for
the RAM section.
this allows the application to write any data at this address
without the rest of the code messing with the content.
since the SRAM is preserved after reset, this allows to share
data between firmware.
in particular it allows the application to tell the bootloader it
should start the flashing procedure.
this is already implemented in the osmo-asf4-dfu DFU bootloader.
if the application wants to switch to the DFU bootloader, write
the DFU magic 0x44465521 (DFU!) at the beginning of RAM at address
(uint32_t*)HSRAM_ADDR, and perform a system reset.

Change-Id: Ibafd08429b05fd3cab6af060904201db83186a4e
2020-01-14 14:58:56 +01:00
Harald Welte 0af2079fc9 jenkins.sh: Add verify_value_string_arrays_are_terminated.py
Change-Id: I214bd21212b696d1aa9357b57b545d15bdf74e7f
2019-12-17 12:46:44 +00:00
Harald Welte 0385ef2186 Add --disable-libusb for libosmocore cross-compile
libosmocore.git after I656a1a38cbb5b1f3a9145d2869d3b4d0adefcae3
includes support for USB (and a new dependency to libusb).

But there's no libusb1 in the Cortex-M4 anyway :)

Change-Id: I68da7985001f4f9018995166458006ee47cdf216
2019-12-17 11:51:56 +01:00
Harald Welte a944129d64 change iManufacturer to full sysmocom company name
... like in USB descriptors of other products

Change-Id: I3227c3bb42f67aa166256e0c3f512087e0146e9d
2019-12-06 23:22:54 +01:00
Eric Wild 8cde9d29c0 reenable host builds
Change-Id: Ie00468b7abcd1e9a3efe85b52f08a708430426fe
2019-12-02 14:21:19 +01:00
Eric Wild dd2e82e2b5 rename the global talloc context
both the host and the firmware build require a global talloc context
with external linkage, so let's agree on one name.

Change-Id: Idced24869863983bfde0c9c438498999717f2042
2019-12-02 14:21:19 +01:00
Eric Wild e84a571c04 fix the host/emulation build
Going for __ARM__ to distinguish host and firmware builds is not
sufficient here, since we might be building on a ARM host, so there is
now a OCTSIMFWBUILD define.

Change-Id: Ib07a58b6102b1709f295d08a764c6f118a2d0b9e
2019-12-02 08:47:45 +00:00
Harald Welte 89b1e06803 Check for osmo_fsm_register() error return value
Change-Id: Id2556cf01341b67735fff2685d2f7532f50a4850
2019-12-01 13:30:14 +01:00
Harald Welte 1f1c1c00c0 jenkins.sh: Add --publish to publish binaries, similar to simtrace2.git
Change-Id: Ife4cd90ab856f06d4026a9e7ee67da94517379be
2019-11-30 15:55:57 +01:00
Eric Wild 4cfa9ca54c reenable firmware build
Host build is still disabled until it is fixed

Change-Id: Iee56a50c0cd818887a8e9d8f2f660acaef16a8ca
2019-11-28 13:50:12 +01:00
Eric Wild 20a836890a prettier slot bitmask code
Change-Id: Ia70c589c06d8d786afac54063d41e775e8d850c2
2019-11-28 13:42:16 +01:00
Eric Wild 2288703527 enable the final slot
The debug uart is shared with slot 7, so in order to use sim slot 7 the
pin config and the uart config needs to be changed. Going back to using
the debug uart works by defining ENABLE_DBG_UART7

Change-Id: I8f3c7c60306941159c35307a5c1e38c2a2bd2fe1
2019-11-28 13:42:16 +01:00
Eric Wild 2f5cdd1c46 first attempt at rx timeout handling
The general idea is to provide hints to cuart so it can calculate
a reasonable timeout value when receiving multiple bytes instead of
having per-byte timeouts

Change-Id: Ia6ad2d83cea48a8661ed2e4eb50f9bcb85218454
2019-11-28 13:42:16 +01:00
Eric Wild e708088354 cuart cleanup
Change-Id: I15ea4d68263b62fca3da76795969358a07e7f1a6
2019-11-28 13:42:16 +01:00
Eric Wild dbff42122d cuart: fix etu calculation
Change-Id: Ib2f83654bdaae5090bb1dfd75e0906551d6b6aa7
2019-11-28 13:42:16 +01:00
Eric Wild 9970ca0be7 cuart: allow getting the icc baud rate and clock freq
Change-Id: I577907e6c60582a80666d43b17c20de4e03cc8df
2019-11-28 13:42:16 +01:00
Eric Wild 587d4fbb88 change uart ctl define names
Change-Id: I656e9e32c67d6e7b70a53f8f113583f25619e00f
2019-11-28 13:42:16 +01:00
Eric Wild 474cf59ad0 the magic sauce that makes it work
1mio concurrent select mf transfers, 5mhz, fi/di 512/32

Change-Id: Ica8539e4428ca3e3eb3e8ca9f5a5b50eb738ca8d
2019-11-28 13:42:16 +01:00
Eric Wild 5de00c2842 boost uart priority
Change-Id: I10ea17ca8b120c09b8926da010c9e358b219f7ed
2019-11-28 13:42:16 +01:00
Eric Wild a057457f6a pps warning
Change-Id: Ia125b7983e81342af224bc6e8771d8be4c4bfa42
2019-11-28 13:42:16 +01:00
Eric Wild 45e930d9c5 add a note for D=64 pecularities
Change-Id: Icf2845e0f07f2d23f5090d35b6d8d145ad65a2f8
2019-11-28 13:42:16 +01:00
Eric Wild 759a646a05 fsm completion event handling from main loop
The main loop will now poll for finished/failed transactions and handle
them, this was previously handled during the last rx interrupt of a
transaction, which was bad for timing. This does also fix malloc/free
while handling interrupts.

Change-Id: I055110720089e20e65db592eccc3ce4d618e8c63
2019-11-28 13:42:16 +01:00
Eric Wild 6ce4e5fab1 fix power descriptor value
The previous value would allow using the device
without external power, i.e. on a hub, which leads
to silent failures trying to power up the slots
(nothing happens, no atr will be received)

Change-Id: I40c48ea56151d13de362b8f73cae5b21aba0ebfa
FIXME: The device should offer at least one 100mA configuration.
2019-11-28 13:42:16 +01:00
Eric Wild 9155231ef4 better ccid error handling, fix buffer leaks
Change-Id: Ib8b8524809e12608a7ade79ce7d7c3ced16eeb57
2019-11-28 13:42:16 +01:00
Eric Wild 3e85990577 add some volatility to debug missing state changes
Change-Id: I2e12e32ad27b03d73ba3533903c34abc2fcce37a
2019-11-28 13:42:16 +01:00
Eric Wild 4c4583a65f switching rx/tx is too slow, and not necessary
Change-Id: Ic91b3e183ba451b4e327e407aae0497273652f56
2019-11-28 13:42:16 +01:00
Eric Wild fd0baceb95 add a "no rx or tx" state
Change-Id: I27def4feff5a01b751fd48c5aa844ffdbb087f63
2019-11-28 13:42:16 +01:00
Eric Wild 9a2279cf63 debug code to measure uart timing using the CAN header
Change-Id: I5f2c174076b5599dcb56f887330de27f470aeffc
2019-11-28 13:42:16 +01:00
Eric Wild 9b3fe27e53 debug code to use the DWT unit
Change-Id: Ide6e34425e77425b260139ac1b4c528953a994f4
2019-11-28 13:42:16 +01:00
Eric Wild e8012b6897 increase the debug uart buffer size
printing to the buffer is faster than getting the data out, so let's
increase it a bit to drop less information

Change-Id: I343b03d5b06962b90f0c1aaceda03aa871a2f98b
2019-11-28 13:42:16 +01:00
Eric Wild 9e622dc4b7 attempt at handling card insertion/removal
Change-Id: I88130de7f889811425c0a2ca4063ea8822c83f66
2019-11-28 13:42:16 +01:00
Eric Wild ad1edce363 ccid setparameters/PPS support
Change-Id: I280969ec9fe681dedae14ae8e6806f69eed3ff5a
2019-11-28 13:42:16 +01:00
Eric Wild b39d83251c cuart icc clock freq and divider setting support
Change-Id: I9c99c68511d3972513348ee6be5e7bb3b3a5f99e
2019-11-28 13:42:16 +01:00
Eric Wild c7d980cc86 move iso7816_3 to common dir
Change-Id: Id8cfc9247988ae999f5544d936d67f12e3902b92
2019-11-28 13:42:16 +01:00
Eric Wild da142a086d prevent uart interrupts before having proper structs
Change-Id: I9cf7ff883721211ae11821339505d2e3b2a7961e
2019-11-28 13:42:16 +01:00
Eric Wild 27f6045e4a no logging, no memory pool
Change-Id: Iaf5123ab0340efec7b8e11e689f529f2e95e31ca
2019-11-28 13:42:16 +01:00
Eric Wild 8200fccb3f talloc asserts
Change-Id: I00df6e41f38eba6b6f06a0dab52035f446718a99
2019-11-28 13:42:16 +01:00
Eric Wild e4f90fe4ef increase the uart ring buffer size
must be be a power of 2, and should be at least as large as the largest
transfer that we might be waiting for - revisit this, is 256 enough?

Change-Id: Id4b4691dd32d465f627ba42c0ba3d509dcf8f42c
2019-11-28 13:42:16 +01:00