hi3516a的uboot自动升级相关问题的解决
2016-04-08 20:03
351 查看
一.uboot命令行加密
实现uboot 进入命令行,需要输入密码功能。1.设置环境变量
在include/configs/hi3516a.h文件中
#define CONFIG_UBOOT_PWD
2.加密函数
common/main.c
在int readline (const char *const prompt)函数中添加下面代码
*time :2016.3.25 *func :command line add passwd *auther : liu *******************************/ #ifdef CONFIG_UBOOT_PWD char pwd[64]; char c; int index; static int bPwd = 1; while (bPwd) { puts ("password: "); index = 0; while ((c = getc()) != '\r') { if (c == 8) // Backspace { if (index > 0) { printf ("\b \b"); index--; } continue; } putc('*'); pwd[index] = c; index++; } pwd[index] = '\0'; putc ('\n'); char *s; s = getenv ("ubootpwd"); if (!s) { s = "123456"; } if (!strcmp (pwd, s)) { bPwd = 0; } } #endif
二.升级过程中led指示问题
实现功能:正在升级中(从内存拷贝到spi flash中):led闪5下
升级失败:led以 2次/s的频率闪
升级成功:关闭led
*time :2016.3.23 *func :on led *name :liusir *********************************************************************/ #define GPIO12_CON (*((volatile unsigned int *)0x200F01AC))//GPIO控制寄存器 #define GPIO12_DIR (*((volatile unsigned int *)0x20200400))//GPIO方向寄存器 #define GPIO12_DAT (*((volatile unsigned int *)0x20200004))//GPIO数据寄存器 void led_on(void)//on led { GPIO12_CON &= ~(0x3); GPIO12_DIR |= 0x1; GPIO12_DAT |= 0x1; } void led_off(void)//off led { GPIO12_CON &= ~(0x3); GPIO12_DIR |= 0x1; GPIO12_DAT &= ~(0x1); } void led_flash()//write flash failed run { GPIO12_CON &= ~(0x3); while(1) { GPIO12_DAT &= 0x0; udelay(2500000); GPIO12_DAT |= 0X1; udelay(2500000); } } for (int i = 0; i < 6; ++i)// write flash run { led_off(); udelay(100000); led_on(); udelay(100000); }
三.版本检测问题防止重复升级
1.设置环境变量include/configs/hi3516a.h
#define CONFIG_FIRMWAREVER //"3516A_uboot_20160328" #define CONFIG_KERNELVER //"3516A_kernel_20160328" #define CONFIG_ROOTFSVER //"3516A_rootfs_20160328" #define CONFIG_APPFSVER //"3516A_appfs_20160328" #define CONFIG_CONFSVER //"3516A_confs_20160328"
2.common/env_common.c
/************************** *time : 2016.3.23 ****************************/ #ifdef CONFIG_FIRMWAREVER "firmware_ver=" CONFIG_FIRMWAREVER "\0" #endif #ifdef CONFIG_KERNELVER "kernel_ver=" CONFIG_FIRMWAREVER "\0" #endif #ifdef CONFIG_ROOTFSVER "rootfs_ver=" CONFIG_FIRMWAREVER "\0" #endif #ifdef CONFIG_APPFSVER "appfs_ver=" CONFIG_FIRMWAREVER "\0" #endif #ifdef CONFIG_CONFSVER "confs_ver=" CONFIG_FIRMWAREVER "\0" #endif /*******************************************/
注意:如果想让该环境变量未设置之前print打印不显示的话,该段可以省略不加
3.检测版本是否相同(auto_update.c )
原理:通过对比版本号这个环境变量是否相同来决定是否升级。
/**************************************** *time : 2016.3.25 *func : check version *name : liu ****************************************/ static int check_version(int i) { char *env_img[AU_MAXFILES] = { "firmware_ver", "kernel_ver", "rootfs_ver", "appfs_ver", "confs_ver" }; const image_header_t *hdr; hdr = (image_header_t *)LOAD_ADDR; char *old_ver = getenv(env_img[i]);//get image version env if (NULL == old_ver) { printf("get env failed!\n"); return 0; } char *new_ver = image_get_name(hdr);//get image name if (!(strcmp((const char*)new_ver,(const char*)old_ver))) //compare version name { printf("The version had been the new version!\n" ); return 1; } printf("-------------updating---------------- %s\n",hdr->ih_name); setenv(env_img[j],image_get_name(hdr));//save new version env printf("the envriment have been save\n"); return 0; }
相关文章推荐
- hdoj-1496-Equations
- 未来在哪里
- HDU 1062 Text Reverse 字符串反转
- PostgreSQL异步客户端(并模拟redis 数据结构)
- C基础 北京大公司面试简单总结
- JZOJ 4296【NOIP2015模拟11.2】有趣的有趣的家庭菜园
- 关于筛选法的补充 素数较快筛选法 杭电1431
- UIButton
- ROC和AUC介绍以及如何计算AUC
- 朝闻道,夕死可矣!
- C语言读取CSV文件
- RecyclerView设置间距
- c3p0 使用及配置说明
- 【从VB.NET视频看学习态度】
- Linux搭建svn服务器并设置客户端提交自动更新
- c++ Lambda 表达式介绍
- 虚拟机类加载机制
- SpringMVC实现ajax文件上传
- 敏感词过滤 DFA 状态机 cocos2d-js 实现版
- 开发中常见的一些插件收藏