Commit Graph

845 Commits

Author SHA1 Message Date
Harald Welte 9ba5b5c1b9 host/lib/gsmtap.c: Add GPLv2 disclaimer
Change-Id: Ie163af869c6aa2f3e2bd9007432dc6945384aaf2
2020-01-17 10:59:41 +01:00
Harald Welte 2c673c38f5 host: Add COPYING file for host software (GPLv2)
Change-Id: I0f89a204939b0648eed94cc4f6e7c4f735c118fa
2020-01-17 10:59:32 +01:00
Harald Welte 87940f1f83 Build only 'reasonable' combinations of APP/MEMORY
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
2019-12-06 20:08:33 +01:00
Harald Welte 36f888f8b5 Patch actual board name into the USB iProduct string descriptor
"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
2019-12-06 19:19:23 +01:00
Harald Welte 0a7c691b90 usb_strings.txt: s/SIMtrace Phone/SIMtrace Card Emulation/
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
2019-12-06 19:19:23 +01:00
Harald Welte c9af72dccb qmod DFU: Don't overwrite memory beyond end of usb_strings[]
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
2019-12-06 18:47:25 +01:00
Kevin Redon d70836f965 DFU: restart bootloader when USB conf failed
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
2019-12-03 15:51:52 +00:00
Kevin Redon ed3ceec56f DFU: increase USB reset duration to 50 ms
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
2019-12-03 15:51:52 +00:00
Kevin Redon 15f48b2e89 minor: fix typo
Change-Id: I462291078fe9b05bfdf6fb7ab0f96b1edeecdac6
2019-12-03 15:48:51 +00:00
Kevin Redon 503e184157 cardem: use simplest ATR as default ATR
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
2019-12-02 19:38:45 +01:00
Kevin Redon 24c6fe21ab simtrace2-remsim: Use simplest ATR
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
2019-12-02 19:35:45 +01:00
Kevin Redon 8cbede7067 minor: ignore usbstring binary
Change-Id: I18fc3179f8b7f3f1272d26853007876156fc1e03
2019-12-02 19:30:37 +01:00
Kevin Redon 8b6991c18c better detect VCC and nRST changes on simtrace2 board
monitoring the state changes of the VCC and nRST lines is required
to correctly detect warm and cold reset

Change-Id: I72099956332724f84226e1495fdc5a5b1a034695
2019-12-02 19:28:52 +01:00
Kevin Redon 1cfc25e8c1 minor : fix typo in comment
Change-Id: Ie310143fe713a51fa1adf8bf7599374282341f2e
2019-12-02 19:28:07 +01:00
Kevin Redon 3864a794b4 minor: improve debug output
Change-Id: Ibfc22b95c0be3ac78bd50a40e31cc7d8546d81d9
2019-12-02 19:28:00 +01:00
Kevin Redon e051ddd1f3 minor: move USB debug output from info to debug level
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
2019-12-02 19:27:19 +01:00
Kevin Redon 98fbf23897 dfu: minor: make debug output only verbose in info level
the longer output is to fast and often incomplete.
the shorter version is enough to view the progress when not
debugging.

Change-Id: I97bb84da68d1f3bc14fb7c05400edf1748f55460
2019-12-02 19:26:56 +01:00
Kevin Redon 9b367872c8 minor: updated copyright years
Change-Id: I9254b1ddf6436b5a4964b9124a36ae17bfc22886
2019-12-02 19:26:11 +01:00
Harald Welte 0b7e5f3af0 fix baudrate of 'make log'
Change-Id: Id186a594b1ce3ea0cd38f0cb82a99e5d87101433
2019-12-02 19:25:55 +01:00
Kevin Redon 72a62cfdb9 minor: fix spacing
Change-Id: I2f3127c7b276c9726fd0242e3e29be22f9d6255c
2019-12-02 19:25:37 +01:00
Harald Welte 483a3203fb simtrace2_api: Remove dead code
Change-Id: Iab393a6cf9ae1218e1554d9c0bfb7aab2cc3c35e
2019-12-02 11:23:51 +01:00
Oliver Smith 71cfc2b90d Fix topdir Makefile and debian packaging
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
2019-11-28 11:53:09 +01:00
Oliver Smith 15e943ab8b simtrace2-sniff.c: fix printf usage
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
2019-11-27 19:10:02 +01:00
Kevin Redon b7f94dcb9f qmod: lower VCC threshold to 2.5V
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
2019-11-26 13:49:53 +01:00
Kevin Redon c90de6983c free USB buffer when allocation failed
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
2019-11-26 09:57:28 +00:00
Harald Welte 6f41349db9 merge simtrace2-discovery.[ch] to libusb_util.[ch]
Change-Id: I4defbec70986a90c1f0cfb7587393265b73c0163
2019-11-24 23:15:53 +01:00
Harald Welte 208890ad6e use osmo_st2_ or osmo_ prefix for [shared] library symbols
Change-Id: Ie2686b30717b9541b1217802ca967cd0a4cbde9b
2019-11-24 23:15:53 +01:00
Harald Welte 964cda309d host: use autotools and split shared code to libosmo-simtrace2
Change-Id: I57e77f927ee9e169cc794c5dc6b128a2d590201b
2019-11-24 23:15:53 +01:00
Harald Welte 331fa5a237 remove unused function process_do_error()
Change-Id: I02bc23a340b086b0de4e69affb6f965bff6bbc0b
2019-11-24 23:15:53 +01:00
Harald Welte 6fada5604b simtrace2-remsim: Implement/Fix the 'skip_atr' option
Change-Id: Id8206738635af0dd55836bbbcbfbe7381c375e97
2019-11-24 23:15:53 +01:00
Harald Welte 931fe558df fix typo: libisb -> libusb
Change-Id: I0a9505e3eeb7ae4ffda7081dcbb1ed63835600a5
2019-11-24 23:15:53 +01:00
Harald Welte d401b12136 card_emu_tests: Cosmetic changes (re-order code; more comments)
Change-Id: I36aefc824187ee99d83a451d869b137c13334d91
2019-11-24 23:12:04 +01:00
Kevin Redon 389a4040d5 add DFU enter override capability
in case flashing the main application firmware using DFU failed,
the main application might be broken and not allow to switch again
to DFU mode to re-flash it correctly.
the other board have a way to force entering (e.g. staying in) the
bootloader using an external signal (e.g. a switch on the SIMtrace
board).
the OWHW DFU firmware did not have this functionality implemented.
the design (e.g. schematic) already has the SIMTRACE_BOOTLOADER
signal (on PA31) for this purpose.
now the DFU bootloader will start the DFU mode when the
SIMTRACE_BOOTLOADER is high.

