58
IB113
5.3.
How to use Watchdog in Linux
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
int main(void)
{
int fd = open("/dev/watchdog", O_WRONLY);
int ret = 0;
if (fd == -1) {
perror("watchdog");
exit(EXIT_FAILURE);
}
while (1) {
ret = write(fd, "\0", 1);
if (ret != 1) {
ret = -1;
break;
}
puts("[WDT] Keep alive");
sleep(50);
}
close(fd);
return ret;
}
Note: hexdump command 524288 come from dd bs=1024 seek=512 , 1024*512=524288.
5.4.
eMMC test
Note! This operation may damage the data stored in eMMC flash. Please make sure there
is no critical data in the eMMC flash being used for this test
5.4.1.
Erase and check
#dd if=/dev/zero of=/dev/mmcblk0 bs=1024 count=1 seek=512
1+0 records in
1+0 records out
#hexdump -C /dev/mmcblk0 -s 524288 -n 16
01887800 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
5.4.2.
Write and check