# HG changeset patch # User Mychaela Falconia # Date 1606449191 0 # Node ID b8cb116a7dc70f29986bbeb610b2ea9a72aed336 # Parent e4281d3f76f2d8fee5b824319d0d8b82b7bc0c92 arfcn2ti utility added to miscutil diff -r e4281d3f76f2 -r b8cb116a7dc7 .hgignore --- a/.hgignore Fri Nov 06 00:51:22 2020 +0000 +++ b/.hgignore Fri Nov 27 03:53:11 2020 +0000 @@ -30,6 +30,7 @@ ^loadtools/fc-loadtool$ ^loadtools/fc-xram$ +^miscutil/arfcn2ti$ ^miscutil/fc-fr2tch$ ^miscutil/fc-gsm2vm$ ^miscutil/fc-pulse-dtr$ diff -r e4281d3f76f2 -r b8cb116a7dc7 miscutil/Makefile --- a/miscutil/Makefile Fri Nov 06 00:51:22 2020 +0000 +++ b/miscutil/Makefile Fri Nov 27 03:53:11 2020 +0000 @@ -1,7 +1,8 @@ CC= gcc CFLAGS= -O2 -PROGS= fc-fr2tch fc-gsm2vm fc-pulse-dtr fc-pulse-rts fc-rgbconv fc-serterm \ - fc-tch2fr fc-vm2hex imei-luhn make-imeisv mokosrec2bin srec-regions +PROGS= arfcn2ti fc-fr2tch fc-gsm2vm fc-pulse-dtr fc-pulse-rts fc-rgbconv \ + fc-serterm fc-tch2fr fc-vm2hex imei-luhn make-imeisv mokosrec2bin \ + srec-regions SCRIPTS=c139explore pirexplore INSTALL_PREFIX= /opt/freecalypso @@ -15,6 +16,9 @@ TCH2FR_OBJS= fc-tch2fr.o gsm0610.o SERTERM_OBJS= fc-serterm.o ttypassthru.o ../libserial/libserial.a +arfcn2ti: arfcn2ti.c + ${CC} ${CFLAGS} -o $@ $@.c + fc-fr2tch: ${FR2TCH_OBJS} ${CC} ${CFLAGS} -o $@ ${FR2TCH_OBJS} diff -r e4281d3f76f2 -r b8cb116a7dc7 miscutil/arfcn2ti.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/miscutil/arfcn2ti.c Fri Nov 27 03:53:11 2020 +0000 @@ -0,0 +1,67 @@ +/* + * TI's TCS211 L1 does not use standard ARFCNs internally, instead it uses + * its own non-standard radio_freq numbers in their place. Other firmware + * components and all external interfaces do use standard ARFCNs, thus + * conversion functions are invoked at appropriate points in the firmware. + * However, L1-internal radio_freq numbers are emitted in L1 debug traces, + * thus anyone looking at these traces needs to be able to convert between + * standard ARFCNs and L1-internal radio_freq. + * + * The present utility converts a standard ARFCN into TI L1 radio_freq. + */ + +#include +#include +#include +#include + +main(argc, argv) + char **argv; +{ + int arfcn; + + if (argc != 3) { +usage: fprintf(stderr, "usage: %s {eu|us} arfcn\n", argv[0]); + exit(1); + } + arfcn = atoi(argv[2]); + if (!strcmp(argv[1], "eu")) + arfcn2ti_eu(arfcn); + else if (!strcmp(argv[1], "us")) + arfcn2ti_us(arfcn); + else + goto usage; + exit(0); +} + +arfcn2ti_eu(arfcn) +{ + if (arfcn == 0) + arfcn = 174; + else if ((arfcn >= 975) && (arfcn <= 1023)) + arfcn -= 850; + else if ((arfcn >= 512) && (arfcn <= 885)) + arfcn -= 337; + else if ((arfcn >= 1) && (arfcn <= 124)) + ; + else { + fprintf(stderr, + "error: specified ARFCN is invalid for dual-EU\n"); + exit(1); + } + printf("%d\n", arfcn); +} + +arfcn2ti_us(arfcn) +{ + if ((arfcn >= 128) && (arfcn <= 251)) + arfcn -= 127; + else if ((arfcn >= 512) && (arfcn <= 810)) + arfcn -= 387; + else { + fprintf(stderr, + "error: specified ARFCN is invalid for dual-US\n"); + exit(1); + } + printf("%d\n", arfcn); +}