Commit Graph

822 Commits

Author SHA1 Message Date
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
Harald Welte 155f57abcf firmware: name binaries including their git version number
Change-Id: I4309810368ce4e8e13ede974b67e69ca3f0a6f53
Closes: OS#3452
2019-06-20 18:31:28 +02:00
Harald Welte bc62335768 qmod: Disable hub reset and EEPROM erase/write by default
We recently introduced ALLOW_PEER_ERASE to control if the firmware
should contain code for the SAM3 to reset each other on QMOD.

Let's use the same define to also remove code for putting the USB
hub into reset as well as code for erasing + writing the hub EEPROM.

This is needed only during production, but it shouldn't be enabled
during normal operation of the product at the end user.

Change-Id: I1c8cca2f7f0f0070d7bf1ade676e035c45e4d5ab
2019-06-19 20:35:37 +02:00
Kevin Redon 63490361d2 remove unused make define
Change-Id: Ia9ef8ce705803df06cf1e4c3ac9731ce69e5e6c5
2019-05-23 16:34:29 +00:00
Kevin Redon 6228d187da add make DEFINE to remove assert ERASE code
remove code to assert peer ERASE line by default.
see README for more information.

Change-Id: I5f88ecf1e2dcf00c0297597f88dd361a6e088c1e
2019-05-23 16:34:29 +00:00
Kevin Redon a634c0efee make peer ERASE more robust
adds command 'a' to allow setting/asserting the peer SAM3S ERASE
line on the next command.
this prevents against accidental erase since only the command 'y'
was required, without confirmation.
this could happen not only through accidental user input, but
noise on the serial line (noise would still cause other issues,
but at least now it will not "brick" the device).
now the sequence 'ay' is required, as any other command following
'a' would clear the permission again.

note: since ERASE is only setting a GPIO within this command
parsing function, not accidental function pointer problem calling
'board_exec_dbg_cmd' should cause accidental ERASE since it would
need to be called two times with the exact sequence

Change-Id: I06bfeaef09a397bd554bec84321e0dd64ccc3aac
2019-05-23 16:34:29 +00:00
Harald Welte bb9b0dc8e8 Add freq_ctr app
The freq_ctr app is a small application that is implementing a
simplistic direct-mode frequency counter using the internal 32.768kHz
oscillator and two TC blocks. One of them is used to generate a 1Hz
signal, which is then subsequently used by the other TC to trigger
a counter read after exactly 1s.

This is in itself not something useful on a simtrace2 device.  However,
it is a separate 'app' and I prefer to have the code here in master
over some obscure branch that's easy to forget about.

Change-Id: I2249bfb8dd6a88d85d406f3b33537377133d0939
2019-02-28 20:05:59 +01:00
Harald Welte b7e326cad3 Add minimal board-support for Olimex SAM3-P256
This is a general purpose evaluation board, and it makes sense to
support it particularly for the DFU bootloader.

Change-Id: I85aea8f1441158f991493c5fc767fdcad405545e
2019-02-28 19:10:07 +01:00
Kevin Redon 2fdcf3b38d cardem: add more debug information for TPDU state
this just adds the name of the TPDU state on top of the state number.

the ISO state is cleaned up accordingly

Change-Id: Id5104a2c3579dedb092c179748e9ed525673841c
2018-10-25 10:42:33 +02:00
Kevin Redon 7e5cda5732 remsim: fix TPDU response size transmission
the TDPU response data size can be up to 256.
this length cannot be stored in a uint8_t, which would cause the
length to become 0, no data being send, and the reader reset the
card because of misbehaviour of the card (i.e. no/malformed
response leading to the timeout of the waiting time).

Change-Id: Iae7671085aaa3115a02d82530dd7a0e7e2d4155e
2018-10-21 12:29:26 +00:00
Kevin Redon 032fc5f844 remsim: update copyright
Change-Id: Ibcf093877ee53f8446c97bfa50c8370ceda24c53
2018-10-21 12:29:10 +00:00
Kevin Redon b1f99c909c remsim: add already parsed USB path argument info
Change-Id: I03de93ebb92b1d1b5004cbe865cdf1fa0b2b23ac
2018-10-21 12:29:10 +00:00
Martin Hauke 53b4e593aa Fix compiler warning: no-return-in-nonvoid-function simtrace2_usb.c
RPM post-build-checks found some issue and marks these as error:
[   61s] I: Program returns random data in a function
[   61s] E: simtrace2 no-return-in-nonvoid-function simtrace2_usb.c:88

Change-Id: Id16fb7fc4f13176b2b6443af02a5848d8fcfb069
2018-10-13 22:14:06 +00:00
Harald Welte dc85fbc3e1 libusb_util.c: Avoid gcc warning about strncpy()
What we're doing is actually legal: We copy the full size of the
destination array, and then overwrite the last byte with NUL.  However,
gcc isn't smart enough to see that:

libusb_util.c:162:5: warning: ‘strncpy’ specified bound 20 equals destination size [-Wstringop-truncation]
     strncpy(out[out_idx].path, path, sizeof(out[out_idx].path));
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Let's copy one byte less to make it happy.

Change-Id: I30ddacdc73e5245c7c38b92d1e94e39b13fae7d3
2018-10-12 15:15:08 +02:00
Harald Welte 66ffb6d493 debian/control: Add dependency to libpcsclite-dev
The host utilities use libpcsclite, and the missing build dependency
causes build failures in our nightly OBS builds since commit
faf1e88e48 was merged:

[  131s] cc -o simtrace2-remsim simtrace2-remsim.o apdu_dispatch.o simtrace2-discovery.o libusb_util.o -Wl,-z,relro `pkg-config --libs libusb-1.0 libosmocore` -pthread `pkg-config --libs libosmosim libpcsclite`
[  131s] Package libpcsclite was not found in the pkg-config search path.
[  131s] Perhaps you should add the directory containing `libpcsclite.pc'
[  131s] to the PKG_CONFIG_PATH environment variable
[  131s] No package 'libpcsclite' found

Change-Id: I29adfc629e5e4ffd0bf8b9035ef9138fe7693d96
2018-09-23 16:59:23 +02:00
Kevin Redon 5b5d24ebf3 owhw: set the right simtrace USB ID in usb2udp
Change-Id: I0b54c2eb98b3fad1e2afaf9b81fbe4518b01fbda
2018-09-08 08:22:56 +02:00
Kevin Redon faf1e88e48 host: clean library dependencies
remsim also needs libpcsclite
`pkg-config --libs libosmocore` and -losmocore are duplicates
`pkg-config --libs libosmosim` is equivalent to -losmosim
pthread it needed (by most applications) for static compilation
LDFLAGS+= allows static compilation when running
LDFLAGS="-static" make

Change-Id: Ic7bd6f2be074d6f652d4f84f4996c8588ea5f851
2018-09-06 23:15:44 +02:00
Kevin Redon 64f69fc4ac owhw: add missing function board_main_top
the board_main_top function was not defined, causing a hard fault
when initializing the board

Change-Id: Ib92003416648822c4115472992850c592bc4047a
2018-09-06 22:52:45 +02:00
Kevin Redon 6303c39a00 owhw: add missing function board_exec_dbg_cmd
the board_exec_dbg_cmd function was not defined, causing a hard
fault on user input

Change-Id: I3ecc1f7bdb2484f5a67c36163d33ebc065e4e709
2018-09-06 22:51:32 +02:00
Kevin Redon ad0958e9e3 minor: update copyright
Change-Id: Iafcd029be9b3f8cf2e90f08d5e9802912d6a59b1
2018-09-06 22:49:56 +02:00
Kevin Redon 4f3a0356a4 minor: fix typo in comment
Change-Id: I3edb50abe93bc8574c9c1f25b34f75dab2e8f0ce
2018-09-06 22:48:11 +02:00
Kevin Redon 7d5d011095 minor: add checks on configurations and functions
these checks prevent out of bounds access and running
unset function pointers.

Change-Id: Ida889d40b898fc1ab8b885800431833570fdaafe
2018-09-06 22:47:01 +02:00
Kevin Redon 1dbcf62295 qmod: add LED user control
this is used during board testing

Change-Id: I4ccd787f6e307f523821725de158e3c6f1508ee2
2018-09-04 16:15:15 +02:00
Kevin Redon e5f891a825 EEPROM: fix Wformat compile warning
Change-Id: I86434a46a75f2acc30e20c33edab6dd3f87e052b
2018-09-04 13:31:26 +02:00