mirror of
https://github.com/sipeed/NanoKVM.git
synced 2026-09-11 00:22:56 -05:00
Fix abnormal updates of some models
Add function: If the program does not execute after the update, execute a restart
This commit is contained in:
@@ -41,6 +41,7 @@
|
||||
#define hdmi_mode_path "/etc/kvm/hdmi_mode"
|
||||
#define hdmi_state_path "/proc/lt_int"
|
||||
#define watchdog_mode_path "/etc/kvm/watchdog"
|
||||
#define watchdog_temp_path "/tmp/watchdog"
|
||||
#define watchdog_file "/tmp/nanokvm_wd"
|
||||
|
||||
#define LT6911_ADDR 0x2B
|
||||
@@ -309,9 +310,10 @@ int get_hdmi_mode(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t watchdog_sf_is_open()
|
||||
uint8_t watchdog_sf_is_open(void)
|
||||
{
|
||||
if(access(watchdog_mode_path, F_OK) == 0) return 1;
|
||||
else if(access(watchdog_temp_path, F_OK) == 0) return 1;
|
||||
else return 0;
|
||||
}
|
||||
|
||||
@@ -1017,7 +1019,7 @@ void* watchdog_sf_feed(void * arg)
|
||||
debug("[kvmv] Ion memory is full reboot now!\n");
|
||||
system("reboot");
|
||||
}
|
||||
debug("[kvmv] watchdog_sf_feed now!\n");
|
||||
// debug("[kvmv] watchdog_sf_feed now!\n");
|
||||
vision_update_watchdog();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#define OLED_SLEEP_DELAY_MIN 10
|
||||
#define OLED_SLEEP_DELAY_DEFAULT 30
|
||||
#define KVM_WD_COUNT_MAX 10
|
||||
#define RM_Watchdog_times 60
|
||||
|
||||
typedef struct {
|
||||
int8_t page = 0;
|
||||
|
||||
@@ -130,6 +130,9 @@ void new_app_init(void)
|
||||
else if(RW_Data[0] == 'u') hdmi_ver = 2;
|
||||
}
|
||||
|
||||
system("/etc/init.d/S03usbdev stop_start");
|
||||
create_temp_watchdog();
|
||||
|
||||
if(hdmi_ver == 2){
|
||||
if(RW_Data_1[0] != '/'){
|
||||
system("cp /kvmapp/system/ko/soph_mipi_rx.ko /mnt/system/ko/soph_mipi_rx.ko");
|
||||
@@ -161,7 +164,6 @@ void new_app_init(void)
|
||||
system("rm -r /tmp/server");
|
||||
system("cp -r /kvmapp/server /tmp/");
|
||||
system("/tmp/server/NanoKVM-Server &");
|
||||
system("/etc/init.d/S03usbdev stop_start");
|
||||
}
|
||||
|
||||
void build_complete_resolv(void)
|
||||
|
||||
@@ -470,9 +470,43 @@ uint8_t ion_free_space(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t watchdog_sf_is_open()
|
||||
int create_temp_watchdog(void)
|
||||
{
|
||||
FILE *file;
|
||||
|
||||
file = fopen(watchdog_temp_path, "w");
|
||||
if (file == NULL) {
|
||||
printf("[kvmv] Temp watchdog create error\n");
|
||||
return -1;
|
||||
}
|
||||
// fprintf(file, "%s", 'v');
|
||||
fclose(file);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void rm_temp_watchdog(void)
|
||||
{
|
||||
if(access(watchdog_temp_path, F_OK) == 0) {
|
||||
remove(watchdog_temp_path);
|
||||
}
|
||||
}
|
||||
|
||||
void auto_remove_temp_watchdog(void)
|
||||
{
|
||||
static uint8_t run_times = 0;
|
||||
static uint8_t temp_watchdog_removed = 0;
|
||||
if(temp_watchdog_removed) return;
|
||||
if(run_times++ >= RM_Watchdog_times){
|
||||
run_times = 0;
|
||||
temp_watchdog_removed = 1;
|
||||
rm_temp_watchdog();
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t watchdog_sf_is_open(void)
|
||||
{
|
||||
if(access(watchdog_mode_path, F_OK) == 0) return 1;
|
||||
if(access(watchdog_temp_path, F_OK) == 0) return 1;
|
||||
else return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ enum ip_addr_t
|
||||
#define NIC_STATE_NO_EXIST -2
|
||||
|
||||
#define watchdog_mode_path "/etc/kvm/watchdog"
|
||||
#define watchdog_temp_path "/tmp/watchdog"
|
||||
#define watchdog_file "/tmp/nanokvm_wd"
|
||||
|
||||
// net_port
|
||||
@@ -34,7 +35,10 @@ void kvm_update_rndis_state(void);
|
||||
void kvm_update_tailscale_state(void);
|
||||
uint8_t ion_free_space(void);
|
||||
int get_nic_state(const char* interface_name);
|
||||
uint8_t watchdog_sf_is_open();
|
||||
int create_temp_watchdog(void);
|
||||
void rm_temp_watchdog(void);
|
||||
void auto_remove_temp_watchdog(void);
|
||||
uint8_t watchdog_sf_is_open(void);
|
||||
int check_watchdog();
|
||||
|
||||
#endif // SYSTEM_STATE_H_
|
||||
|
||||
@@ -167,6 +167,7 @@ void* thread_sys_handle(void * arg)
|
||||
}
|
||||
|
||||
time::sleep_ms(STATE_DELAY);
|
||||
auto_remove_temp_watchdog();
|
||||
}
|
||||
kvm_sys_state.sys_thread_running = 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user