SlideShare a Scribd company logo
TIMER DEVICE DRIVER 
(SYSTEM TIMER, RTC, WATCHDOG) 
1
系統宣告(arch/arm/mach-ixp4xx) 
MACHINE_START(IXDP425, "Intel IXDP425 Development Platform") 
/* Maintainer: MontaVista Software, Inc. */ 
.phys_io = IXP4XX_PERIPHERAL_BASE_PHYS, 
.io_pg_offst = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 
0xfffc, 
.map_io = ixp4xx_map_io, 
.init_irq = ixp4xx_init_irq, 
.timer = &ixp4xx_timer, 
.boot_params = 0x0100, 
.init_machine = ixdp425_init, 
MACHINE_END 
2
struct sys_timer armcpu_timer __initdata = 
{ 
.init = armcpu_timer_init, 
.offset = armcpu_gettimeoffset, 
.resume = armcpu_timer_setup, 
}; 
3 
Timer 資料結構宣告
static void armcpu_timer_setup(void) 
{ 
armcpu_timer_set_reload(USED_TIMER, APB_CLK/HZ); 
armcpu_timer_set_counter(USED_TIMER, APB_CLK/HZ); 
……………… 
} 
void __init armcpu_timer_init(void) 
{ 
armcpu_timer_setup(); 
setup_irq(IRQ_TIMER1, &armcpu_timer_irq); 
} 
4 
Timer Initiailzation
static irqreturn_t 
armcpu_timer_interrupt(int irq, void *dev_id) 
{ 
write_seqlock(&xtime_lock); 
timer_tick(); 
write_sequnlock(&xtime_lock); 
return IRQ_HANDLED; 
} 
5 
Timer interrupt
unsigned long armcpu_gettimeoffset (void) 
{ 
unsigned long volatile offsetticks; 
offsetticks = SET_COUNTER-armcpu_timer_get_counter(USED_TIMER); 
if ( *(volatile unsigned int *)(CPE_TIMER1_VA_BASE+TIMER_INTR_STATE) ) { 
offsetticks = SET_COUNTER-armcpu_timer_get_counter(USED_TIMER); 
offsetticks += SET_COUNTER; 
} 
offsetticks = offsetticks / (APB_CLK / 1000000); // tansfer ticks to usec 
return offsetticks; 
} 
6 
gettimeoffset callback 
#include <sys/time.h> 
int gettimeofday(struct timeval *tv, struct timezone *tz); 
struct timeval { 
time_t tv_sec; /* seconds */ 
suseconds_t tv_usec; /* microseconds */ 
};
RTC DRIVER 
7
簡單來看它就是一個時鐘,通常它只能計 
時至秒。 
大都規格是在一年內誤差為10幾秒。 
它需要電池供電,上電一輩子需要有一次 
啓動的動作,斷電後則時間停止。 
以PC為例系統時間(用date指令,或者任何 
API取得的時間)在開機時會讀入RTC時間並 
設定時間,關機時會將系統時間設回RTC。 
其應用層設定的程式為hwclock,使用的 
device node 為/dev/rtc (10, 135)。 
8 
RTC (Real Time Clock)
Usage: hwclock [-r|--show] [-s|--hctosys] [-w|--systohc] [-l|-- 
localtime] [-u|--utc] [-f FILE] 
Query and set hardware clock (RTC) 
Options: 
-r Show hardware clock time 
-s Set system time from hardware clock 
-w Set hardware clock to system time 
-u Hardware clock is in UTC 
-l Hardware clock is in local time 
-f FILE Use specified device (e.g. /dev/rtc2) 
9 
hwclock usage
RTC Device Driver Example 
可架構在misc之下 
主要是支援兩個ioctl command 
1) RTC_RD_TIME 讀取時間 
2) RTC_SET_TIME 設定時間 
struct rtc_time { 
int tm_sec; 
int tm_min; 
int tm_hour; 
int tm_mday; 
int tm_mon; 
int tm_year; 
int tm_wday; 
int tm_yday; 
int tm_isdst; 
}; 
10
Module Initialize Example 
static struct file_operations rtc_fops = { 
owner:THIS_MODULE, 
ioctl:rtc_ioctl, 
open:rtc_open, 
release:rtc_release, 
}; 
static struct miscdevice rtc_dev = { 
RTC_MINOR, 
"rtc", 
&rtc_fops 
}; 
static int __init rtc_init(void) 
{ 
misc_register(&rtc_dev); 
return 0; 
}
Ioctl Example 
static int 
rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) 
{ 
struct rtc_time rtc_tm; 
switch (cmd) { 
case RTC_RD_TIME: /* Read the time/date from RTC */ 
get_rtc_time(&rtc_tm); 
return copy_to_user((void *) arg, &rtc_tm, sizeof(rtc_tm)) ? -EFAULT : 0; 
case RTC_SET_TIME: /* Set the RTC */ 
if (copy_from_user(&rtc_tm, (struct rtc_time *) arg, sizeof(struct rtc_time))) 
return -EFAULT; 
// set to hardware RTC with the time 
return 0; 
default: 
return -EINVAL; 
} 
}
新RTC Driver 
Device node is put on /dev/misc directory. 
Up to 16 RTC node, from rtc0 
The major number is 254. 
The minor number is from 0. 
These are the same IOCTL command with the 
old type RTC driver. 
More features.
RTC Class Structure 
struct rtc_class_ops { 
int (*open)(struct device *); 
void (*release)(struct device *); 
int (*ioctl)(struct device *, unsigned int, unsigned long); 
int (*read_time)(struct device *, struct rtc_time *); 
int (*set_time)(struct device *, struct rtc_time *); 
int (*read_alarm)(struct device *, struct rtc_wkalrm *); 
int (*set_alarm)(struct device *, struct rtc_wkalrm *); 
int (*proc)(struct device *, struct seq_file *); 
int (*set_mmss)(struct device *, unsigned long secs); 
int (*irq_set_state)(struct device *, int enabled); 
int (*irq_set_freq)(struct device *, int freq); 
int (*read_callback)(struct device *, int data); 
int (*alarm_irq_enable)(struct device *, unsigned int enabled); 
int (*update_irq_enable)(struct device *, unsigned int enabled); 
};
RTC Time structure 
struct rtc_time { 
int tm_sec; 
int tm_min; 
int tm_hour; 
int tm_mday; 
int tm_mon; 
int tm_year; 
int tm_wday; 
int tm_yday; 
int tm_isdst; 
};
New RTC Driver Example 
static int rtc_read_time(struct device *dev, struct rtc_time *tm) 
{ 
……………. 
} 
static int rtc_set_time(struct device *dev, struct rtc_time *tm) 
{ 
………….. 
} 
static struct rtc_class_ops rtc_ops = { 
.read_time = rtc_read_time, 
.set_time = rtc_set_time, 
}; 
static struct rtc_device *rtc; 
static int rtc_module_init(void) 
{ 
………….. 
rtc = rtc_device_register(“name”, NULL, &rtc_ops, THIS_MODULE); 
if ( IS_ERR(rtc) { 
…….. 
} 
return 0; 
} 
static void rtc_module_exit(void) 
{ 
rtc_device_unregister(rtc); 
….. 
}
WATCHDOG DRIVER 
17
什麼是Watchdog 
1) 它是一種可以reset CPU的機制, 在一定的時間 
內需要觸發, 若沒有將會引起CPU reset 
它有什麼注意事項 
1) 小心檔案系統crashed, 因為它是直接CPU reset, 
並沒有做很好的shutdown動作 
2) 可能因為Flash在write state,使得reset之後無 
法boot from flash 
3) 硬體需配合reset CPU週邊元件, 否則系統還是 
無法reset 
View source code newwdt 
18 
Watchdog面面觀
Ad

