Port Environment (Bold font in redIs the modified content,Blue bold ChineseFor special attention)
1. host environment: centos 5.5 and 1 GB memory in vmare.
2. Integrated Development Environment: Elipse ide
3. compiling environment: Arm-Linux-GCC v4.4.3 and arm-None-Linux-gnueabi-GCC v4.5.1.
4. Development Board: mini2440, 2 m nor flash, 128 m nand Flash.
5, U-boot version: u-boot-2009.08
6, Linux: linux-2.6.32.2
7. References:
Complete embedded Linux application development manual, edited by Wei Dongshan.
Mini2440 Linux porting Development Practice Guide
Linux-2.6.32.2 kernel has perfect S3C2440 vision dog driver, we only need to configure it to use.
Tip: in fact, the default Linux-2.6.32.2 kernel mini2440_defconfig has been configured with the dog driver, we just open here to see the specific configuration path.
[1] configure the watchdog driver in the kernel
Run make menuconfig in the kernel source code directory to go to The Kernel configuration main menu, and choose to go to the following sub-menu:
Device Drivers --->
[*] Watchdog timer support --->
<*> S3C2410 Watchdog
Here you can select the configuration option for the Watchdog in s2c2410/2440. The driver source code corresponding to the above configuration is: linux-2.6.32.2/Drivers/watchdog/s3c2410_wdt.c.
You can view the startup information in the terminal startup information of the Development Board:
......
I2C/dev entries driver
S3C2410 watchdog timer, (c) 2004 simtec Electronics
S3c2410-wdt s3c2410-wdt: watchdog inactive, reset disabled, IRQ Enabled
Cpuidle: Using Governor ladder
......
[2] about opening and disabling the Watchdog
In the dog driver, we noticed that there is such a function. Note that the font in blue bold is as follows:
# Define pfx "s3c2410-wdt :"
# Define config_s3c2410_watchdog_atboot (0)
// It indicates that the default time of the watchdog is 15 seconds. If the default time is exceeded, the system restarts automatically.
# Define config_s3c2410_watchdog_default_time (15)
Static ssize_t s3c2410wdt_write (struct file * file, const char _ User * data,
Size_t Len, loff_t * PPOs)
{
/*
* Refresh the timer.
*/
If (LEN ){
If (! Nowayout ){
Size_t I;
/* In case it was set long ago */
Expect_close = 0;
For (I = 0; I! = Len; I ++ ){
Char C;
If (get_user (C, Data + I ))
Return-efault;
If (C = 'V ')
Expect_close = 42;
}
}
S3c2410wdt_keepalive ();
}
Return Len;
}
Based on this code, it is determined that some data can be written to the watchdog randomly after the watchdog device (/dev/watchdog) is enabled to feed the dog. However, when "v" is written, the watchdog can be disabled.
[3] test the Watchdog
Based on the above analysis, we can use the echo command to write some data to the/dev/watchdog device to enable the watchdog, for example, Echo 0>/dev/watchdog, as follows:
[Root @ mini2440/] # Echo 0>/dev/Watchdog
S3c2410-wdt s3c2410-wdt: Unexpected close, not stopping Watchdog
[Root @ mini2440/] #
At this time, if you wait for 15 seconds, the system will automatically restart, which confirms that the watchdog has been enabled. If we repeat the "dog Feed" operation within 15 seconds, that is, we use the echo command to write data to the dog, then the system will not restart. So how can we stop the dog? According to the above analysis, you only need to write "V. You need to know that, but when we use the echo command to write data to/dev/watchdog, we also send the "enter" message, so you can do this: echo-N v>/dev/watchdog the "-n" here means "Remove the carriage return". To test the function, enter:
Echo 0>/dev/Watchdog
Then enter:
Echo-N v>/dev/Watchdog
Then wait. After a long time, the system is still running normally, which proves that the watchdog has been disabled.
Next, we will transplant the LED Driver