liusir

liusir

0个粉丝

28

问答

0

专栏

2

资料

liusir  发布于  2016-03-22 09:27:54
采纳率 0%
28个问答
11681

【已解决】Hi3516实现uboot自动升级(U盘),如何加入led指示?

 
本帖最后由 goodman 于 2016-3-23 12:04 编辑

1.如果U盘不拔出,怎么防止重复升级
2.在Uboot升级或启动时如何加入正常启动、正在升级、升级成功、升级失败的LED指示。

麻烦了解这一块的前辈给我一些指点,谢谢!

补充内容 (2016-3-23 09:00):
问题已解决
我来回答
回答19个
时间排序
认可量排序

cfgrpg

0个粉丝

7

问答

0

专栏

1

资料

cfgrpg 2016-03-22 11:05:43
认可0
1、防止重复升级,可以在升级文件的name上做文章,加入型号,版本号,并且在uboot环境变量中加上当前的型号,版本号,升级的时候读取环境变量的型号和版本号进行对比,再决定是否升级。
如:[code]../bin/pc/mkimage -A arm -T filesystem -C none -n "hi3518ev200-ly96_0008" -d rootfs_hi3518ev200_64k.jffs2 rootfs[/code]
hi3518ev200-ly96_0008 包含cpu型号,产品型号,版本号。其他的升级文件都可以照着此方法来做。

2、uboot下直接操作led的io,来控制灯。

liusir

0个粉丝

28

问答

0

专栏

2

资料

liusir 2016-03-22 13:48:52
认可0
[quote][url=forum.php?mod=redirect&goto=findpost&pid=27121&ptid=10609]cfgrpg 发表于 2016-3-22 11:05[/url]
1、防止重复升级,可以在升级文件的name上做文章,加入型号,版本号,并且在uboot环境变量中加上当前的型号 ...[/quote]

谢谢您,前辈。
我还有个疑问:因为每次升级时都是新的版本号,那是不是每次升级之前都要设置一下这个环境变量呢?

cfgrpg

0个粉丝

7

问答

0

专栏

1

资料

cfgrpg 2016-03-22 14:28:15
认可0
[quote][url=forum.php?mod=redirect&goto=findpost&pid=27135&ptid=10609]liusir 发表于 2016-3-22 13:48[/url]
谢谢您,前辈。
我还有个疑问:因为每次升级时都是新的版本号,那是不是每次升级之前都要设置一下这个环 ...[/quote]

升级成功了,更新版本号为当前的版本号。

liusir

0个粉丝

28

问答

0

专栏

2

资料

liusir 2016-03-22 16:11:11
认可0
[quote][url=forum.php?mod=redirect&goto=findpost&pid=27140&ptid=10609]cfgrpg 发表于 2016-3-22 14:28[/url]
升级成功了,更新版本号为当前的版本号。[/quote]

升级成功后,uboot会自动更新版本号为当前版本号吗?

david

33个粉丝

368

问答

253

专栏

229

资料

david 2016-03-22 17:31:38
认可0
在2楼的基础上,建议在升级文件的前放8个字节,其中4字节 Magic_Num 用来判断当前文件是不是有效文件,后面四个字节可以放一些版本号啥的。
判断完了后,烧写前把这8个字节干掉。

liusir

0个粉丝

28

问答

0

专栏

2

资料

liusir 2016-03-22 20:48:44
认可0
[quote][url=forum.php?mod=redirect&goto=findpost&pid=27171&ptid=10609]david 发表于 2016-3-22 17:31[/url]
在2楼的基础上,建议在升级文件的前放8个字节,其中4字节 Magic_Num 用来判断当前文件是不是有效文件,后面 ...[/quote]

好的,谢谢您认真的回复

goodman

2个粉丝

30

问答

18

专栏

17

资料

goodman 2016-03-22 21:48:11
认可0
[quote][url=forum.php?mod=redirect&goto=findpost&pid=27189&ptid=10609]liusir 发表于 2016-3-22 20:48[/url]
好的,谢谢您认真的回复[/quote]

问题解决了,请把问题标记为【已解决】

liusir

0个粉丝

28

问答

0

专栏

2

资料

liusir 2016-03-23 08:57:35
认可0
[quote][url=forum.php?mod=redirect&goto=findpost&pid=27192&ptid=10609]goodman 发表于 2016-3-22 21:48[/url]
问题解决了,请把问题标记为【已解决】[/quote]