More Related Content

What's hot (20)

Sysprog 16
Sysprog 16Sysprog 16
Sysprog 16
Ahmed Mekkawy
 
Character drivers
Character driversCharacter drivers
Character drivers
pradeep_tewani
 
Staging driver sins
Staging driver sinsStaging driver sins
Staging driver sins
Stephen Hemminger
 
grsecurity and PaX
grsecurity and PaXgrsecurity and PaX
grsecurity and PaX
Kernel TLV
 
Semtex.c [CVE-2013-2094] - A Linux Privelege Escalation
Semtex.c [CVE-2013-2094] - A Linux Privelege EscalationSemtex.c [CVE-2013-2094] - A Linux Privelege Escalation
Semtex.c [CVE-2013-2094] - A Linux Privelege Escalation
Kernel TLV
 
[嵌入式系統] MCS-51 實驗 - 使用 IAR (2)
[嵌入式系統] MCS-51 實驗 - 使用 IAR (2)[嵌入式系統] MCS-51 實驗 - 使用 IAR (2)
[嵌入式系統] MCS-51 實驗 - 使用 IAR (2)
Simen Li
 
U-boot and Android Verified Boot 2.0
U-boot and Android Verified Boot 2.0U-boot and Android Verified Boot 2.0
U-boot and Android Verified Boot 2.0
GlobalLogic Ukraine
 
Building Network Functions with eBPF & BCC
Building Network Functions with eBPF & BCCBuilding Network Functions with eBPF & BCC
Building Network Functions with eBPF & BCC
Kernel TLV
 
Zn task - defcon russia 20
Zn task  - defcon russia 20Zn task  - defcon russia 20
Zn task - defcon russia 20
DefconRussia
 
I2c drivers
I2c driversI2c drivers
I2c drivers
Pradeep Tewani
 
“Automation Testing for Embedded Systems”
“Automation Testing for Embedded Systems” “Automation Testing for Embedded Systems”
“Automation Testing for Embedded Systems”
GlobalLogic Ukraine
 
Kernel crashdump
Kernel crashdumpKernel crashdump
Kernel crashdump
Adrien Mahieux
 
Debugging linux kernel tools and techniques
Debugging linux kernel tools and  techniquesDebugging linux kernel tools and  techniques
Debugging linux kernel tools and techniques
Satpal Parmar
 
Linux Kernel MMC Storage driver Overview
Linux Kernel MMC Storage driver OverviewLinux Kernel MMC Storage driver Overview
Linux Kernel MMC Storage driver Overview
RajKumar Rampelli
 
“Linux Kernel CPU Hotplug in the Multicore System”
“Linux Kernel CPU Hotplug in the Multicore System”“Linux Kernel CPU Hotplug in the Multicore System”
“Linux Kernel CPU Hotplug in the Multicore System”
GlobalLogic Ukraine
 
Debugging linux
Debugging linuxDebugging linux
Debugging linux
Andrea Righi
 
[2007 CodeEngn Conference 01] dual5651 - Windows 커널단의 후킹
[2007 CodeEngn Conference 01] dual5651 - Windows 커널단의 후킹[2007 CodeEngn Conference 01] dual5651 - Windows 커널단의 후킹
[2007 CodeEngn Conference 01] dual5651 - Windows 커널단의 후킹
GangSeok Lee
 
Linux kernel debugging(ODP format)
Linux kernel debugging(ODP format)Linux kernel debugging(ODP format)
Linux kernel debugging(ODP format)
yang firo
 
Spectre(v1%2 fv2%2fv4) v.s. meltdown(v3)
Spectre(v1%2 fv2%2fv4) v.s. meltdown(v3)Spectre(v1%2 fv2%2fv4) v.s. meltdown(v3)
Spectre(v1%2 fv2%2fv4) v.s. meltdown(v3)
Gavin Guo
 
Linux interrupts
Linux interruptsLinux interrupts
Linux interrupts
mukul bhardwaj
 
grsecurity and PaX
grsecurity and PaXgrsecurity and PaX
grsecurity and PaX
Kernel TLV
 
Semtex.c [CVE-2013-2094] - A Linux Privelege Escalation
Semtex.c [CVE-2013-2094] - A Linux Privelege EscalationSemtex.c [CVE-2013-2094] - A Linux Privelege Escalation
Semtex.c [CVE-2013-2094] - A Linux Privelege Escalation
Kernel TLV
 
[嵌入式系統] MCS-51 實驗 - 使用 IAR (2)
[嵌入式系統] MCS-51 實驗 - 使用 IAR (2)[嵌入式系統] MCS-51 實驗 - 使用 IAR (2)
[嵌入式系統] MCS-51 實驗 - 使用 IAR (2)
Simen Li
 
U-boot and Android Verified Boot 2.0
U-boot and Android Verified Boot 2.0U-boot and Android Verified Boot 2.0
U-boot and Android Verified Boot 2.0
GlobalLogic Ukraine
 
Building Network Functions with eBPF & BCC
Building Network Functions with eBPF & BCCBuilding Network Functions with eBPF & BCC
Building Network Functions with eBPF & BCC
Kernel TLV
 
