All standard phones and modems based on the Calypso chipset from TI implementseveral different power saving modes, called sleep modes, and one of these sleepmodes has a profound impact on the operation of the externally visible UARTinterfaces provided by the device. The power saving mode in question is calleddeep sleep, and the phone or modem can only enter this deep sleep mode when itis in the so-called idle state, meaning that it is camped on a cell and is readyto receive incoming calls, messages or GPRS packets - deep sleep cannot beentered while in an active call or in the middle of packet data transfer. Whena Calypso GSM device is idle with deep sleep enabled, it will only wake up atpreprogrammed intervals to listen on the paging channel, and will stay in deepsleep in between these paging windows. Calypso GSM devices also enter deepsleep when they are completely idle with no radio network connection.When a Calypso GSM device enters deep sleep, the main VCXO or VCTCXO that runsat 13 or 26 MHz and provides all other clocks in normal operation is completelystopped (powered off), and the only clock that remains running is the 32.768 kHzwatch crystal oscillator. The preprogrammed wakeup timing (waking up to listenon the paging channel at the right time) is driven by this 32.768 kHz clock, butthe Calypso can also be woken up ahead of the programmed time by an externalinterrupt such as a button press on the phone keypad.This deep sleep mode provides a very important power saving measure (theextremely low current draw that is achieved during deep sleep is not possiblewithout stopping the fast clock), but it presents a real challenge for theexternal UART interfaces. Consider what happens when an external host sendssome characters to one of Calypso's UARTs (either the AT command interface orRVTMUX) while the GSM device is in deep sleep. In normal operation a UARTrequires a clock of 16x the baud rate (some vendors' UARTs can make do withonly 8x the baud rate) in order to receive asynchronous incoming characters,and in the Calypso these UART clocks come from the 13 MHz master clock - butthat master clock is stopped during deep sleep!Calypso UARTs have some special asynchronous (non-clock-dependent) logic thatcauses a wakeup signal to be generated if some incoming traffic is detected ata UART while in deep sleep, but the first character that triggers this wakeupwill be lost: the asynchronous logic can detect that there is "somethinghappening" on the UART RxD line, but it cannot catch the actual byte contentwithout a clock: the *only* clock available during deep sleep is 32.768 kHz,and even at 9600 baud one would need a clock several times faster than thisrate in order to receive and register an incoming byte. Furthermore, wakeupfrom deep sleep takes a non-trivial length of time, thus if someone tries tosend lots of data to a Calypso UART while in deep sleep, quite a bit more thanjust the first character will be lost: I did some experiments to characterizethe delay which needs to be inserted between the first "sacrificial" wakeupcharacter and the subsequent character which is expected to be receivedcorrectly, and 40 ms wasn't enough, whereas 60 ms did the trick.So how can one have reliable communication with a Calypso GSM device over aUART if the GSM device goes into and out of deep sleep at times which areunpredictable to the external host and if sending characters to the Calypsoduring deep sleep causes those characters to be lost? The solution involves aspecial protocol:1) On the Calypso side, TI's reference firmware implements a UART activitytimer: every time some characters are received at a UART, the timer is reset to10 s, and until that timer expires, the GSM device is not allowed to go intodeep sleep.2) Host systems sending command traffic to Calypso modems need to keep track ofhow much time has elapsed since the last time they sent something to the modem,and if enough time has elapsed that the modem is now allowed to enter deepsleep, the host needs to perform a precautionary wakeup transmission before theactual desired one.What is a precautionary wakeup transmission? The idea is to send something tothe modem can be either accepted or lost by the latter: if the modem happens tobe awake at the time, the transmission will be received normally, and if themodem is in deep sleep, the transmission will be lost but will cause the modemto wake up and start the 10 s UART activity timer. Our FC host tools currentlyuse the following wakeup transmissions:* On the AT command channel we send A-delay-T-delay-CR, i.e., AT and a carriagereturn (3 characters total) with delays inserted in between; each of the twodelays is currently set to 30 ms based on empirical testing. We expect theresponse to be either AT<newline>OK<newline> (echo of command followed by OKresponse) if the modem was awake or just <newline>OK<newline> if we woke it up:if we are waking the modem from deep sleep, our initial characters will triggerthe wakeup sequence but will themselves be lost, and the modem is expected tobe awake with UARTs working by the time the CR comes in; we make use of a quirkof TI's AT command interpreter implementation in that sending a CR by itselfproduces a <newline>OK<newline> response.* On the RVTMUX interface we send a string of 64 zero bytes followed by 100 msof delay; it is certainly overkill, but this approach was implemented back in2013 (near the very beginning of FreeCalypso) and has worked without anyproblems ever since, hence we are not changing it.In the case of RVTMUX, our serial communication engine through which everythingfunnels is rvinterf. Rvinterf will do the "wakeup shot" the first time it sendsanything to the target, and for all subsequent transmissions it will considerthe time since the last transmission: if it is greater than a set threshold(7 s by default), the wakeup shot is sent again. Thus there will be noextraneous wakeup shots and associated delays during reasonably continuousback to back communication, but the wakeup shot delay will be incurred ifrvinterf is killed and restarted or if a non-trivial pause occurs in thecommunication flow.In the case of AT commands, our fcup-* tools described in the User-phone-toolsarticle go through a back-end program called fcup-atinterf which does the serialtalking, and the latter helper program is responsible for the wakeup logic.However, fcup-atinterf is not a daemon like rvinterf, it is run anew for everyfcup-* user command, hence every fcup-* command currently involves the wakeupdelay step. It is certainly inefficient, but the underlying philosophy valuesreliability over efficiency.The one remaining use case which has not been addressed at all yet is the GSM07.10 MUX; the current plan is to investigate it after the fc-host-tools-r9release and after we get FCDEV3B V2 boards which will hopefully be free fromthe sleep mode bug that afflicts FCDEV3B V1.