好的,没经验,以后要多多指教

liusir

0个粉丝

28

问答

0

专栏

2

资料

liusir 2016-03-24 16:11:56
认可0
[quote][url=forum.php?mod=redirect&goto=findpost&pid=27121&ptid=10609]cfgrpg 发表于 2016-3-22 11:05[/url]
1、防止重复升级,可以在升级文件的name上做文章,加入型号,版本号,并且在uboot环境变量中加上当前的型号 ...[/quote]

“在uboot环境变量中加上当前的型号,版本号”,这个具体的是怎么添加呢?可以指点一下思路吗?

cfgrpg

0个粉丝

7

问答

0

专栏

1

资料

cfgrpg 2016-03-24 16:28:54
认可0
[quote][url=forum.php?mod=redirect&goto=findpost&pid=27306&ptid=10609]liusir 发表于 2016-3-24 16:11[/url]
“在uboot环境变量中加上当前的型号,版本号”,这个具体的是怎么添加呢?可以指点一下思路吗?[/quote]

1、比如3518ev200 ,在include/configs/hi3518ev200.h 中增加如下宏。
[code]#define CONFIG_FIRMWAREVER        "hi3518ev200-ly96_0001"                /* fireware version */[/code]

2、在common/env_common.c 中的default_environment中增加如下代码
[code]#ifdef        CONFIG_FIRMWAREVER
        "firmware="        CONFIG_FIRMWAREVER                "\0"
#endif[/code]

就跟头文件中的默认ip ,bootarg一样,可以搜索下。

liusir

0个粉丝

28

问答

0

专栏

2

资料

liusir 2016-03-24 16:38:15
认可0
[quote][url=forum.php?mod=redirect&goto=findpost&pid=27314&ptid=10609]cfgrpg 发表于 2016-3-24 16:28[/url]
1、比如3518ev200 ,在include/configs/hi3518ev200.h 中增加如下宏。


[/quote]

恩恩,好的,太感谢你了!

liusir

0个粉丝

28

问答

0

专栏

2

资料

liusir 2016-03-25 11:15:24
认可0
[quote][url=forum.php?mod=redirect&goto=findpost&pid=27314&ptid=10609]cfgrpg 发表于 2016-3-24 16:28[/url]
1、比如3518ev200 ,在include/configs/hi3518ev200.h 中增加如下宏。


[/quote]

我在include/configs/hi3516a.h文件中添加一个宏定义:
[code]#define CONFIG_FIRMWAREVER        "hi3516av300-ls16_0001"                /* fireware version */[/code]

在common/env_common.c文件中添加下面几行代码:
[code]#ifdef        CONFIG_FIRMWAREVER
        "firmware="        CONFIG_FIRMWAREVER                "\0"
#endif[/code]


然后在product/hiupdate/auto_update.c文件中加入下面代码
[code]static int check_version(void)
{
        image_header_t *hdr;
        char *new_ver,*old_ver;

        old_ver = getenv(firmware);
        if (NULL == old_ver)
        {
                printf("The old_ver is null!!!!!!!!!!!!\n");
                return 0;
        }

        *new_ver = (unsigned long)ntohl(hdr->ih_name[IH_NMLEN]);

        if (!(strcmp(new_ver,old_ver)))
        {
                printf("The version had been the best version!\n" );
                return 1;
        }

        return 0;
}


//auto_update.c文件中的头文件为:
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include [/code]



结果编译时报错:
auto_update.c: In function ‘check_version’:
auto_update.c:180:19: error: ‘firmware’ undeclared (first use in this function)
  old_ver = getenv(firmware);
                   ^
auto_update.c:180:19: note: each undeclared identifier is reported only once for each function it appears in
/home/liusz/git/uboot/uboot_hi3516a_s030/config.mk:252: recipe for target 'auto_update.o' failed
make[1]: *** [auto_update.o] Error 1
make[1]: Leaving directory '/home/liusz/git/uboot/uboot_hi3516a_s030/product/hiupdate'
Makefile:415: recipe for target 'product/hiupdate/libhiupdate.a' failed
make: *** [product/hiupdate/libhiupdate.a] Error 2


我觉得错误在getenv(firmware),但不知道怎么修改?还有getenv()函数的参数是环境变量名的指针,不知道直接使用firmware对吗?


