mirror of
https://gitea.osmocom.org/sim-card/simtrace2.git
synced 2026-03-19 06:48:34 +03:00
Compare commits
19 Commits
laforge/ca
...
laforge/ca
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
87c5bdf329 | ||
|
|
76c73aaa99 | ||
|
|
e33c2907bc | ||
|
|
0f75d6ef1e | ||
|
|
c690a1f130 | ||
|
|
8e6ba005d4 | ||
|
|
206d613b4d | ||
|
|
7b681981ea | ||
|
|
e410842d8e | ||
|
|
752bc7f4b5 | ||
|
|
7f421ef014 | ||
|
|
a708ea1d99 | ||
|
|
c1ffc8a603 | ||
|
|
79f0ea73a2 | ||
|
|
9454a062b5 | ||
|
|
6b7f8d142f | ||
|
|
9c95162d5c | ||
|
|
878fadd74f | ||
|
|
9e0e0ddd5a |
@@ -28,7 +28,7 @@ export PKG_CONFIG_PATH="$inst/lib/pkgconfig:$PKG_CONFIG_PATH"
|
|||||||
export LD_LIBRARY_PATH="$inst/lib"
|
export LD_LIBRARY_PATH="$inst/lib"
|
||||||
|
|
||||||
BUILDS=""
|
BUILDS=""
|
||||||
BUILDS+="simtrace/dfu simtrace/trace "
|
BUILDS+="simtrace/dfu simtrace/trace simtrace/cardem "
|
||||||
BUILDS+="qmod/dfu qmod/cardem "
|
BUILDS+="qmod/dfu qmod/cardem "
|
||||||
BUILDS+="owhw/dfu owhw/cardem "
|
BUILDS+="owhw/dfu owhw/cardem "
|
||||||
|
|
||||||
@@ -71,13 +71,13 @@ if [ "x$publish" = "x--publish" ]; then
|
|||||||
$TOPDIR/contrib/prepare_upload.sh
|
$TOPDIR/contrib/prepare_upload.sh
|
||||||
|
|
||||||
cat > "/build/known_hosts" <<EOF
|
cat > "/build/known_hosts" <<EOF
|
||||||
[rita.osmocom.org]:48 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDDgQ9HntlpWNmh953a2Gc8NysKE4orOatVT1wQkyzhARnfYUerRuwyNr1GqMyBKdSI9amYVBXJIOUFcpV81niA7zQRUs66bpIMkE9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ZdHtdMw2zuX
|
[ftp.osmocom.org]:48 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIK8iivY70EiR5NiGChV39gRLjNpC8lvu1ZdHtdMw2zuX
|
||||||
EOF
|
EOF
|
||||||
SSH_COMMAND="ssh -o 'UserKnownHostsFile=/build/known_hosts' -p 48"
|
SSH_COMMAND="ssh -o 'UserKnownHostsFile=/build/known_hosts' -p 48"
|
||||||
rsync --archive --verbose --compress --delete --rsh "$SSH_COMMAND" $TOPDIR/firmware/bin/*-latest.{bin,elf} binaries@rita.osmocom.org:web-files/simtrace2/firmware/latest/
|
rsync --archive --verbose --compress --delete --rsh "$SSH_COMMAND" $TOPDIR/firmware/bin/*-latest.{bin,elf} binaries@ftp.osmocom.org:web-files/simtrace2/firmware/latest/
|
||||||
rsync --archive --verbose --compress --rsh "$SSH_COMMAND" --exclude $TOPDIR/firmware/bin/*-latest.{bin,elf} $TOPDIR/firmware/bin/*-*-*-*.{bin,elf} binaries@rita.osmocom.org:web-files/simtrace2/firmware/all/
|
rsync --archive --verbose --compress --rsh "$SSH_COMMAND" --exclude $TOPDIR/firmware/bin/*-latest.{bin,elf} $TOPDIR/firmware/bin/*-*-*-*.{bin,elf} binaries@ftp.osmocom.org:web-files/simtrace2/firmware/all/
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo
|
echo
|
||||||
|
|||||||
@@ -178,6 +178,14 @@ CFLAGS += -ffunction-sections -g $(OPTIMIZATION) $(INCLUDES) -D$(CHIP) -DTRACE_L
|
|||||||
CFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\"
|
CFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\"
|
||||||
CFLAGS += -DBOARD=\"$(BOARD)\" -DBOARD_$(BOARD)
|
CFLAGS += -DBOARD=\"$(BOARD)\" -DBOARD_$(BOARD)
|
||||||
CFLAGS += -DAPPLICATION=\"$(APP)\" -DAPPLICATION_$(APP)
|
CFLAGS += -DAPPLICATION=\"$(APP)\" -DAPPLICATION_$(APP)
|
||||||
|
|
||||||
|
# Disable stack protector by default (OS#5081)
|
||||||
|
ifeq ($(STACK_PROTECTOR), 1)
|
||||||
|
CFLAGS += -fstack-protector
|
||||||
|
else
|
||||||
|
CFLAGS += -fno-stack-protector
|
||||||
|
endif
|
||||||
|
|
||||||
ASFLAGS = -mcpu=cortex-m3 -mthumb -Wall -g $(OPTIMIZATION) $(INCLUDES) -D$(CHIP) -D__ASSEMBLY__
|
ASFLAGS = -mcpu=cortex-m3 -mthumb -Wall -g $(OPTIMIZATION) $(INCLUDES) -D$(CHIP) -D__ASSEMBLY__
|
||||||
LDFLAGS = -mcpu=cortex-m3 -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--entry=ResetException -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -Wl,--print-memory-usage -Wl,--no-undefined $(LIB)
|
LDFLAGS = -mcpu=cortex-m3 -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--entry=ResetException -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -Wl,--print-memory-usage -Wl,--no-undefined $(LIB)
|
||||||
#LD_OPTIONAL=-Wl,--print-gc-sections -Wl,--stats
|
#LD_OPTIONAL=-Wl,--print-gc-sections -Wl,--stats
|
||||||
|
|||||||
@@ -153,10 +153,14 @@
|
|||||||
|
|
||||||
/** Supported modes */
|
/** Supported modes */
|
||||||
/* SIMtrace board supports sniffer mode */
|
/* SIMtrace board supports sniffer mode */
|
||||||
|
#ifdef APPLICATION_trace
|
||||||
#define HAVE_SNIFFER
|
#define HAVE_SNIFFER
|
||||||
|
#endif
|
||||||
/* SIMtrace board supports CCID mode */
|
/* SIMtrace board supports CCID mode */
|
||||||
//#define HAVE_CCID
|
//#define HAVE_CCID
|
||||||
/* SIMtrace board supports card emulation mode */
|
/* SIMtrace board supports card emulation mode */
|
||||||
//#define HAVE_CARDEM
|
#ifdef APPLICATION_cardem
|
||||||
|
#define HAVE_CARDEM
|
||||||
|
#endif
|
||||||
/* SIMtrace board supports man-in-the-middle mode */
|
/* SIMtrace board supports man-in-the-middle mode */
|
||||||
//#define HAVE_MITM
|
//#define HAVE_MITM
|
||||||
|
|||||||
@@ -13,6 +13,20 @@
|
|||||||
#define PHONE_INT 2
|
#define PHONE_INT 2
|
||||||
#define PHONE_DATAOUT 3
|
#define PHONE_DATAOUT 3
|
||||||
|
|
||||||
|
/* stub for stdio */
|
||||||
|
signed int printf_sync(const char *pFormat, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
signed int result;
|
||||||
|
|
||||||
|
va_start(ap, pFormat);
|
||||||
|
result = vprintf(pFormat, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* stub functions required by card_emu.c
|
* stub functions required by card_emu.c
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
@@ -50,6 +64,9 @@ void card_emu_uart_enable(uint8_t uart_chan, uint8_t rxtx)
|
|||||||
case ENABLE_TX:
|
case ENABLE_TX:
|
||||||
rts = "TX";
|
rts = "TX";
|
||||||
break;
|
break;
|
||||||
|
case ENABLE_TX_TIMER_ONLY:
|
||||||
|
rts = "TX-TIMER-ONLY";
|
||||||
|
break;
|
||||||
case ENABLE_RX:
|
case ENABLE_RX:
|
||||||
rts = "RX";
|
rts = "RX";
|
||||||
break;
|
break;
|
||||||
@@ -66,29 +83,14 @@ void card_emu_uart_interrupt(uint8_t uart_chan)
|
|||||||
printf("uart_interrupt(uart_chan=%u)\n", uart_chan);
|
printf("uart_interrupt(uart_chan=%u)\n", uart_chan);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tc_etu_set_wtime(uint8_t tc_chan, uint16_t wtime)
|
void card_emu_uart_update_wt(uint8_t uart_chan, uint32_t wt)
|
||||||
{
|
{
|
||||||
printf("tc_etu_set_wtime(tc_chan=%u, wtime=%u)\n", tc_chan, wtime);
|
printf("%s(uart_chan=%u, wtime=%u)\n", __func__, uart_chan, wt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tc_etu_set_etu(uint8_t tc_chan, uint16_t etu)
|
void card_emu_uart_reset_wt(uint8_t uart_chan)
|
||||||
{
|
{
|
||||||
printf("tc_etu_set_etu(tc_chan=%u, etu=%u)\n", tc_chan, etu);
|
printf("%s(uart_chan=%u\n", __func__, uart_chan);
|
||||||
}
|
|
||||||
|
|
||||||
void tc_etu_init(uint8_t chan_nr, void *handle)
|
|
||||||
{
|
|
||||||
printf("tc_etu_init(tc_chan=%u)\n", chan_nr);
|
|
||||||
}
|
|
||||||
|
|
||||||
void tc_etu_enable(uint8_t chan_nr)
|
|
||||||
{
|
|
||||||
printf("tc_etu_enable(tc_chan=%u)\n", chan_nr);
|
|
||||||
}
|
|
||||||
|
|
||||||
void tc_etu_disable(uint8_t chan_nr)
|
|
||||||
{
|
|
||||||
printf("tc_etu_disable(tc_chan=%u)\n", chan_nr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -136,7 +138,7 @@ static void io_start_card(struct card_handle *ch)
|
|||||||
/* release from reset and verify th ATR */
|
/* release from reset and verify th ATR */
|
||||||
card_emu_io_statechg(ch, CARD_IO_RST, 0);
|
card_emu_io_statechg(ch, CARD_IO_RST, 0);
|
||||||
/* simulate waiting time before ATR expired */
|
/* simulate waiting time before ATR expired */
|
||||||
tc_etu_wtime_expired(ch);
|
card_emu_wtime_expired(ch);
|
||||||
verify_atr(ch);
|
verify_atr(ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -408,7 +410,7 @@ int main(int argc, char **argv)
|
|||||||
struct card_handle *ch;
|
struct card_handle *ch;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
ch = card_emu_init(0, 23, 42, PHONE_DATAIN, PHONE_INT, false, true, false);
|
ch = card_emu_init(0, 42, PHONE_DATAIN, PHONE_INT, false, true, false);
|
||||||
assert(ch);
|
assert(ch);
|
||||||
|
|
||||||
usb_buf_init();
|
usb_buf_init();
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* simtrace2-cardem-pcsc - main program for the host PC to provide a remote SIM
|
/* simtrace2-cardem-pcsc - main program for the host PC to provide a remote SIM
|
||||||
* using the SIMtrace 2 firmware in card emulation mode
|
* using the SIMtrace 2 firmware in card emulation mode
|
||||||
*
|
*
|
||||||
* (C) 2016-2020 by Harald Welte <hwelte@hmw-consulting.de>
|
* (C) 2016-2021 by Harald Welte <hwelte@hmw-consulting.de>
|
||||||
* (C) 2018, sysmocom -s.f.m.c. GmbH, Author: Kevin Redon <kredon@sysmocom.de>
|
* (C) 2018, sysmocom -s.f.m.c. GmbH, Author: Kevin Redon <kredon@sysmocom.de>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
@@ -51,29 +51,8 @@
|
|||||||
#include <osmocom/sim/class_tables.h>
|
#include <osmocom/sim/class_tables.h>
|
||||||
#include <osmocom/sim/sim.h>
|
#include <osmocom/sim/sim.h>
|
||||||
|
|
||||||
#define ATR_MAX_LEN 33
|
|
||||||
|
|
||||||
#define LOGCI(ci, lvl, fmt, args ...) printf(fmt, ## args)
|
#define LOGCI(ci, lvl, fmt, args ...) printf(fmt, ## args)
|
||||||
|
|
||||||
/* reasonable ATR offering all protocols and voltages
|
|
||||||
* smartphones might not care, but other readers do
|
|
||||||
*
|
|
||||||
* TS = 0x3B Direct Convention
|
|
||||||
* T0 = 0x80 Y(1): b1000, K: 0 (historical bytes)
|
|
||||||
* TD(1) = 0x80 Y(i+1) = b1000, Protocol T=0
|
|
||||||
* ----
|
|
||||||
* TD(2) = 0x81 Y(i+1) = b1000, Protocol T=1
|
|
||||||
* ----
|
|
||||||
* TD(3) = 0x1F Y(i+1) = b0001, Protocol T=15
|
|
||||||
* ----
|
|
||||||
* TA(4) = 0xC7 Clock stop: no preference - Class accepted by the card: (3G) A 5V B 3V C 1.8V
|
|
||||||
* ----
|
|
||||||
* Historical bytes
|
|
||||||
* TCK = 0x59 correct checksum
|
|
||||||
*/
|
|
||||||
#define DEFAULT_ATR_STR "3B8080811FC759"
|
|
||||||
|
|
||||||
|
|
||||||
static void atr_update_csum(uint8_t *atr, unsigned int atr_len)
|
static void atr_update_csum(uint8_t *atr, unsigned int atr_len)
|
||||||
{
|
{
|
||||||
uint8_t csum = 0;
|
uint8_t csum = 0;
|
||||||
@@ -415,9 +394,9 @@ int main(int argc, char **argv)
|
|||||||
int rc;
|
int rc;
|
||||||
int c, ret = 1;
|
int c, ret = 1;
|
||||||
int skip_atr = 0;
|
int skip_atr = 0;
|
||||||
char *atr = DEFAULT_ATR_STR;
|
char *atr = NULL;
|
||||||
uint8_t real_atr[ATR_MAX_LEN];
|
uint8_t override_atr[OSIM_MAX_ATR_LEN];
|
||||||
int atr_len;
|
int override_atr_len = 0;
|
||||||
int keep_running = 0;
|
int keep_running = 0;
|
||||||
int if_num = 0, vendor_id = -1, product_id = -1;
|
int if_num = 0, vendor_id = -1, product_id = -1;
|
||||||
int config_id = -1, altsetting = 0, addr = -1;
|
int config_id = -1, altsetting = 0, addr = -1;
|
||||||
@@ -484,11 +463,13 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
atr_len = osmo_hexparse(atr,real_atr,ATR_MAX_LEN);
|
if (atr) {
|
||||||
if (atr_len < 2) {
|
override_atr_len = osmo_hexparse(atr, override_atr, sizeof(override_atr));
|
||||||
fprintf(stderr, "Invalid ATR - please omit a leading 0x and only use valid hex "
|
if (override_atr_len < 2) {
|
||||||
"digits and whitespace. ATRs need to be between 2 and 33 bytes long.\n");
|
fprintf(stderr, "Invalid ATR - please omit a leading 0x and only use valid hex "
|
||||||
goto do_exit;
|
"digits and whitespace. ATRs need to be between 2 and 33 bytes long.\n");
|
||||||
|
goto do_exit;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vendor_id < 0 || product_id < 0) {
|
if (vendor_id < 0 || product_id < 0) {
|
||||||
@@ -545,20 +526,20 @@ int main(int argc, char **argv)
|
|||||||
transp->usb_devh = osmo_libusb_open_claim_interface(NULL, NULL, ifm);
|
transp->usb_devh = osmo_libusb_open_claim_interface(NULL, NULL, ifm);
|
||||||
if (!transp->usb_devh) {
|
if (!transp->usb_devh) {
|
||||||
fprintf(stderr, "can't open USB device\n");
|
fprintf(stderr, "can't open USB device\n");
|
||||||
goto close_exit;
|
goto close;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = libusb_claim_interface(transp->usb_devh, if_num);
|
rc = libusb_claim_interface(transp->usb_devh, if_num);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
fprintf(stderr, "can't claim interface %d; rc=%d\n", if_num, rc);
|
fprintf(stderr, "can't claim interface %d; rc=%d\n", if_num, rc);
|
||||||
goto close_exit;
|
goto close;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = osmo_libusb_get_ep_addrs(transp->usb_devh, if_num, &transp->usb_ep.out,
|
rc = osmo_libusb_get_ep_addrs(transp->usb_devh, if_num, &transp->usb_ep.out,
|
||||||
&transp->usb_ep.in, &transp->usb_ep.irq_in);
|
&transp->usb_ep.in, &transp->usb_ep.irq_in);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
fprintf(stderr, "can't obtain EP addrs; rc=%d\n", rc);
|
fprintf(stderr, "can't obtain EP addrs; rc=%d\n", rc);
|
||||||
goto close_exit;
|
goto close;
|
||||||
}
|
}
|
||||||
|
|
||||||
allocate_and_submit_irq(ci);
|
allocate_and_submit_irq(ci);
|
||||||
@@ -576,8 +557,14 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
if (!skip_atr) {
|
if (!skip_atr) {
|
||||||
/* set the ATR */
|
/* set the ATR */
|
||||||
atr_update_csum(real_atr, atr_len);
|
if (override_atr_len) {
|
||||||
osmo_st2_cardem_request_set_atr(ci, real_atr, atr_len);
|
/* user has specified an override-ATR */
|
||||||
|
atr_update_csum(override_atr, override_atr_len);
|
||||||
|
osmo_st2_cardem_request_set_atr(ci, override_atr, override_atr_len);
|
||||||
|
} else {
|
||||||
|
/* use the real ATR of the card */
|
||||||
|
osmo_st2_cardem_request_set_atr(ci, card->atr, card->atr_len);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* select remote (forwarded) SIM */
|
/* select remote (forwarded) SIM */
|
||||||
@@ -587,13 +574,20 @@ int main(int argc, char **argv)
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
libusb_release_interface(transp->usb_devh, 0);
|
libusb_release_interface(transp->usb_devh, 0);
|
||||||
close_exit:
|
|
||||||
if (transp->usb_devh)
|
close:
|
||||||
|
if (transp->usb_devh) {
|
||||||
libusb_close(transp->usb_devh);
|
libusb_close(transp->usb_devh);
|
||||||
|
transp->usb_devh = NULL;
|
||||||
|
}
|
||||||
if (keep_running)
|
if (keep_running)
|
||||||
sleep(1);
|
sleep(1);
|
||||||
} while (keep_running);
|
} while (keep_running);
|
||||||
|
|
||||||
|
close_exit:
|
||||||
|
if (transp->usb_devh)
|
||||||
|
libusb_close(transp->usb_devh);
|
||||||
|
|
||||||
libusb_exit(NULL);
|
libusb_exit(NULL);
|
||||||
do_exit:
|
do_exit:
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
Reference in New Issue
Block a user