Zn task - defcon russia 20
Zn task  - defcon russia 20Zn task  - defcon russia 20
Zn task - defcon russia 20
DefconRussia
 
“Automation Testing for Embedded Systems”
“Automation Testing for Embedded Systems” “Automation Testing for Embedded Systems”
“Automation Testing for Embedded Systems”
GlobalLogic Ukraine
 
Debugging linux kernel tools and techniques
Debugging linux kernel tools and  techniquesDebugging linux kernel tools and  techniques
Debugging linux kernel tools and techniques
Satpal Parmar
 
Linux Kernel MMC Storage driver Overview
Linux Kernel MMC Storage driver OverviewLinux Kernel MMC Storage driver Overview
Linux Kernel MMC Storage driver Overview
RajKumar Rampelli
 
“Linux Kernel CPU Hotplug in the Multicore System”
“Linux Kernel CPU Hotplug in the Multicore System”“Linux Kernel CPU Hotplug in the Multicore System”
“Linux Kernel CPU Hotplug in the Multicore System”
GlobalLogic Ukraine
 
[2007 CodeEngn Conference 01] dual5651 - Windows 커널단의 후킹
[2007 CodeEngn Conference 01] dual5651 - Windows 커널단의 후킹[2007 CodeEngn Conference 01] dual5651 - Windows 커널단의 후킹
[2007 CodeEngn Conference 01] dual5651 - Windows 커널단의 후킹
GangSeok Lee
 
Linux kernel debugging(ODP format)
Linux kernel debugging(ODP format)Linux kernel debugging(ODP format)
Linux kernel debugging(ODP format)
yang firo
 
Spectre(v1%2 fv2%2fv4) v.s. meltdown(v3)
Spectre(v1%2 fv2%2fv4) v.s. meltdown(v3)Spectre(v1%2 fv2%2fv4) v.s. meltdown(v3)
Spectre(v1%2 fv2%2fv4) v.s. meltdown(v3)
Gavin Guo
 

Viewers also liked (20)

S emb t7-arch_bus
S emb t7-arch_busS emb t7-arch_bus
S emb t7-arch_bus
João Moreira
 
Embedded systems
Embedded systemsEmbedded systems
Embedded systems
Rajanikanth U
 
Selection and Integration of Embedded Display Devices
Selection and Integration of Embedded Display DevicesSelection and Integration of Embedded Display Devices
Selection and Integration of Embedded Display Devices
VIA Embedded
 
RFID embedded - MAGIC-PCB containing MAGICSTRAP
RFID embedded - MAGIC-PCB containing MAGICSTRAPRFID embedded - MAGIC-PCB containing MAGICSTRAP
RFID embedded - MAGIC-PCB containing MAGICSTRAP
Alexander M. Schmoldt
 
Serial Communication & Embedded System Interface
Serial Communication & Embedded System InterfaceSerial Communication & Embedded System Interface
Serial Communication & Embedded System Interface
KUET
 
Embedded c
Embedded cEmbedded c
Embedded c
Nandan Desai
 
Embedded systems
Embedded systemsEmbedded systems
Embedded systems
Manju Nathan
 
Linux watchdog timer
Linux watchdog timerLinux watchdog timer
Linux watchdog timer
RajKumar Rampelli
 
Serial peripheral Interface - Embedded System Protocol
Serial peripheral Interface - Embedded System ProtocolSerial peripheral Interface - Embedded System Protocol
Serial peripheral Interface - Embedded System Protocol
Aditya Porwal
 
FSK , FM DEMODULATOR & VOLTAGE REGULATOR ICS
FSK , FM DEMODULATOR & VOLTAGE REGULATOR ICS  FSK , FM DEMODULATOR & VOLTAGE REGULATOR ICS
FSK , FM DEMODULATOR & VOLTAGE REGULATOR ICS
vishalgohel12195
 
Programmable Logic Devices Plds
Programmable Logic Devices PldsProgrammable Logic Devices Plds
Programmable Logic Devices Plds
Gaditek
 
Embedded system
Embedded systemEmbedded system
Embedded system
mangal das
 
Risc and cisc eugene clewlow
Risc and cisc   eugene clewlowRisc and cisc   eugene clewlow
Risc and cisc eugene clewlow
Manish Prajapati
 
Prerna sharma
Prerna sharmaPrerna sharma
Prerna sharma
RCET
 
SysTick, Timer & Watchdog
SysTick, Timer & WatchdogSysTick, Timer & Watchdog
SysTick, Timer & Watchdog
Giovanni Panice
 
Chapter 19 - Real Time Systems
Chapter 19 - Real Time SystemsChapter 19 - Real Time Systems
Chapter 19 - Real Time Systems
Wayne Jones Jnr
 
Microprocessor and Microcontroller lec1
Microprocessor and Microcontroller lec1Microprocessor and Microcontroller lec1
Microprocessor and Microcontroller lec1
Ameen San
 
Embedded System
Embedded SystemEmbedded System
Embedded System
sureskal
 
Embedded c program and programming structure for beginners
Embedded c program and programming structure for beginnersEmbedded c program and programming structure for beginners
Embedded c program and programming structure for beginners
Kamesh Mtec
 
Introduction to embedded systems
Introduction to embedded systemsIntroduction to embedded systems
Introduction to embedded systems
Apurva Zope
 
Selection and Integration of Embedded Display Devices
Selection and Integration of Embedded Display DevicesSelection and Integration of Embedded Display Devices
Selection and Integration of Embedded Display Devices
VIA Embedded
 
RFID embedded - MAGIC-PCB containing MAGICSTRAP
RFID embedded - MAGIC-PCB containing MAGICSTRAPRFID embedded - MAGIC-PCB containing MAGICSTRAP
RFID embedded - MAGIC-PCB containing MAGICSTRAP
Alexander M. Schmoldt
 
Serial Communication & Embedded System Interface
Serial Communication & Embedded System InterfaceSerial Communication & Embedded System Interface
Serial Communication & Embedded System Interface
KUET
 
Serial peripheral Interface - Embedded System Protocol
Serial peripheral Interface - Embedded System ProtocolSerial peripheral Interface - Embedded System Protocol
Serial peripheral Interface - Embedded System Protocol
Aditya Porwal
 
FSK , FM DEMODULATOR & VOLTAGE REGULATOR ICS
FSK , FM DEMODULATOR & VOLTAGE REGULATOR ICS  FSK , FM DEMODULATOR & VOLTAGE REGULATOR ICS
FSK , FM DEMODULATOR & VOLTAGE REGULATOR ICS
vishalgohel12195
 