能不能指点一下,谢谢啦。

cfgrpg

0个粉丝

7

问答

0

专栏

1

资料

cfgrpg 2016-03-27 09:54:18
认可0
[quote][url=forum.php?mod=redirect&goto=findpost&pid=27382&ptid=10609]liusir 发表于 2016-3-25 11:15[/url]
我在include/configs/hi3516a.h文件中添加一个宏定义:


[/quote]

[code]       char *p = getenv("firmware");
        if (p == NULL)
        return 0;

    g_auversion = strdup(p);
        if (g_auversion == NULL)
        return 0;[/code]

[code]setenv("firmware", image_get_name(hdr));[/code]

[code]    char *versd = strrchr(image_get_name(hdr), '_');
    char *vercur = strrchr(g_auversion, '_');
    if(versd == NULL || vercur == NULL)
    {
        printf("check version error:%s|||%s\n", g_auversion, image_get_name(hdr));
        return -1;
    }
    printf("versd->%s|vercur->%s\n", versd+1, vercur+1);
    if(strncmp(g_auversion, image_get_name(hdr), strlen(g_auversion) - strlen(vercur)))
    {
        printf("model number error:%s|||%s\n", g_auversion, image_get_name(hdr));
        return -1;
    }

    if(simple_strtoul(versd+1,NULL,10) <= simple_strtoul(vercur+1,NULL,10))
    {
        printf("same or low version:versd->%s|vercur->%s\n", versd+1, vercur+1);
        return -1;
    }
    printf("----------updating-------\n");[/code]

liusir

0个粉丝

28

问答

0

专栏

2

资料

liusir 2016-03-28 09:03:24
认可0
[quote][url=forum.php?mod=redirect&goto=findpost&pid=27502&ptid=10609]cfgrpg 发表于 2016-3-27 09:54[/url]
[/quote]

真是太感谢你了

yeahtoo

0个粉丝

6

问答

0

专栏

0

资料

yeahtoo 2017-12-01 19:34:54
认可0
[quote][url=forum.php?mod=redirect&goto=findpost&pid=27121&ptid=10609]cfgrpg 发表于 2016-3-22 11:05[/url]
1、防止重复升级,可以在升级文件的name上做文章,加入型号,版本号,并且在uboot环境变量中加上当前的型号 ...[/quote]

请教大神,“2、uboot下直接操作led的io,来控制灯。”,这步是怎么实现的,可以指点下吗谢谢?

ngswfx

1个粉丝

55

问答

1

专栏

40

资料

ngswfx 2017-12-02 14:07:16
认可0
本帖最后由 ngswfx 于 2017-12-2 14:09 编辑

[quote][url=forum.php?mod=redirect&goto=findpost&pid=81509&ptid=10609]yeahtoo 发表于 2017-12-1 19:34[/url]
请教大神,“2、uboot下直接操作led的io,来控制灯。”,这步是怎么实现的,可以指点下吗谢谢?[/quote]

就是标准的gpio操作,我开始也不知道,其实非常简单

开始还想着需要一个特殊的写寄存器的函数,后来一看uboot代码,直接访问寄存器地址了

下面代码有你需要的操作方法:注意里面代码可能牵扯好几个不同板子,

GPIO_LED_CON = 0x00;
        GPIO_LED_DIR = 0xFF;
        GPIO_LED_DAT = 0x00;

就是亮灯

GPIO_LED_CON = 0x00;
        GPIO_LED_DIR = 0xFF;
        GPIO_LED_DAT = 0xFF; 就是灭灯



////////////////////////////////////

