u32 nv_read_write_test(void) { u32 i; u32 ret; struct nv_ctrl_file_info_stru* ctrl_info = (struct nv_ctrl_file_info_stru*)NV_GLOBAL_CTRL_INFO_ADDR; struct nv_ref_data_info_stru* ref_info = (struct nv_ref_data_info_stru*)(NV_GLOBAL_CTRL_INFO_ADDR+NV_GLOBAL_CTRL_INFO_SIZE\ +NV_GLOBAL_FILE_ELEMENT_SIZE*ctrl_info->file_num); u8* pdata; pdata = (u8*)nv_malloc(3072); if(NULL == pdata) { return NV_ERROR; } for(i = 0;i<ctrl_info->ref_count;i++) { printf("*****************read & write 0x%x****************\n",ref_info->itemid); ret = bsp_nvm_read(ref_info->itemid,pdata,ref_info->nv_len); if(ret) { nv_free(pdata); return ret; } ret = bsp_nvm_write(ref_info->itemid,pdata,ref_info->nv_len); if(ret) { nv_free(pdata); return ret; } ref_info++; } nv_free(pdata); return NV_OK; }
void nvlist_move_string_array(nvlist_t *nvl, const char *name, char **value, size_t nitems) { nvpair_t *nvp; size_t i; if (nvlist_error(nvl) != 0) { if (value != NULL) { for (i = 0; i < nitems; i++) nv_free(value[i]); nv_free(value); } ERRNO_SET(nvlist_error(nvl)); return; } nvp = nvpair_move_string_array(name, value, nitems); if (nvp == NULL) { nvl->nvl_error = ERRNO_OR_DEFAULT(ENOMEM); ERRNO_SET(nvl->nvl_error); } else { (void)nvlist_move_nvpair(nvl, nvp); } }
u32 nv_read_part_test(u32 nvid,u32 off,u32 len) { u32 ret; u8* tempdata; u32 i= 0; tempdata = (u8*)nv_malloc(len +1); if(NULL == tempdata) { return BSP_ERR_NV_MALLOC_FAIL; } ret = bsp_nvm_readpart(nvid,off,tempdata,len); if(NV_OK != ret) { nv_free(tempdata); return BSP_ERR_NV_READ_DATA_FAIL; } for(i=0;i<len;i++) { if((i%16) == 0) { printf("\n"); } printf("%2.2x ",(u8)(*(tempdata+i))); } printf("\n"); nv_free(tempdata); return NV_OK; }
static void nv_mlp_train_accuracy(const nv_mlp_t *mlp, const nv_matrix_t *data, const nv_matrix_t *label) { int i; int output = mlp->output; int *correct_count = nv_alloc_type(int, output); int *error_count = nv_alloc_type(int, output); memset(correct_count, 0, sizeof(int) * output); memset(error_count, 0, sizeof(int) * output); for (i = 0; i < data->m; ++i) { int predict = nv_mlp_predict_label(mlp, data, i); int teach = (int)NV_MAT_V(label, i, 0); if (predict == teach) { ++correct_count[teach]; } else { ++error_count[teach]; } } for (i = 0; i < output; ++i) { if (correct_count[i] + error_count[i] > 0) { printf("%d: correct: %d, ng: %d, %f\n", i, correct_count[i], error_count[i], (float)correct_count[i] / (float)(correct_count[i] + error_count[i])); } else { printf("%d: no data found\n", i); } } nv_free(correct_count); nv_free(error_count); }
/*copy img to backup*/ u32 nv_copy_img2backup(void) { u32 ret; FILE* fp = NULL; u32 total_len; u32 phy_off = 0; u32 unit_len; void* pdata = NULL; fp = BSP_fopen((char*)NV_IMG_PATH,"rb"); if(!fp) { return BSP_ERR_NV_NO_FILE; } BSP_fseek(fp,0,SEEK_END); total_len = (u32)BSP_ftell(fp); BSP_fseek(fp,0,SEEK_SET); pdata = (void*)nv_malloc(NV_FILE_COPY_UNIT_SIZE); if(!pdata) { BSP_fclose(fp); return BSP_ERR_NV_MALLOC_FAIL; } nv_create_flag_file((s8*)NV_BACK_FLAG_PATH); while(total_len) { unit_len = (total_len >= NV_FILE_COPY_UNIT_SIZE)?NV_FILE_COPY_UNIT_SIZE : total_len; ret = (u32)BSP_fread(pdata,1,unit_len,fp); if(ret != unit_len) { nv_free(pdata); BSP_fclose(fp); return BSP_ERR_NV_READ_FILE_FAIL; } ret = (u32)bsp_nand_write((char*)NV_BACK_SEC_NAME,phy_off,pdata,unit_len); if(ret) { nv_free(pdata); BSP_fclose(fp); return BSP_ERR_NV_WRITE_FILE_FAIL; } phy_off += unit_len; total_len -= unit_len; } nv_free(pdata); BSP_fclose(fp); nv_delete_flag_file((s8*)NV_BACK_FLAG_PATH); return NV_OK; }
nvlist_t * nvlist_recv(int sock, int flags) { struct nvlist_header nvlhdr; nvlist_t *nvl, *ret; unsigned char *buf; size_t nfds, size, i; int *fds; if (buf_recv(sock, &nvlhdr, sizeof(nvlhdr)) == -1) return (NULL); if (!nvlist_check_header(&nvlhdr)) return (NULL); nfds = (size_t)nvlhdr.nvlh_descriptors; size = sizeof(nvlhdr) + (size_t)nvlhdr.nvlh_size; buf = nv_malloc(size); if (buf == NULL) return (NULL); memcpy(buf, &nvlhdr, sizeof(nvlhdr)); ret = NULL; fds = NULL; if (buf_recv(sock, buf + sizeof(nvlhdr), size - sizeof(nvlhdr)) == -1) goto out; if (nfds > 0) { fds = nv_malloc(nfds * sizeof(fds[0])); if (fds == NULL) goto out; if (fd_recv(sock, fds, nfds) == -1) goto out; } nvl = nvlist_xunpack(buf, size, fds, nfds, flags); if (nvl == NULL) { ERRNO_SAVE(); for (i = 0; i < nfds; i++) close(fds[i]); ERRNO_RESTORE(); goto out; } ret = nvl; out: ERRNO_SAVE(); nv_free(buf); nv_free(fds); ERRNO_RESTORE(); return (ret); }
u32 nvm_read_randex(u32 nvid,u32 modem_id) { u32 ret; u8* tempdata; u32 i= 0; struct nv_ref_data_info_stru ref_info = {0}; struct nv_file_list_info_stru file_info = {0}; ret = nv_search_byid(nvid, (u8*)NV_GLOBAL_CTRL_INFO_ADDR,&ref_info,&file_info); if(NV_OK != ret) { return ret; } if(ref_info.nv_len == 0) { return NV_ERROR; } /*lint -save -e515 -e516*/ printf_nv("[0x%x]:len 0x%x,off 0x%x,file id %d\n",nvid,ref_info.nv_len,ref_info.nv_off,ref_info.file_id); printf_nv("[0x%x]:dsda 0x%x\n",nvid,ref_info.modem_num); /*lint -restore*/ /*lint -save -e516*/ tempdata = (u8*)nv_malloc(ref_info.nv_len +1); /*lint -restore +e516*/ if(NULL == tempdata) { return BSP_ERR_NV_MALLOC_FAIL; } ret = bsp_nvm_dcread(modem_id,nvid,tempdata,ref_info.nv_len); if(NV_OK != ret) { nv_free(tempdata); return BSP_ERR_NV_READ_DATA_FAIL; } /*lint -save -e515 -e516*/ for(i=0;i<ref_info.nv_len;i++) { if((i%32) == 0) { printf_nv("\n"); } printf_nv("%02x ",(u8)(*(tempdata+i))); } printf_nv("\n\n"); /*lint -restore*/ nv_free(tempdata); return 0; }
u32 nv_crc_write_test04(void) { struct nv_ref_data_info_stru nvArray[10] = {}; u32 count = 0; u32 i = 0; u32 ret = 0; u8 *pOldNvData = NULL; u8 *pNewNvData = NULL; pOldNvData = (u8 *)nv_malloc(NV_MAX_UNIT_SIZE); pNewNvData = (u8 *)nv_malloc(NV_MAX_UNIT_SIZE); if((pOldNvData == NULL)||(pNewNvData == NULL)) { nv_printf("malloc error 1111\n"); return NV_ERROR; } count = nv_test_find_edge_nv(nvArray); for(i = 0; i < count; i++) { ret = bsp_nvm_read(nvArray[i].itemid, (u8 *)pOldNvData, nvArray[i].nv_len); if(ret) { nv_printf("read error 222, nvid = 0x%x\n", nvArray[i].itemid); return ret; } pOldNvData[0]+=2; ret = bsp_nvm_write(nvArray[i].itemid, (u8 *)pOldNvData, nvArray[i].nv_len); if(ret) { nv_printf("read error 3333, nvid = 0x%x\n", nvArray[i].itemid); return ret; } ret = bsp_nvm_read(nvArray[i].itemid, (u8 *)pNewNvData, nvArray[i].nv_len); if((ret)||(pNewNvData[0] != pOldNvData[0])) { nv_printf("read error 4444, nvid = 0x%x\n", nvArray[i].itemid); return ret; } ret = nv_check_ddr_crc(); if(ret) { nv_printf("read error 5555, nvid = 0x%x\n", nvArray[i].itemid); return ret; } } nv_free(pOldNvData); nv_free(pNewNvData); return NV_OK; }
void nvlist_destroy(nvlist_t *nvl) { nvpair_t *nvp; if (nvl == NULL) return; ERRNO_SAVE(); NVLIST_ASSERT(nvl); while ((nvp = nvlist_first_nvpair(nvl)) != NULL) { nvlist_remove_nvpair(nvl, nvp); nvpair_free(nvp); } if (nvl->nvl_array_next != NULL) nvpair_free_structure(nvl->nvl_array_next); nvl->nvl_array_next = NULL; nvl->nvl_parent = NULL; nvl->nvl_magic = 0; nv_free(nvl); ERRNO_RESTORE(); }
/* * Function: nv_file_open * Discription: open file * Parameter: path : file path * mode : file ops type etc:"r+","rb+","w+","wb+" * Output : file pointer */ FILE* nv_file_open(const s8* path,const s8* mode) { struct nv_file_p* fp = NULL; fp = (struct nv_file_p*)nv_malloc(sizeof(struct nv_file_p)); if(!fp) { return NULL; } #ifdef BSP_CONFIG_HI3630 if(0 == strcmp((char*)path,(char*)NV_IMG_PATH)) #else if(0 == strcmp((char*)path,(char*)NV_IMG_PATH)) #endif { fp->fd = BSP_fopen((char*)path,(char*)mode); fp->stor_type = NV_FILE_STOR_FS; } else { fp->fd = g_nv_ops.fo(path,mode); fp->stor_type = NV_FILE_STOR_NON_FS; } if(NULL == fp->fd) { nv_free(fp); return NULL; } return fp; }
void print_freqs(struct print_freqs_param *param) { char *start = param->start; int length = param->length; int frame = param->frame; char *output = param->output; int output_size = param->output_size; struct ht_ht *ht = ht_create(32); char buffer[frame + 1]; int output_pos = 0; generate_seqences(start, length, frame, ht); struct ht_node *counts = ht_values_as_vector(ht); int size = ht->items; qsort(counts, size, sizeof(struct ht_node), &key_count_cmp); int total_count = 0; for (int i = 0; i < size; i++) { total_count += counts[i].val; } for (int i = 0; i < size; i++) { unpack_key(counts[i].key, frame, buffer); output_pos += snprintf(output + output_pos, output_size - output_pos, "%s %.3f\n", buffer, counts[i].val*100.0f/total_count); } nv_free(counts); ht_destroy(ht); }
/* * Load the configuration plugin from the given file. * If the configuration plugin structure is NULL then it is allocated. * This should normally be the case. */ int config_p_init(char *file) { char *buf = NULL; int len = 0; lt_dlhandle module = NULL; int (*config_init)(struct nv_config_p *); int stat = 0; int ret = 0; /* get reference to config plugin file */ nv_log(NVLOG_INFO, "loading config plugin from %s", file); len = strlen(CONFIG_PATH)+strlen(file)+2; buf = nv_calloc(char, len); snprintf(buf, len, "%s/%s", CONFIG_PATH, file); module = lt_dlopen(buf); nv_free(buf); if (module == NULL) { nv_log(NVLOG_ERROR, "lt_dlopen(): %s", lt_dlerror()); stat = -1; goto cleanup; } /* allocate memory for config plugin struct if necessary */ if (nv_config_p == NULL) { nv_config_p = nv_calloc(struct nv_config_p, 1); }
void xml_getjumpinfo(s8* map_path) { FILE* fp = NULL; s32 ret = 0; u32 file_len; XNV_MAP_HEAD_STRU* map_file = NULL; XNV_MAP_PRODUCT_INFO product_info = {0}; if(!map_path) return; fp = nv_emmc_open(map_path,(s8*)NV_FILE_READ); if(!fp) return; file_len = nv_boot_get_file_len(fp); /* coverity[negative_returns] */ map_file = (XNV_MAP_HEAD_STRU*)nv_malloc(file_len+2*EMMC_BLOCK_SIZE); if(!map_file) { nv_emmc_close(fp); return; } ret = nv_emmc_read((u8*)map_file,1,file_len,fp); /*lint -save -e737*/ if(ret != file_len) { goto out; } /*lint -restore +e737*/ ret = xml_search_productinfo((u32)(xml_ctrl.g_stlxmlproductid),(u8*)map_file,&product_info); if(ret) goto out; memcpy(&xml_ctrl.g_stlxmljumpinfo,&product_info,sizeof(product_info)); xml_ctrl.g_stlxmljumpflag = XML_DECODE_STATUS_JUMP; nv_emmc_close(fp); nv_free(map_file); return; out: nv_emmc_close(fp); nv_free(map_file); memset(&xml_ctrl.g_stlxmljumpinfo,0,sizeof(xml_ctrl.g_stlxmljumpinfo)); xml_ctrl.g_stlxmljumpflag = XML_DECODE_STATUS_NOJUMP; return; }
int metadata_write(struct hast_resource *res) { struct ebuf *eb; struct nv *nv; unsigned char *buf, *ptr; size_t size; ssize_t done; int ret; buf = calloc(1, METADATA_SIZE); if (buf == NULL) { pjdlog_error("Unable to allocate %zu bytes for metadata.", (size_t)METADATA_SIZE); return (-1); } ret = -1; nv = nv_alloc(); nv_add_string(nv, res->hr_name, "resource"); nv_add_uint64(nv, (uint64_t)res->hr_datasize, "datasize"); nv_add_uint32(nv, (uint32_t)res->hr_extentsize, "extentsize"); nv_add_uint32(nv, (uint32_t)res->hr_keepdirty, "keepdirty"); nv_add_uint64(nv, (uint64_t)res->hr_localoff, "offset"); nv_add_uint64(nv, res->hr_resuid, "resuid"); if (res->hr_role == HAST_ROLE_PRIMARY || res->hr_role == HAST_ROLE_INIT) { nv_add_uint64(nv, res->hr_primary_localcnt, "localcnt"); nv_add_uint64(nv, res->hr_primary_remotecnt, "remotecnt"); } else /* if (res->hr_role == HAST_ROLE_SECONDARY) */ { PJDLOG_ASSERT(res->hr_role == HAST_ROLE_SECONDARY); nv_add_uint64(nv, res->hr_secondary_localcnt, "localcnt"); nv_add_uint64(nv, res->hr_secondary_remotecnt, "remotecnt"); } nv_add_string(nv, role2str(res->hr_role), "prevrole"); if (nv_error(nv) != 0) { pjdlog_error("Unable to create metadata."); goto end; } res->hr_previous_role = res->hr_role; eb = nv_hton(nv); PJDLOG_ASSERT(eb != NULL); ptr = ebuf_data(eb, &size); PJDLOG_ASSERT(ptr != NULL); PJDLOG_ASSERT(size < METADATA_SIZE); bcopy(ptr, buf, size); done = pwrite(res->hr_localfd, buf, METADATA_SIZE, 0); if (done == -1 || done != METADATA_SIZE) { pjdlog_errno(LOG_ERR, "Unable to write metadata"); goto end; } ret = 0; end: free(buf); nv_free(nv); return (ret); }
void nv_lr_free(nv_lr_t **lr) { if (*lr) { nv_matrix_free(&(*lr)->w); nv_free(*lr); *lr = NULL; } }
void otama_image_free(otama_image_t **image) { if (image && *image) { nv_matrix_free(&(*image)->image); nv_free(*image); *image = NULL; } }
void nv_pa_free(nv_pa_t **pa) { if (pa && *pa) { nv_matrix_free(&(*pa)->w); nv_free(*pa); *pa = NULL; } }
u32 nv_read_rand_test(u32 nvid) { u32 ret; u8* tempdata; u32 i= 0; struct nv_ref_data_info_stru ref_info = {0}; struct nv_file_list_info_stru file_info = {0}; ret = nv_search_byid(nvid, (u8*)NV_GLOBAL_CTRL_INFO_ADDR,&ref_info,&file_info); if(NV_OK != ret) { return ret; } if(ref_info.nv_len == 0) { return NV_ERROR; } tempdata = (u8*)nv_malloc((u32)(ref_info.nv_len) +1); if(NULL == tempdata) { return BSP_ERR_NV_MALLOC_FAIL; } ret = bsp_nvm_read(nvid,tempdata,ref_info.nv_len); if(NV_OK != ret) { nv_free(tempdata); return BSP_ERR_NV_READ_DATA_FAIL; } for(i=0;i<ref_info.nv_len;i++) { if((i%16) == 0) { printf("\n"); } printf("%2.2x ",(u8)(*(tempdata+i))); } printf("\n"); nv_free(tempdata); return NV_OK; }
void nv_arow_free(nv_arow_t **arow) { if (arow && *arow) { nv_matrix_free(&(*arow)->w); nv_matrix_free(&(*arow)->bias); nv_free(*arow); *arow = NULL; } }
void nv_bgseg_free(nv_bgseg_t **bg) { if (bg && *bg) { nv_matrix_free(&(*bg)->av); nv_matrix_free(&(*bg)->sgm); nv_free(*bg); *bg = NULL; } }
/* *get file info in back ,default,nvdload */ u32 nv_sec_file_info_init(const s8* name,struct nv_file_info_stru* sec_info) { u32 ret = NV_ERROR; u32 file_len = 0; struct nv_file_info_stru info; struct nv_ctrl_file_info_stru ctrl_info; u8* file_info; /*first: read nv ctrl file*/ ret = (u32)bsp_nand_read((char*)name,0,&ctrl_info,sizeof(ctrl_info),NULL); if(NAND_OK != ret) { printf("[%s]:patrition name %s,get file magic fail ret 0x%x,\n",__func__,name,ret); return ret; } /*second :check magic num in file head*/ if(ctrl_info.magicnum != NV_CTRL_FILE_MAGIC_NUM) { printf("[%s]:enter this way 1111! %s\n",__func__,name); return NV_OK; } /*third: read all nv ctrl file*/ file_info = (u8*)nv_malloc(ctrl_info.file_size+1); if(NULL == file_info) { printf("[%s]:enter this way 2222! %s\n",__func__,name); return BSP_ERR_NV_MALLOC_FAIL; } ret = (u32)bsp_nand_read((char*)name,sizeof(struct nv_ctrl_file_info_stru),file_info,ctrl_info.file_size,NULL); if(NAND_OK != ret) { printf("[%s]:enter this way 3333! %s\n",__func__,name); goto init_end; } /*fourth: count nv file len base the ctrl file info*/ ret = nv_get_bin_crc_file_len(&ctrl_info,(struct nv_file_list_info_stru*)file_info,&file_len); if(ret) { printf("[%s]:enter this way 4444! %s\n",__func__,name); goto init_end; } info.len = file_len; info.magic_num = NV_FILE_EXIST; info.off = 0; memcpy(sec_info,&info,sizeof(info)); init_end: nv_free(file_info); return NV_OK; }
int nvlist_send(int sock, const nvlist_t *nvl) { size_t datasize, nfds; int *fds; void *data; int64_t fdidx; int ret; if (nvlist_error(nvl) != 0) { ERRNO_SET(nvlist_error(nvl)); return (-1); } fds = nvlist_descriptors(nvl, &nfds); if (fds == NULL) return (-1); ret = -1; data = NULL; fdidx = 0; data = nvlist_xpack(nvl, &fdidx, &datasize); if (data == NULL) goto out; if (buf_send(sock, data, datasize) == -1) goto out; if (nfds > 0) { if (fd_send(sock, fds, nfds) == -1) goto out; } ret = 0; out: ERRNO_SAVE(); nv_free(fds); nv_free(data); ERRNO_RESTORE(); return (ret); }
void nv_matrix_free(nv_matrix_t **matrix) { if (*matrix != NULL) { if ((*matrix)->alias == 0) { nv_aligned_free((*matrix)->v); } nv_free(*matrix); *matrix = NULL; } }
void nv_shapecontext_free(nv_shapecontext_t **sctx) { if (*sctx) { nv_matrix_free(&(*sctx)->sctx); nv_matrix_free(&(*sctx)->tan_angle); nv_matrix_free(&(*sctx)->coodinate); nv_matrix_free(&(*sctx)->radius); nv_free(*sctx); *sctx = NULL; } }
void nv_plsi_free(nv_plsi_t **p) { if (*p) { nv_matrix_free(&(*p)->z); nv_matrix_free(&(*p)->dz); nv_matrix_free(&(*p)->wz); nv_free(*p); *p = NULL; } }
void nv_mlp_free(nv_mlp_t **mlp) { if (*mlp) { nv_matrix_free(&(*mlp)->input_w); nv_matrix_free(&(*mlp)->input_bias); nv_matrix_free(&(*mlp)->hidden_w); nv_matrix_free(&(*mlp)->hidden_bias); nv_free(*mlp); *mlp = NULL; } }
u32 nv_function_test(void) { u32 i; u32 ret; struct nv_ctrl_file_info_stru* ctrl_info = (struct nv_ctrl_file_info_stru*)NV_GLOBAL_CTRL_INFO_ADDR; struct nv_ref_data_info_stru* ref_info = (struct nv_ref_data_info_stru*)(NV_GLOBAL_CTRL_INFO_ADDR+NV_GLOBAL_CTRL_INFO_SIZE\ +NV_GLOBAL_FILE_ELEMENT_SIZE*ctrl_info->file_num); u8* pdata; u32 start,end; start = bsp_get_slice_value(); pdata = (u8*)nv_malloc(3072); if(NULL == pdata) { return NV_ERROR; } for(i = 0;i<100;i++) { printf("*****************read & write 0x%x****************\n",ref_info->itemid); ret = bsp_nvm_read(ref_info->itemid,pdata,ref_info->nv_len); if(ret) { nv_free(pdata); return ret; } ret = bsp_nvm_write(ref_info->itemid,pdata,ref_info->nv_len); if(ret) { nv_free(pdata); return ret; } ref_info++; } end = bsp_get_slice_value(); nv_free(pdata); printf("[%s]:slice 0x%x\n",__func__,end-start); return NV_OK; }
void nv_pstable_free(nv_pstable_t **ps) { if (ps != NULL && *ps != NULL) { nv_matrix_free(&(*ps)->a); nv_matrix_free(&(*ps)->b); nv_matrix_free(&(*ps)->r1); nv_matrix_free(&(*ps)->r2); nv_free(*ps); *ps = NULL; } }
/* * Thread sends requests back to primary node. */ static void * send_thread(void *arg) { struct hast_resource *res = arg; struct nv *nvout; struct hio *hio; void *data; size_t length; for (;;) { pjdlog_debug(2, "send: Taking request."); QUEUE_TAKE(send, hio); reqlog(LOG_DEBUG, 2, -1, hio, "send: (%p) Got request: ", hio); nvout = nv_alloc(); /* Copy sequence number. */ nv_add_uint64(nvout, hio->hio_seq, "seq"); switch (hio->hio_cmd) { case HIO_READ: if (hio->hio_error == 0) { data = hio->hio_data; length = hio->hio_length; break; } /* * We send no data in case of an error. */ /* FALLTHROUGH */ case HIO_DELETE: case HIO_FLUSH: case HIO_WRITE: data = NULL; length = 0; break; default: PJDLOG_ABORT("Unexpected command (cmd=%hhu).", hio->hio_cmd); } if (hio->hio_error != 0) nv_add_int16(nvout, hio->hio_error, "error"); if (hast_proto_send(res, res->hr_remoteout, nvout, data, length) < 0) { secondary_exit(EX_TEMPFAIL, "Unable to send reply."); } nv_free(nvout); pjdlog_debug(2, "send: (%p) Moving request to the free queue.", hio); hio_clear(hio); QUEUE_INSERT(free, hio); } /* NOTREACHED */ return (NULL); }
u32 nv_write_test_08(u32 itemid) { struct nv_file_list_info_stru file_info = {}; struct nv_ref_data_info_stru ref_info = {}; u8* pData = NULL; u32 ret = 0; pData = (u8*)nv_malloc(2*2048); if(NULL == pData) { nv_printf("alloc error\n"); return NV_ERROR; } ret = nv_search_byid(itemid, (u8 *)NV_GLOBAL_CTRL_INFO_ADDR, &ref_info, &file_info); if(ret) { nv_printf("nv_search_byid error\n"); nv_free(pData); return ret; } ret = bsp_nvm_read(itemid, pData, ref_info.nv_len); if(ret) { nv_printf("bsp_nvm_read error, ret = 0x%x 1111\n", ret); return ret; } pData[0]++; ret = bsp_nvm_write(itemid, pData, ref_info.nv_len); if(ret) { nv_printf("bsp_nvm_read error, ret = 0x%x 2222\n", ret); return ret; } nv_free(pData); return NV_OK; }