changeset 547:c3f2f79dc5b8

l1_rf12.c compiled-in default RF band tables: a round of cleanup * Uncalibrated default g_magic values changed from old Clara RF numbers (yes, Clara, not even Leonardo) to the approximately correct value for our current hw; * Uncalibrated default Rx and Tx channel calibration tables providing neutral correction values: fixed bogus ARFCNs from blind copy-n-paste between different bands; * Restored #if (ORDER2_TX_TEMP_CAL==1) in the Tx temperature compensation tables; * Fully rewrote the big comment before these rf_XXX structures to reflect the current situation. This change is part of the larger transition in FreeCalypso from reverse to forward engineering, from reconstruction of lost original bits to ongoing forward development and maintenance.
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 17 Nov 2018 19:57:34 +0000
parents e48cc313ea31
children 9f191ca0051f
files src/cs/layer1/cust0/l1_rf12.c
diffstat 1 files changed, 188 insertions(+), 119 deletions(-) [+]
line wrap: on
line diff
--- a/src/cs/layer1/cust0/l1_rf12.c	Sat Nov 17 07:58:41 2018 +0000
+++ b/src/cs/layer1/cust0/l1_rf12.c	Sat Nov 17 19:57:34 2018 +0000
@@ -429,37 +429,87 @@
 
 /*
  * The const T_RF_BAND rf_{900,1800,850,1900} structures that follow
- * are the versions that appear in the .const section of l1_cust.obj
- * in the l1_custom_int.lib Leonardo blob, used successfully in leo2moko.
- * As revealed with objgrep, this .const section with these uncalibrated
- * defaults in it also appears in the moko11 binary - I'm guessing that
- * Openmoko probably had no source for this part either, and used TI's
- * standard Leonardo binary lib.  The pretty C formatting presented here
- * is courtesy of the calextract utility.
+ * provide compiled-in defaults for each frequency band.  The present
+ * FreeCalypso versions of these structs began life as verbatim extracts
+ * from Openmoko's l1_cust.obj blob made with our calextract utility,
+ * providing undisrupted continuity from previous built-from-blobs
+ * firmwares, but have since been modified as follows:
+ *
+ * - The uncalibrated default g_magic values for all bands have been
+ * set to 200, which is the approximately correct number on FC/OM hw.
+ * The numbers in TI's l1_cust.obj blob delivery were quite obviously
+ * unchanged from Clara RF, and probably weren't even correct for the
+ * original Leonardo, let alone OM.
  *
- * Late 2017 addition: when building the fw for Compal targets, we use the
- * ramps tables extracted from C139 firmware, so we run with Tx ramp
- * templates that are supposed to be correct for the hw we are running on.
+ * - The uncalibrated default Rx and Tx channel calibration tables
+ * have been cleaned up.  The only sensible default is to set all
+ * channel corrections to neutral (0 for Rx and 128 for Tx), which the
+ * original blob versions already did, but many of those copy-n-pasted
+ * tables had ARFCNs that are invalid for the band they are supposed
+ * to apply to.  The latter bug has been fixed.
+ *
+ * - For the Tx ramps tables we now select between two different versions
+ * at compile time: for Mot C1xx targets (CONFIG_TARGET_COMPAL) we use
+ * the version extracted from Mot's official C139 fw, whereas for all
+ * other targets (principally FreeCalypso hw) we continue to use the
+ * version extracted from OM's l1_cust.obj blob.
+ *
+ * NONE of these compiled-in tables matter if you are running the fw
+ * on an Openmoko, Pirelli or FreeCalypso device that has already been
+ * fully calibrated at the respective factory: in all of these cases
+ * all of these compiled-in tables are fully overridden by the factory-
+ * calibrated ones read from FFS, or in the Pirelli DP-L10 case,
+ * read from Pirelli's factory data block and written into FreeCalypso FFS
+ * by the pirelli-magnetite-init command you are supposed to issue
+ * in fc-fsio when you set up FC on this target.  Instead these
+ * compiled-in tables matter in the following use cases:
  *
- * When we build the fw for FreeCalypso targets (not Compal), we use the
- * original ramps tables from TI which are presumed to be correct for
- * Openmoko's RF3166 PA: these compiled-in ramps tables end up
- * in the FFS of our shipping products when our production calibration
- * station (or more precisely, fc-rfcal-txband) issues the me 104 command.
+ * - When FC fw is run on a Mot C1xx phone, our c1xx-calextr tool
+ * generates Rx agcparams, Rx channel calibration and Tx levels tables
+ * from Motorola's factory bits, but for the Tx ramp templates the tables
+ * compiled into our fw are used - hence these tables need to be correct
+ * for the target in question, which is why we have extracted and included
+ * the tables from Mot C139 official fw.  We also weren't able to grok
+ * Mot's way of doing Tx channel corrections, hence we run without those
+ * - thus we rely on the compiled-in channel calibration tables providing
+ * a neutral set of correction values.
+ *
+ * - Firmware images that are programmed into newly made FreeCalypso hw
+ * devices in the factory production environment prior to RF calibration
+ * need to have correct Tx ramp template tables in them, as well as
+ * indices in the Tx levels tables pointing to these ramps, plus the
+ * other 3 values in the T_RX_CAL_PARAMS structure besides g_magic:
+ * while all other table bits are generated from scratch by our
+ * fc-rfcal-rxband and fc-rfcal-txband programs without regard to
+ * any previous compiled-in values, the just-listed tables and fields
+ * are unchanged by the calibration procedure and must already be
+ * correct prior to it.
  *
- * For the Pirelli target the compiled-in ramps tables do not matter
- * as we use the ramps tables from Pirelli's factory data block on this
- * target, courtesy of the fc-fsio pirelli-magnetite-init command.
+ * The compiled-in default Tx levels tables have been kept unchanged
+ * from the original extracts from OM's l1_cust.obj blob.  There is
+ * no point in changing these tables because they are nothing but dummy
+ * placeholders in reality: these tables absolutely MUST be calibrated
+ * for the individual device unit before that device can be used safely
+ * on public land mobile networks (if you are not doing your own RF
+ * calibration, you need to extract and apply the original manufacturer's
+ * calibration records, like our c1xx-calextr and pirelli-magnetite-init
+ * tools do), and if the compiled-in tables are nothing but placeholders,
+ * it would be rather moot to argue whether set of numbers A or set of
+ * numbers B would make a better placeholder.
+ *
+ * For the Tx ramp templates on our newly made FreeCalypso hw we currently
+ * use the ramps tables extracted from OM's l1_cust.obj blob: they were
+ * used by OM, and our current RF hw is unchanged from OM GTA02.  However,
+ * these Tx ramp templates are currently only *assumed* to be correct,
+ * and no actual testing has been done yet - these Tx power ramps will
+ * need to be revisited and tested empirically before we apply for type
+ * approval certification.
  */
 
