MTK MODEM (1) - - Basic Functions and Operation of MTK Platform NV

Keywords: Mobile Android

Basic Functions and Operation of MTK Platform NV
I. Basic concepts of NVRAM
NV is the abbreviation of Non Volatile, which means non-volatile storage. Generally speaking, even if the system is powered down, the data stored in the memory will not be lost.  
Why to backup and restore, NV values need to be calibrated and final test to make the mobile phone hardware work best, especially the RF related NV items. After calibration and final test, these NV values of each mobile phone are basically different. Plus, NV data is stored in the mirror file, and the mirror file data is likely to be damaged (e.g. re-burnt version). The NV data will also be destroyed, and the NV data after the previous calibration and final test will not be recovered, which will make the mobile phone face the production process of re-calibration and final test.  
 
Figure 1-NVRAM Framework
Non-Volatile Repository Access Manager(MTK):  
Save mobile phone configuration, such as IMEI, radio frequency calibration data, volume, caller ringtone, interface language, timer, video settings, etc. Applications can safely save data to memory (NAND/NOR Flash, EMMC). When the system crashes, it can protect daily configuration data, backup files and default configuration are not lost.  
AP BIN region:  
The AP side of smartphone backs up a NVRAM data version, including Modem NVRAM data, such as important RF calibration data. (CALIBRAT, NVD_IMEI)

  
NVRAM data structure
MTK platform uses the data structure of LID (Logical Data Item) and LID Table hash table to manage NV Item list.  
 

Describes a data item that operates on the minimum unit of NV.
Attributes 
Restrict reading and writing
Category 
Restricted storage (physical classification)
LID table 
Restricted storage (logical classification)

 
  
3. NVRAM Addition Steps

Basic steps for adding LID to NV
1. Adding LID Enumerated Variables
2. Define Record Size and Number
3. Define LID Version Number (VERNO)
4. Declare Default
5. Declare LID entry
 

IV. NVRAM adjustable and measurable
The external programmable interface of NVRAM is as follows, which reads and writes specific NVs.

kal_bool nvram_external_read_data(nvram_lid_enum LID, kal_uint16 rec_index, kal_uint8 *buffer, kal_uint32 buffer_size);
kal_bool nvram_external_write_data(nvram_lid_enum LID, kal_uint16 rec_index, kal_uint8 *buffer, kal_uint32 buffer_size);
kal_bool nvram_external_reset_data(nvram_lid_enum LID, kal_uint16 rec_index, kal_uint16 rec_amount);
  • 1
  • 2
  • 3

The following write NV operation

----------
    //lid read
    if( !nvram_external_read_data(ldi->LID, 1, (kal_uint8 *)cmp_buffer, ldi->size) )
    {
        nvram_ut_trace("[NVUT] nvram_security_test(): first read test LID fail!\n\r");
        return KAL_FALSE;
    }

    if( KAL_TRUE == nvram_external_write_data(ldi->LID, 1, (kal_uint8 *)cmp_buffer, ldi->size) )
    {
        nvram_ut_trace("[NVUT] nvram_security_test(): write fail not happen!\n\r");
        return KAL_FALSE;
    }
    else
    {
        nvram_ut_trace("[NVUT] nvram_security_test(): can't write when locked!\n\r");
    }

    //lid reset
    nvram_reset_data_items(NVRAM_RESET_CERTAIN, NVRAM_APP_RESERVED, ldi, 1, ldi->total_records);
    nvram_get_default_value_to_write(ldi, 1, (kal_uint8 *)data_buffer, ldi->size); //get new default value
    if( !nvram_external_read_data(ldi->LID, 1, (kal_uint8 *)cmp_buffer, ldi->size) )
    {
        nvram_ut_trace("[NVUT] nvram_security_test(): third read test LID fail!\n\r");
        return KAL_FALSE;
    }
  • PC META tool can read and write backup NV related files

Android daemon location

vendor\mediatek\libs\nvram_daemon
LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
LOCAL_MODULE = nvram_daemon
LOCAL_MODULE_CLASS = EXECUTABLES
LOCAL_MODULE_OWNER = mtk
LOCAL_PROPRIETARY_MODULE = true
LOCAL_MODULE_TAGS = optional
LOCAL_SHARED_LIBRARIES = libnvram libcustom_nvram libfile_op libnvram_daemon_callback libhwm libc++
LOCAL_MULTILIB = 32
LOCAL_SRC_FILES_32 = arm/nvram_daemon
include $(BUILD_PREBUILT)
\vendor\mediatek\proprietary\external\nvram
\vendor\mediatek\proprietary\external\nvram\libcustom_nvram
\vendor\mediatek\proprietary\external\nvram\libnvram
\vendor\mediatek\proprietary\external\nvram\libnvram_daemon_callback
\vendor\mediatek\proprietary\external\nvram\nvramagentclient

Camera-related NV position

\vendor\mediatek\proprietary\hardware\mtkcam\feature\mfnr\modules\nvram

Posted by bsamson on Sun, 16 Dec 2018 12:09:05 -0800