annotate src/cs/drivers/drv_app/fchg/fchg_ffs_init.c @ 303:f76436d19a7a default tip

!GPRS config: fix long-standing AT+COPS chance hanging bug There has been a long-standing bug in FreeCalypso going back years: sometimes in the AT command bring-up sequence of an ACI-only MS, the AT+COPS command would produce only a power scan followed by cessation of protocol stack activity (only L1 ADC traces), instead of the expected network search sequence. This behaviour was seen in different FC firmware versions going back to Citrine, and seemed to follow some law of chance, not reliably repeatable. This bug has been tracked down and found to be specific to !GPRS configuration, stemming from our TCS2/TCS3 hybrid and reconstruction of !GPRS support that was bitrotten in TCS3.2/LoCosto version. ACI module psa_mms.c, needed only for !GPRS, was missing in the TCS3 version and had to be pulled from TCS2 - but as it turns out, there is a new field in the MMR_REG_REQ primitive that needs to be set correctly, and that psa_mms.c module is the place where this initialization needed to be added.
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 08 Jun 2023 08:23:37 +0000
parents 769cf6273fe4
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
4e78acac3d88 src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
4e78acac3d88 src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * In this module we implement the loading of the charging config
4e78acac3d88 src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * and the battery table from FFS.
4e78acac3d88 src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 */
4e78acac3d88 src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5
4e78acac3d88 src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include "fchg/fchg_env.h"
4e78acac3d88 src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include "fchg/fchg_func_i.h"
4e78acac3d88 src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include "rv/rv_general.h"
4e78acac3d88 src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include "rvf/rvf_api.h"
4e78acac3d88 src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include "rvm/rvm_use_id_list.h"
4e78acac3d88 src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include "ffs/ffs_api.h"
4e78acac3d88 src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12
4e78acac3d88 src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 void pwr_load_ffs_charging_config(void)
4e78acac3d88 src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 {
4e78acac3d88 src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 int rc;
4e78acac3d88 src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16
4e78acac3d88 src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 rc = ffs_file_read("/etc/charging", &pwr_ctrl->config,
4e78acac3d88 src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 sizeof(struct charging_config));
4e78acac3d88 src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 if (rc == sizeof(struct charging_config)) {
4e78acac3d88 src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 pwr_ctrl->config_present = TRUE;
4e78acac3d88 src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 rvf_send_trace(
4e78acac3d88 src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 "FCHG: read charging config from FFS, charging enabled", 53,
4e78acac3d88 src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 NULL_PARAM, RV_TRACE_LEVEL_DEBUG_HIGH,
4e78acac3d88 src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 FCHG_USE_ID);
4e78acac3d88 src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 } else {
4e78acac3d88 src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 pwr_ctrl->config_present = FALSE;
4e78acac3d88 src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 rvf_send_trace(
4e78acac3d88 src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 "FCHG: no charging config in FFS, will not charge", 48,
4e78acac3d88 src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 NULL_PARAM, RV_TRACE_LEVEL_WARNING,
4e78acac3d88 src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 FCHG_USE_ID);
4e78acac3d88 src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 }
4e78acac3d88 src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 }
4e78acac3d88 src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33
4e78acac3d88 src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 void pwr_load_ffs_batt_table(void)
4e78acac3d88 src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 {
4e78acac3d88 src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 int rc;
4e78acac3d88 src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37
61
75067af48bfd FCHG updates for Tourmaline UI integration
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
38 rc = ffs_file_read("/etc/batterytab2", &pwr_ctrl->batt,
75067af48bfd FCHG updates for Tourmaline UI integration
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
39 sizeof(struct battery_config));
75067af48bfd FCHG updates for Tourmaline UI integration
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
40 if (rc >= (int)(sizeof(T_PWR_THRESHOLDS) * MIN_PERCENT_THRESH + 4)) {
75067af48bfd FCHG updates for Tourmaline UI integration
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
41 pwr_ctrl->nb_percent_thresh =
75067af48bfd FCHG updates for Tourmaline UI integration
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
42 (rc - 4) / sizeof(T_PWR_THRESHOLDS);
0
4e78acac3d88 src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 rvf_send_trace("FCHG: battery table loaded from FFS", 35,
4e78acac3d88 src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 NULL_PARAM, RV_TRACE_LEVEL_DEBUG_HIGH,
4e78acac3d88 src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 FCHG_USE_ID);
4e78acac3d88 src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 } else {
4e78acac3d88 src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 pwr_set_default_batt_table();
4e78acac3d88 src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 rvf_send_trace("FCHG: using compiled-in default battery table",
4e78acac3d88 src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 45, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_HIGH,
4e78acac3d88 src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 FCHG_USE_ID);
4e78acac3d88 src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 }
4e78acac3d88 src/{condat,cs,gpf,nucleus}: import from Selenite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 }
253
769cf6273fe4 FCHG: beginning of battery simulation mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 61
diff changeset
53
769cf6273fe4 FCHG: beginning of battery simulation mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 61
diff changeset
54 void pwr_check_ffs_bsim(void)
769cf6273fe4 FCHG: beginning of battery simulation mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 61
diff changeset
55 {
769cf6273fe4 FCHG: beginning of battery simulation mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 61
diff changeset
56 int rc;
769cf6273fe4 FCHG: beginning of battery simulation mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 61
diff changeset
57
769cf6273fe4 FCHG: beginning of battery simulation mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 61
diff changeset
58 rc = ffs_file_read("/etc/batterysim", &pwr_ctrl->bsim,
769cf6273fe4 FCHG: beginning of battery simulation mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 61
diff changeset
59 sizeof(struct bsim_config));
769cf6273fe4 FCHG: beginning of battery simulation mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 61
diff changeset
60 if (rc == sizeof(struct bsim_config)) {
769cf6273fe4 FCHG: beginning of battery simulation mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 61
diff changeset
61 pwr_ctrl->bsim_mode = TRUE;
769cf6273fe4 FCHG: beginning of battery simulation mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 61
diff changeset
62 rvf_send_trace(
769cf6273fe4 FCHG: beginning of battery simulation mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 61
diff changeset
63 "FCHG: operating in battery simulation mode per FFS config!",
769cf6273fe4 FCHG: beginning of battery simulation mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 61
diff changeset
64 58, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_HIGH,
769cf6273fe4 FCHG: beginning of battery simulation mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 61
diff changeset
65 FCHG_USE_ID);
769cf6273fe4 FCHG: beginning of battery simulation mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 61
diff changeset
66 } else {
769cf6273fe4 FCHG: beginning of battery simulation mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 61
diff changeset
67 pwr_ctrl->bsim_mode = FALSE;
769cf6273fe4 FCHG: beginning of battery simulation mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 61
diff changeset
68 }
769cf6273fe4 FCHG: beginning of battery simulation mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 61
diff changeset
69 }