luckfox-pico-sdk/media/sysutils/examples/rk_watchdog_test.c
luckfox-eng29 8f34c2760d project:build.sh: Added fastboot support; custom modifications to U-Boot and kernel implemented using patches.
project:cfg:BoardConfig_IPC: Added fastboot BoardConfig file and firmware post-scripts, distinguishing between
the BoardConfigs for Luckfox Pico Pro and Luckfox Pico Max. project:app: Added fastboot_client and rk_smart_door
for quick boot applications; updated rkipc app to adapt to the latest media library. media:samples: Added more
usage examples. media:rockit: Fixed bugs; removed support for retrieving data frames from VPSS. media:isp:
Updated rkaiq library and related tools to support connection to RKISP_Tuner. sysdrv:Makefile: Added support for
compiling drv_ko on Luckfox Pico Ultra W using Ubuntu; added support for custom root filesystem.
sysdrv:tools:board: Updated Buildroot optional mirror sources, updated some software versions, and stored device
tree files and configuration files that undergo multiple modifications for U-Boot and kernel separately.
sysdrv:source:mcu: Used RISC-V MCU SDK with RT-Thread system, mainly for initializing camera AE during quick
boot. sysdrv:source:uboot: Added support for fastboot; added high baud rate DDR bin for serial firmware upgrades.
sysdrv:source:kernel: Upgraded to version 5.10.160; increased NPU frequency for RV1106G3; added support for
fastboot.

Signed-off-by: luckfox-eng29 <eng29@luckfox.com>
2024-10-14 09:47:04 +08:00

80 lines
1.5 KiB
C

/*
* Copyright (c) 2022 rockchip
*
*/
#include "rk_watchdog.h"
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
#include <sys/time.h>
#include <pthread.h>
#define DEFAULT_PING_RATE 1
static int feeddog_quit;
static pthread_t watchdog_tid = 0;
static void *rk_feeddog_thread(void *arg) {
int i = 0;
while (feeddog_quit == 0) {
rk_watchdog_refresh();
printf(".%d",i);
i++;
if (i == 60)
i = 0;
sleep(DEFAULT_PING_RATE);
}
return NULL;
}
int main(int argc, char *argv[])
{
int ret;
bool is_quit = true;
setbuf(stdout, NULL);
ret = rk_watchdog_start(0);
if (ret)
printf("rk_watchdog_start fail!\n");
feeddog_quit = 0;
if (pthread_create(&watchdog_tid, NULL,
rk_feeddog_thread, NULL)) {
printf("rk_feeddog_thread create failed!");
goto fail;
}
char cmd[64];
printf("\n#Usage: input 'quit' to exit programe!\n");
while (is_quit) {
fgets(cmd, sizeof(cmd), stdin);
if (strstr(cmd, "quit")) {
printf("#Get 'quit' cmd!\n");
break;
}
printf("alive\n");
usleep(500000);
}
if (watchdog_tid) {
feeddog_quit = 1;
pthread_cancel(watchdog_tid);
if (pthread_join(watchdog_tid, NULL)) {
printf("rk_feeddog_thread join failed!");
return -1;
}
watchdog_tid = 0;
}
fail:
ret = rk_watchdog_stop();
return 0;
}