FreeCalypso > hg > freecalypso-tools
annotate doc/Deep-sleep-support @ 656:9f5a3e9e6294
fc-xram: implemented CRC-32 verification
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 03 Mar 2020 00:08:27 +0000 |
parents | 19cabe7c8e08 |
children |
rev | line source |
---|---|
427
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 All standard phones and modems based on the Calypso chipset from TI implement |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 several different power saving modes, called sleep modes, and one of these sleep |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 modes has a profound impact on the operation of the externally visible UART |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 interfaces provided by the device. The power saving mode in question is called |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 deep sleep, and the phone or modem can only enter this deep sleep mode when it |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 is in the so-called idle state, meaning that it is camped on a cell and is ready |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 to receive incoming calls, messages or GPRS packets - deep sleep cannot be |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 entered while in an active call or in the middle of packet data transfer. When |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 a Calypso GSM device is idle with deep sleep enabled, it will only wake up at |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 preprogrammed intervals to listen on the paging channel, and will stay in deep |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 sleep in between these paging windows. Calypso GSM devices also enter deep |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 sleep when they are completely idle with no radio network connection. |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 When a Calypso GSM device enters deep sleep, the main VCXO or VCTCXO that runs |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 at 13 or 26 MHz and provides all other clocks in normal operation is completely |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 stopped (powered off), and the only clock that remains running is the 32.768 kHz |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 watch crystal oscillator. The preprogrammed wakeup timing (waking up to listen |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 on the paging channel at the right time) is driven by this 32.768 kHz clock, but |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 the Calypso can also be woken up ahead of the programmed time by an external |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 interrupt such as a button press on the phone keypad. |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 This deep sleep mode provides a very important power saving measure (the |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 extremely low current draw that is achieved during deep sleep is not possible |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 without stopping the fast clock), but it presents a real challenge for the |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 external UART interfaces. Consider what happens when an external host sends |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 some characters to one of Calypso's UARTs (either the AT command interface or |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 RVTMUX) while the GSM device is in deep sleep. In normal operation a UART |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 requires a clock of 16x the baud rate (some vendors' UARTs can make do with |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 only 8x the baud rate) in order to receive asynchronous incoming characters, |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 and in the Calypso these UART clocks come from the 13 MHz master clock - but |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 that master clock is stopped during deep sleep! |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 Calypso UARTs have some special asynchronous (non-clock-dependent) logic that |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 causes a wakeup signal to be generated if some incoming traffic is detected at |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 a UART while in deep sleep, but the first character that triggers this wakeup |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 will be lost: the asynchronous logic can detect that there is "something |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 happening" on the UART RxD line, but it cannot catch the actual byte content |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 without a clock: the *only* clock available during deep sleep is 32.768 kHz, |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 and even at 9600 baud one would need a clock several times faster than this |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 rate in order to receive and register an incoming byte. Furthermore, wakeup |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 from deep sleep takes a non-trivial length of time, thus if someone tries to |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 send lots of data to a Calypso UART while in deep sleep, quite a bit more than |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 just the first character will be lost: I did some experiments to characterize |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 the delay which needs to be inserted between the first "sacrificial" wakeup |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 character and the subsequent character which is expected to be received |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 correctly, and 40 ms wasn't enough, whereas 60 ms did the trick. |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 So how can one have reliable communication with a Calypso GSM device over a |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 UART if the GSM device goes into and out of deep sleep at times which are |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 unpredictable to the external host and if sending characters to the Calypso |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 during deep sleep causes those characters to be lost? The solution involves a |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 special protocol: |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 1) On the Calypso side, TI's reference firmware implements a UART activity |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 timer: every time some characters are received at a UART, the timer is reset to |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 10 s, and until that timer expires, the GSM device is not allowed to go into |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 deep sleep. |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 2) Host systems sending command traffic to Calypso modems need to keep track of |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 how much time has elapsed since the last time they sent something to the modem, |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 and if enough time has elapsed that the modem is now allowed to enter deep |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 sleep, the host needs to perform a precautionary wakeup transmission before the |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 actual desired one. |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 What is a precautionary wakeup transmission? The idea is to send something to |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 the modem can be either accepted or lost by the latter: if the modem happens to |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 be awake at the time, the transmission will be received normally, and if the |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 modem is in deep sleep, the transmission will be lost but will cause the modem |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 to wake up and start the 10 s UART activity timer. Our FC host tools currently |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 use the following wakeup transmissions: |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 * On the AT command channel we send A-delay-T-delay-CR, i.e., AT and a carriage |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 return (3 characters total) with delays inserted in between; each of the two |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 delays is currently set to 30 ms based on empirical testing. We expect the |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 response to be either AT<newline>OK<newline> (echo of command followed by OK |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 response) if the modem was awake or just <newline>OK<newline> if we woke it up: |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 if we are waking the modem from deep sleep, our initial characters will trigger |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 the wakeup sequence but will themselves be lost, and the modem is expected to |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 be awake with UARTs working by the time the CR comes in; we make use of a quirk |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 of TI's AT command interpreter implementation in that sending a CR by itself |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 produces a <newline>OK<newline> response. |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 * On the RVTMUX interface we send a string of 64 zero bytes followed by 100 ms |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 of delay; it is certainly overkill, but this approach was implemented back in |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 2013 (near the very beginning of FreeCalypso) and has worked without any |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 problems ever since, hence we are not changing it. |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 In the case of RVTMUX, our serial communication engine through which everything |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 funnels is rvinterf. Rvinterf will do the "wakeup shot" the first time it sends |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 anything to the target, and for all subsequent transmissions it will consider |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 the time since the last transmission: if it is greater than a set threshold |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 (7 s by default), the wakeup shot is sent again. Thus there will be no |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 extraneous wakeup shots and associated delays during reasonably continuous |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 back to back communication, but the wakeup shot delay will be incurred if |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 rvinterf is killed and restarted or if a non-trivial pause occurs in the |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 communication flow. |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 In the case of AT commands, our fcup-* tools described in the User-phone-tools |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 article go through a back-end program called fcup-atinterf which does the serial |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 talking, and the latter helper program is responsible for the wakeup logic. |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 However, fcup-atinterf is not a daemon like rvinterf, it is run anew for every |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 fcup-* user command, hence every fcup-* command currently involves the wakeup |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 delay step. It is certainly inefficient, but the underlying philosophy values |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 reliability over efficiency. |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 The one remaining use case which has not been addressed at all yet is the GSM |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 07.10 MUX; the current plan is to investigate it after the fc-host-tools-r9 |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 release and after we get FCDEV3B V2 boards which will hopefully be free from |
19cabe7c8e08
doc/Deep-sleep-support article written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 the sleep mode bug that afflicts FCDEV3B V1. |