8953系列----在aboot中读取boot version
来源:互联网 发布:黑马程序员 课程表 编辑:程序博客网 时间:2024/04/30 22:14
在aboot.c中
void get_image_version(unsigned char *buf)
{
unsigned long long ptn = 0;
int index = INVALID_PTN;
char *src_ptr;
char *dest_str;
uint32_t ret = 0,blocksize;
src_ptr = malloc(PAGE_SIZE + 1); //先搞个buffer
memset((void*)src_ptr,0,PAGE_SIZE + 1);
index = partition_get_index("boot"); //获取boot在partition中的位置
if(!index)
{
dprintf(CRITICAL,"get boot index failed!\n");
goto error;
}
mmc_set_lun(partition_get_lun(index));
ptn = partition_get_offset(index); //获取offset
if(!ptn)
{
dprintf(CRITICAL,"get boot sector offset failed!\n");
goto error;
}
blocksize = mmc_get_device_blocksize(); //获取block大小
if(!src_ptr)
{
dprintf(CRITICAL, "Failed to allocate memory for src_ptr!\n");
goto error;
}
ret = mmc_read(ptn,(uint32_t*)src_ptr,blocksize); //读取内容
if(ret)
{
dprintf(CRITICAL,"read boot header info failed!\n");
goto error;
}
dest_str = findstr_in_binheader(src_ptr,"buildv=",512); //找到对应的字符串
if(!dest_str)
{
dprintf(CRITICAL,"get image version failed.\n");
goto error;
}
snprintf((char*)buf, MAX_RSP_SIZE, "%s",dest_str);
error:
free(src_ptr);
return;
}
char* findstr_in_binheader(char* src,const char* target,int src_size)
{
char *head,*tail,*pos,*result;
head = src;
tail = src + src_size;
for(pos = head; pos != tail;pos++)
{
if(!*pos)
continue;
if((result = strstr(pos,target)))
return result + strlen(target);
}
return NULL;
}
- 8953系列----在aboot中读取boot version
- 在Aboot中添加i2c使用得方法二
- 在U-BOOT中实现读取电池电量
- 在构建maven项目中 <version>${spring.version}</version>含义
- 在Spring-boot中,为@Value注解添加从数据库读取properties支持
- Spring boot 在Java文件中读取Resource下的文件
- Spring Boot系列(三):Spring Boot中Redis的使用
- torch系列:torch中如何读取存放在hdf5文件中的字符串
- Spring Boot:在Spring Boot中使用Mysql和JPA
- Spring Boot:在Spring Boot中使用定时任务
- Spring Boot:在Spring Boot中使用定时任务
- Spring Boot入门一:在Eclipse中使用Spring boot
- Spring-boot中读取config配置文件的两种方式
- Spring-boot中读取config配置文件的两种方式
- spring boot中properties类读取配置文件的Date
- spring boot 中配置文件的读取和多环境配置
- Spring-boot中读取config配置文件的两种方式
- Spring-boot中读取config配置文件的两种方式
- 小程序中圆角边框的设置
- SpringMVC容器中Servlet如何调用service层接口
- 特殊文件--proc文件系统
- adb logcat命令查看并过滤android输出log
- Faster R-CNN实验记录总结
- 8953系列----在aboot中读取boot version
- final关键字
- 如何让浏览器主动识别网站icon图标
- Hrbust 1801 肖申克的救赎【Floyd求最大环】
- [译]在C中表示补码最小值
- redis中各种数据类型对应的jedis操作命令
- PHP登陆跳转
- 图像基本运算
- Linux文件夹权限777,无法创建文件