Sleep mode improvements and new C1xx release

Mychaela Falconia mychaela.falconia at gmail.com
Mon Jan 7 20:56:51 UTC 2019


Hello FreeCalypso community,

In anticipation of hopefully soon getting our new FCDEV3B V2 boards
with a different flash reset circuit which will hopefully fix our
current inability to enable Calypso sleep modes on our hw, I have been
making some improvements to the sleep mode selection logic in the
firmware.  First we need to cover some background:

A key part of the sleep mode selection logic in our (formerly TI's)
modem firmware is the 10 s UART activity timer.  Because the main
13 or 26 MHz VCXO is stopped in deep sleep (to save power), the UARTs
lose their ability to register incoming characters during this sleep
mode: if an external host sends something via one of the UARTs to a
Calypso modem while the latter is in deep sleep, a special circuit in
the Calypso (asynchronous, I am guessing) will detect that there is
*some* activity on the UART lines and initiate the sequence to wake up
from deep sleep, but the actual characters being sent by the external
host will be lost during the 60 ms or so that it takes for the modem
to wake up.  Therefore, if an AT-command-controlled modem is to be
able to go into deep sleep, the modem and the external host need to
agree on a special protocol.  On the Calypso side, every time some
incoming characters are received at one of the UARTs, a 10 s timer is
started or restarted, and until that timer expires, the modem is not
allowed to go into deep sleep.  The external host also needs special
logic: if it has been a long time since the last transmission to the
modem, such that the modem is allowed to be in deep sleep, the next
time the host needs to send something to the modem, it needs to send a
throwaway message first (a do-nothing which the modem may or may not
receive depending on whether it happens to be awake or sleeping at
that moment), then wait 60 ms for the modem to wake up if it needs to,
and then send the actual intended command.  I assume that Openmoko
must have implemented this logic in their modem-interfacing host sw,
as their modem has exactly the same quirk.

All of the above logic has already been implemented in TI's firmware
and its various derivatives long before we came onto the scene, and we
are not changing it.  But my recent change concerns this question:
when the modem is not allowed to go into deep sleep while the UART
activity timer is running, what other sleep modes are allowed?  It
appears that TI's original intent was to allow both small and big
sleep, but around the time of Openmoko and Pirelli someone at TI made
a change that had an effect (probably unintended) of suppressing not
only deep sleep, but also big sleep when the UART activity timer is
running.  My recent change restores the originally intended sensible
behaviour: when deep sleep is not allowed because the 10 s UART
activity timer or the similar 2.3 s SIM activity timer is running, the
modem does big sleep instead.  Previously when big sleep was suppressed,
the modem was doing small sleep instead, which is less power-saving:
with small sleep the modem has to wake up on every TDMA frame (4.615 ms),
whereas big sleep involves a calculated wake-up time between paging
windows (many multiframes) just like deep sleep, and also big sleep
includes stopping the DPLL inside the Calypso that multiplies 13 MHz
up to 104 MHz, which is not stopped in small sleep.

The other change I haven't made yet, but I plan on making it when we
get our new boards on which it will be relevant: remember how I
mentioned above that in order for an AT-command-controlled Calypso
modem to be able to go into deep sleep, the external host needs to
implement a special protocol?  One obvious issue is that many external
host implementers may rightfully consider this requirement to be a
completely unreasonable burden.  As often happens in all of engineering,
there is no perfect solution here, only trade-offs and compromises,
and the best compromise will be different from one use case to another.
We need to offer our users two options: either they can enable deep
sleep, get the best possible power saving, but have the additional
interface burden of making their host software sleep-aware, or they
can disable deep sleep, get a straightforward AT command interface
without any weird wake-up logic requirements (send your command at
whatever time you like and it will always work), but at the expense of
greater power consumption.

Right now the firmware offers 5 possible sleep mode configurations:

#define NO_SLEEP              00   // ------ + ------ + ------
#define SMALL_SLEEP           01   // SMALL  + ------ + ------
#define BIG_SLEEP             02   // ------ +   BIG  + ------
#define DEEP_SLEEP            03   // ------ +   BIG  +  DEEP
#define ALL_SLEEP             04   // SMALL  +   BIG  +  DEEP

Notice that there is no option is keep both small and big sleep, but
disable deep sleep.  When Openmoko discovered that deep sleep does not
work on some of their devices because of a board-level hw problem,
their software workaround was to disable deep sleep, for which they
issue an AT%SLEEP=2 command.  However, as you can see from the sleep
mode definitions above, this setting disables not only deep sleep, but
also small sleep, leaving only big sleep.  There are many times when
the modem is not able to enter either big or deep sleep for various
reasons, and during those times small sleep comes in handy: it stops
the clock to the ARM7 core until the next TDMA frame or other
interrupt.  Disabling small sleep causes the ARM7 core to keep running
with its 52 MHz clock enabled, wasting power.

My plan is to add a new mode that allows small and big sleep, but not
deep sleep.  The default will still be ALL_SLEEP (all 3 sleep modes
enabled), but if someone needs a simpler host interface without sleep
awareness, they will be able to issue an AT%SLEEP=5 command (the new
mode to be added) and get the benefit of both small and big sleep
while deep sleep is disabled.  I haven't implemented it yet, but I
will implement it when we get our FCDEV3B V2 boards with working sleep.
This new sleep mode will only be relevant for our FreeCalypso AT modem
offering and for Openmoko GTA01/02 modems, but it is not applicable
for handset configurations or when running FreeCalypso on Mot C1xx as
a voice psuedo-modem: in the latter configuration there is no dedicated
AT command UART, everything has to go through rvinterf which is already
sleep-aware, thus there is never any need to disable deep sleep in
those configurations.

Speaking of Mot C1xx, I just put out a new binary release for those
phones:

ftp://ftp.freecalypso.org/pub/GSM/FreeCalypso/c1xx-fcmag-20190107.tar.bz2

Just like before, the untethered phone fw for C139/140 is only a demo,
not practically usable, and the more interesting fw images are the VPM
ones which turn the phone into an AT-command-controlled voice and SMS
pseudo-modem.  Compared to the previous 20180711 release, this new
update supports all 3 C1xx subfamilies (C11x/12x, C139/140 and C155/156),
it includes the sms_for.c malloc bugfix, and it includes my recent
improvements: the big sleep fix (allowing big sleep and not just small
sleep when the UART activity timer is running), the AT%VBAT addition
and the melody play command enhancements.

Hasta la Victoria, Siempre,
Mychaela aka The Mother


More information about the Community mailing list