view 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
line wrap: on
line source

/*
 * In this module we implement the loading of the charging config
 * and the battery table from FFS.
 */

#include "fchg/fchg_env.h"
#include "fchg/fchg_func_i.h"
#include "rv/rv_general.h"
#include "rvf/rvf_api.h"
#include "rvm/rvm_use_id_list.h"
#include "ffs/ffs_api.h"

void pwr_load_ffs_charging_config(void)
{
	int rc;

	rc = ffs_file_read("/etc/charging", &pwr_ctrl->config,
			   sizeof(struct charging_config));
	if (rc == sizeof(struct charging_config)) {
		pwr_ctrl->config_present = TRUE;
		rvf_send_trace(
		"FCHG: read charging config from FFS, charging enabled", 53,
				NULL_PARAM, RV_TRACE_LEVEL_DEBUG_HIGH,
				FCHG_USE_ID);
	} else {
		pwr_ctrl->config_present = FALSE;
		rvf_send_trace(
		"FCHG: no charging config in FFS, will not charge", 48,
				NULL_PARAM, RV_TRACE_LEVEL_WARNING,
				FCHG_USE_ID);
	}
}

void pwr_load_ffs_batt_table(void)
{
	int rc;

	rc = ffs_file_read("/etc/batterytab2", &pwr_ctrl->batt,
			   sizeof(struct battery_config));
	if (rc >= (int)(sizeof(T_PWR_THRESHOLDS) * MIN_PERCENT_THRESH + 4)) {
		pwr_ctrl->nb_percent_thresh =
					(rc - 4) / sizeof(T_PWR_THRESHOLDS);
		rvf_send_trace("FCHG: battery table loaded from FFS", 35,
				NULL_PARAM, RV_TRACE_LEVEL_DEBUG_HIGH,
				FCHG_USE_ID);
	} else {
		pwr_set_default_batt_table();
		rvf_send_trace("FCHG: using compiled-in default battery table",
				45, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_HIGH,
				FCHG_USE_ID);
	}
}

void pwr_check_ffs_bsim(void)
{
	int rc;

	rc = ffs_file_read("/etc/batterysim", &pwr_ctrl->bsim,
			   sizeof(struct bsim_config));
	if (rc == sizeof(struct bsim_config)) {
		pwr_ctrl->bsim_mode = TRUE;
		rvf_send_trace(
		"FCHG: operating in battery simulation mode per FFS config!",
				58, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_HIGH,
				FCHG_USE_ID);
	} else {
		pwr_ctrl->bsim_mode = FALSE;
	}
}