Programmable Logic Devices Plds
Programmable Logic Devices PldsProgrammable Logic Devices Plds
Programmable Logic Devices Plds
Gaditek
 
Embedded system
Embedded systemEmbedded system
Embedded system
mangal das
 
Risc and cisc eugene clewlow
Risc and cisc   eugene clewlowRisc and cisc   eugene clewlow
Risc and cisc eugene clewlow
Manish Prajapati
 
Prerna sharma
Prerna sharmaPrerna sharma
Prerna sharma
RCET
 
SysTick, Timer & Watchdog
SysTick, Timer & WatchdogSysTick, Timer & Watchdog
SysTick, Timer & Watchdog
Giovanni Panice
 
Chapter 19 - Real Time Systems
Chapter 19 - Real Time SystemsChapter 19 - Real Time Systems
Chapter 19 - Real Time Systems
Wayne Jones Jnr
 
Microprocessor and Microcontroller lec1
Microprocessor and Microcontroller lec1Microprocessor and Microcontroller lec1
Microprocessor and Microcontroller lec1
Ameen San
 
Embedded System
Embedded SystemEmbedded System
Embedded System
sureskal
 
Embedded c program and programming structure for beginners
Embedded c program and programming structure for beginnersEmbedded c program and programming structure for beginners
Embedded c program and programming structure for beginners
Kamesh Mtec
 
Introduction to embedded systems
Introduction to embedded systemsIntroduction to embedded systems
Introduction to embedded systems
Apurva Zope
 
Ad

Similar to Linux Timer device driver (20)

Linux kernel debugging
Linux kernel debuggingLinux kernel debugging
Linux kernel debugging
JungMinSEO5
 
Embedded JavaScript
Embedded JavaScriptEmbedded JavaScript
Embedded JavaScript
Jens Siebert
 
Microkernel Development
Microkernel DevelopmentMicrokernel Development
Microkernel Development
Rodrigo Almeida
 
Sysprog 12
Sysprog 12Sysprog 12
Sysprog 12
Ahmed Mekkawy
 
Sysprog 12
Sysprog 12Sysprog 12
Sysprog 12
Ahmed Mekkawy
 
Lee 2020 what the clock !
Lee 2020  what the clock !Lee 2020  what the clock !
Lee 2020 what the clock !
Neil Armstrong
 
Timers in Unix/Linux
Timers in Unix/LinuxTimers in Unix/Linux
Timers in Unix/Linux
geeksrik
 
Sysprog17
Sysprog17Sysprog17
Sysprog17
Ahmed Mekkawy
 
Attack your Trusted Core
Attack your Trusted CoreAttack your Trusted Core
Attack your Trusted Core
Di Shen
 
망고100 보드로 놀아보자 15
망고100 보드로 놀아보자 15망고100 보드로 놀아보자 15
망고100 보드로 놀아보자 15
종인 전
 
Epoll - from the kernel side
Epoll -  from the kernel sideEpoll -  from the kernel side
Epoll - from the kernel side
llj098
 
RTOS implementation
RTOS implementationRTOS implementation
RTOS implementation
Rajan Kumar
 
[ZigBee 嵌入式系統] ZigBee 應用實作 - 使用 TI Z-Stack Firmware
[ZigBee 嵌入式系統] ZigBee 應用實作 - 使用 TI Z-Stack Firmware[ZigBee 嵌入式系統] ZigBee 應用實作 - 使用 TI Z-Stack Firmware
[ZigBee 嵌入式系統] ZigBee 應用實作 - 使用 TI Z-Stack Firmware
Simen Li
 
ARM® Cortex™ M Bootup_CMSIS_Part_2_3
ARM® Cortex™ M Bootup_CMSIS_Part_2_3ARM® Cortex™ M Bootup_CMSIS_Part_2_3
ARM® Cortex™ M Bootup_CMSIS_Part_2_3
Raahul Raghavan
 
Unix-module4.Unit 2 Virtualization Part I.pptx
Unix-module4.Unit 2 Virtualization Part I.pptxUnix-module4.Unit 2 Virtualization Part I.pptx
Unix-module4.Unit 2 Virtualization Part I.pptx
ssuser8594b8
 
Contiki introduction I.
Contiki introduction I.Contiki introduction I.
Contiki introduction I.
Dingxin Xu
 
RxJava on Android
RxJava on AndroidRxJava on Android
RxJava on Android
Dustin Graham
 
Ieee 1149.1-2013-tutorial-ijtag
Ieee 1149.1-2013-tutorial-ijtagIeee 1149.1-2013-tutorial-ijtag
Ieee 1149.1-2013-tutorial-ijtag
Venkateshwar Motamarri
 
Kernel Recipes 2015 - Porting Linux to a new processor architecture
Kernel Recipes 2015 - Porting Linux to a new processor architectureKernel Recipes 2015 - Porting Linux to a new processor architecture
Kernel Recipes 2015 - Porting Linux to a new processor architecture
Anne Nicolas
 
Taipei.py 2018 - Control device via ioctl from Python
Taipei.py 2018 - Control device via ioctl from Python Taipei.py 2018 - Control device via ioctl from Python
Taipei.py 2018 - Control device via ioctl from Python
Hua Chu
 
Linux kernel debugging
Linux kernel debuggingLinux kernel debugging
Linux kernel debugging
JungMinSEO5
 
Embedded JavaScript
Embedded JavaScriptEmbedded JavaScript
Embedded JavaScript
Jens Siebert
 
Lee 2020 what the clock !
Lee 2020  what the clock !Lee 2020  what the clock !
Lee 2020 what the clock !
Neil Armstrong
 
Timers in Unix/Linux
Timers in Unix/LinuxTimers in Unix/Linux
Timers in Unix/Linux
geeksrik
 
Attack your Trusted Core
Attack your Trusted CoreAttack your Trusted Core
Attack your Trusted Core
Di Shen
 
망고100 보드로 놀아보자 15
망고100 보드로 놀아보자 15망고100 보드로 놀아보자 15
망고100 보드로 놀아보자 15
종인 전
 
Epoll - from the kernel side
Epoll -  from the kernel sideEpoll -  from the kernel side
Epoll - from the kernel side
llj098
 
RTOS implementation
RTOS implementationRTOS implementation
RTOS implementation
Rajan Kumar
 
