FreeCalypso > hg > fc-magnetite
view doc/Bootloader @ 600:8f50b202e81f
board preprocessor conditionals: prep for more FC hw in the future
This change eliminates the CONFIG_TARGET_FCDEV3B preprocessor symbol and
all preprocessor conditionals throughout the code base that tested for it,
replacing them with CONFIG_TARGET_FCFAM or CONFIG_TARGET_FCMODEM. These
new symbols are specified as follows:
CONFIG_TARGET_FCFAM is intended to cover all hardware designs created by
Mother Mychaela under the FreeCalypso trademark. This family will include
modem products (repackagings of the FCDEV3B, possibly with RFFE or even
RF transceiver changes), and also my desired FreeCalypso handset product.
CONFIG_TARGET_FCMODEM is intended to cover all FreeCalypso modem products
(which will be firmware-compatible with the FCDEV3B if they use TI Rita
transceiver, or will require a different fw build if we switch to one of
Silabs Aero transceivers), but not the handset product. Right now this
CONFIG_TARGET_FCMODEM preprocessor symbol is used to conditionalize
everything dealing with MCSI.
At the present moment the future of FC hardware evolution is still unknown:
it is not known whether we will ever have any beyond-FCDEV3B hardware at all
(contingent on uncertain funding), and if we do produce further FC hardware
designs, it is not known whether they will retain the same FIC modem core
(triband), if we are going to have a quadband design that still retains the
classic Rita transceiver, or if we are going to switch to Silabs Aero II
or some other transceiver. If we produce a quadband modem that still uses
Rita, it will run exactly the same fw as the FCDEV3B thanks to the way we
define TSPACT signals for the RF_FAM=12 && CONFIG_TARGET_FCFAM combination,
and the current fcdev3b build target will be renamed to fcmodem. OTOH, if
that putative quadband modem will be Aero-based, then it will require a
different fw build target, the fcdev3b target will stay as it is, and the
two targets will both define CONFIG_TARGET_FCFAM and CONFIG_TARGET_FCMODEM,
but will have different RF_FAM numbers. But no matter which way we are
going to evolve, it is not right to have conditionals on CONFIG_TARGET_FCDEV3B
in places like ACI, and the present change clears the way for future
evolution.
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 01 Apr 2019 01:05:24 +0000 |
parents | fbf0fabc5505 |
children |
line wrap: on
line source
As we understand it, TI's earlier DBB (digital baseband processor) chips prior to our Calypso did not have an on-chip ARM boot ROM: instead they would execute code directly out of flash immediately out of reset, like our Calypso does when its boot ROM is disabled with nIBOOT high. To get the firmware code into the flash initially, one had to either use JTAG or populate preprogrammed chips onto the board, and if you bricked your flash, you were screwed without JTAG. To assist with loading new firmware images during casual development, TI incorporated a bootloader stage into their firmware architecture. This bootloader stage is placed at the beginning of the flash at the reset vector, and the rest of the firmware begins at an erase unit boundary. The bootloader stage executes first, and before it jumps to the main firmware entry point (_INT_Initialize) for normal boot, it offers an opportunity for the boot process to be interrupted and diverted if an external host sends certain magic command packets into either of the two UARTs during the allotted time window. If the external host does interrupt and divert the boot process in this manner, it can feed a code image to the bootloader to be written somewhere in target RAM, and then command the bootloader to jump to it. It is exactly the same functionality (though with different serial protocol specifics) as implemented in the Calypso boot ROM. The ROM version is obviously superior because it is unbrickable, but the flash-resident, built-with-firmware version is what TI used before they came up with the idea of the boot ROM for the Calypso. When the boot-ROM-equipped Calypso came along, TI kept the flash-resident bootloader in the firmware: it does no harm aside from adding a little bit of delay to the boot process, it does not conflict with the ROM bootloader as the two speak different serial protocols and respond to different interrupt-boot sequences, and it allowed TI to keep the same firmware architecture for platforms with and without a boot ROM. (Using flash boot mode 1, TI's firmwares boot and run exactly the same way whether the Calypso boot ROM is present and enabled or not.) However, in our FreeCalypso firmwares starting with Magnetite we have removed this extra bootloader stage for the following reasons: * It is not useful to us on any of our hardware targets: on those devices that have the Calypso boot ROM enabled, we use that boot ROM and get full unbrickability, whereas on Mot C1xx phones we have to work with Mot/Compal's own different bootloader and serial protocol at least initially, hence it makes the most sense to stick with the same after the conversion to FreeCalypso as well. * As delivered by TI with their full production TCS211 fw releases, their firmware-resident bootloader works as intended only on hw platforms with 13 MHz VCXOs like the original D-Sample (Clara RF), and is broken on platforms like Rita RF (the only RF chip for which we have driver code!) with 26 MHz VCXOs: there is no conditionally-compiled code anywhere in the bootloader code path to set the VCLKOUT_DIV2 bit in the CNTL_CLK register on 26 MHz platforms, thus the UARTs are fed with 26 MHz instead of the standard 13 MHz clock expected in normal operation, and the intended baud rate of 115200 bps turns into 230400. Because 230400 bps is a baud rate which Calypso UARTs *cannot* produce in normal GSM operation (when the peripheral clock network runs at the expected 13 MHz), tools that are designed to talk to Calypso GSM devices are typically not designed to support this baud rate. In particular for CP2102 USB-serial adapters, the precedent established by the factory CP2102 EEPROM programming in the Pirelli DP-L10 phone is that the baud rate entry for 230400 bps is replaced with 203125 bps, which is a valid baud rate for Calypso UARTs running at 13 MHz. * We have no source for TI's firmware-resident bootloader, only linkable binary objects that came with our world's last surviving copy of TCS211, which are incompatible with our goal of blob-free firmware. Because this extra bootloader stage is ultimately unnecessary in our environment, the deblobbing goal was easier accomplished by removing it altogether instead of expending effort on a blob-free replacement. Because I wasn't comfortable with modifying TMS470 assembly code and linker script magic, the removal of the bootloader was accomplished by stubbing out its C body with an empty function. A 'build_lib bootloader' instruction in a firmware configuration recipe causes a dummy do-nothing bootloader to be built from this stubbed-out source. We have been removing (stubbing out) the bootloader from our TCS211-based firmwares since 2015, but in 2018-09 I (Mother Mychaela) finally took the time to study TI's bootloader code via disassembly and finally figured out what it does and how it works. Now that it is no longer an unknown, it may be interesting to build some fw images with this bootloader blob re-enabled for experimentation purposes, and a new experimental (not for production!) l1reconst-bl configuration has been created for this purpose. The bootloader blob has also been re-enabled in the classic configuration, whose only purpose is to serve as a reference point that preserves almost everything from our TCS211/Leonardo starting point. Finally, it needs to be noted for the sake of completeness that Compal's bootloader used on Mot C1xx phones is a modified version based on TI's original bootloader. However, this factoid matters only for historians and genealogists; for all practical purposes it is an unrelated animal, as Mot/Compal's serial protocol for interrupting and diverting the boot process is their own and bears no resemblance to TI's version. And yes, Mot/Compal's version does set the VCLKOUT_DIV2 bit in the CNTL_CLK register to adjust for the 26 MHz clock input as its first order of business; it was probably the very first issue they had to fix.