当前位置:网站首页>imx6ull看门狗使用
imx6ull看门狗使用
2022-07-31 11:52:00 【szembed】
一、内部看门狗
1、内部看门狗使用说明
内部看门狗使用WDOG1,
复位输出控制选择WDOG1_B —— MX6UL_PAD_GPIO1_IO08__WDOG1_WDOG_B
注:该引脚正常使用时为高电平,当看门狗超时或系统重启后输出低电平,仅设备重新上电才能够恢复为高电平。


【IMX6ULL参考手册(11/2017 )——59.5.6.2 WDOG_B generation (P4087)】
2、设备树配置
2.1配置输出引脚电器属性
&iomuxc {
pinctrl-names = "default";
……
pinctrl_gpio1_wdg1: gpio1_wdg1_grp {
fsl,pins = <
MX6UL_PAD_GPIO1_IO08__WDOG1_WDOG_B 0x30b0
>;
};
……
};
2.2配置看门狗参数
&wdog1 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_gpio1_wdg1>;
fsl,ext-reset-output;
timeout-sec = <5>;
status = "okay";
};
fsl,ext-reset-output 开启复位输出
timeout-sec 设置看门狗超时复位时间,上述配置为5S
3、内核配置
Device Drivers --->
[*] Watchdog Timer Support --->
[*] Update boot-enabled watchdog until userspace takes over
<*> IMX2+ Watchdog

4、验证
4.1烧写内核与设备树,重启系统
4.2查看设备

