uboot-mtk-20220606: fix auto enter failsafe on autoboot failure

Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
This commit is contained in:
Tianling Shen
2024-09-08 00:35:38 +08:00
committed by hanwckf
parent 5ba6fa3783
commit fccfae83a6
3 changed files with 18 additions and 28 deletions

View File

@@ -15,13 +15,16 @@
static int do_mtkboardboot(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
{
int ret;
int ret = CMD_RET_SUCCESS;
ret = board_boot_default();
if (ret)
return CMD_RET_FAILURE;
ret = CMD_RET_FAILURE;
return CMD_RET_SUCCESS;
if (IS_ENABLED(CONFIG_WEBUI_FAILSAFE_ON_AUTOBOOT_FAIL))
run_command("httpd", 0);
return ret;
}
U_BOOT_CMD(mtkboardboot, 1, 0, do_mtkboardboot,

View File

@@ -15,6 +15,7 @@
#include <net/tcp.h>
#include <net/httpd.h>
#include <u-boot/md5.h>
#include <linux/stringify.h>
#include <dm/ofnode.h>
#include <version_string.h>
@@ -468,9 +469,20 @@ int start_web_failsafe(void)
static int do_httpd(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
{
u32 local_ip;
int ret;
#ifdef CONFIG_NET_FORCE_IPADDR
net_ip = string_to_ip(__stringify(CONFIG_IPADDR));
net_netmask = string_to_ip(__stringify(CONFIG_NETMASK));
#endif
local_ip = ntohl(net_ip.s_addr);
printf("\nWeb failsafe UI started\n");
printf("URL: http://%u.%u.%u.%u/\n",
(local_ip >> 24) & 0xff, (local_ip >> 16) & 0xff,
(local_ip >> 8) & 0xff, local_ip & 0xff);
printf("\nPress Ctrl+C to exit\n");
ret = start_web_failsafe();

View File

@@ -855,37 +855,12 @@ static void tcp_conn_check(struct tcp_conn *c)
}
}
static ulong tcp_timeout_ms = 0;
void tcp_led_blink(void)
{
#ifdef CONFIG_WEBUI_FAILSAFE_ON_AUTOBOOT_FAIL
#if CONFIG_FAILSAFE_LED_GPIO_NUMBER >= 0
static int value = 0;
int ret;
ret = gpio_request(CONFIG_FAILSAFE_LED_GPIO_NUMBER, "failsafe");
if (ret && ret != -EBUSY) {
printf("gpio: requesting pin %u failed\n", CONFIG_FAILSAFE_LED_GPIO_NUMBER);
}
gpio_direction_input(CONFIG_FAILSAFE_LED_GPIO_NUMBER);
gpio_direction_output(CONFIG_FAILSAFE_LED_GPIO_NUMBER, value);
value = !value;
#endif
#endif
}
void tcp_periodic_check(void)
{
struct list_head *lh, *n;
struct tcp_conn *c;
int num = 0;
if(get_timer(0) - tcp_timeout_ms > CONFIG_SYS_HZ) {
tcp_timeout_ms = get_timer(0);
puts("T ");
tcp_led_blink();
}
list_for_each_safe(lh, n, &conn_head) {
c = list_entry(lh, struct tcp_conn, node);
tcp_conn_check(c);