-#if (ORDER2_TX_TEMP_CAL != 1)
-#error "Hard-coded T_RF_BAND structs expect ORDER2_TX_TEMP_CAL to be 1"
-#endif
-
 const T_RF_BAND rf_900 = {
   { /* Rx structure */
     { /* T_RX_CAL_PARAMS */
-       193,
+       200,
         40,
         40,
         44,
@@ -473,7 +523,7 @@
       {  112,     0},
       {  124,     0},
       {  991,     0},
-      {  992,     0},
+      { 1009,     0},
       { 1023,     0},
     },
     { /* Rx temperature compensation */
@@ -569,6 +619,7 @@
     },
     { /* ramps */
 #ifdef CONFIG_TARGET_COMPAL
+      /* from Mot C139 official fw */
       { /* profile 0 */
 	/* ramp-up */
 	{  0,  0,  2,  0,  0,  0,  0,  0, 13, 24, 24, 25, 26, 14,  0,  0},
@@ -666,6 +717,7 @@
 	{ 31, 31, 31, 31,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
       },
 #else
+      /* TI/Openmoko version */
       { /* profile 0 */
 	/* ramp-up */
 	{  0,  0,  0,  0,  0,  0,  0,  0,  9, 18, 25, 31, 30, 15,  0,  0},
@@ -765,11 +817,19 @@
 #endif
     },
     { /* Tx temperature compensation */
-      {   -11,     0,     0,     0},
-      {     9,     0,     0,     0},
-      {    39,     0,     0,     0},
-      {    59,     0,     0,     0},
-      {   127,     0,     0,     0},
+#if (ORDER2_TX_TEMP_CAL==1)
+      { -11,  0, 0, 0 },
+      {  +9,  0, 0, 0 },
+      { +39,  0, 0, 0 },
+      { +59,  0, 0, 0 },
+      { 127,  0, 0, 0 }
+#else
+      { -11,  0 },
+      {  +9,  0 },
+      { +39,  0 },
+      { +59,  0 },
+      { 127,  0 }
+#endif
     },
   },
   //IQ swap
@@ -779,7 +839,7 @@
 const T_RF_BAND rf_1800 = {
   { /* Rx structure */
     { /* T_RX_CAL_PARAMS */
-       188,
+       200,
         40,
         40,
         44,
@@ -792,9 +852,9 @@
       {  812,     0},
       {  860,     0},
       {  885,     0},
-      {  991,     0},
-      {  992,     0},
-      { 1023,     0},
+      {    0,     0},
+      {    0,     0},
+      {    0,     0},
     },
     { /* Rx temperature compensation */
       {   -15,     0},
@@ -889,6 +949,7 @@
     },
     { /* ramps */
 #ifdef CONFIG_TARGET_COMPAL
+      /* from Mot C139 official fw */
       { /* profile 0 */
 	/* ramp-up */
 	{  6,  0,  0,  0,  0,  0,  0,  0,  0, 26, 26, 30, 30, 10,  0,  0},
@@ -986,6 +1047,7 @@
 	{ 31, 31, 31, 31,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
       },
 #else
+      /* TI/Openmoko version */
       { /* profile 0 */
 	/* ramp-up */
 	{  0,  0,  0,  0,  0,  0,  2,  3,  5, 16, 31, 31, 31,  9,  0,  0},
@@ -1085,11 +1147,19 @@
 #endif
     },
     { /* Tx temperature compensation */
-      {   -11,     0,     0,     0},
-      {     9,     0,     0,     0},
-      {    39,     0,     0,     0},
-      {    59,     0,     0,     0},
-      {   127,     0,     0,     0},
+#if (ORDER2_TX_TEMP_CAL==1)
+      { -11,  0, 0, 0 },
+      {  +9,  0, 0, 0 },
+      { +39,  0, 0, 0 },
+      { +59,  0, 0, 0 },
+      { 127,  0, 0, 0 }
+#else
+      { -11,  0 },
+      {  +9,  0 },
+      { +39,  0 },
+      { +59,  0 },
+      { 127,  0 }
+#endif
     },
   },
   //IQ swap
@@ -1099,22 +1169,22 @@
 const T_RF_BAND rf_850 = {
   { /* Rx structure */
     { /* T_RX_CAL_PARAMS */
-       181,
+       200,
         40,
         40,
         44,
     },
     { /* T_RF_AGC_BANDs */
-      {   10,     0},
-      {   30,     0},
-      {   51,     0},
-      {   71,     0},
-      {   90,     0},
-      {  112,     0},
-      {  124,     0},
-      {  991,     0},
-      {  992,     0},
-      { 1023,     0},
+      {  138,     0},
+      {  157,     0},
+      {  178,     0},
+      {  199,     0},
+      {  217,     0},
+      {  239,     0},
+      {  251,     0},
+      {    0,     0},
+      {    0,     0},
+      {    0,     0},
     },
     { /* Rx temperature compensation */
       {   -15,     0},
@@ -1167,69 +1237,49 @@
     },
     { /* channel calibration tables */
       { /* calibration table 0 */
-	{   40,   128},
-	{   80,   128},
-	{  124,   128},
-	{  586,   128},
-	{  661,   128},
-	{  736,   128},
-	{  885,   128},
-	{ 1023,   128},
+	{  134,   128},
+	{  150,   128},
+	{  166,   128},
+	{  182,   128},
+	{  197,   128},
+	{  213,   128},
+	{  229,   128},
+	{  251,   128},
       },
       { /* calibration table 1 */
-#if 0
-	/*
-	 * This bogon appears in the l1_custom_int.lib Leonardo blob
-	 * and in Openmoko's official firmwares, from which it has
-	 * propagated into the /gsm/rf/tx/calchan.850 file programmed
-	 * into every produced GTA02 unit, or at least the units
-	 * without the 850 MHz band.  It also appears in the MV100 version
-	 * of l1_rf12.c and in the "dead" rf_850 table in Pirelli's fw
-	 * binary.  Whew!
-	 */
-	{  554,   130},
-	{  722,   128},
-	{  746,   129},
-	{  774,   131},
-	{  808,   132},
-	{  851,   134},
-	{  870,   138},
-	{  885,   140},
-#else
-	/* make it the same as the others */
-	{   40,   128},
-	{   80,   128},
-	{  124,   128},
-	{  586,   128},
-	{  661,   128},
-	{  736,   128},
-	{  885,   128},
-	{ 1023,   128},
-#endif
+	{  134,   128},
+	{  150,   128},
+	{  166,   128},
+	{  182,   128},
+	{  197,   128},
+	{  213,   128},
+	{  229,   128},
+	{  251,   128},
       },
       { /* calibration table 2 */
-	{   40,   128},
-	{   80,   128},
-	{  124,   128},
-	{  586,   128},
-	{  661,   128},
-	{  736,   128},
-	{  885,   128},
-	{ 1023,   128},
+	{  134,   128},
+	{  150,   128},
+	{  166,   128},
+	{  182,   128},
+	{  197,   128},
+	{  213,   128},
+	{  229,   128},
+	{  251,   128},
       },
       { /* calibration table 3 */
-	{   40,   128},
-	{   80,   128},
-	{  124,   128},
-	{  586,   128},
-	{  661,   128},
-	{  736,   128},
-	{  885,   128},
-	{ 1023,   128},
+	{  134,   128},
+	{  150,   128},
+	{  166,   128},
+	{  182,   128},
+	{  197,   128},
+	{  213,   128},
+	{  229,   128},
+	{  251,   128},
       },
     },
     { /* ramps */
 #ifdef CONFIG_TARGET_COMPAL
+      /* from Mot C139 official fw */
       { /* profile 0 */
 	/* ramp-up */
 	{  0,  0,  3,  0,  0,  0,  0,  0,  2, 31, 30, 31, 31,  0,  0,  0},
@@ -1327,6 +1377,7 @@
 	{ 31, 31, 31, 31,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
       },
 #else
+      /* TI/Openmoko version */
       { /* profile 0 */
 	/* ramp-up */
 	{  0,  0,  0,  0,  0,  0,  0,  0,  9, 18, 25, 31, 30, 15,  0,  0},
@@ -1426,11 +1477,19 @@
 #endif
     },
     { /* Tx temperature compensation */
-      {   -11,     0,     0,     0},
-      {     9,     0,     0,     0},
-      {    39,     0,     0,     0},
-      {    59,     0,     0,     0},
-      {   127,     0,     0,     0},
+#if (ORDER2_TX_TEMP_CAL==1)
+      { -11,  0, 0, 0 },
+      {  +9,  0, 0, 0 },
+      { +39,  0, 0, 0 },
+      { +59,  0, 0, 0 },
+      { 127,  0, 0, 0 }
+#else
+      { -11,  0 },
+      {  +9,  0 },
+      { +39,  0 },
+      { +59,  0 },
+      { 127,  0 }
+#endif
     },
   },
   //IQ swap
@@ -1440,7 +1499,7 @@
 const T_RF_BAND rf_1900 = {
   { /* Rx structure */
     { /* T_RX_CAL_PARAMS */
-       188,
+       200,
         40,
         40,
         44,
@@ -1450,12 +1509,12 @@
       {  622,     0},
       {  680,     0},
       {  745,     0},
-      {  812,     0},
-      {  860,     0},
-      {  885,     0},
-      {  991,     0},
-      {  992,     0},
-      { 1023,     0},
+      {  795,     0},
+      {  810,     0},
+      {    0,     0},
+      {    0,     0},
+      {    0,     0},
+      {    0,     0},
     },
     { /* Rx temperature compensation */
       {   -15,     0},
@@ -1550,6 +1609,7 @@
     },
     { /* ramps */
 #ifdef CONFIG_TARGET_COMPAL
+      /* from Mot C139 official fw */
       { /* profile 0 */
 	/* ramp-up */
 	{ 10,  0,  0,  0,  0,  0,  0,  0,  6, 15, 31, 31, 23, 12,  0,  0},
@@ -1647,6 +1707,7 @@
 	{ 31, 31, 31, 31,  4,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0},
       },
 #else
+      /* TI/Openmoko version */
       { /* profile 0 */
 	/* ramp-up */
 	{  0,  0,  0,  0,  0,  0,  7,  0,  0, 16, 31, 31, 31, 12,  0,  0},
@@ -1746,11 +1807,19 @@
 #endif
     },
     { /* Tx temperature compensation */
-      {   -11,     0,     0,     0},
-      {     9,     0,     0,     0},
-      {    39,     0,     0,     0},
-      {    59,     0,     0,     0},
-      {   127,     0,     0,     0},
+#if (ORDER2_TX_TEMP_CAL==1)
+      { -11,  0, 0, 0 },
+      {  +9,  0, 0, 0 },
+      { +39,  0, 0, 0 },
+      { +59,  0, 0, 0 },
+      { 127,  0, 0, 0 }
+#else
+      { -11,  0 },
+      {  +9,  0 },
+      { +39,  0 },
+      { +59,  0 },
+      { 127,  0 }
+#endif
     },
   },
   //IQ swap