MTK平台 AP Nvram 如何实现更新某个nvram中某项数据
文摘 MediaTek 2020-02-4 阅读:6131[DESCRIPTION]
已经出货手机,需要更新wifi nvram LID 中某项数据,因为这个数据是备份数据,而已经出货手机,不能再做校准,所以在开机使用前实时改;
[SOLUTION]
修改 libnvram_daemon_callback.c, 客制化my_callback 函数
int my_callback(void) {
F_ID wifi_nvram_fd;
int iFileDesc;
int rec_size = 0;
int rec_num = 0;
int result = 0;
WIFI_CFG_PARAM_STRUCT pPara;
INT_8 cTxPwr5GOFDM_BPSK;
INT_8 ucEnable5GBand;
const TCFG_FILE *pCfgFielTable = NULL;
int wifisize = 0;
wifisize = sizeof(WIFI_CFG_PARAM_STRUCT);
ALOGD("whf nvram daemon callback will run!!!");
ALOGD("whf my_callback, wifisize: %d",wifisize);
wifi_nvram_fd = NVM_GetFileDesc(iFileWIFILID, &rec_size, &rec_num, true);
ALOGD("whf my_callback, rec_size: %d, rec_num: %d", rec_size, rec_num);
ALOGD("whf my_callback, rec_size wifi_nvram_fd.iFileDesc=%d", wifi_nvram_fd.iFileDesc);
if (wifi_nvram_fd.iFileDesc != -1)
{
ALOGD("whf my_callback, rec_size:");
result = read(wifi_nvram_fd.iFileDesc, &pPara , rec_size * rec_num);
if(result ==-1)
{
ALOGD("whf read end error\n");
return -1;
}
else
{
NVM_CloseFileDesc(wifi_nvram_fd);
ALOGD("whf read end\n");
}
}
else
{
ALOGD("whf read cTxPwr5GOFDM_BPSK %s\n", strerror(errno));
return -1;
}
if (pPara.rTxPwr.cTxPwr5GOFDM_BPSK != 36)
{
//1. memcpy 17321 para to pPara
//update_wifi_nvram_data(pPara, rec_size * rec_num);
//2.update nv flag
pPara.rTxPwr.cTxPwr5GOFDM_BPSK = 36; //0x24= 36
wifi_nvram_fd = NVM_GetFileDesc(iFileWIFILID, &rec_size, &rec_num, ISWRITE);
if (wifi_nvram_fd.iFileDesc != -1)
{
result = write(wifi_nvram_fd.iFileDesc, &pPara,rec_size * rec_num);
if(result ==-1)
{
ALOGD("whf write error %s\n", strerror(errno));
return -1;
}
else
{
ALOGD("whf write \n");
NVM_CloseFileDesc(wifi_nvram_fd);}
}
else
{
ALOGD("whf write NVM_GetFileDesc %s\n", strerror(errno));
return -1;
}
}
return 0;
}
共0
条评论
作者
Pixiv日榜Top50