首页 > 其他 > 详细

关于在Recovery mode下读写nvram(IMEI SVN)失败

时间:2015-03-13 18:42:29      阅读:1223      评论:0      收藏:0      [点我收藏+]

有关需求需要在recovery下读写imei svn,但是通过读写nvram操作相关节点并不能成功,下面主要实现代码和编译异常,而且跟同事沟通的时候了解到即便是可以编译通过也无法调用libnvram.so的相关函数。若有大神路过,请指点一二。

实现代码:

//#include "../../../../external/nvram/libnvram/libnvram.h"//这里已经引入了相关的头文件
#include "libnvram.h"
#include "CFG_PRODUCT_INFO_File.h"//struct
#include "Custom_NvRam_LID.h"//lid
#include "CFG_module_file.h"//module

int read_write(){

    int result;
    F_ID imei_imeisv_nvram_id;
    int test_fd;
    int rec_size;
    int rec_num;
    nvram_ef_imei_imeisv_struct*  imei_imeisv_struct;
    bool IsRead = true,IsWrite = false;
    printf("read:\n");
    imei_imeisv_nvram_id = NVM_GetFileDesc(AP_CFG_REEB_PRODUCT_INFO_LID, &rec_size, &rec_num,IsRead);//IsRead=true
    if(imei_imeisv_nvram_id.iFileDesc < 0){
        printf("NVM_GetFileDesc failed\n");
        return 0;
    }
    result = read(imei_imeisv_nvram_id.iFileDesc,&imei_imeisv_struct,rec_num*rec_size);
    if(result != rec_num*rec_size){
        printf("Get file failed\n");
        return 0;
    }


    printf("---------read---------\n");
    printf("svn:%s\n",imei_imeisv_struct->svn);
    ui->Print("svn:%s\n",imei_imeisv_struct->svn);
    printf("------------------\n");
    if(!NVM_CloseFileDesc(imei_imeisv_nvram_id))
    {
        printf("NVM_CloseFileDesc failed\n");
    }
    printf("write:\n");
    imei_imeisv_nvram_id = NVM_GetFileDesc(AP_CFG_REEB_PRODUCT_INFO_LID, &rec_size, &rec_num,IsWrite);//IsWrite=false
    if(imei_imeisv_nvram_id.iFileDesc < 0){
        printf("NVM_GetFileDesc failed\n");
        return 0;
    }
    imei_imeisv_struct->svn = 55;
    printf("--------write----------\n");
    result = write(imei_imeisv_nvram_id.iFileDesc,&imei_imeisv_struct,rec_num*rec_size);
    if(result != rec_num*rec_size){
        printf("write file failed\n");
        return 0;
    }
    if(!NVM_CloseFileDesc(imei_imeisv_nvram_id))
    {
        printf("NVM_CloseFileDesc failed\n");
    }
 return 0;
}

Android.mk相关修改:

LOCAL_C_INCLUDES := $(MTK_PATH_SOURCE)/external/nvram/libnvram
LOCAL_SHARED_LIBRARIES := libnvram

下面是编译异常:

bootable/recovery/recovery.cpp:2088: error: undefined reference to 'NVM_GetFileDesc'
bootable/recovery/recovery.cpp:2104: error: undefined reference to 'NVM_CloseFileDesc'
bootable/recovery/recovery.cpp:2109: error: undefined reference to 'NVM_GetFileDesc'
bootable/recovery/recovery.cpp:2121: error: undefined reference to 'NVM_CloseFileDesc'
collect2: error: ld returned 1 exit status



关于在Recovery mode下读写nvram(IMEI SVN)失败

原文:http://blog.csdn.net/huangyabin001/article/details/44244313

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!