其中/dev/watchdog0便是内部看门狗WDOG1
4.3编写应用测试
-
#include <stdio.h>
-
#include <stdlib.h>
-
#include <string.h>
-
#include <unistd.h>
-
#include <fcntl.h>
-
#include <sys/ioctl.h>
-
#include <linux/types.h>
-
#include <linux/watchdog.h>
-
-
#define cst_str2(c1, c2) (((unsigned int)0 | \
-
(char)c2) << 8 | \
-
(char)c1)
-
-
-
int main(int argc, char *argv[])
-
{
-
int fd;
-
int flags;
-
int timeout =
10;
-
int dummy =
0;
-
-
fd =
open(
"/dev/watchdog0", O_WRONLY);
-
-
if (fd ==
-1) {
-
printf(
"Watchdog open fail.\n");
-
exit(
-1);
-
}
-
-
if (argc >
1) {
-
switch (
cst_str2(argv[
1][
0], argv[
1][
1]))
-
{
-
case cst_str2('-','s'):
-
if(argc > 2)
-
timeout =
atoi(argv[
2]);
-
ioctl(fd, WDIOC_SETTIMEOUT, &timeout);
-
printf(
"set timeout : %d\n", timeout);
-
break;
-
case cst_str2('-', 'g'):
-
ioctl(fd, WDIOC_GETTIMEOUT, &timeout);
-
printf(
"get timeout : %d\n", timeout);
-
break;
-
case cst_str2('-', 'e'): //使能看门狗
-
flags = WDIOS_ENABLECARD;
-
ioctl(fd, WDIOC_SETOPTIONS, &flags);
-
printf(
"Watchdog card enabled.\n");
-
break;
-
case cst_str2('-', 'd'): //禁用看门狗
-
flags = WDIOS_DISABLECARD;
-
ioctl(fd, WDIOC_SETOPTIONS, &flags);
-
printf(
"Watchdog card disabled.\n");
-
close(fd);
-
return
0;
-
break;
-
-
default:
-
printf(
"\
-
\t-s set timeout.\n\
-
\t-g get timeout.\n\
-
\t-d to disable.\n\
-
\t-e to enable.\n\
-
");
-
break;
-
}
-
}
-
-
while (
1) {
-
ioctl(fd, WDIOC_KEEPALIVE, &dummy);
//喂狗
-
sleep(
1);
-
}
-
}
二、外部看门狗
1、使用说明
imx6ull外部看门狗使用GPIO控制,利用GPIO输出高低电平保证看门狗芯片(CAT823TTDI-GT3 )不重启。

2、设备树配置
2.1配置输出引脚电器属性
&iomuxc {
pinctrl-names = "default";
……
pinctrl_gpio_wdog: gpio_wdg_grp {
fsl,pins = <
MX6UL_PAD_GPIO1_IO01__GPIO1_IO01 0x010b0
>;
};
……
};
2.2配置看门狗参数
/ {
model = "Freescale i.MX6 ULL 14x14 EVK Board";
compatible = "fsl,imx6ull-14x14-evk", "fsl,imx6ull";
……
watchdog {
compatible = "linux,wdt-gpio";
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_gpio_wdog>;
gpios = <&gpio1 1 GPIO_ACTIVE_LOW>;
hw_algo = "toggle";
always-running;
hw_margin_ms = <1000>;
};
……
};
hw_margin_ms 电平反转周期
3、内核配置
Device Drivers --->
[*] Watchdog Timer Support --->
[*] Update boot-enabled watchdog until userspace takes over
<*> Watchdog device controlled through GPIO-line
[*] Register the watchdog as early as possible

4、验证
4.1烧写内核与设备树,重启系统
4.2查看设备

其中/dev/watchdog1便是外部看门狗设备,无需控制,GPIO1_IO01引脚每隔1000ms自动进行两次电平反转。

边栏推荐
- After class, watching the documentation and walking back to the lab, I picked up the forgotten SQL operators again
- B/S架构模式的一个整体执行流程
- Power BI----几个常用的分析方法和相适应的视觉对象
- 科学论文和学术论文写作
- 分布式事务Seata详细使用教程
- Acwing第 62 场周赛【未完结】
- 线程池 ThreadPoolExecutor 详解
- Android studio connects to MySQL and completes simple login and registration functions
- 便利贴--46{基于移动端长页中分页加载逻辑封装}
- mysql 索引使用与优化
猜你喜欢

The item 'node.exe' was not recognized as the name of a cmdlet, function, script file, or runnable program.

多线程学习笔记-2.final关键字和不变性

下课看着文档走回实验室,我重新拾起了遗忘的SQL运算符

透过开发抽奖小程序,体会创新与迭代

AWS Amazon cloud account registration, free application for 12 months Amazon cloud server detailed tutorial

Docker实践经验:Docker 上部署 mysql8 主从复制

准确率(Accuracy)、精度(Precision)、召回率(Recall)和 mAP 的图解

Mysql环境变量的配置(详细图解)

分布式事务——分布式事务简介、分布式事务框架 Seata(AT模式、Tcc模式、Tcc Vs AT)、分布式事务—MQ

WebGL给Unity传递参数问题1: Cannot read properties of undefined (reading ‘SendMessage‘)
随机推荐
ApiPost is really fragrant and powerful, it's time to throw away Postman and Swagger
keras自带数据集(横线生成器)
kubernetes之服务发现
关于Mysql数据库的介绍
科学论文和学术论文写作
MySQL模糊查询性能优化
最新MySql安装教学,非常详细
三六零与公安部三所发布报告:关基设施保护成为网络安全博弈关键
LeetCode - 025. 链表中的两数相加
在 Excel 内使用 ODBC 消费 SAP ABAP CDS view
R 语言data.frame 中的另一行中减去一行
基于C51实现按键控制
mysql根据多字段分组——group by带两个或多个参数
MySQL 的几种碎片整理方案总结(解决delete大量数据后空间不释放的问题)
Power BI----几个常用的分析方法和相适应的视觉对象
Three-tier architecture service, dao, controller layer
xmind使用指南(XMind具有下列哪些功能)
Summary of several defragmentation schemes for MySQL (to solve the problem of not releasing space after deleting a large amount of data)
Life is endless, there are more questions, simple questions to learn knowledge points
一文带你了解redux的工作流程——actionreducerstore