[ZigBee 嵌入式系統] ZigBee 應用實作 - 使用 TI Z-Stack Firmware
[ZigBee 嵌入式系統] ZigBee 應用實作 - 使用 TI Z-Stack Firmware[ZigBee 嵌入式系統] ZigBee 應用實作 - 使用 TI Z-Stack Firmware
[ZigBee 嵌入式系統] ZigBee 應用實作 - 使用 TI Z-Stack Firmware
Simen Li
 
ARM® Cortex™ M Bootup_CMSIS_Part_2_3
ARM® Cortex™ M Bootup_CMSIS_Part_2_3ARM® Cortex™ M Bootup_CMSIS_Part_2_3
ARM® Cortex™ M Bootup_CMSIS_Part_2_3
Raahul Raghavan
 
Unix-module4.Unit 2 Virtualization Part I.pptx
Unix-module4.Unit 2 Virtualization Part I.pptxUnix-module4.Unit 2 Virtualization Part I.pptx
Unix-module4.Unit 2 Virtualization Part I.pptx
ssuser8594b8
 
Contiki introduction I.
Contiki introduction I.Contiki introduction I.
Contiki introduction I.
Dingxin Xu
 
Kernel Recipes 2015 - Porting Linux to a new processor architecture
Kernel Recipes 2015 - Porting Linux to a new processor architectureKernel Recipes 2015 - Porting Linux to a new processor architecture
Kernel Recipes 2015 - Porting Linux to a new processor architecture
Anne Nicolas
 
Taipei.py 2018 - Control device via ioctl from Python
Taipei.py 2018 - Control device via ioctl from Python Taipei.py 2018 - Control device via ioctl from Python
Taipei.py 2018 - Control device via ioctl from Python
Hua Chu
 
Ad

More from 艾鍗科技 (20)

AI 技術浪潮, 什麼是機器學習? 什麼是深度學習, 什麼是生成式AI, AI 能力認證
AI 技術浪潮, 什麼是機器學習? 什麼是深度學習, 什麼是生成式AI, AI 能力認證AI 技術浪潮, 什麼是機器學習? 什麼是深度學習, 什麼是生成式AI, AI 能力認證
AI 技術浪潮, 什麼是機器學習? 什麼是深度學習, 什麼是生成式AI, AI 能力認證
艾鍗科技
 
TinyML - 4 speech recognition
TinyML - 4 speech recognition TinyML - 4 speech recognition
TinyML - 4 speech recognition
艾鍗科技
 
Appendix 1 Goolge colab
Appendix 1 Goolge colabAppendix 1 Goolge colab
Appendix 1 Goolge colab
艾鍗科技
 
Project-IOT於餐館系統的應用
Project-IOT於餐館系統的應用Project-IOT於餐館系統的應用
Project-IOT於餐館系統的應用
艾鍗科技
 
02 IoT implementation
02 IoT implementation02 IoT implementation
02 IoT implementation
艾鍗科技
 
Tiny ML for spark Fun Edge
Tiny ML for spark Fun EdgeTiny ML for spark Fun Edge
Tiny ML for spark Fun Edge
艾鍗科技
 
Openvino ncs2
Openvino ncs2Openvino ncs2
Openvino ncs2
艾鍗科技
 
Step motor
Step motorStep motor
Step motor
艾鍗科技
 
2. 機器學習簡介
2. 機器學習簡介2. 機器學習簡介
2. 機器學習簡介
艾鍗科技
 
5.MLP(Multi-Layer Perceptron)
5.MLP(Multi-Layer Perceptron) 5.MLP(Multi-Layer Perceptron)
5.MLP(Multi-Layer Perceptron)
艾鍗科技
 
3. data features
3. data features3. data features
3. data features
艾鍗科技
 
心率血氧檢測與運動促進
心率血氧檢測與運動促進心率血氧檢測與運動促進
心率血氧檢測與運動促進
艾鍗科技
 
利用音樂&情境燈幫助放鬆
利用音樂&情境燈幫助放鬆利用音樂&情境燈幫助放鬆
利用音樂&情境燈幫助放鬆
艾鍗科技
 
IoT感測器驅動程式 在樹莓派上實作
IoT感測器驅動程式在樹莓派上實作IoT感測器驅動程式在樹莓派上實作
IoT感測器驅動程式 在樹莓派上實作
艾鍗科技
 
無線聲控遙控車
無線聲控遙控車無線聲控遙控車
無線聲控遙控車
艾鍗科技
 
最佳光源的研究和實作
最佳光源的研究和實作最佳光源的研究和實作
最佳光源的研究和實作
艾鍗科技
 
無線監控網路攝影機與控制自走車
無線監控網路攝影機與控制自走車無線監控網路攝影機與控制自走車
無線監控網路攝影機與控制自走車
艾鍗科技
 
Reinforcement Learning
Reinforcement LearningReinforcement Learning
Reinforcement Learning
艾鍗科技
 
人臉辨識考勤系統
人臉辨識考勤系統人臉辨識考勤系統
人臉辨識考勤系統
艾鍗科技
 
智慧家庭Smart Home
智慧家庭Smart Home智慧家庭Smart Home
智慧家庭Smart Home
艾鍗科技
 
AI 技術浪潮, 什麼是機器學習? 什麼是深度學習, 什麼是生成式AI, AI 能力認證
AI 技術浪潮, 什麼是機器學習? 什麼是深度學習, 什麼是生成式AI, AI 能力認證AI 技術浪潮, 什麼是機器學習? 什麼是深度學習, 什麼是生成式AI, AI 能力認證
AI 技術浪潮, 什麼是機器學習? 什麼是深度學習, 什麼是生成式AI, AI 能力認證
艾鍗科技
 
TinyML - 4 speech recognition
TinyML - 4 speech recognition TinyML - 4 speech recognition
TinyML - 4 speech recognition
艾鍗科技
 
Appendix 1 Goolge colab
Appendix 1 Goolge colabAppendix 1 Goolge colab
Appendix 1 Goolge colab
艾鍗科技
 
Project-IOT於餐館系統的應用
Project-IOT於餐館系統的應用Project-IOT於餐館系統的應用
Project-IOT於餐館系統的應用
艾鍗科技
 
02 IoT implementation
02 IoT implementation02 IoT implementation
02 IoT implementation
艾鍗科技
 
Tiny ML for spark Fun Edge
Tiny ML for spark Fun EdgeTiny ML for spark Fun Edge
Tiny ML for spark Fun Edge
艾鍗科技
 
