NVRAM read/write operations in MTK

Source: Internet
Author: User

There are three methods to define NVRAM data:

 

(1) add them to the nvram_editor_data_item.h, nvram_data_item.h, and nvram_data_item.c files.

 

1. Define the struct data type stored in nvram in the nvram_editor_data_item.h file.

Example: typedef struct

{

Int;

Char B;

} My_nvram_data_t;

2. Define Your nvram_assist_core_enum in the nvram_data_item.h file. (We recommend that you add the nvram_ef_last_assist_core at the end ). Define two macros. One macro is the byte size of the previously defined struct, and the other is the number of data stored in NVRAM. If only one data needs to be saved in NVRAM, it is defined as 1.

Example: typedef Enum

{

......

......

My_nvram_data_lid, // custom NVRAM ID

Nvram_ef_last_1__core

} Nvram_lid_core_enum;

 

# Define my_nvram_data_size sizeof (my_nvram_data_t)

# Define my_nvram_data_total 1

 

3. add your own items to the lobical_data_item_table_core struct array in the nvram_data_items.c file. We recommend that you add it at the end, as shown in the preceding figure.

Example: itable_entry_struct logical_data_item_table_core [] =

{

......

......

,{

My_nvram_data_lid, // The enumerated ID defined above

My_nvram_data_size, // macro defined earlier, struct size

My_nvram_data_total, // macro defined earlier, number of data in NVRAM

Nvram_ef_zero_default,

Nvram_attr_average,

Nvram_category_user,

"Mt1d", // increases progressively according to the previous data item

Ver (my_nvram_data_lid ),

"My NVRAM test/0", // data description, only for reference, no other function

Nvram_reserved_value

}

, {Nvram_ef_reserved_lid}

}

 

4. my_nvram_data_t my_nvram_data = {0 };

S16 error;

// Write the data in my_nvram_data to the my_nvram_data_lid mark in NVRAM. The error mark is saved.

Writerecord (my_nvram_data_lid, 1, & my_nvram_data, sizeof (my_nvram_data_t), & error );

 

// Read the data in the my_nvram_data_lid flag in NVRAM to my_nvram_data. The error flag is saved.

Readrecord (my_nvram_data_lid, 1, & my_nvram_data, sizeof (my_nvram_data_t), & error );

 

 

2. Define in common_nvram_editor_data_item.h, nvram_user_defs.h, and nvram_user_config.c

1. common_nvram_editor_data_item.h define the structure data type of the data stored in NVRAM.

2. nvram_user_defs.h the nvram id, struct data size, and total data size are defined here.

3. nvram_user_config.c fill in the NVRAM structure data content and defult value here

(We recommend using this method to modify NVRAM in MTK)

 

 

3. Define in coustom_mmi_default_value.h, common_mmi_cache_config.c

1. The custom_mmi_default_value.h file contains three enumeration types: bytedata, shortdata, and doubledata. 1 byte, 2 byte, and 8 bytes respectively. Define Your nvram id in the corresponding enumeration according to the data size you want to save. It is recommended to add at the end, but all must be before the last item.

Example: typedef Enum

{

......

......

Nvram_my_1_data_id,

Nvram_last_short_element

} Collect data;

2. The common_mmi_cache_config.c file contains three struct Arrays: common_mmi_cache_byte [], common_mmi_cache_short [], and common_mmi_cache_double []. Add your own data items to the corresponding array and set the initial value of NVRAM.

For example, mmi_cache_short_entry common_mmi_cache_short [] =

{

......

......

Short_entry (nvram_my_1_data_id, 0x00, 0x00 ),

{0xff, 0xff, 0xff, "", "", "}

};

 

3. Short int mynvramdata;

S16 error;

// Write NVRAM

Writevalue (nvram_my_1_data_id, & mynvramdata, ds_short, & error );

// Read NVRAM

Readvalue (nvram_my_1_data_id, & mynvramdata, ds_short, & error );

(Note: In the simulator, when NVRAM is modified, all the new commands are re-compiled in DOS)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.