MTK有一个特殊的存储区域,叫NVRam,这部分存储器用来保存重要的数据,如:校准参数、IMEI写号、FactoryMode等,即使刷机,只要不格式化下载,这些数据还在,恢复出厂设置也不会被擦除。今天就来与大家探讨NVRam的具体用法
一、底层,include我都省掉了
1.添加id
vendor/mediatek/proprietary/custom/xxxx/cgen/inc/Custom_NvRam_LID.h
typedef enum
{
AP_CFG_RDCL_FILE_AUDIO_LID=AP_CFG_CUSTOM_BEGIN_LID, //AP_CFG_CUSTOM_BEGIN_LID是另外一个枚举类型
-----------------------
AP_CFG_CUSTOM_FILE_CUSTOM_CALL_CALCULATE_LID, //新定义的id,id序号为73(从上往下数,这个id号很重要)
AP_CFG_CUSTOM_FILE_MAX_LID,
} CUSTOM_CFG_FILE_LID;
-----------------------
#define AP_CFG_CUSTOM_FILE_CUSTOM_CALL_CALCULATE_LID_VERNO "000" //定义版本号
2.申请空间
vendor/mediatek/proprietary/external/nvram/libcustom_nvram/CFG_file_info.c
FileName aBackupToBinRegion[]=
{
-----------------
{"Custom_CallCal",AP_CFG_CUSTOM_FILE_CUSTOM_CALL_CALCULATE_LID},
};
vendor/mediatek/proprietary/custom/xxx/cgen/inc/CFG_file_info_custom.h
const TCFG_FILE g_akCFG_File_Custom[]=
{
------------------
{
"/data/nvram/APCFG/APRDEB/CUSTOM1", VER(AP_CFG_CUSTOM_FILE_CUSTOM1_LID), CFG_FILE_CUSTOM1_REC_SIZE,
CFG_FILE_CUSTOM1_REC_TOTAL, DEFAULT_ZERO, (char *)&stCustom1Default, DataReset, NULL
},
vendor/mediatek/proprietary/custom/xxx/cgen/inc/Custom_NvRam_data_item.h
LID_BIT VER_LID(AP_CFG_CUSTOM_FILE_CUSTOM_CALL_CALCULATE_LID)
File_Custom_CallCalculate_Struct *CFG_FILE_CUSTOM_CALL_CALCULATE_TOTAL
{
};
3.定义类型及默认值
vendor/mediatek/proprietary/custom/xxx/cgen/cfgfileinc/CFG_Custom_CallCalculate_File.h
CFG_Custom_CallCalculate_File.h是新添加的,定义一个char型的数组
typedef struct
{
unsigned char Callresult[16];
}File_Custom_CallCalculate_Struct;
#define CFG_FILE_CUSTOM_CALL_CALCULATE_SIZE sizeof(File_Custom_CallCalculate_Struct)
#define CFG_FILE_CUSTOM_CALL_CALCULATE_TOTAL 1
vendor/mediatek/proprietary/custom/xxx/cgen/cfgdefault/CFG_Custom_CallCalculate_Default.h
CFG_Custom_CallCalculate_Default.h是新添加的,用来初始化数组
File_Custom_CallCalculate_Struct stCustomCallDefault =
{
0x00//, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 , 0x00
};
到此,底层部分的工作做好了