为OpenWrt添加实时钟(RTC)--以MT7620为例
来源:互联网 发布:python webservice 编辑:程序博客网 时间:2024/06/05 08:03
前言
实时钟,英文名RTC(Real Time Clock),在PC里面很常见,在OpenWrt里面却鲜有提及,手头上有一个DS1307的TinyRTC实时钟模块,经过一番折腾,将其融合到了OpenWrt系统,遂将操作过程记录成文.
背景知识
DS1307在最新的OpenWrt中已经提供支持,却没有整合进ramips中,因此,本文的一个重点便是如何为ramips系统配置ds1307.另外,为ds1307编写合适的dts节点也是本文的一个重点.
实现过程
1.为ramips配置ds1307支持
系统在./scripts/medatata.pl中判断并处理RTC_SUPPORT开关,分析之后,原来是在 target/linux/ramips/mt7620/target.mk中,将
原始的内容:
FEATURES+=usb
修改为:
FEATURES+=usb rtc
即可打开mt7620对rtc的支持.
此时,make kernel_menuconfig进入配置菜单.同时应注意,由于ds1307是i2c接口的模块,因此,在device中需要配置i2c的支持.选中i2c之后,便可以在
Device Drivers -> Real Time Clock中看到ds1307
.config - Linux/mips 3.14.28 Kernel Configuration > Device Drivers > Real Time Clock ───────────────────────────────────── ┌──── Dallas/Maxim DS1307/37/38/39/40, ST M41T00, EPSON RX-8025 ────┐ │ CONFIG_RTC_DRV_DS1307: │ │ │ │ If you say yes here you get support for various compatible RTC │ │ chips (often with battery backup) connected with I2C. This driver │ │ should handle DS1307, DS1337, DS1338, DS1339, DS1340, ST M41T00, │ │ EPSON RX-8025 and probably other chips. In some cases the RTC │ │ must already have been initialized (by manufacturing or a │ │ bootloader). │ │ │ │ The first seven registers on these chips hold an RTC, and other │ │ registers may add features such as NVRAM, a trickle charger for │ │ the RTC/NVRAM backup power, and alarms. NVRAM is visible in │ │ sysfs, but other chip features may not be available. │ │ │ │ This driver can also be built as a module. If so, the module │ │ will be called rtc-ds1307. │ │ │ │ Symbol: RTC_DRV_DS1307 [=y] │ │ Type : tristate │ │ Prompt: Dallas/Maxim DS1307/37/38/39/40, ST M41T00, EPSON RX-8025 │ │ Location: │ │ -> Device Drivers │ │ -> Real Time Clock (RTC_CLASS [=y]) │ │ Defined at drivers/rtc/Kconfig:166 │ │ Depends on: RTC_CLASS [=y] && I2C [=y] │ │ │ │ │ │ │ ├───────────────────────────────────────────────────────────(100%)──┤ │ < Exit > │ └───────────────────────────────────────────────────────────────────┘
2.为ds1307建立dts节点
配置好ds1307的编译开关后,接下来的工作就要在dts里面添加ds1307的设备节点.查阅ds1307的资料,其配置的i2c地址为0x68,因此,dts中可以添加如下内容:
i2c@0 { compatible = "i2c-gpio";gpios = <&gpio2 0 0 /* sda = wan_led*/ &gpio3 0 0 /* scl = wlan_led*/ >; i2c-gpio,delay-us = <10>;/* ~20 kHz */#address-cells = <1>;#size-cells = <0>;rtc@68 { compatible = "dallas,ds1307";reg = <0x68>; }; };完成这两步后,就可以make出支持ds1307的固件.
系统启动时,可以在TTL中看到如下内容:
[ 0.130000] i2c-gpio i2c.4: using pins 40 (SDA) and 72 (SCL)...[ 0.790000] rtc-ds1307 0-0068: rtc core: registered ds1307 as rtc0[ 0.810000] rtc-ds1307 0-0068: 56 bytes nvram...[ 0.810000] rtc-ds1307 0-0068: setting system clock to 2015-01-26 22:31:15 UTC (1422311475)
说明RTC已经成功的整合到了mt7620的系统中.
ps:系统自带的hwclock命令可以很方便的对RTC进行相应的操作.
后记
kernel 3.14.28中的i2c-ralink驱动已经能够正常驱动7620的硬件i2c,只是在用i2cdetect的时候,需要加上-r参数,这样才能正确probe到设备.
- 为OpenWrt添加实时钟(RTC)--以MT7620为例
- 为mt7620 RT5350添加reset按键
- 如何在OpenWrt中添加新的profile【以百度音乐盒为例】
- 无限可能!为MT7620添加N个SPI接口
- openwrt 离线安装curl(以MT7688为例)
- 以RTC为例分析linux platform_bus platform_device和platform_driver注册过程
- QEMU(基于QEMU 2.0.0)设备初始化流程 - realizefn 调用流程(以 RTC为例)
- 为OpenWrt添加service,自启动问题
- 为openwrt添加MT7620a的wifi驱动
- 为openwrt添加新的profile
- OpenWRT添加RTC时钟模块(DS1307)
- 编译openwrt官方不支持的路由型号固件——以WR720N为例
- openwrt 3G无线上网卡拨号--以华为EC189为例
- openwrt 3G无线上网卡拨号--以华为EC189为例
- OPENWRT网络打印机TCP/IP共享设置教程 以703N为例
- 编译openwrt官方不支持的路由型号固件——以WR720N为例
- 编译openwrt官方不支持的路由型号固件——以WR720N为例
- imx6之openwrt 3G无线上网卡拨号--以华为EC189为例
- javaweb种常见错误分析
- HDU 2204 Eddy's爱好 容斥
- java.lang.RuntimeException: Unable to instantiate activity ComponentInfo
- leetcode-----------Longest Substring Without Repeating Characters
- ssh无密码登陆终极解释
- 为OpenWrt添加实时钟(RTC)--以MT7620为例
- Linux显示登入系统的帐号名称和总人数
- android学习资料库
- ThinkPython摘录-Operators and operands
- Unity3D【火星大战一】
- mysql 中limit的用法
- Unity3D【火星大战二】
- [30天轻松掌握JavaWeb视频]-dom解析xml的增删查改
- [leetcode] Dungeon Game