uboot-202307: sync failsafe webui with glinet uboot
This commit is contained in:
@@ -11,12 +11,25 @@
|
||||
#include <errno.h>
|
||||
#include <linux/string.h>
|
||||
#include <asm/global_data.h>
|
||||
#include <failsafe/fw_type.h>
|
||||
#include "upgrade_helper.h"
|
||||
#include "colored_print.h"
|
||||
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
|
||||
#define UPGRADE_PART "fw"
|
||||
void led_control(const char *cmd, const char *name, const char *arg);
|
||||
|
||||
const char *fw_to_part_name(failsafe_fw_t fw)
|
||||
{
|
||||
switch (fw)
|
||||
{
|
||||
case FW_TYPE_GPT: return "gpt";
|
||||
case FW_TYPE_BL2: return "bl2";
|
||||
case FW_TYPE_FIP: return "fip";
|
||||
case FW_TYPE_FW: return "fw";
|
||||
default: return "err";
|
||||
}
|
||||
}
|
||||
|
||||
static const struct data_part_entry *find_part(const struct data_part_entry *parts,
|
||||
u32 num_parts, const char *abbr)
|
||||
@@ -42,7 +55,7 @@ void *httpd_get_upload_buffer_ptr(size_t size)
|
||||
return (void *)gd->ram_base + 0x4000000;
|
||||
}
|
||||
|
||||
int failsafe_validate_image(const void *data, size_t size)
|
||||
int failsafe_validate_image(const void *data, size_t size, failsafe_fw_t fw)
|
||||
{
|
||||
const struct data_part_entry *upgrade_parts, *dpe;
|
||||
u32 num_parts;
|
||||
@@ -54,7 +67,7 @@ int failsafe_validate_image(const void *data, size_t size)
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
dpe = find_part(upgrade_parts, num_parts, UPGRADE_PART);
|
||||
dpe = find_part(upgrade_parts, num_parts, fw_to_part_name(fw));
|
||||
if (!dpe)
|
||||
return -ENODEV;
|
||||
|
||||
@@ -64,7 +77,7 @@ int failsafe_validate_image(const void *data, size_t size)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int failsafe_write_image(const void *data, size_t size)
|
||||
int failsafe_write_image(const void *data, size_t size, failsafe_fw_t fw)
|
||||
{
|
||||
const struct data_part_entry *upgrade_parts, *dpe;
|
||||
u32 num_parts;
|
||||
@@ -77,10 +90,12 @@ int failsafe_write_image(const void *data, size_t size)
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
dpe = find_part(upgrade_parts, num_parts, UPGRADE_PART);
|
||||
dpe = find_part(upgrade_parts, num_parts, fw_to_part_name(fw));
|
||||
if (!dpe)
|
||||
return -ENODEV;
|
||||
|
||||
led_control("led", "system_led", "off");
|
||||
led_control("ledblink", "blink_led", "100");
|
||||
printf("\n");
|
||||
cprintln(PROMPT, "*** Upgrading %s ***", dpe->name);
|
||||
cprintln(PROMPT, "*** Data: %zd (0x%zx) bytes at 0x%08lx ***",
|
||||
@@ -88,6 +103,8 @@ int failsafe_write_image(const void *data, size_t size)
|
||||
printf("\n");
|
||||
|
||||
ret = dpe->write(dpe->priv, dpe, data, size);
|
||||
led_control("ledblink", "blink_led", "0");
|
||||
led_control("led", "system_led", "on");
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
||||
@@ -15,19 +15,22 @@
|
||||
#include <net/mtk_httpd.h>
|
||||
#include <u-boot/md5.h>
|
||||
#include <vsprintf.h>
|
||||
#include <version_string.h>
|
||||
#include <failsafe/fw_type.h>
|
||||
#include "fs.h"
|
||||
|
||||
static u32 upload_data_id;
|
||||
static const void *upload_data;
|
||||
static size_t upload_size;
|
||||
static int upgrade_success;
|
||||
static failsafe_fw_t fw_type;
|
||||
|
||||
int __weak failsafe_validate_image(const void *data, size_t size)
|
||||
int __weak failsafe_validate_image(const void *data, size_t size, failsafe_fw_t fw)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int __weak failsafe_write_image(const void *data, size_t size)
|
||||
int __weak failsafe_write_image(const void *data, size_t size, failsafe_fw_t fw)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
@@ -58,6 +61,23 @@ static int output_plain_file(struct httpd_response *response,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void version_handler(enum httpd_uri_handler_status status,
|
||||
struct httpd_request *request,
|
||||
struct httpd_response *response)
|
||||
{
|
||||
if (status != HTTP_CB_NEW)
|
||||
return;
|
||||
|
||||
response->status = HTTP_RESP_STD;
|
||||
|
||||
response->data = version_string;
|
||||
response->size = strlen(response->data);
|
||||
|
||||
response->info.code = 200;
|
||||
response->info.connection_close = 1;
|
||||
response->info.content_type = "text/plain";
|
||||
}
|
||||
|
||||
static void index_handler(enum httpd_uri_handler_status status,
|
||||
struct httpd_request *request,
|
||||
struct httpd_response *response)
|
||||
@@ -66,109 +86,84 @@ static void index_handler(enum httpd_uri_handler_status status,
|
||||
output_plain_file(response, "index.html");
|
||||
}
|
||||
|
||||
struct upload_status {
|
||||
bool free_response_data;
|
||||
};
|
||||
|
||||
static void upload_handler(enum httpd_uri_handler_status status,
|
||||
struct httpd_request *request,
|
||||
struct httpd_response *response)
|
||||
{
|
||||
char *buff, *md5_ptr, *size_ptr, size_str[16];
|
||||
static char md5_str[33] = "";
|
||||
static char resp[128];
|
||||
struct httpd_form_value *fw;
|
||||
struct upload_status *us;
|
||||
u8 md5_sum[16];
|
||||
int i;
|
||||
|
||||
static char hexchars[] = "0123456789abcdef";
|
||||
|
||||
if (status == HTTP_CB_NEW) {
|
||||
us = calloc(1, sizeof(*us));
|
||||
if (!us) {
|
||||
response->info.code = 500;
|
||||
return;
|
||||
}
|
||||
|
||||
response->session_data = us;
|
||||
|
||||
fw = httpd_request_find_value(request, "firmware");
|
||||
if (!fw) {
|
||||
response->info.code = 302;
|
||||
response->info.connection_close = 1;
|
||||
response->info.location = "/";
|
||||
return;
|
||||
}
|
||||
|
||||
if (failsafe_validate_image(fw->data, fw->size)) {
|
||||
if (output_plain_file(response, "validate_fail.html"))
|
||||
response->info.code = 500;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (output_plain_file(response, "upload.html")) {
|
||||
response->info.code = 500;
|
||||
return;
|
||||
}
|
||||
|
||||
buff = malloc(response->size + 1);
|
||||
if (buff) {
|
||||
memcpy(buff, response->data, response->size);
|
||||
buff[response->size] = 0;
|
||||
|
||||
md5_ptr = strstr(buff, "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
|
||||
size_ptr = strstr(buff, "YYYYYYYYYY");
|
||||
|
||||
if (md5_ptr) {
|
||||
md5((u8 *)fw->data, fw->size, md5_sum);
|
||||
for (i = 0; i < 16; i++) {
|
||||
u8 hex;
|
||||
|
||||
hex = (md5_sum[i] >> 4) & 0xf;
|
||||
md5_ptr[i * 2] = hexchars[hex];
|
||||
hex = md5_sum[i] & 0xf;
|
||||
md5_ptr[i * 2 + 1] = hexchars[hex];
|
||||
}
|
||||
}
|
||||
|
||||
if (size_ptr) {
|
||||
u32 n;
|
||||
|
||||
n = snprintf(size_str, sizeof(size_str), "%zu",
|
||||
fw->size);
|
||||
memset(size_str + n, ' ', sizeof(size_str) - n);
|
||||
memcpy(size_ptr, size_str, 10);
|
||||
}
|
||||
|
||||
response->data = buff;
|
||||
us->free_response_data = true;
|
||||
}
|
||||
|
||||
upload_data_id = upload_id;
|
||||
upload_data = fw->data;
|
||||
upload_size = fw->size;
|
||||
|
||||
if (status != HTTP_CB_NEW)
|
||||
return;
|
||||
|
||||
response->status = HTTP_RESP_STD;
|
||||
response->info.code = 200;
|
||||
response->info.connection_close = 1;
|
||||
response->info.content_type = "text/plain";
|
||||
|
||||
#ifdef CONFIG_MTK_BOOTMENU_MMC
|
||||
fw = httpd_request_find_value(request, "gpt");
|
||||
if (fw) {
|
||||
fw_type = FW_TYPE_GPT;
|
||||
goto done;
|
||||
}
|
||||
#endif
|
||||
|
||||
fw = httpd_request_find_value(request, "fip");
|
||||
if (fw) {
|
||||
fw_type = FW_TYPE_FIP;
|
||||
if (failsafe_validate_image(fw->data, fw->size, fw_type))
|
||||
goto fail;
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (status == HTTP_CB_CLOSED) {
|
||||
if (response->session_data) {
|
||||
us = response->session_data;
|
||||
|
||||
if (us->free_response_data)
|
||||
free((void *)response->data);
|
||||
|
||||
free(response->session_data);
|
||||
}
|
||||
fw = httpd_request_find_value(request, "bl2");
|
||||
if (fw) {
|
||||
fw_type = FW_TYPE_BL2;
|
||||
if (failsafe_validate_image(fw->data, fw->size, fw_type))
|
||||
goto fail;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
static void flashing_handler(enum httpd_uri_handler_status status,
|
||||
struct httpd_request *request,
|
||||
struct httpd_response *response)
|
||||
{
|
||||
if (status == HTTP_CB_NEW)
|
||||
output_plain_file(response, "flashing.html");
|
||||
fw = httpd_request_find_value(request, "firmware");
|
||||
if (fw) {
|
||||
fw_type = FW_TYPE_FW;
|
||||
if (failsafe_validate_image(fw->data, fw->size, fw_type))
|
||||
goto fail;
|
||||
goto done;
|
||||
}
|
||||
|
||||
fail:
|
||||
response->data = "fail";
|
||||
response->size = strlen(response->data);
|
||||
return;
|
||||
|
||||
done:
|
||||
upload_data_id = upload_id;
|
||||
upload_data = fw->data;
|
||||
upload_size = fw->size;
|
||||
|
||||
md5((u8 *)fw->data, fw->size, md5_sum);
|
||||
for (i = 0; i < 16; i++) {
|
||||
u8 hex = (md5_sum[i] >> 4) & 0xf;
|
||||
md5_str[i * 2] = hexchars[hex];
|
||||
hex = md5_sum[i] & 0xf;
|
||||
md5_str[i * 2 + 1] = hexchars[hex];
|
||||
}
|
||||
|
||||
sprintf(resp, "%ld %s", fw->size, md5_str);
|
||||
|
||||
response->data = resp;
|
||||
response->size = strlen(response->data);
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
struct flashing_status {
|
||||
@@ -181,7 +176,6 @@ static void result_handler(enum httpd_uri_handler_status status,
|
||||
struct httpd_request *request,
|
||||
struct httpd_response *response)
|
||||
{
|
||||
const struct fs_desc *file;
|
||||
struct flashing_status *st;
|
||||
u32 size;
|
||||
|
||||
@@ -223,27 +217,17 @@ static void result_handler(enum httpd_uri_handler_status status,
|
||||
|
||||
if (upload_data_id == upload_id)
|
||||
st->ret = failsafe_write_image(upload_data,
|
||||
upload_size);
|
||||
upload_size, fw_type);
|
||||
|
||||
/* invalidate upload identifier */
|
||||
upload_data_id = rand();
|
||||
|
||||
if (!st->ret)
|
||||
file = fs_find_file("success.html");
|
||||
response->data = "success";
|
||||
else
|
||||
file = fs_find_file("fail.html");
|
||||
response->data = "failed";
|
||||
|
||||
if (!file) {
|
||||
if (!st->ret)
|
||||
response->data = "Upgrade completed!";
|
||||
else
|
||||
response->data = "Upgrade failed!";
|
||||
response->size = strlen(response->data);
|
||||
return;
|
||||
}
|
||||
|
||||
response->data = file->data;
|
||||
response->size = file->size;
|
||||
response->size = strlen(response->data);
|
||||
|
||||
st->body_sent = 1;
|
||||
|
||||
@@ -272,6 +256,16 @@ static void style_handler(enum httpd_uri_handler_status status,
|
||||
}
|
||||
}
|
||||
|
||||
static void js_handler(enum httpd_uri_handler_status status,
|
||||
struct httpd_request *request,
|
||||
struct httpd_response *response)
|
||||
{
|
||||
if (status == HTTP_CB_NEW) {
|
||||
output_plain_file(response, "main.js");
|
||||
response->info.content_type = "text/javascript";
|
||||
}
|
||||
}
|
||||
|
||||
static void not_found_handler(enum httpd_uri_handler_status status,
|
||||
struct httpd_request *request,
|
||||
struct httpd_response *response)
|
||||
@@ -282,6 +276,17 @@ static void not_found_handler(enum httpd_uri_handler_status status,
|
||||
}
|
||||
}
|
||||
|
||||
static void html_handler(enum httpd_uri_handler_status status,
|
||||
struct httpd_request *request,
|
||||
struct httpd_response *response)
|
||||
{
|
||||
if (status != HTTP_CB_NEW)
|
||||
return;
|
||||
|
||||
if (output_plain_file(response, request->urih->uri + 1))
|
||||
not_found_handler(status, request, response);
|
||||
}
|
||||
|
||||
int start_web_failsafe(void)
|
||||
{
|
||||
struct httpd_instance *inst;
|
||||
@@ -298,10 +303,19 @@ int start_web_failsafe(void)
|
||||
|
||||
httpd_register_uri_handler(inst, "/", &index_handler, NULL);
|
||||
httpd_register_uri_handler(inst, "/cgi-bin/luci", &index_handler, NULL);
|
||||
httpd_register_uri_handler(inst, "/cgi-bin/luci/", &index_handler, NULL);
|
||||
httpd_register_uri_handler(inst, "/upload", &upload_handler, NULL);
|
||||
httpd_register_uri_handler(inst, "/flashing", &flashing_handler, NULL);
|
||||
httpd_register_uri_handler(inst, "/fail.html", &html_handler, NULL);
|
||||
httpd_register_uri_handler(inst, "/flashing.html", &html_handler, NULL);
|
||||
httpd_register_uri_handler(inst, "/uboot.html", &html_handler, NULL);
|
||||
httpd_register_uri_handler(inst, "/bl2.html", &html_handler, NULL);
|
||||
#ifdef CONFIG_MTK_BOOTMENU_MMC
|
||||
httpd_register_uri_handler(inst, "/gpt.html", &html_handler, NULL);
|
||||
#endif
|
||||
httpd_register_uri_handler(inst, "/version", &version_handler, NULL);
|
||||
httpd_register_uri_handler(inst, "/result", &result_handler, NULL);
|
||||
httpd_register_uri_handler(inst, "/style.css", &style_handler, NULL);
|
||||
httpd_register_uri_handler(inst, "/main.js", &js_handler, NULL);
|
||||
httpd_register_uri_handler(inst, "", ¬_found_handler, NULL);
|
||||
|
||||
net_loop(MTK_TCP);
|
||||
@@ -312,9 +326,15 @@ int start_web_failsafe(void)
|
||||
static int do_httpd(struct cmd_tbl *cmdtp, int flag, int argc,
|
||||
char *const argv[])
|
||||
{
|
||||
u32 local_ip = ntohl(net_ip.s_addr);
|
||||
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,
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
<!DOCTYPE html>
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>404 - MediaTek System Recovery Mode</title>
|
||||
<link rel="stylesheet" type="text/css" href="/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="banner">
|
||||
MediaTek U-Boot System Recovery Mode
|
||||
</div>
|
||||
<div id="main">
|
||||
<p><strong>Page not found</strong></p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="Cache-Control" content="no-cache" />
|
||||
<meta http-equiv="refresh" content="2; URL=/" />
|
||||
<title>Page not found</title>
|
||||
<link rel="stylesheet" href="/style.css">
|
||||
<script src="/main.js"></script>
|
||||
</head>
|
||||
<body onload="getversion()">
|
||||
<div id="m">
|
||||
<h1 class="red">PAGE NOT FOUND</h1>
|
||||
<div class="i e">The page you were looking for doesn't exist!</div>
|
||||
</div>
|
||||
<div id="version"></div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -9,30 +9,34 @@ obj-y += index.o
|
||||
FILE_index.o := index.html
|
||||
FSPATH_index.o := index.html
|
||||
|
||||
obj-y += upload.o
|
||||
FILE_upload.o := upload.html
|
||||
FSPATH_upload.o := upload.html
|
||||
obj-y += main.o
|
||||
FILE_main.o := main.js
|
||||
FSPATH_main.o := main.js
|
||||
|
||||
obj-y += flashing.o
|
||||
FILE_flashing.o := flashing.html
|
||||
FSPATH_flashing.o := flashing.html
|
||||
|
||||
obj-y += success.o
|
||||
FILE_success.o := success.html
|
||||
FSPATH_success.o := success.html
|
||||
|
||||
obj-y += fail.o
|
||||
FILE_fail.o := fail.html
|
||||
FSPATH_fail.o := fail.html
|
||||
|
||||
obj-y += validate_fail.o
|
||||
FILE_validate_fail.o := validate_fail.html
|
||||
FSPATH_validate_fail.o := validate_fail.html
|
||||
|
||||
obj-y += 404.o
|
||||
FILE_404.o := 404.html
|
||||
FSPATH_404.o := 404.html
|
||||
|
||||
obj-y += uboot.o
|
||||
FILE_uboot.o := uboot.html
|
||||
FSPATH_uboot.o := uboot.html
|
||||
|
||||
obj-y += bl2.o
|
||||
FILE_bl2.o := bl2.html
|
||||
FSPATH_bl2.o := bl2.html
|
||||
|
||||
obj-y += gpt.o
|
||||
FILE_gpt.o := gpt.html
|
||||
FSPATH_gpt.o := gpt.html
|
||||
|
||||
obj-y += style.o
|
||||
FILE_style.o := style.css
|
||||
FSPATH_style.o := style.css
|
||||
@@ -60,3 +64,7 @@ $(obj)/%.o: $(src)/%.html FORCE
|
||||
$(obj)/%.o: $(src)/%.css FORCE
|
||||
$(call cmd,force_checksrc)
|
||||
$(call if_changed_dep,as_o_html)
|
||||
|
||||
$(obj)/%.o: $(src)/%.js FORCE
|
||||
$(call cmd,force_checksrc)
|
||||
$(call if_changed_dep,as_o_html)
|
||||
|
||||
38
uboot-mtk-20230718-09eda825/failsafe/fsdata/bl2.html
Executable file
38
uboot-mtk-20230718-09eda825/failsafe/fsdata/bl2.html
Executable file
@@ -0,0 +1,38 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>U-Boot update</title>
|
||||
<link rel="stylesheet" href="/style.css">
|
||||
<script src="/main.js"></script>
|
||||
</head>
|
||||
<body onload="getversion()">
|
||||
<div id="m">
|
||||
<h1>BL2 UPDATE</h1>
|
||||
<p id="hint">You are going to update <strong>BL2 bootloader</strong> on the device.<br>Please, choose file from your local hard drive and click <strong>Upload</strong> button.</p>
|
||||
<form id="form">
|
||||
<input id="file" type="file" name="bl2">
|
||||
<input type="button" value="Upload" onclick="upload('bl2')">
|
||||
</form>
|
||||
<div>
|
||||
<div class="bar" id="bar" style="display: none; --percent: 0;"></div>
|
||||
</div>
|
||||
<div id="size" style="display: none;">Size: xxxx</div>
|
||||
<div id="md5" style="display: none;">MD5: xxxx</div>
|
||||
<div id="upgrade" style="display: none;">
|
||||
<p>The BL2 has been uploaded, please click "Update"</p>
|
||||
<button class="button" onclick="location = '/flashing.html'">Update</button>
|
||||
</div>
|
||||
<div class="i w">
|
||||
<strong>WARNINGS</strong>
|
||||
<ul>
|
||||
<li>do not power off the device during update</li>
|
||||
<li>if everything goes well, the device will restart</li>
|
||||
<li>you can upload whatever you want, so be sure that you choose proper BL2 image for your device</li>
|
||||
<li>updating BL2 is a very dangerous operation and may damage your device!</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div id="version"></div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,2 +1,16 @@
|
||||
<p><strong>Upgrade failed!</strong></p>
|
||||
<p><input type="button" value="Return" onclick="location='/'" /></p>
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Update failed</title>
|
||||
<link rel="stylesheet" href="/style.css">
|
||||
<script src="/main.js"></script>
|
||||
</head>
|
||||
<body onload="getversion()">
|
||||
<div id="m">
|
||||
<h1 class="red">UPDATE FAILED</h1>
|
||||
<div class="i e"><strong>Something went wrong during update</strong>Probably you have chosen wrong file. Please, try again or contact with the author of this modification. You can also get more information during update in U-Boot console.</div>
|
||||
</div>
|
||||
<div id="version"></div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,32 +1,36 @@
|
||||
<!DOCTYPE html>
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Flashing - MediaTek System Recovery Mode</title>
|
||||
<link rel="stylesheet" type="text/css" href="/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="banner">
|
||||
MediaTek U-Boot System Recovery Mode
|
||||
</div>
|
||||
<div id="main">
|
||||
<p>Upgrading is in progressing, please wait ...</p>
|
||||
<p>This page may be in not responding status for a short time.</p>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
var interval = window.setInterval(function () {
|
||||
var xmlhttp = new XMLHttpRequest();
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Update in progress</title>
|
||||
<style>h1,p,ul{margin:0;padding:0}html,body{font:13px/20px Arial,sans-serif;background:#EDEDED}#m{max-width:750px;margin:30px auto 10px;border:solid 1px #BABABA;background:#FFF;border-radius:7px;box-shadow:0 0 10px #D2D1D1}#m > *{padding:20px}h1{font:bold 50px/50px Tahoma;border-bottom:solid 1px #E8E8E8}a,h1{color:#2450AD;text-decoration:none}.i{margin:20px;border-radius:7px;text-align:justify}.w{background:#FEFDCE;border:solid 1px #FFC643}#version{text-align:center;}form,p,h1{text-align:center}ul{list-style:square;margin:0 0 0 20px}.i strong{margin:0 0 5px;display:block}#l{height:30px;width:30px;margin:0 auto 20px;-webkit-animation:r 1s infinite linear;-moz-animation:r 1s infinite linear;-o-animation:r 1s infinite linear;animation:r 1s infinite linear;border-left:7px solid #EAF1FF;border-right:7px solid #EAF1FF;border-bottom:7px solid #EAF1FF;border-top:7px solid #2450AD;border-radius:100%}@-webkit-keyframes r{from{-webkit-transform:rotate(0deg)}to{-webkit-transform:rotate(359deg)}}@-moz-keyframes r{from{-moz-transform:rotate(0deg)}to{-moz-transform:rotate(359deg)}}@-o-keyframes r{from{-o-transform:rotate(0deg)}to{-o-transform:rotate(359deg)}}@keyframes r{from{transform:rotate(0deg)}to{transform:rotate(359deg)}}
|
||||
</style>
|
||||
<script src="/main.js"></script>
|
||||
<script>
|
||||
function init() {
|
||||
getversion();
|
||||
|
||||
window.clearInterval(interval);
|
||||
|
||||
xmlhttp.timeout = 300000;
|
||||
xmlhttp.open("GET", "/result", true);
|
||||
xmlhttp.send();
|
||||
xmlhttp.onreadystatechange = function () {
|
||||
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
|
||||
document.getElementById("main").innerHTML = xmlhttp.responseText;
|
||||
}
|
||||
ajax({
|
||||
url: '/result',
|
||||
done: function(response) {
|
||||
if (response == 'failed') {
|
||||
location = '/fail.html'
|
||||
return
|
||||
}
|
||||
document.getElementById('title').innerHTML = 'UPGRADE COMPLETE!'
|
||||
document.getElementById('info').innerHTML = 'Your device was successfully Upgraded! Now Rebooting...'
|
||||
},
|
||||
timeout: 30000
|
||||
})
|
||||
}
|
||||
}, 1000);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
</script>
|
||||
</head>
|
||||
<body onload="init()">
|
||||
<div id="m">
|
||||
<h1 id="title">UPDATE IN PROGRESS</h1>
|
||||
<p id="info">Your file was successfully uploaded! Update is in progress and you should wait for automatic reset of the device.<br>Update time depends on image size and may take up to a few minutes.</p>
|
||||
<div id="l"></div>
|
||||
</div>
|
||||
<div id="version"></div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
38
uboot-mtk-20230718-09eda825/failsafe/fsdata/gpt.html
Executable file
38
uboot-mtk-20230718-09eda825/failsafe/fsdata/gpt.html
Executable file
@@ -0,0 +1,38 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>U-Boot update</title>
|
||||
<link rel="stylesheet" href="/style.css">
|
||||
<script src="/main.js"></script>
|
||||
</head>
|
||||
<body onload="getversion()">
|
||||
<div id="m">
|
||||
<h1>GPT UPDATE</h1>
|
||||
<p id="hint">You are going to update <strong>GPT</strong> on the device.<br>Please, choose file from your local hard drive and click <strong>Upload</strong> button.</p>
|
||||
<form id="form">
|
||||
<input id="file" type="file" name="gpt">
|
||||
<input type="button" value="Upload" onclick="upload('gpt')">
|
||||
</form>
|
||||
<div>
|
||||
<div class="bar" id="bar" style="display: none; --percent: 0;"></div>
|
||||
</div>
|
||||
<div id="size" style="display: none;">Size: xxxx</div>
|
||||
<div id="md5" style="display: none;">MD5: xxxx</div>
|
||||
<div id="upgrade" style="display: none;">
|
||||
<p>The GPT has been uploaded, please click "Update"</p>
|
||||
<button class="button" onclick="location = '/flashing.html'">Update</button>
|
||||
</div>
|
||||
<div class="i w">
|
||||
<strong>WARNINGS</strong>
|
||||
<ul>
|
||||
<li>do not power off the device during update</li>
|
||||
<li>if everything goes well, the device will restart</li>
|
||||
<li>you can upload whatever you want, so be sure that you choose proper GPT for your device</li>
|
||||
<li>updating U-Boot is a very dangerous operation and may damage your device!</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div id="version"></div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,19 +1,37 @@
|
||||
<!doctype html>
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>MediaTek System Recovery Mode</title>
|
||||
<link rel="stylesheet" type="text/css" href="/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="banner">
|
||||
MediaTek U-Boot System Recovery Mode
|
||||
</div>
|
||||
<div id="main">
|
||||
<p>Upload new firmware:</p>
|
||||
<form action="/upload" method="post" enctype="multipart/form-data">
|
||||
<p><input type="file" name="firmware" /></p>
|
||||
<p><input type="submit" id="submit" value="Upload" /></p>
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Firmware update</title>
|
||||
<link rel="stylesheet" href="/style.css">
|
||||
<script src="/main.js"></script>
|
||||
</head>
|
||||
<body onload="getversion()">
|
||||
<div id="m">
|
||||
<h1>FIRMWARE UPDATE</h1>
|
||||
<p id="hint">You are going to update <strong>firmware</strong> on the device.<br>Please, choose file from your local hard drive and click <strong>Upload</strong> button.</p>
|
||||
<form id="form">
|
||||
<input id="file" type="file" name="firmware">
|
||||
<input type="button" value="Upload" onclick="upload('firmware')">
|
||||
</form>
|
||||
<div>
|
||||
<div class="bar" id="bar" style="display: none; --percent: 0;"></div>
|
||||
</div>
|
||||
<div id="size" style="display: none;">Size: xxxx</div>
|
||||
<div id="md5" style="display: none;">MD5: xxxx</div>
|
||||
<div id="upgrade" style="display: none;">
|
||||
<p>The firmware has been uploaded, please click "Update"</p>
|
||||
<button class="button" onclick="location = '/flashing.html'">Update</button>
|
||||
</div>
|
||||
<div class="i w">
|
||||
<strong>WARNINGS</strong>
|
||||
<ul>
|
||||
<li>do not power off the device during update</li>
|
||||
<li>if everything goes well, the device will restart</li>
|
||||
<li>you can upload whatever you want, so be sure that you choose proper firmware image for your device</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div id="version"></div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
80
uboot-mtk-20230718-09eda825/failsafe/fsdata/main.js
Normal file
80
uboot-mtk-20230718-09eda825/failsafe/fsdata/main.js
Normal file
@@ -0,0 +1,80 @@
|
||||
|
||||
function ajax(opt) {
|
||||
var xmlhttp;
|
||||
|
||||
if (window.XMLHttpRequest) {
|
||||
// IE7+, Firefox, Chrome, Opera, Safari
|
||||
xmlhttp = new XMLHttpRequest();
|
||||
} else {
|
||||
// IE6, IE5
|
||||
xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
|
||||
}
|
||||
|
||||
xmlhttp.upload.addEventListener('progress', function (e) {
|
||||
if (opt.progress)
|
||||
opt.progress(e)
|
||||
})
|
||||
|
||||
xmlhttp.onreadystatechange = function() {
|
||||
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
|
||||
if (opt.done)
|
||||
opt.done(xmlhttp.responseText);
|
||||
}
|
||||
}
|
||||
|
||||
if (opt.timeout)
|
||||
xmlhttp.timeout = opt.timeout;
|
||||
|
||||
var method = 'GET';
|
||||
|
||||
if (opt.data)
|
||||
method = 'POST'
|
||||
|
||||
xmlhttp.open(method, opt.url);
|
||||
xmlhttp.send(opt.data);
|
||||
}
|
||||
|
||||
function getversion() {
|
||||
ajax({
|
||||
url: '/version',
|
||||
done: function(version) {
|
||||
document.getElementById('version').innerHTML = version
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function upload(name) {
|
||||
var file = document.getElementById('file').files[0]
|
||||
if (!file)
|
||||
return
|
||||
|
||||
document.getElementById('form').style.display = 'none';
|
||||
document.getElementById('hint').style.display = 'none';
|
||||
|
||||
var form = new FormData();
|
||||
form.append(name, file);
|
||||
|
||||
ajax({
|
||||
url: '/upload',
|
||||
data: form,
|
||||
done: function(resp) {
|
||||
if (resp == 'fail') {
|
||||
location = '/fail.html';
|
||||
} else {
|
||||
const info = resp.split(' ');
|
||||
|
||||
document.getElementById('size').style.display = 'block';
|
||||
document.getElementById('size').innerHTML = 'Size: ' + info[0];
|
||||
|
||||
document.getElementById('md5').style.display = 'block';
|
||||
document.getElementById('md5').innerHTML = 'MD5: ' + info[1];
|
||||
|
||||
document.getElementById('upgrade').style.display = 'block';
|
||||
}
|
||||
},
|
||||
progress: function(e) {
|
||||
var percentage = parseInt(e.loaded / e.total * 100)
|
||||
document.getElementById('bar').setAttribute('style', '--percent: ' + percentage);
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -1,26 +1,134 @@
|
||||
h1,
|
||||
p,
|
||||
form,
|
||||
ul {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
html,
|
||||
body {
|
||||
padding: 1em;
|
||||
font: 13px/20px Arial, sans-serif;
|
||||
background: #EDEDED;
|
||||
}
|
||||
|
||||
#banner {
|
||||
width: 100%;
|
||||
height: 40px;
|
||||
font-size: 2em;
|
||||
#m {
|
||||
max-width: 750px;
|
||||
margin: 30px auto 10px;
|
||||
border: solid 1px #BABABA;
|
||||
background: #FFF;
|
||||
border-radius: 7px;
|
||||
box-shadow: 0 0 10px #D2D1D1;
|
||||
}
|
||||
|
||||
#m > * {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font: bold 50px/50px Tahoma;
|
||||
border-bottom: solid 1px #E8E8E8;
|
||||
}
|
||||
|
||||
a,
|
||||
h1 {
|
||||
color: #2450AD;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.i {
|
||||
margin: 20px;
|
||||
border-radius: 7px;
|
||||
text-align: justify;
|
||||
}
|
||||
|
||||
.w {
|
||||
background: #FEFDCE;
|
||||
border: solid 1px #FFC643;
|
||||
}
|
||||
|
||||
.e {
|
||||
background: #FFE7E7;
|
||||
border:solid 1px #FE7171;
|
||||
}
|
||||
|
||||
#version {
|
||||
text-align: center;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
#main {
|
||||
width: 500px;
|
||||
margin: auto;
|
||||
form,
|
||||
p,
|
||||
h1 {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#submit {
|
||||
ul {
|
||||
list-style: square;
|
||||
margin: 0 0 0 20px;
|
||||
}
|
||||
|
||||
.red {
|
||||
color: #E41616;
|
||||
}
|
||||
|
||||
.i strong {
|
||||
margin: 0 0 5px;
|
||||
display: block;
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
#fileinfo {
|
||||
padding-left: 20px;
|
||||
}
|
||||
#upgrade-btn {
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.bar {
|
||||
height: 20px; width:400px;
|
||||
background-color: #f5f5f5;
|
||||
border-radius: 25px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.bar::before {
|
||||
counter-reset: progress var(--percent);
|
||||
content: counter(progress) '%\2002';
|
||||
display: block;
|
||||
width: calc(400px * var(--percent) / 100);
|
||||
font-size: 12px;
|
||||
color: #fff;
|
||||
background-color: #2486ff;
|
||||
text-align: right;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
border-radius: 25px;
|
||||
}
|
||||
|
||||
#md5, #size {
|
||||
font-size: 1.6em;
|
||||
margin-left: 155px;
|
||||
}
|
||||
|
||||
#upgrade {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#upgrade p {
|
||||
color: green;
|
||||
font-size: 2em;
|
||||
}
|
||||
|
||||
.button {
|
||||
box-shadow: inset 0px -3px 7px 0px #29bbff;
|
||||
background: linear-gradient(to bottom, #2dabf9 5%, #0688fa 100%);
|
||||
background-color: #2dabf9;
|
||||
border-radius: 10px;
|
||||
border: 1px solid #0b0e07;
|
||||
color: white;
|
||||
font-size: 2em;
|
||||
padding: 9px 23px;
|
||||
text-shadow: 0px 1px 0px #263666;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.button:hover {
|
||||
background: linear-gradient(to bottom, #0688fa 5%, #2dabf9 100%);
|
||||
background-color: #0688fa;
|
||||
}
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
<p><strong>Upgrade complete!</strong></p>
|
||||
<p>Rebooting ...</p>
|
||||
38
uboot-mtk-20230718-09eda825/failsafe/fsdata/uboot.html
Executable file
38
uboot-mtk-20230718-09eda825/failsafe/fsdata/uboot.html
Executable file
@@ -0,0 +1,38 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>U-Boot update</title>
|
||||
<link rel="stylesheet" href="/style.css">
|
||||
<script src="/main.js"></script>
|
||||
</head>
|
||||
<body onload="getversion()">
|
||||
<div id="m">
|
||||
<h1>U-BOOT UPDATE</h1>
|
||||
<p id="hint">You are going to update <strong>U-Boot bootloader</strong> on the device.<br>Please, choose file from your local hard drive and click <strong>Upload</strong> button.</p>
|
||||
<form id="form">
|
||||
<input id="file" type="file" name="fip">
|
||||
<input type="button" value="Upload" onclick="upload('fip')">
|
||||
</form>
|
||||
<div>
|
||||
<div class="bar" id="bar" style="display: none; --percent: 0;"></div>
|
||||
</div>
|
||||
<div id="size" style="display: none;">Size: xxxx</div>
|
||||
<div id="md5" style="display: none;">MD5: xxxx</div>
|
||||
<div id="upgrade" style="display: none;">
|
||||
<p>The U-Boot has been uploaded, please click "Update"</p>
|
||||
<button class="button" onclick="location = '/flashing.html'">Update</button>
|
||||
</div>
|
||||
<div class="i w">
|
||||
<strong>WARNINGS</strong>
|
||||
<ul>
|
||||
<li>do not power off the device during update</li>
|
||||
<li>if everything goes well, the device will restart</li>
|
||||
<li>you can upload whatever you want, so be sure that you choose proper U-Boot image for your device</li>
|
||||
<li>updating U-Boot is a very dangerous operation and may damage your device!</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div id="version"></div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,23 +0,0 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Confirm - MediaTek System Recovery Mode</title>
|
||||
<link rel="stylesheet" type="text/css" href="/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="banner">
|
||||
MediaTek U-Boot System Recovery Mode
|
||||
</div>
|
||||
<div id="main">
|
||||
<p>File confirmation:</p>
|
||||
<div id="fileinfo">
|
||||
<p>MD5: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</p>
|
||||
<p>Size: YYYYYYYYYY Bytes</p>
|
||||
</div>
|
||||
<p>If all information above is correct, click [Proceed].</p>
|
||||
<form action="/flashing" method="post" enctype="multipart/form-data">
|
||||
<p><input type="submit" id="submit" value="Proceed" /></p>
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,16 +0,0 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Error - MediaTek System Recovery Mode</title>
|
||||
<link rel="stylesheet" type="text/css" href="/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="banner">
|
||||
MediaTek U-Boot System Recovery Mode
|
||||
</div>
|
||||
<div id="main">
|
||||
<p><strong>Firmware image verification failed!</strong></p>
|
||||
<p><input type="button" value="Return" onclick="location='/'" /></p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
13
uboot-mtk-20230718-09eda825/include/failsafe/fw_type.h
Normal file
13
uboot-mtk-20230718-09eda825/include/failsafe/fw_type.h
Normal file
@@ -0,0 +1,13 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
|
||||
#ifndef _FAILSAFE_FW_TYPE_H_
|
||||
#define _FAILSAFE_FW_TYPE_H_
|
||||
|
||||
typedef enum {
|
||||
FW_TYPE_GPT,
|
||||
FW_TYPE_BL2,
|
||||
FW_TYPE_FIP,
|
||||
FW_TYPE_FW,
|
||||
} failsafe_fw_t;
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user