2. 機器學習簡介
2. 機器學習簡介2. 機器學習簡介
2. 機器學習簡介
艾鍗科技
 
5.MLP(Multi-Layer Perceptron)
5.MLP(Multi-Layer Perceptron) 5.MLP(Multi-Layer Perceptron)
5.MLP(Multi-Layer Perceptron)
艾鍗科技
 
心率血氧檢測與運動促進
心率血氧檢測與運動促進心率血氧檢測與運動促進
心率血氧檢測與運動促進
艾鍗科技
 
利用音樂&情境燈幫助放鬆
利用音樂&情境燈幫助放鬆利用音樂&情境燈幫助放鬆
利用音樂&情境燈幫助放鬆
艾鍗科技
 
IoT感測器驅動程式 在樹莓派上實作
IoT感測器驅動程式在樹莓派上實作IoT感測器驅動程式在樹莓派上實作
IoT感測器驅動程式 在樹莓派上實作
艾鍗科技
 
無線聲控遙控車
無線聲控遙控車無線聲控遙控車
無線聲控遙控車
艾鍗科技
 
最佳光源的研究和實作
最佳光源的研究和實作最佳光源的研究和實作
最佳光源的研究和實作
艾鍗科技
 
無線監控網路攝影機與控制自走車
無線監控網路攝影機與控制自走車無線監控網路攝影機與控制自走車
無線監控網路攝影機與控制自走車
艾鍗科技
 
Reinforcement Learning
Reinforcement LearningReinforcement Learning
Reinforcement Learning
艾鍗科技
 
人臉辨識考勤系統
人臉辨識考勤系統人臉辨識考勤系統
人臉辨識考勤系統
艾鍗科技
 
智慧家庭Smart Home
智慧家庭Smart Home智慧家庭Smart Home
智慧家庭Smart Home
艾鍗科技
 

Recently uploaded (20)

How I solved production issues with OpenTelemetry
How I solved production issues with OpenTelemetryHow I solved production issues with OpenTelemetry
How I solved production issues with OpenTelemetry
Cees Bos
 
Unit Two - Java Architecture and OOPS
Unit Two  -   Java Architecture and OOPSUnit Two  -   Java Architecture and OOPS
Unit Two - Java Architecture and OOPS
Nabin Dhakal
 
Best HR and Payroll Software in Bangladesh - accordHRM
Best HR and Payroll Software in Bangladesh - accordHRMBest HR and Payroll Software in Bangladesh - accordHRM
Best HR and Payroll Software in Bangladesh - accordHRM
accordHRM
 
What Do Candidates Really Think About AI-Powered Recruitment Tools?
What Do Candidates Really Think About AI-Powered Recruitment Tools?What Do Candidates Really Think About AI-Powered Recruitment Tools?
What Do Candidates Really Think About AI-Powered Recruitment Tools?
HireME
 
Top Magento Hyvä Theme Features That Make It Ideal for E-commerce.pdf
Top Magento Hyvä Theme Features That Make It Ideal for E-commerce.pdfTop Magento Hyvä Theme Features That Make It Ideal for E-commerce.pdf
Top Magento Hyvä Theme Features That Make It Ideal for E-commerce.pdf
evrigsolution
 
Digital Twins Software Service in Belfast
Digital Twins Software Service in BelfastDigital Twins Software Service in Belfast
Digital Twins Software Service in Belfast
julia smits
 
How to Install and Activate ListGrabber Plugin
How to Install and Activate ListGrabber PluginHow to Install and Activate ListGrabber Plugin
How to Install and Activate ListGrabber Plugin
eGrabber
 
The-Future-is-Hybrid-Exploring-Azure’s-Role-in-Multi-Cloud-Strategies.pptx
The-Future-is-Hybrid-Exploring-Azure’s-Role-in-Multi-Cloud-Strategies.pptxThe-Future-is-Hybrid-Exploring-Azure’s-Role-in-Multi-Cloud-Strategies.pptx
The-Future-is-Hybrid-Exploring-Azure’s-Role-in-Multi-Cloud-Strategies.pptx
james brownuae
 
Memory Management and Leaks in Postgres from pgext.day 2025
Memory Management and Leaks in Postgres from pgext.day 2025Memory Management and Leaks in Postgres from pgext.day 2025
Memory Management and Leaks in Postgres from pgext.day 2025
Phil Eaton
 
GC Tuning: A Masterpiece in Performance Engineering
GC Tuning: A Masterpiece in Performance EngineeringGC Tuning: A Masterpiece in Performance Engineering
GC Tuning: A Masterpiece in Performance Engineering
Tier1 app
 
Adobe InDesign Crack FREE Download 2025 link
Adobe InDesign Crack FREE Download 2025 linkAdobe InDesign Crack FREE Download 2025 link
Adobe InDesign Crack FREE Download 2025 link
mahmadzubair09
 
Surviving a Downturn Making Smarter Portfolio Decisions with OnePlan - Webina...
Surviving a Downturn Making Smarter Portfolio Decisions with OnePlan - Webina...Surviving a Downturn Making Smarter Portfolio Decisions with OnePlan - Webina...
Surviving a Downturn Making Smarter Portfolio Decisions with OnePlan - Webina...
OnePlan Solutions
 
Mastering Selenium WebDriver: A Comprehensive Tutorial with Real-World Examples
Mastering Selenium WebDriver: A Comprehensive Tutorial with Real-World ExamplesMastering Selenium WebDriver: A Comprehensive Tutorial with Real-World Examples
Mastering Selenium WebDriver: A Comprehensive Tutorial with Real-World Examples
jamescantor38
 
Adobe Media Encoder Crack FREE Download 2025
Adobe Media Encoder  Crack FREE Download 2025Adobe Media Encoder  Crack FREE Download 2025
Adobe Media Encoder Crack FREE Download 2025
zafranwaqar90
 
!%& IDM Crack with Internet Download Manager 6.42 Build 32 >
!%& IDM Crack with Internet Download Manager 6.42 Build 32 >!%& IDM Crack with Internet Download Manager 6.42 Build 32 >
!%& IDM Crack with Internet Download Manager 6.42 Build 32 >
Ranking Google
 
Download MathType Crack Version 2025???
Download MathType Crack  Version 2025???Download MathType Crack  Version 2025???
Download MathType Crack Version 2025???
Google
 