this change has been tested on OWHWv2.

Change-Id: Iefff51a811ad0f3bf3a46b8e256b905d11344bea
2019-11-18 20:26:59 +01:00
Kevin Redon 5db9402a5f add serial and version info in USB description
as for the main application firmware, the DFU bootloader firmware
now also has the unique chip ID as iSerial in the USB description,
and an additional empty USB configuration indicates the firmware
version (e.g. DFU bootloader version).
these are only visible when the device is in DFU mode.

Change-Id: I11a2cd8079fda374d816da180f39f1c33d10af60
2019-11-18 20:06:13 +01:00
Kevin Redon ac7e73a579 check RST/VCC/CLK line at every step of the activation
ISO-7816 specifies a card activation sequence: VCC on, CLK active, then RST
release.
we now check for the end state at every state of the activation in case the
reader does not strictly follows the sequence.

change has been tested on OWHW slot 1.

Change-Id: Ie55505ab3a70cbd64281af40af53d5e120313228
2019-11-14 20:11:48 +01:00
Kevin Redon 7233cf803a initialize VCC, RST, and VCC with actual values
previously the card RST, VCC, and CLK signal states have been initialized with
default values corresponding to an inactive reader.
this worked fine for actual inactive readers since the default values match
and would be updated when the signal changes (edge detection).
but if the reader is in another state, card activation detection could fail.
this is fixed since the actual signal values are now used during initialisation.

at the same time I changed the variable type from uint8_t to boolean since they
have only two possible states, and understanding the actual state when coding
is simpler (no need to check which integer corresponds to which state).

this change has been successfully tested on the 2 slots of OWHW board.

Change-Id: Ie9245d75d48ae93d16f97897d4fa5ad6cd402e73
2019-11-14 19:54:17 +01:00
Harald Welte cdcdcc9f6d firmare/test/Makefile: Fix link order
Change-Id: I3ee8031f2823ad0817cb469526b1edfc0230b26b
2019-10-30 09:26:38 +01:00
Harald Welte e876bf53e8 Attempt to fix master-simtrace2 publish stage (missing WORKSPACE env)
Change-Id: I5dfb22199727d424d83584f58c6517c80573e880
Related: OS#4243
2019-10-30 09:26:38 +01:00
Joachim Steiger f7f1ea864d add/fix mcp23017 i2c gpio expander functions and tests
Change-Id: Ia2e5a1bf3f97272931014e54e587109297556c03
2019-10-24 18:09:05 +02:00
Kevin Redon 3feadfa910 define LEDs for octsimtest
the OctSIM tester has only one amber LED.
this is now mapped to the normally green LED, used for activity.
because the LED is driven by an NPN transistor (as open collector)
instead of being directly connected to the pin (as open collector)
like on the other boards, the logic is inverted.
since normally the LED is on on idle and blinks during activity,
it will now be off on idle an only blink on activity (unless the
code is extended to cope with the possible inverted logic).
because there is no second LED but the current code requires one,
I mapped is to an unused pin.

the octosimtest target still does not compile completely, but at
least the LED issue is fixed.

Change-Id: I1296833bef2804c611640fcf4756e47905660e7b
2019-10-04 15:55:02 +00:00
Kevin Redon 9acff5ee5a make LED definitions board specific
the LEDs (2 of them) were connected to the same pins on all
boards, up to the octsim-tester.
to be able to have board specific LEDs the definitions have moved
from common to the each board.
at the same time I added a bit of documentation what the LEDs are
used for.

