Project

General

Profile

Feature #3582

Merge reading of factory RF calibration values

Added by fixeria 5 months ago. Updated 9 days ago.

Status:
Feedback
Priority:
Normal
Assignee:
Category:
OsmocomBB Firmware
Target version:
-
Start date:
09/21/2018
Due date:
% Done:

90%

Resolution:
Spec Reference:
Tags:

Description

Reading of factory RF calibration values was implemented together with adding FCDEV1B board support (see #3581) by Mychaela Falconia, but was not merged to the upstream. The corresponding code changes should be organized as a patch-set, and then uploaded to Gerrit for further review.

The modified source code archive can be downloaded from: ftp://ftp.freecalypso.org/pub/GSM/FreeCalypso/obb-fcmods-r1.tar.bz2


Related issues

Related to OsmocomBB - Support #2704: set up FCDEV1B board so it can be remotely accessed remotelyFeedback2017-12-03

Related to OsmocomBB - Feature #3581: Merge FCDEV3B board supportResolved2018-09-21

Related to OsmocomBB - Bug #1458: AGC broken (strong cell cannot be syncedNew

Related to OsmocomBB - Support #3801: dump flash of Sony Ericsson SJ100iNew2019-02-13

History

#1 Updated by fixeria 5 months ago

  • Related to Support #2704: set up FCDEV1B board so it can be remotely accessed remotely added

#2 Updated by fixeria 5 months ago

#3 Updated by fixeria 10 days ago

  • Related to Bug #1458: AGC broken (strong cell cannot be synced added

#4 Updated by fixeria 9 days ago

  • Status changed from New to Feedback
  • Assignee set to fixeria
  • % Done changed from 0 to 90

Please see:

https://gerrit.osmocom.org/#/c/osmocom-bb/+/12885 firmware/lib: introduce TIFFS filesystem support
https://gerrit.osmocom.org/#/c/osmocom-bb/+/12886 firmware/board/compal_e99: enable reading the second half of flash
https://gerrit.osmocom.org/#/c/osmocom-bb/+/12887 firmware: implement reading of factory RF calibration values

#5 Updated by falconia 9 days ago

Please note: at the time when I wrote this code (2017-Nov), I did not realize that setting the APC offset (MY_OFFSET macro in the l1s_tx_apc_helper() function) to 48 is only correct for TI-classic targets (meaning pristine/unchanged from TI's reference), practically meaning Openmoko and FreeCalypso devices. Later in 2018 I discovered that Mot/Compal's and Pirelli's firmwares (both heavily modified relative to TI) use different APC offset settings: 32 for Compal and 0 for Pirelli. See this change in FC Magnetite firmware for Compal and Pirelli support:

https://bitbucket.org/falconian/fc-magnetite/commits/395e464e4005ee0ca8afeaa59bcc84478e13cb1b

(The RF_PA preprocessor symbol is set to 2 for Openmoko/FreeCalypso targets in the above code.)

What does this news mean for the present OsmocomBB change? Answer: the code currently under review is correct for GTA0x and FCDEV3B targets, but is NOT correct for Compal or Pirelli. The per-unit Tx APC calibration values produced by their respective factories were calibrated with the APC offset set to 32 or 0 (Compal and Pirelli, respectively), and if these factory calibration values are used with the APC offset set to 48 instead, the resulting RF power output levels will be a little too high.

My suggestion is to replace the MY_OFFSET macro with a global variable (named apc_offset perhaps), and define this global variable to the correct number in per-board rf_tables.c files, similarly to what I did with the VCXO slope for AFC.

#6 Updated by falconia 9 days ago

Regarding the linking of this feature to bug #1458, please note that my patch from 2017-Nov only makes OsmocomBB make use of the factory calibration values for the Tx path (plus the AFC initial setting for FB search), but does not do anything for the Rx path. I couldn't figure out how to make OBB make use of the factory calibration values for Rx because OBB's architecture is too different from TI's in this regard. But if someone else wishes to put in the extra work to make use of factory calibration values for Rx, they are there: there is a GMagic number for each band, as well as per-band tables of finer subband corrections. On Openmoko and FreeCalypso devices, look in the agcparams and calchan files under /gsm/rf/rx in FFS, on the Pirelli DP-L10 the factory data block contains Rx calibration structures which directly correspond to these agcparams and calchan files. Mot/Compal's version is different, but both the per-band GMagic number and a table of subband corrections for each supported band are still there, and here is the code that groks those Mot/Compal data structures:

https://bitbucket.org/falconian/freecalypso-tools/src/368ffb8a08e5491c58ed29823e3658d06821545c/ffstools/caltools/c1xx-calextr.c?at=default&fileviewer=file-view-default

And here is my article that describes the theory behind these numbers:

https://bitbucket.org/falconian/fc-rfcal-tools/src/9f09a7c3607a63cd406ce593ef99e547de399ab3/doc/Rx-cal-theory?at=default&fileviewer=file-view-default

#7 Updated by falconia 9 days ago

I just took another look, and the hard-coded Rx path gain settings used by the current OsmocomBB code (not touched at all by my 2017-Nov patch) correspond to GMagic=196 (98.0 dB) in TI's universe. How did I get this number? Answer: SYSTEM_INHERENT_GAIN setting of 71 in board/*/rffe*.c files + TRF6151_FE_GAIN_HIGH defined to 27 in rf/trf6151.c = 98; TI's GMagic units are half-dB, hence the GMagic=196 result.

For comparison, the center-of-band GMagic numbers calibrated on my FCDEV3B boards with the use of a CMU200 instrument (test instrument itself calibrated at R&S Maryland, cable insertion loss accounted for) fall in the range from 199 to 201 (99.5 to 100.5 dB); the numbers I have read out of Openmoko-made units I laid my hands on similarly fall in the range from 199 to 202 (99.5 to 101.0 dB). Thus if it is too difficult to apply the calibrated numbers because of firmware architectural differences, GMagic=200 makes a very reasonable hard-coded default. Thus the GMagic equivalent used by the current OBB is a little low in comparison, but it is only off by 2 dB - not much.

If you wish to make your Rx gain control spot-on, you might want to change the SYSTEM_INHERENT_GAIN definition in board/gta0x/rffe_gta0x_triband.c from 71 to 73 - it would produce the equivalent of GMagic=200. I did not make this change in my 2017-Nov patch because at that time I wasn't as certain regarding the correct numbers - I only got my CMU200 instrument officially calibrated in 2018-Feb - it cost a non-trivial amount of money, hence the delay.

#8 Updated by fixeria 9 days ago

Hi Mychaela,

Please note: at the time when I wrote this code (2017-Nov), I did not
realize that setting the APC offset (MY_OFFSET macro in the
l1s_tx_apc_helper() function) to 48 is only correct for TI-classic
targets (meaning pristine/unchanged from TI's reference), practically
meaning Openmoko and FreeCalypso devices. Later in 2018 I discovered
that Mot/Compal's and Pirelli's firmwares (both heavily modified relative
to TI) use different APC offset settings: 32 for Compal and 0 for Pirelli.

thank you very much for this clarification!

My suggestion is to replace the MY_OFFSET macro with a global variable
(named apc_offset perhaps), and define this global variable to the correct
number in per-board rf_tables.c files, similarly to what I did with the
VCXO slope for AFC.

I just updated the change following your recommendations.

Regarding the linking of this feature to bug #1458, please note that
my patch from 2017-Nov only makes OsmocomBB make use of the factory
calibration values for the Tx path (plus the AFC initial setting for
FB search), but does not do anything for the Rx path.

Yep, I already noticed that the Rx path remains unchanged.
This also needs to be noted in the commit message (TODO for me).

Thanks for your tips regarding the Rx path, I'll have a look
at your code and documentation :)

#9 Updated by falconia 9 days ago

It should also be noted that my original 2017-Nov patch adds the reading and parsing of factory RF Tx calibration values for all previously supported targets with the single exception of Sony Ericsson J100. Of all OBB-supported Calypso phone models, SE J100 is the only one I have never laid my hands on, hence I do not currently know where and how its RF calibration values are stored. If someone can send me a flash dump from one of those SE J100 phones, I would be able to tell you pretty much immediately how to read and apply its calibration values, making all target support complete.

#10 Updated by laforge 9 days ago

On Tue, Feb 12, 2019 at 11:25:51PM +0000, falconia [REDMINE] wrote:

Of all OBB-supported Calypso phone models, SE J100 is the only one I have never laid my hands on, hence I do not currently know where and how its RF calibration values are stored.

If you'd like, I can send one to you by postal mail. Please contact me privately with
a postal address to where I can mail it. The phone and shipping would be free of charge.

If someone can send me a flash dump from one of those SE J100 phones, I would be able to tell you pretty much immediately how to read and apply its calibration values, making all target support complete.

I guess that's also an option. Is there a "ready made" firmware / tool
for dumping the flash, or would I need to write that code on my own?
I'm only aware of the compal_dsp_dump, but that's not for flash...

#11 Updated by fixeria 9 days ago

Hi Harald,

I guess that's also an option. Is there a "ready made" firmware / tool
for dumping the flash, or would I need to write that code on my own?
I'm only aware of the compal_dsp_dump, but that's not for flash...

FreeCalypso has all required tools and great documentation.
Not sure if J100i is supported by fc-loadtool though.

Please see:

https://bitbucket.org/falconian/freecalypso-tools/
https://bitbucket.org/falconian/freecalypso-tools/src/6f804a5ff3bc895e405ca711cbff620a62365385/doc/Loadtools-usage?at=default&fileviewer=file-view-default

General steps of dumping the firmware:

# Make sure you have freecalypso-tools installed
$ cd /opt/freecalypso/bin/
# Also, make sure you have the payloads compiled
$ ls /opt/freecalypso/target-bin/

# Start the fc-loadtool (similar to our osmocon)
# "-h compal" corresponds to "compalstage-plain.bin" payload,
# which is valid for Mot C11x/123. According to our wiki,
# the RAM loader of the J100i is the same as used on the
# MotorolaC140 series, but expects a "1003" magic word
# to be present at address 0x803ce0, thus we need another
# payload called "compalstage-1003.bin":
$ ./fc-loadtool -h compal -c 1003 /dev/ttyUSB0

# See "help flash" for more details
$ flash dump2bin OUTFILE

Alternatively, you can use OsmocomBB:

$ cd osmocom-bb/src/
$ host/osmocon/osmocon -p /dev/ttyUSB0 -m c140 -c target/firmware/board/se_j100/loader.highram.bin

# Check the info about flash
$ host/osmocon/osmoload finfo

# Dump the whole flash (example for Mot C11x/123, check your finfo)
$ host/osmocon/osmoload memdump 0x00000000 0x200000 /tmp/dump.bin

#12 Updated by laforge 8 days ago

  • Related to Support #3801: dump flash of Sony Ericsson SJ100i added

Also available in: Atom PDF

Add picture from clipboard (Maximum size: 48.8 MB)