#define GPIO8_5_CON (*((volatile unsigned int *)0x200F0000))//GPIO控制寄存器
#define GPIO8_5_DIR (*((volatile unsigned int *)0x201D0400))//GPIO方向寄存器
#define GPIO8_5_DAT (*((volatile unsigned int *)0x201D0080))//GPIO数据寄存器
/////////////////////
#define GPIO_LED_CON GPIO8_5_CON
#define GPIO_LED_DIR GPIO8_5_DIR
#define GPIO_LED_DAT GPIO8_5_DAT
//板子上有个LED UART1_CTSN  
//196 UART1_CTSN muxctrl_reg21 GPIO5_2 UART1_CTSN PWM_SVB
//偏移地址0x054
///#define GPIO5_REG_BASE                        0x201A0000
#define GPIO5_2_CON (*((volatile unsigned int *)0x200F0054))//GPIO控制寄存器
#define GPIO5_2_DIR (*((volatile unsigned int *)0x201A0400))//GPIO方向寄存器
#define GPIO5_2_DAT (*((volatile unsigned int *)0x201A0010))//GPIO数据寄存器  // 00 00000100 00  10000 0x10
///////////////////////
void led_on(void)//on led
{
        watchdog_reset();
        GPIO_LED_CON = 0x00;
        GPIO_LED_DIR = 0xFF;
        GPIO_LED_DAT = 0x00;
        /////////ZW////////////
        GPIO5_2_CON = 0x00;
        GPIO5_2_DIR = 0xFF;
        GPIO5_2_DAT = 0x00;
}
void led_off(void)//off led
{
        watchdog_reset();
        GPIO_LED_CON = 0x00;
        GPIO_LED_DIR = 0xFF;
        GPIO_LED_DAT = 0xFF;
        ////////////////
        GPIO5_2_CON = 0x00;
        GPIO5_2_DIR = 0xFF;
        GPIO5_2_DAT = 0xFF;
}
void led_flash_Failed()//write flash  failed run
{
        GPIO_LED_CON = 0x00;
        GPIO_LED_DIR = 0xFF;
        ///////////////
        GPIO5_2_CON = 0x00;
        GPIO5_2_DIR = 0xFF;
        while(1)
        {
                GPIO_LED_DAT = 0x0;
                GPIO5_2_DAT = 0x0;
                udelayMs(1500);
                GPIO_LED_DAT = 0XFF;
                GPIO5_2_DAT = 0XFF;
                udelayMs(1500);
        }
}

/////////////开始写
void led_flash_Start()
{
        led_off();
        udelayMs(200);
        led_on();
        udelayMs(200);
        led_off();
        udelayMs(200);
        led_on();
        udelayMs(200);
        led_off();
        udelayMs(200);
        led_on();
        udelayMs(200);
        led_off();
        udelayMs(200);
        led_on();
        udelayMs(200);
}
///////////////////////////////////////////////////////////////////////////////////

yeahtoo

0个粉丝

6

问答

0

专栏

0

资料

yeahtoo 2017-12-04 10:17:34
认可0
[quote][url=forum.php?mod=redirect&goto=findpost&pid=81525&ptid=10609]ngswfx 发表于 2017-12-2 14:07[/url]
就是标准的gpio操作,我开始也不知道,其实非常简单

开始还想着需要一个特殊的写寄存器的函数,后来 ...[/quote]

大神,感激不尽:handshake

浅浅

0个粉丝

9

问答

0

专栏

0

资料

浅浅 2019-08-14 16:11:13
认可0
LED提示怎么加的求指导啊

qn1522720710

0个粉丝

9

问答

0

专栏

0

资料

qn1522720710 2020-06-09 20:21:51
认可0
[quote][url=forum.php?mod=redirect&goto=findpost&pid=81525&ptid=10609]ngswfx 发表于 2017-12-2 14:07[/url]
就是标准的gpio操作,我开始也不知道,其实非常简单

开始还想着需要一个特殊的写寄存器的函数,后来 ...[/quote]

uboot下能创建线程吗,做下载闪烁提示,好像不大好搞!
或将文件直接拖到这里
悬赏:
E币
网盘
* 网盘链接:
* 提取码:
悬赏:
E币

Markdown 语法

  • 加粗**内容**
  • 斜体*内容*
  • 删除线~~内容~~
  • 引用> 引用内容
  • 代码`代码`
  • 代码块```编程语言↵代码```
  • 链接[链接标题](url)
  • 无序列表- 内容
  • 有序列表1. 内容
  • 缩进内容
  • 图片![alt](url)
+ 添加网盘链接/附件

Markdown 语法

  • 加粗**内容**
  • 斜体*内容*
  • 删除线~~内容~~
  • 引用> 引用内容
  • 代码`代码`
  • 代码块```编程语言↵代码```
  • 链接[链接标题](url)
  • 无序列表- 内容
  • 有序列表1. 内容
  • 缩进内容
  • 图片![alt](url)
举报反馈

举报类型

  • 内容涉黄/赌/毒
  • 内容侵权/抄袭
  • 政治相关
  • 涉嫌广告
  • 侮辱谩骂
  • 其他

详细说明

易百纳技术社区