Change-Id: I3226a9187a8d0b657ccf5dcd8f3586b2578f96d2
2019-10-04 15:55:02 +00:00
Kevin Redon e5efbb156c hw: put board specific pin definition in corresponding file
SIM_PWEN and VCC_FWD are signals specific to the simtrace boards.
the corresponding pins PA5 and PA26 are used for other signal
on the octsim-tester.

Change-Id: I51f37dd112cf681f4b1dbb3d2320ff9a697eaa08
2019-10-04 15:55:02 +00:00
Kevin Redon ede87e067d USB: place version string in interface
previously the version string was in the iConfiguration field of a
dedicated USB configuration.
this configuration had no interface, but the USB specification
requires at least one interface.
an interface has been added to this configuration.
the version string is now in the iInterface field, and the
iConfiguration field contains "firmware version".
the USB specification does not require an end-point, and none are
present.

Change-Id: I99361e313979711f4f45ad424a52faa3ddd7c558
2019-08-13 17:03:23 +02:00
Kevin Redon acb7bd9fbe disable ERASE pin
disabling the ERASE pin prevents accidental erase for the flash
memory while the board is powered on (e.g. in case the user
overcomes the weak 100 kOhm pull-down for more than 220 ms by
touching or shorting the pin).
the flash is still erasable using the ERASE pin during power up.
it is only disabled after boot completed.

Change-Id: Ic3332eb1d4247a07988b2fd841f40e79862d06a7
2019-08-12 20:49:12 +02:00
Harald Welte 4b487b836a Fix builds on Ubuntu 16.04
The most recent commits introduced 'C99' syntax by declaring variables
inside the 'for' statement itself, rather than before.

This resulted in compile failures in the Ubuntu 16.04 builds on
build.opensuse.org:

[  105s] libcommon/source/usb.c: In function 'SIMtrace_USB_Initialize':
[  105s] libcommon/source/usb.c:679:2: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
[  105s]   for (uint8_t i = 0; i < ARRAY_SIZE(device_id_string) - 1; i++) {
[  105s]   ^
[  105s] libcommon/source/usb.c:679:2: note: use option -std=c99, -std=gnu99, -std=c11 or -std=gnu11 to compile your code
[  105s] libcommon/source/usb.c:686:15: error: redefinition of 'i'
[  105s]   for (uint8_t i = 0; i < ARRAY_SIZE(git_version) - 1; i++) {
[  105s]                ^
[  105s] libcommon/source/usb.c:679:15: note: previous definition of 'i' was here
[  105s]   for (uint8_t i = 0; i < ARRAY_SIZE(device_id_string) - 1; i++) {
[  105s]                ^
[  105s] libcommon/source/usb.c:686:2: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
[  105s]   for (uint8_t i = 0; i < ARRAY_SIZE(git_version) - 1; i++) {
[  105s]   ^
[  105s] libcommon/source/usb.c:692:15: error: redefinition of 'i'
[  105s]   for (uint8_t i = 0; i < ARRAY_SIZE(usb_strings) && i < ARRAY_SIZE(usb_strings_extended); i++) {
[  105s]                ^
[  105s] libcommon/source/usb.c:686:15: note: previous definition of 'i' was here
[  105s]   for (uint8_t i = 0; i < ARRAY_SIZE(git_version) - 1; i++) {
[  105s]                ^
[  105s] libcommon/source/usb.c:692:2: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
[  105s]   for (uint8_t i = 0; i < ARRAY_SIZE(usb_strings) && i < ARRAY_SIZE(usb_strings_extended); i++) {
[  105s]   ^
[  105s] Makefile:227: recipe for target 'obj/simtrace/flash_usb.o' faile

Change-Id: Ibdb837ac105664484b10873c2c0d9561051b1c2a
2019-08-08 10:18:35 +02:00
Kevin Redon e0265462d8 add serial and version information in USB descriptor
the device ID (unique to the micro-controller) is now displayed in
the USB iSerial descriptor.
the git version is now also displayed in iConfiguration in an
additional (empty) configuration descriptor.
this allows the user to quickly get the device hardware serial and
firmware version just by using lsusb (no need for a custom USB
software).

Change-Id: If9fadecc097ca3e006990160936bf11b22eae4e0
2019-08-06 16:24:58 +00:00
Kevin Redon d14970f95b publish: also upload latest
the jenkins script will now upload the versioned output to the
all directory, and a copy named "latest" in the latest directory.

Change-Id: I70114ef8414779e369da5cbf945854c9ace3464e
2019-08-01 17:23:23 +02:00
Joachim Steiger b1a81c130e add new board and app for gpio testing on octsimtest board
Change-Id: I01243044002f51b34e8dc12c1b1f565bbf1740a2
2019-07-30 10:56:51 +02:00
Harald Welte 298a5ba722 contrib/jenkins.sh: don't delete old builds from ftp
Change-Id: I2b34b5d4525d62564d34a6583ee3739b82c07c68
2019-07-19 18:58:49 +02:00
Harald Welte c3ef475ea5 contrib/jenkins.sh: also push the .elf files to the ftp (for gdb/objdump)
Change-Id: Ibccf92e30c84f34ff61b3e823151cf33f20a1c4f
2019-07-19 18:58:44 +02:00