Exchange Migration Tool- Shoviv Software
Exchange Migration Tool- Shoviv SoftwareExchange Migration Tool- Shoviv Software
Exchange Migration Tool- Shoviv Software
Shoviv Software
 
Programs as Values - Write code and don't get lost
Programs as Values - Write code and don't get lostPrograms as Values - Write code and don't get lost
Programs as Values - Write code and don't get lost
Pierangelo Cecchetto
 
Buy vs. Build: Unlocking the right path for your training tech
Buy vs. Build: Unlocking the right path for your training techBuy vs. Build: Unlocking the right path for your training tech
Buy vs. Build: Unlocking the right path for your training tech
Rustici Software
 
The Elixir Developer - All Things Open
The Elixir Developer - All Things OpenThe Elixir Developer - All Things Open
The Elixir Developer - All Things Open
Carlo Gilmar Padilla Santana
 
How I solved production issues with OpenTelemetry
How I solved production issues with OpenTelemetryHow I solved production issues with OpenTelemetry
How I solved production issues with OpenTelemetry
Cees Bos
 
Unit Two - Java Architecture and OOPS
Unit Two  -   Java Architecture and OOPSUnit Two  -   Java Architecture and OOPS
Unit Two - Java Architecture and OOPS
Nabin Dhakal
 
Best HR and Payroll Software in Bangladesh - accordHRM
Best HR and Payroll Software in Bangladesh - accordHRMBest HR and Payroll Software in Bangladesh - accordHRM
Best HR and Payroll Software in Bangladesh - accordHRM
accordHRM
 
What Do Candidates Really Think About AI-Powered Recruitment Tools?
What Do Candidates Really Think About AI-Powered Recruitment Tools?What Do Candidates Really Think About AI-Powered Recruitment Tools?
What Do Candidates Really Think About AI-Powered Recruitment Tools?
HireME
 
Top Magento Hyvä Theme Features That Make It Ideal for E-commerce.pdf
Top Magento Hyvä Theme Features That Make It Ideal for E-commerce.pdfTop Magento Hyvä Theme Features That Make It Ideal for E-commerce.pdf
Top Magento Hyvä Theme Features That Make It Ideal for E-commerce.pdf
evrigsolution
 
Digital Twins Software Service in Belfast
Digital Twins Software Service in BelfastDigital Twins Software Service in Belfast
Digital Twins Software Service in Belfast
julia smits
 
How to Install and Activate ListGrabber Plugin
How to Install and Activate ListGrabber PluginHow to Install and Activate ListGrabber Plugin
How to Install and Activate ListGrabber Plugin
eGrabber
 
The-Future-is-Hybrid-Exploring-Azure’s-Role-in-Multi-Cloud-Strategies.pptx
The-Future-is-Hybrid-Exploring-Azure’s-Role-in-Multi-Cloud-Strategies.pptxThe-Future-is-Hybrid-Exploring-Azure’s-Role-in-Multi-Cloud-Strategies.pptx
The-Future-is-Hybrid-Exploring-Azure’s-Role-in-Multi-Cloud-Strategies.pptx
james brownuae
 
Memory Management and Leaks in Postgres from pgext.day 2025
Memory Management and Leaks in Postgres from pgext.day 2025Memory Management and Leaks in Postgres from pgext.day 2025
Memory Management and Leaks in Postgres from pgext.day 2025
Phil Eaton
 
GC Tuning: A Masterpiece in Performance Engineering
GC Tuning: A Masterpiece in Performance EngineeringGC Tuning: A Masterpiece in Performance Engineering
GC Tuning: A Masterpiece in Performance Engineering
Tier1 app
 
Adobe InDesign Crack FREE Download 2025 link
Adobe InDesign Crack FREE Download 2025 linkAdobe InDesign Crack FREE Download 2025 link
Adobe InDesign Crack FREE Download 2025 link
mahmadzubair09
 
Surviving a Downturn Making Smarter Portfolio Decisions with OnePlan - Webina...
Surviving a Downturn Making Smarter Portfolio Decisions with OnePlan - Webina...Surviving a Downturn Making Smarter Portfolio Decisions with OnePlan - Webina...
Surviving a Downturn Making Smarter Portfolio Decisions with OnePlan - Webina...
OnePlan Solutions
 
Mastering Selenium WebDriver: A Comprehensive Tutorial with Real-World Examples
Mastering Selenium WebDriver: A Comprehensive Tutorial with Real-World ExamplesMastering Selenium WebDriver: A Comprehensive Tutorial with Real-World Examples
Mastering Selenium WebDriver: A Comprehensive Tutorial with Real-World Examples
jamescantor38
 
Adobe Media Encoder Crack FREE Download 2025
Adobe Media Encoder  Crack FREE Download 2025Adobe Media Encoder  Crack FREE Download 2025
Adobe Media Encoder Crack FREE Download 2025
zafranwaqar90
 
!%& IDM Crack with Internet Download Manager 6.42 Build 32 >
!%& IDM Crack with Internet Download Manager 6.42 Build 32 >!%& IDM Crack with Internet Download Manager 6.42 Build 32 >
!%& IDM Crack with Internet Download Manager 6.42 Build 32 >
Ranking Google
 
Download MathType Crack Version 2025???
Download MathType Crack  Version 2025???Download MathType Crack  Version 2025???
Download MathType Crack Version 2025???
Google
 
Exchange Migration Tool- Shoviv Software
Exchange Migration Tool- Shoviv SoftwareExchange Migration Tool- Shoviv Software
Exchange Migration Tool- Shoviv Software
Shoviv Software
 
Programs as Values - Write code and don't get lost
Programs as Values - Write code and don't get lostPrograms as Values - Write code and don't get lost
Programs as Values - Write code and don't get lost
Pierangelo Cecchetto
 
Buy vs. Build: Unlocking the right path for your training tech
Buy vs. Build: Unlocking the right path for your training techBuy vs. Build: Unlocking the right path for your training tech
Buy vs. Build: Unlocking the right path for your training tech
Rustici Software
 

