当前位置:网站首页>uboot 增加硬件看门狗
uboot 增加硬件看门狗
2022-07-15 23:58:00 【wandersky0822】
先说说uboot的编译过程:
1.make distclean
2.make defconfig
3. make
在执行上面之前,还需要必要 的设置,比如配置ARCH CROSS_COMPILE_等等,嵌入式开发中配置这个环境变量,要形成条件反射。 然后才能运行上面3步:
1. 清除,
2. 配置,这个得详细说说,这步就是根据configs/defconfig 文件,来做一些基本配置,并生成include/config.h头文件。
3. make 这才是真正的编译
其实uboot的框架 中是支持硬件看门狗的,
在系列配置文件中configs/mx6qsabreauto.h,定义CONFIG_HW_WATCHDOG
然后实现下面这2个函数,这2个函数 在watchdog.h中有声明,顾名思义,一个是初始化, 一个是喂狗,
void hw_watchdog_init(void);
void hw_watchdog_reset(void);
喂狗hw_watchdog_reset,在uboot中调用的频率非常高,不要试图在里面增加打印信息,一旦加printf,就会死机。
在uboot中增加看门狗,其实是不复杂的,但是我这个看门狗芯片用的是 MAX6323,这个芯片我第1次用,跟我之前用的看门狗不一样,我之前用的看门狗DS1832,只要一直喂狗,就不会产生复位,但是这个MAX6323,比较变态,喂快了也不行,喂慢了也不行,必须不快不慢才行,如下图:

这就比较麻烦了,如果在Uboot提供的喂猪函数hw_watchdog_reset()中,直接变换电平的话,会小于FAST模式的值,造成喂狗过快而复位,所以一定要把喂狗时间控制在15ms<t<10s, 这样才能满足MAX6323的要求。
上关键代码,解释: 喂狗中利用了芯片内部的get_ticks();在初始化ticks后,此函数得到的值会一直递增,因此可以利用此值来做一个记数,当满足这个记数时,才会在hw_watchdog_reset()中改变电平,
void hw_watchdog_reset(void)
{
static int sta =1;
static unsigned long long tim_bak = 0;
unsigned long long ticks = get_ticks();
if(ticks > tim_bak) {
if((ticks-tim_bak) > 1000000)
{
tim_bak = ticks;
if(sta){
sta = 0;
}
else{
sta = 1;
}
gpio_direction_output(IMX_GPIO_NR(4, 30), sta);
}
}
}边栏推荐
- Calculate the average wage excluding the maximum wage and the minimum wage of the Department (ByteDance interview)
- 电力系统机组组合(Matlab代码实现)
- Jeesite login process
- Installation method of memory module on dual channel (Dual CPU) server motherboard
- 【ES实战】Spark写入ES支持
- 如何基于知识图谱技术构建现代搜索引擎系统、智能问答系统、智能推荐系统?
- 无线通信安全作业2
- 低代码渲染那些事
- Flink (III) processing function
- 晴空一“鹤”排“云”上:以数为翅的中国飞鹤
猜你喜欢
随机推荐
Mqtt - quality of service QoS
subset sum problem
Intel helps open medical service and promote the intellectualization of ultrasonic prenatal examination
[unity3d] toggle of ugui
Flink (II) time and window
mysql 查询时过滤 html
Flink(四)分流合流
转本结束暑假2022.6.29-7.13我的深圳之行(体验)
伦敦银规则有哪一些?
Pytoch distributed training
PBFT简单介绍
Reading the pointpillar code of openpcdet -- Part 2: network structure
Quweihai: insisting on choosing and not giving up is the magic weapon to realize the original intention
Flink (VI) fault tolerance mechanism
Filter HTML during MySQL query
Pbft brief introduction
Reading the pointpillar code of openpcdet -- Part 1: data enhancement and data processing
Shutter ShowDialog Popup
如何写好论文的每个部分?
Vertical/Column text select in PyCharm



![[Flink] Flink connection reject: localhost / 127.0.0.1:8081](/img/46/6c5071016a04e511f1bbb9fe3f7643.jpg)





