annotate doc/TCH-bit-access @ 106:18b3183611fb

target-utils/pirexplore: vibe command alias for buz
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 01 Nov 2016 01:00:43 +0000
parents 2748f257312b
children 3de3b34189be
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 It has been discovered that the DSP ROM in the Calypso GSM baseband processor
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 implements one nifty feature which is not used at all in standard phone or modem
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 operation, but which can be used for all kinds of interesting hacks: the traffic
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 channel (TCH) bits coming out of the GSM 05.03 channel decoder in the downlink
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 direction (to be fed to one of several speech decoders) can be read out of the
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 DSP's API RAM in real time, and in the uplink direction the user can feed her
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 own bits to the input of the GSM 05.03 channel encoder, effectively suppressing
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 the output of the internal vocoder.
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 The DSP mechanism in question is known to work in TCH/FS and TCH/EFS channel
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 modes, corresponding to the FR and EFR codecs; it is not currently known if it
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 can also be used in TCH/HS, data traffic or AMR modes. I am aware though of an
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 anecdotal report that someone tried to make this feature work with AMR, but was
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 unsuccessful - hence we should be prepared for the possibility that the hack
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 is not possible with AMR.
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 In order to make use of this TCH bit access feature, one needs 3 things:
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 1) Firmware on the Calypso (the ARM part) that reads downlink bits from the DSP
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 and writes uplink bits into it while doing everything else that a GSM fw must
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 do in order to operate the MS;
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 2) Some protocol for passing these TCH bits into and out of the Calypso device;
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 3) A source for TCH UL bits and a sink for TCH DL bits on the external host.
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 In the case of FreeCalypso, we have defined our own protocol for passing TCH
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 bits into and out of Calypso GSM devices running one of our firmwares in the
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 form of an extension to TI's RVTMUX interface, i.e., we have defined a new
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 RVTMUX channel for this TCH interface and defined the packet types and formats
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 to be sent over the wire. On the Calypso side this interface is implemented in
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 FreeCalypso GSM firmwares (currently only in Citrine, but we can also make a
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 special version of TCS211 with this feature added if the need arises), and on
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 the host tools side there is support in rvinterf and fc-shell.
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 The TCH bit access mechanism in FreeCalypso has been designed with an objective
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 of presenting to the user exactly what TI's DSP presents to us, i.e., standing
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 out of the way as much as possible. TI's DSP presents TCH downlink bits and
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 accepts TCH uplink bits in the form of an array of 16-bit words; the bit order
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 within these words corresponds to the GSM 05.03 channel encoder bit order (with
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 a couple of TI-specific quirks documented below) and NOT that of the GSM 06.10
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 or EFR codecs. On the RVTMUX serial interface between the Calypso device and
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 the external host we transfer each TCH frame as a block of 33 bytes; our Calypso
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 firmwares translate between these bytes and the DSP's 16-bit words, but do not
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 reorder or change the bits in any way.
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 On the host tools side our fc-shell utility provides user commands to save TCH
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 DL bits into a file and to play TCH UL bits from a file; in the present version
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 these files are written and read in an ASCII-based hex format. In these ASCII
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 files each TCH frame is represented as a string of 66 hexadecimal digits, and
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 these hex digits correspond directly to the 33 bytes being read out of or
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 written into DSP API words. Therefore, in order to generate and/or interpret
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 these hexadecimal strings correctly, you (the user) need to understand the bit
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 order and mapping used by TI's implementation of the GSM 05.03 channel encoder.
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 Recall from the GSM specs that the 260 bits which comprise one speech frame are
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 not all treated equally, instead they are divided into 182 class 1 bits which
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 are protected by a convolutional encoder and 78 class 2 bits which are
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 transmitted without any forward error correction. Furthermore, the first 50 of
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 the class 1 bits are also protected by a CRC. The order in which the bits
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 appear on TI's DSP interface corresponds to this division, known as the order of
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 subjective importance.
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 Now let's look at the actual bit order and mapping which you need to understand
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 in order to make sense of the hex strings in tch record and tch play files.
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 The bit numbering is from the most significant bit to the least significant bit,
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 i.e., in our string of 66 hex digits the most significant bit of the leftmost
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 digit is bit 0 and the least significant bit of the rightmost digit is bit 263.
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 TI's DSP assigns these bits as follows:
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 * Bits 0 through 181 correspond to the 182 protected (class 1) bits in the
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 standard GSM 05.03 order;
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 * Bits 182 through 185 are unused - put zeros there if you are generating them
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 yourself;
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 * Bits 186 through 263 correspond to the 78 unprotected (class 2) bits in the
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 standard GSM 05.03 order.
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 Uplink testing
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 ==============
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83 The uplink sending mechanism can be exercised as follows:
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 1. Record a speech sample in the GSM 06.10 codec format using any Unix/Linux
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 audio tool that can write the de facto standard libgsm format. For example,
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 using SoX:
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89 rec -c1 recording.gsm
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91 SoX will write the recording in the GSM 06.10 libgsm format based on the
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92 .gsm suffix at the end of the recording file name; the -c1 option is needed
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93 to disable stereo, otherwise the recording will be slowed down 2x.
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95 2. Convert it from libgsm standard format into our ad hoc hex strings for
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96 playing into the TCH uplink:
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98 fc-fr2tch recording.gsm recording.tch-ul
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100 3. In fc-shell, when you are in an established voice call, issue this command:
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
102 tch play recording.tch-ul
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
103
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
104 You should now hear the speech sample you recorded in step 1 above on the other
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
105 end of the GSM call. Please note, though, that for this example to work, the
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
106 call must be connected in the FR codec mode, not EFR. If you try it on an EFR
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
107 call, the vocoder on the other end of the call will try to interpret your FR
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
108 codec bits per EFR, resulting in garbage. In order to make this procedure work
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
109 properly with EFR, you would need to generate a speech sample in EFR format and
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
110 then put it in the correct hex string form with the correct bit order for
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
111 feeding to TI's GSM 05.03 channel encoder implementation, and at the present
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
112 moment the tools to do this feat are lacking.
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
113
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
114 The fc-fr2tch step above is new with the current version of FreeCalypso host
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
115 tools. My original implementation of the tch play command in fc-shell read
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
116 libgsm GSM 06.10 speech files directly, but I changed it to read hex strings
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
117 which correspond literally to what goes into TI's implementation of the 05.03
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
118 channel encoder to make it more general:
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
119
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
120 1) to support playing EFR speech bits into TCH/EFS channels;
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
121 2) to support people who may want to pass totally non-speech data over traffic
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
122 channels in TFO mode - see below.
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
123
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
124 Downlink testing
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
125 ================
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
126
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
127 When you are in an established voice call in fc-shell, you can record the
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
128 downlink TCH bits as follows:
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
129
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
130 tch record <name of file to put the recording into>
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
131
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
132 If you would like to record an entire call from the beginning, issue the
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
133 tch record command as above before the ATD or ATA command that dials or answers
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
134 the call. Either way, whether you are recording a call from the beginning or
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
135 from the middle, you need to eventually stop your recording with this command:
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
136
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
137 tch record stop
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
138
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
139 You can issue this stop command before or after the call is terminated, but
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
140 until you issue this tch record stop command, the output file is not closed and
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
141 thus may not be written to the file system.
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
142
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
143 The recording is written in an ASCII format that is similar but not identical
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
144 to what the tch play command takes as its input. Here is an example of what
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
145 you might get from tch record:
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
146
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
147 C214 281D 0063 81C008000008200046000000000000000000000000000007056608060B0A010B09
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
148 C204 0540 003A 9391480D3051F4BD81DF5EB35069BEBC4AEDF756351C4C19689BB1CA4EA5D4F5F5
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
149 C204 05A2 0047 65B80F9E690F7C8CE4ED80DEF69DA6436518AB99ABCE5815E6B562C5CE4EAC5DC5
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
150 C204 04CA 0044 A4483744B04371ED0334ECB350AF28C639B7F095519EF0242D299B6405124F77A5
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
151 C214 2544 0066 83800400000C1000E80000000000000000000000000000300674A07070F080D0B2
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
152 C200 4E8A 0000 07071DF0F83B9521EE61CFF095AA8C0E560300F6A5573C31F3E00601ED4AAE7E2F
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
153 C200 4C94 0000 077385ADE20450B2E410961D6C5B0A173ACF9E2D38D77C28CED8495D88AA4DE72E
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
154 C200 4ABC 0000 077F0CF86004132DA5C0A6D5A4B0BD4B28159A07D8F4282DC6AAAB27503BC02701
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
155
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
156 The example above is quoted from an actual recording made from a call to WWV at
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
157 +1-303-499-7111, a time of day service. This example shows 5 garbled frames
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
158 followed by 3 good ones.
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
159
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
160 In each line the first 3 space-separated 16-bit words are status words from the
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
161 DSP, and the rest is a hex string of 66 digits giving the 260-bit frame with 4
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
162 extra dummy bits at the boundary between the protected and unprotected portions.
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
163
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
164 Now here comes the unpleasant part: radio systems are inherently error-prone,
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
165 hence if you are naively expecting every received downlink frame to be a valid
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
166 speech frame that matches exactly what the other end transmitted, you will be
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
167 disappointed. The downlink frame stream will always consist of both valid and
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
168 invalid frames, and in the standard processing chain inside TI's DSP the speech
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
169 decoder block that receives these frames from the channel decoder will look at
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
170 the status words written by the latter in order to decide what to do with each
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
171 frame. But unfortunately I don't know the details, as the DSP is a mostly
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
172 undocumented black box.
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
173
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
174 Our FreeCalypso firmwares forward the downlink frame status words from the DSP
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
175 to the external host and my current implementation of the tch record command
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
176 writes them into the file because it is valuable information which should not
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
177 be discarded, but unfortunately I don't know their meaning. The first status
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
178 word consists of bit flags, the last one seems to be some kind of error count
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
179 (what kind of errors? I don't know), and the middle one is totally unknown.
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
180
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
181 There is also an fc-tch2fr utility that does sort of an inverse of fc-fr2tch,
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
182 except that fc-tch2fr expects files written by tch record which contain the
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
183 status words at the beginning - the files written by fc-fr2tch and read by
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
184 tch play don't have these status words; they just have 66 hex digits per line
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
185 giving the bits to be fed to the GSM 05.03 block in the DSP. The fc-tch2fr
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
186 utility works by disregarding the status words; the result will be a .gsm file
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
187 which you can play with SoX etc, but it will produce horrible sounds wherever
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
188 some garbled frames were received on the call downlink.
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
189
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
190 Passing non-speech data over TCH
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
191 ================================
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
192
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
193 If you are incredibly lucky and you happen to live in a part of the world where
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
194 the local GSM network implements TFO (tandem-free operation, see GSM 02.53),
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
195 i.e., if your GSM network transparently passes codec frames from one end of the
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
196 call to the other without transcoding back and forth in the middle, you might
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
197 be able to send arbitrary non-speech data bits over this TCH connection. If
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
198 you are going to attempt such a feat, you are mostly on your own as the GSM
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
199 network in my part of the world does not support TFO, but here are some general
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
200 ideas:
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
201
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
202 * Heed the difference between the 182 protected bits and the 78 unprotected
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
203 bits of each 260-bit frame. The bits in the first class are less likely to
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
204 be corrupted by radio errors. Also the first 50 out of these class 1 bits
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
205 are protected by a CRC, so if they get corrupted, there will be a flag bit
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
206 somewhere in the DSP status words - but I don't know which bit it is...
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
207
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
208 * Given the lack of detailed information about the exact meaning of the DSP
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
209 status words, implement some error checking of your own, e.g., an in-band
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
210 CRC within your frame payload so you can check on the receiving end if you
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
211 got an uncorrupted frame from your data source or not.
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
212
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
213 * Expect to lose some frames - even if your radio environment is pristine and
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
214 error-free, some frames will still be lost because their timeslots had to be
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
215 stolen by FACCH on either end of the call. You will need to implement
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
216 acknowledgements, retransmissions and retries - the usual stuff.
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
217
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
218 EFR differences
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
219 ===============
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
220
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
221 TCH/FS and TCH/EFS channel modes corresponding to the FR and EFR codecs,
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
222 respectively, share the same channel encoder that takes 260-bit frames as input.
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
223 An EFR speech frame is only 244 bits, but as the GSM 05.03 spec explains, each
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
224 EFR frame gets expanded to 260 bits by adding some CRC and repetition bits.
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
225 One would thus expect that the behaviour of the channel encoder block should be
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
226 strictly identical between TCH/FS and TCH/EFS channel modes, but it appears that
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
227 TI's implementation exhibits one difference in behaviour between the two modes.
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
228
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
229 It appears that TI's implementation of the GSM 05.03 channel encoder computes
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
230 the EFR-specific CRC bits internally, such that bits [65,72] of each uplink
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
231 frame fed to the DSP in the TCH/EFS mode need to be 0 and will be replaced by
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
232 the DSP with CRC bits computed per the standard. It also appears that their
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
233 implementation of the channel decoder verifies this CRC, sets a status bit
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
234 indicating whether the check succeeded or failed, and then zeroes these bits
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
235 out, i.e., the original bits in these CRC bit positions are lost. No problem
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
236 if what you are passing over TCH/EFS is indeed EFR speech frames, but it will
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
237 be a problem if you are passing non-speech data over your TCH and put something
2748f257312b doc/TCH-bit-access: new write-up
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
238 else in those bits which the spec allocates to CRC.