Linux Timer device driver

  • 1. TIMER DEVICE DRIVER (SYSTEM TIMER, RTC, WATCHDOG) 1
  • 2. 系統宣告(arch/arm/mach-ixp4xx) MACHINE_START(IXDP425, "Intel IXDP425 Development Platform") /* Maintainer: MontaVista Software, Inc. */ .phys_io = IXP4XX_PERIPHERAL_BASE_PHYS, .io_pg_offst = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xfffc, .map_io = ixp4xx_map_io, .init_irq = ixp4xx_init_irq, .timer = &ixp4xx_timer, .boot_params = 0x0100, .init_machine = ixdp425_init, MACHINE_END 2
  • 3. struct sys_timer armcpu_timer __initdata = { .init = armcpu_timer_init, .offset = armcpu_gettimeoffset, .resume = armcpu_timer_setup, }; 3 Timer 資料結構宣告
  • 4. static void armcpu_timer_setup(void) { armcpu_timer_set_reload(USED_TIMER, APB_CLK/HZ); armcpu_timer_set_counter(USED_TIMER, APB_CLK/HZ); ……………… } void __init armcpu_timer_init(void) { armcpu_timer_setup(); setup_irq(IRQ_TIMER1, &armcpu_timer_irq); } 4 Timer Initiailzation
  • 5. static irqreturn_t armcpu_timer_interrupt(int irq, void *dev_id) { write_seqlock(&xtime_lock); timer_tick(); write_sequnlock(&xtime_lock); return IRQ_HANDLED; } 5 Timer interrupt
  • 6. unsigned long armcpu_gettimeoffset (void) { unsigned long volatile offsetticks; offsetticks = SET_COUNTER-armcpu_timer_get_counter(USED_TIMER); if ( *(volatile unsigned int *)(CPE_TIMER1_VA_BASE+TIMER_INTR_STATE) ) { offsetticks = SET_COUNTER-armcpu_timer_get_counter(USED_TIMER); offsetticks += SET_COUNTER; } offsetticks = offsetticks / (APB_CLK / 1000000); // tansfer ticks to usec return offsetticks; } 6 gettimeoffset callback #include <sys/time.h> int gettimeofday(struct timeval *tv, struct timezone *tz); struct timeval { time_t tv_sec; /* seconds */ suseconds_t tv_usec; /* microseconds */ };
  • 8. 簡單來看它就是一個時鐘,通常它只能計 時至秒。 大都規格是在一年內誤差為10幾秒。 它需要電池供電,上電一輩子需要有一次 啓動的動作,斷電後則時間停止。 以PC為例系統時間(用date指令,或者任何 API取得的時間)在開機時會讀入RTC時間並 設定時間,關機時會將系統時間設回RTC。 其應用層設定的程式為hwclock,使用的 device node 為/dev/rtc (10, 135)。 8 RTC (Real Time Clock)
  • 9. Usage: hwclock [-r|--show] [-s|--hctosys] [-w|--systohc] [-l|-- localtime] [-u|--utc] [-f FILE] Query and set hardware clock (RTC) Options: -r Show hardware clock time -s Set system time from hardware clock -w Set hardware clock to system time -u Hardware clock is in UTC -l Hardware clock is in local time -f FILE Use specified device (e.g. /dev/rtc2) 9 hwclock usage
  • 10. RTC Device Driver Example 可架構在misc之下 主要是支援兩個ioctl command 1) RTC_RD_TIME 讀取時間 2) RTC_SET_TIME 設定時間 struct rtc_time { int tm_sec; int tm_min; int tm_hour; int tm_mday; int tm_mon; int tm_year; int tm_wday; int tm_yday; int tm_isdst; }; 10
  • 11. Module Initialize Example static struct file_operations rtc_fops = { owner:THIS_MODULE, ioctl:rtc_ioctl, open:rtc_open, release:rtc_release, }; static struct miscdevice rtc_dev = { RTC_MINOR, "rtc", &rtc_fops }; static int __init rtc_init(void) { misc_register(&rtc_dev); return 0; }
  • 12. Ioctl Example static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) { struct rtc_time rtc_tm; switch (cmd) { case RTC_RD_TIME: /* Read the time/date from RTC */ get_rtc_time(&rtc_tm); return copy_to_user((void *) arg, &rtc_tm, sizeof(rtc_tm)) ? -EFAULT : 0; case RTC_SET_TIME: /* Set the RTC */ if (copy_from_user(&rtc_tm, (struct rtc_time *) arg, sizeof(struct rtc_time))) return -EFAULT; // set to hardware RTC with the time return 0; default: return -EINVAL; } }
  • 13. 新RTC Driver Device node is put on /dev/misc directory. Up to 16 RTC node, from rtc0 The major number is 254. The minor number is from 0. These are the same IOCTL command with the old type RTC driver. More features.
  • 14. RTC Class Structure struct rtc_class_ops { int (*open)(struct device *); void (*release)(struct device *); int (*ioctl)(struct device *, unsigned int, unsigned long); int (*read_time)(struct device *, struct rtc_time *); int (*set_time)(struct device *, struct rtc_time *); int (*read_alarm)(struct device *, struct rtc_wkalrm *); int (*set_alarm)(struct device *, struct rtc_wkalrm *); int (*proc)(struct device *, struct seq_file *); int (*set_mmss)(struct device *, unsigned long secs); int (*irq_set_state)(struct device *, int enabled); int (*irq_set_freq)(struct device *, int freq); int (*read_callback)(struct device *, int data); int (*alarm_irq_enable)(struct device *, unsigned int enabled); int (*update_irq_enable)(struct device *, unsigned int enabled); };
  • 15. RTC Time structure struct rtc_time { int tm_sec; int tm_min; int tm_hour; int tm_mday; int tm_mon; int tm_year; int tm_wday; int tm_yday; int tm_isdst; };
  • 16. New RTC Driver Example static int rtc_read_time(struct device *dev, struct rtc_time *tm) { ……………. } static int rtc_set_time(struct device *dev, struct rtc_time *tm) { ………….. } static struct rtc_class_ops rtc_ops = { .read_time = rtc_read_time, .set_time = rtc_set_time, }; static struct rtc_device *rtc; static int rtc_module_init(void) { ………….. rtc = rtc_device_register(“name”, NULL, &rtc_ops, THIS_MODULE); if ( IS_ERR(rtc) { …….. } return 0; } static void rtc_module_exit(void) { rtc_device_unregister(rtc); ….. }
  • 18. 什麼是Watchdog 1) 它是一種可以reset CPU的機制, 在一定的時間 內需要觸發, 若沒有將會引起CPU reset 它有什麼注意事項 1) 小心檔案系統crashed, 因為它是直接CPU reset, 並沒有做很好的shutdown動作 2) 可能因為Flash在write state,使得reset之後無 法boot from flash 3) 硬體需配合reset CPU週邊元件, 否則系統還是 無法reset View source code newwdt 18 Watchdog面面觀
  翻译: