aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)AuthorFilesLines
2020-04-10cardem: choose a more reasonable default ATRhoernchen/simtrace_cardemEric Wild2-4/+38
PCSCd does not like invalid ATRs Change-Id: I1eebfdc06be55931c2e80e2b515ac3a559737c38
2020-04-10firmware: allow verbose buildsEric Wild1-6/+14
make V=1 can be used to echo all compilation commands, which is useful because it allows IDEs to parse the gcc output in oder to properly index the source files using the actual defines passed to the compiler. Change-Id: I25c41dff89302a73ddd2a4aaba7cb14912fac3b8
2020-04-10Revert "cardem: disable upload for simtrace2"Eric Wild1-2/+0
This reverts commit baa62777c845c3466fae5d80729e6b2bd754eea8. cardem w/ simtrae board should now work. Change-Id: I1bce9a57ad2960695c31b8879f5d4ded2dddd7bc
2020-04-10firmware: do not allow undefined symbolsEric Wild3-4/+9
For some reason undefined symbols were downgraded to warnings, which means building a firmware that calls missing functions (= address zero) was perfectly fine, which of course made development more exciting.... This applies to builtins, too, printf of one char gets downgraded to putchar, which we don't have, so disable builtins. Change-Id: I492f41ad4162b9d07b1881ae4aed019db2dff8b5
2020-04-10cardem: ignore set ATRKévin Redon1-1/+4
the PPS procedure with baud rate change has not been tested. by keeping the default ATR instead of applying the ATR sent by the host software, no other baud rate choice is offered. Change-Id: Ibf7c6b83d2cf68172c7aa25116d838e24a95d5fe
2020-04-10cardem: fix TPDU state checkKévin Redon1-1/+1
this change allows to initialize the TPDU state while in ISO_S_WAIT_TPDU, before actually entering ISO_S_TPDU Change-Id: I505d3add32a43de31499b800bc53442f99f65931
2020-04-10cardem: ensure VCC_PHONE is floatingKévin Redon2-1/+17
this change is mainly relevant for the SIMtrace board, but also affects the others. First we ensure VCC_PHONE is not forwarded to VCC_SIM because the card could affect the signal (card could draw too much current or feed back current in). next we disable VCC_SIM. the card slot does not need to be powered, and the FPF2019 leaks current back to VCC_PHONE, even with forwarding disabled (the reverse current protection only kicks in when VCC_PHONE is briefly shorted to ground, but still leaks 0.6V). enable the ADC channels normally used to measure VCC, even if not used. the dedicated ADC pins leak current when left unconfigured. enabling them puts them in high impedance. Change-Id: If1487c1c191838aaa08b654e49cd31c7180ffc19 XX pin reconfig Change-Id: Ib261073e3779ae7d98de18ce78b34ff37eafeaa2
2020-04-10cardem: use USART timeout for waiting timeKévin Redon14-66/+365
the reset/ATR handling has been heavily updated/fixed. instead of using the timer counter peripheral to handle the waiting time and corresponding timeout, the USART peripheral internal timeout mechanism is used. this is particularly important for the SIMtrace board since the clock signal is not connected to the timer counter. thus this change adds card emulation support for SIMtrace boards. Fi and Di have been properly rename to F and D since the "i" stands only for an "indicated" value, not the actual value. this does not change the USB protocol (the variable have just been renamed). additional variables store more information about the card capabilities NOTE: it has only be tested for the SIMtrace board Change-Id: Ibcb2c8cace9137695adf5fb3de43566f7cfb93b5
2020-04-10cardem: currently simtrace does not support cardemKévin Redon1-1/+1
the SIMtrace board does not support the current card emulation application because this uses a timer counter to handle the timeouts, but on the SIMtrace board this is not connected to the CLK signal Change-Id: Idd09ea534179f0ede705573e1373dbd045c9828a
2020-04-10make sim switch board specificKévin Redon4-0/+161
the simtrace board uses a bus switch not used on qmod and owhw to switch the SIM between physical and virtual Change-Id: Ieaf2ed4761fc3e04f33f9aac5c04a768c9a6f71e
2020-04-10cardemu: different init for simtrace board which uses uart timersKévin Redon1-0/+13
Change-Id: I464f0ce1ec5e60be5f9377186b7d13a5e6dc637e
2020-04-10different voltage comparison on powerupKévin Redon1-2/+8
Change-Id: I71b703162219484e43638f1f2f692e9dd554ef55
2020-04-10minor add commentsKévin Redon1-15/+24
this is just to better understand the flow Change-Id: I045286836176da729cc8c863866d6f6aa3836592
2020-03-26rename PIN_PHONE_IO to PIN_USIM1_IOKévin Redon1-2/+2
this matches the naming scheme used for USIM2 Change-Id: I486b14260faec897e8c8698c4b7987bf36492497
2020-03-26add ISO 7816-3 library to remsim projectKévin Redon1-1/+1
Change-Id: I99f3fecbc00d2379c3a6dc457b047c6fee41c292
2020-03-26add library providing ISO 7816-3 utilitiesKévin Redon2-0/+221
this will become part of libosmocore since it it common to smart card related projects (such as osmo-ccid-firmware) Change-Id: I3d4c65d137fc4555fcb256443feadd1c695de73d
2020-03-26minor: use same LED pattern for cardem as other opplicationsKévin Redon1-1/+2
Change-Id: I5608c3312b648c0d59f79338ef1f97b6fe08f5b9
2020-03-19simtrace2_siff: getopt_long() returns int, not charHarald Welte1-1/+1
This may be causing unwanted behavior while parsing the command line arguments, as reported by some Raspi users. Change-Id: I5b7db0795d16ab071e255c2c689e3b4872a933bb Related: OS#4223
2020-03-13pio_it.c: Permit repeated calls to PIO_ConfigureIt()Harald Welte2-7/+19
The original code assumes that calls to PIO_ConfigureIt() are only made once e.g. during board start-up. Hoewever, we call those at USB SetConfiguration time, when we know which particular hardware function we are supposed to perform. This means that after the host has issued SetConfiguration more than a given number of times, the code will assert() due to overflow of the static array. Let's check if we already have allocated an array slot for a given pin and reuse that allocated array bucket rather than allocating new ones for the same pin. Change-Id: I0c46d4b51eeebd58a8786d65e31e7a84e65b6a8e Related: OS#4454
2020-03-13USBD.c: Don't reset EP0 on SetConfiguration(0)Harald Welte1-1/+1
If we do this, the resulting USB code will fail on any of the USB-IF Chapter 9 tests. EP0 should not be reset. Change-Id: I070faf4cb7029d3ccfa6c63f8f04aa0f02657536
2020-03-03cosmetic: Add missing CR to LF in dispatch_received_usb_msg()Harald Welte1-1/+1
Change-Id: Ie1fc38ed4412b806e37688e0f9719573df06fd9f
2020-03-03extend osmo_st2_cardem_inst with fields required by osmo-remsimHarald Welte1-0/+4
Change-Id: Ib568e5212abfd1269a12c9e5672cdf23b4abff91
2020-03-01cardem: Fix infinite loop + watchdog reset on long OUT messageHarald Welte1-0/+1
In dispatch_received_usb_msg(), we ran into an infinite loop if a too long messages was received on the OUT EP. Let's break the loop. Change-Id: I5325ed15d3dd79a42f8dac34d618e86b9334c301 Closes: OS#4429
2020-03-01Disable interrupts during EEFC_ReadUniqueID()Harald Welte1-0/+7
Reading the Unique ID from flash is a rather tricky procedure: After the STUI command has been issued, we cannot read normal flash anymore. Rather, the unique ID is mapped at 0x00000000. This is unfortuantely also where the exception vector table is stored. EEFC_ReadUniqueID() is already linked to RAM, which is good. Hoewver, if an Interrupt happens between STUI and SPUI, then we try to access the vector table and code from flash, which is illegal. We run into a hardfault and stay there until the watchdog resets the processor. Change-Id: I3c4fad55b47e9013f6615a331983b3989ca805a7 Closes: OS#4428
2020-02-22simtrace2_api: Add osmo_st2_cardem_request_config()Harald Welte2-0/+16
In Change-Id I7cdd3f9171dbed45de0089defe29d2b59044bd84 we introduced firmware support for SIMTRACE_MSGT_BD_CEMU_CONFIG. The respective host part was so far only implemented in osmo-remsim-client-st2, but not in libosmo-simtrace2. Let's fix that. Change-Id: Ia4822d360a271d2ce9725f761cb95de58663ac3b
2020-01-30cardem: disable upload for simtrace2Eric Wild1-0/+2
cardem on the st2 has been broken forever and still does not work, so stop uploading cardem binaries Change-Id: I33828f799d41386afb3f8dcd9bb510902877e03f
2020-01-30remsim: allow selecting pcsc reader numberEric Wild1-2/+8
The number can be queried using pcsc_scan -n Change-Id: I9d347501a9f181f68e74799ad04a810553eb2c9e
2020-01-17increase ringbuffer size from 512 to 1024 bytesHarald Welte1-1/+1
As reported in https://osmocom.org/issues/4335, there appear to be some cards / use cases in which the 512 byte sized ringbuffer is insufficient. As we do have free RAM available, we can easily increase the buffer size, despite not entirely knowing yet why it needs to be *that* large. Change-Id: Ie713d614ec5b334e9058d5d430e4bb660f5b8b69 Closes: OS#4335
2020-01-17host/lib/gsmtap.c: Add GPLv2 disclaimerHarald Welte1-0/+19
Change-Id: Ie163af869c6aa2f3e2bd9007432dc6945384aaf2
2020-01-17host: Add COPYING file for host software (GPLv2)Harald Welte1-0/+339
Change-Id: I0f89a204939b0648eed94cc4f6e7c4f735c118fa
2020-01-16add script to flash latest firmwareKévin Redon1-0/+162
this python script lists the SIMtrace 2 devices connected to USB and will flash the latest version of the application (if necessary). it requires pyusb and dfu-util. it is intended for end users so they don't need to read the length and error-prone instructions provided in the wiki. TODO: - support updating bootloader (once dfu-ram image exists) - use python implementation of dfu-util to be python only Change-Id: I3ebe0f54b6e3b7b45478603cc0a5b56e87b1f461
2020-01-16DFU: add DFU applicationKévin Redon9-20/+92
this adds the DFU as application, allowing to flash the bootloader. a USB DFU alternative is added to flash the bootloader partition. when the DFU is started as bootloader, the partition/alternative to flash the bootloader is marked as "not available", and ineffective. the same happens for the application partition when DFU is started as application. this distinction is make at compile time, not at runtime, because of size restrictions (the bootloader was already close to the 16 kB limit). *_dfu_flash.bin should not be mixed with *_dfu_dfu.bin. *_dfu_dfu.bin should be flashed as application using the already existing DFU bootloader. once this images is started (as application), the *_dfu_flash.bin should be flashed as bootloader using the DFU application. once the DFU bootloader has been flashed, soft resetting (not re-powering) will cause the bootloader to start, allowing to flash the application with a normal image (e.g. not DFU), replacing the DFU application. this switch to DFU only happens after downloading (e.g. flashing). it is planned to have the DFU application erase itself after flashing, but this is currently not implemented. Change-Id: Ic273bb593a7669111b0219fe301d7897419167c8
2020-01-11firmware: apps/cardem/main.c: Synchronize with apps/trace/main.cHarald Welte1-3/+4
In the end we want to share most of this, irrespective of the "APP". Let's avoid unnecessary differences. Change-Id: Icf063d4ca79edf66ffbe8e87a915deb77dec478a
2020-01-11firmware: move printing of welcome banner to common function print_banner()Harald Welte6-60/+64
This unifies the printing of the welcome banner, and it also ensures that all modes print all information (serial number, reset cause). Furthermore the APP and BOARD #defines from the make environment are also printed. Change-Id: I7e6bc05cee4b9ec0fd9a05dc90ce0b26a5763e5a
2019-12-26library: Add osmo_st2_compatible_dev_idsp[]Harald Welte4-2/+47
This is a list of known-compatible USB VID/PID pairs. Change-Id: I3ef66ebba307899c57077bfd633f84f30190f4dc
2019-12-26migrate to libosmousbHarald Welte10-429/+17
the code we used to have in libusb_util.c has been migrated to libosmousb, a new part of libosmocore.git. Let's remove our historic copy and use the new shared library instead. Change-Id: Ib588c08f873c4da8f3a02815ee2767674a6a5061
2019-12-26Update .gitignore file for hostHarald Welte1-0/+6
Change-Id: Id6449ea1c3e918e8c7748b9af7c8c354c1b607d5
2019-12-25OSMO_ASSERT() on double-free or invalid pointerHarald Welte1-0/+2
Change-Id: I2ab8fb7b86b6f608bbd9c4f79369c64cbad88bdf
2019-12-17[lib] apdu_dispatch: Don't print APDU state to stdoutHarald Welte2-9/+16
The printing was always only done at the end of osmo_apdu_segment_in(), so let's leave the decision up to the user if he wants to print the state at every iteration or not. We now provide osmo_apdu_dump_context_buf() to the user so he can obtain a string representation of the internal state for logging at any time he requires. Change-Id: Id3e3cf1605dec84077b158c1c5715f8eef2641d5
2019-12-17[lib] apdu_dispatch: Use DLGLOBAL and don't printf() directlyHarald Welte1-6/+7
Change-Id: I2f3ec49d34b6806e13af185fb629cabc486891fb
2019-12-17jenkins.sh: Add verify_value_string_arrays_are_terminated.pyHarald Welte1-0/+3
Change-Id: I15f13e12711b87ce71b38b16ef17620850fd8eb7
2019-12-17firmware: Reformat value_string to pass our validation scriptsHarald Welte2-88/+22
This is a purely cosmetic change in terms of coding style, but it fixes an [invalid] detection for unterminated value_string arrays by our verify_value_string_arrays_are_terminated.py script: Change-Id: I2f2370a673074f6bf5380106b6254b4aa1e8a792 ERROR: file contains unterminated value_string 'struct value_string iso7816_3_card_state_names[]': './deps/simtrace2/firmware/libcommon/source/card_emu.c' ERROR: file contains unterminated value_string 'struct value_string tpdu_state_names[]': './deps/simtrace2/firmware/libcommon/source/card_emu.c'
2019-12-17simtrace2-sniff: Reformat value_string to pass our validation scriptsHarald Welte1-40/+10
This is a purely cosmetic change in terms of coding style, but it fixes an [invalid] detection for unterminated value_string arrays by our verify_value_string_arrays_are_terminated.py script: Change-Id: Iee905c744065df1dc54f04be752a65700897a92c ERROR: file contains unterminated value_string 'struct value_string change_flags[]': './deps/simtrace2/host/src/simtrace2-sniff.c' ERROR: file contains unterminated value_string 'struct value_string data_flags[]': './deps/simtrace2/host/src/simtrace2-sniff.c'
2019-12-16cardem: Implement support for CEMU_FEAT_F_STATUS_IRQHarald Welte1-1/+13
If this feature flag is set by the host application, we will start generating SIMTRACE_MSGT_BD_CEMU_STATUS towards the interrupt endpoint on any changes to the SIM card status, such as change of VCC/CLK/RST Change-Id: I832b4ac4aeb6152195d985067ffdd64fa5a7d4cc Related: OS#4330
2019-12-16cardem: Add SIMTRACE_MSGT_BD_CEMU_CONFIGHarald Welte4-0/+54
The new SIMTRACE_MSGT_BD_CEMU_CONFIG command can be used to set/change a bitmask of optional features that can be enabled in the simtrace by the host software. This is useful for enabling features in the firmware which are not supported by older host utilities. The firmware will return the actually set/configured features in response. The feature bitmask is not yet used anywhere; it will be by subequent patches. Change-Id: I7cdd3f9171dbed45de0089defe29d2b59044bd84
2019-12-16cardem: Make card_emu_report_status() optionally use IRQ endpointHarald Welte4-6/+9
This just introduces the capability to report on IRQ, but we don't actually use it yet. Change-Id: I83db4463b7010ba243a8adbda3ac9393975b4814
2019-12-16card_emu: Remove extraneous initialization of ch->pts.stateHarald Welte1-2/+0
ch->pts.state is initialized every time we enter ISO_S_WAIT_TPDU state, so there's no need to reset it at other locations. KISS. Change-Id: I5ff8b2671c3c893cc5f6542d48b65487ae8c5be1
2019-12-16card_emu: Remove extraneous codeHarald Welte1-3/+1
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
2019-12-16card_emu: Always print state names in string representationHarald Welte1-10/+27
Change-Id: I81469e40f3720afdcb47048b45c63d6474887640
2019-12-16card_emu: Avoid recursive calls to card_set_state()Harald Welte1-7/+17
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