summaryrefslogtreecommitdiffstats
path: root/common/fastboot.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2020-09-25 08:06:22 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2020-09-25 08:06:22 +0200
commitfaddac631a0e521780854ecf9a53f96481a32716 (patch)
tree292c866315fd161df41d90f4bbde1572b14415d1 /common/fastboot.c
parent1ab2e649dc0ccef7ee990b999e1d8f8c32e7cd24 (diff)
parent0d4d157cf0d42206491b7a1b417c9904a9abd553 (diff)
downloadbarebox-faddac631a0e521780854ecf9a53f96481a32716.tar.gz
barebox-faddac631a0e521780854ecf9a53f96481a32716.tar.xz
Merge branch 'for-next/net' into master
Diffstat (limited to 'common/fastboot.c')
-rw-r--r--common/fastboot.c57
1 files changed, 54 insertions, 3 deletions
diff --git a/common/fastboot.c b/common/fastboot.c
index 86e7997a0b..bcfadfad3d 100644
--- a/common/fastboot.c
+++ b/common/fastboot.c
@@ -46,6 +46,8 @@
#define FASTBOOT_VERSION "0.4"
static unsigned int fastboot_max_download_size = SZ_8M;
+static int fastboot_bbu;
+static char *fastboot_partitions;
struct fb_variable {
char *name;
@@ -169,6 +171,8 @@ int fastboot_generic_init(struct fastboot *fb, bool export_bbu)
struct file_list_entry *fentry;
struct fb_variable *var;
+ INIT_LIST_HEAD(&fb->variables);
+
var = fb_addvar(fb, "version");
fb_setvar(var, "0.4");
var = fb_addvar(fb, "bootloader-version");
@@ -241,6 +245,7 @@ static char *fastboot_msg[] = {
[FASTBOOT_MSG_FAIL] = "FAIL",
[FASTBOOT_MSG_INFO] = "INFO",
[FASTBOOT_MSG_DATA] = "DATA",
+ [FASTBOOT_MSG_NONE] = "",
};
int fastboot_tx_print(struct fastboot *fb, enum fastboot_msg_type type,
@@ -269,6 +274,7 @@ int fastboot_tx_print(struct fastboot *fb, enum fastboot_msg_type type,
case FASTBOOT_MSG_INFO:
pr_info("%pV\n", &vaf);
break;
+ case FASTBOOT_MSG_NONE:
case FASTBOOT_MSG_DATA:
break;
}
@@ -283,6 +289,7 @@ int fastboot_tx_print(struct fastboot *fb, enum fastboot_msg_type type,
static void cb_reboot(struct fastboot *fb, const char *cmd)
{
+ fastboot_tx_print(fb, FASTBOOT_MSG_OKAY, "");
restart_machine();
}
@@ -335,6 +342,7 @@ int fastboot_handle_download_data(struct fastboot *fb, const void *buffer,
void fastboot_download_finished(struct fastboot *fb)
{
close(fb->download_fd);
+ fb->download_fd = 0;
printf("\n");
@@ -344,6 +352,18 @@ void fastboot_download_finished(struct fastboot *fb)
fastboot_tx_print(fb, FASTBOOT_MSG_OKAY, "");
}
+void fastboot_abort(struct fastboot *fb)
+{
+ if (fb->download_fd > 0) {
+ close(fb->download_fd);
+ fb->download_fd = 0;
+ }
+
+ fb->active = false;
+
+ unlink(fb->tempname);
+}
+
static void cb_download(struct fastboot *fb, const char *cmd)
{
fb->download_size = simple_strtoul(cmd, NULL, 16);
@@ -354,6 +374,11 @@ static void cb_download(struct fastboot *fb, const char *cmd)
init_progression_bar(fb->download_size);
+ if (fb->download_fd > 0) {
+ pr_err("%s called and %s is still opened\n", __func__, fb->tempname);
+ close(fb->download_fd);
+ }
+
fb->download_fd = open(fb->tempname, O_WRONLY | O_CREAT | O_TRUNC);
if (fb->download_fd < 0) {
fastboot_tx_print(fb, FASTBOOT_MSG_FAIL, "internal error");
@@ -903,17 +928,43 @@ void fastboot_exec_cmd(struct fastboot *fb, const char *cmdbuf)
ARRAY_SIZE(cmd_dispatch_info));
}
+bool get_fastboot_bbu(void)
+{
+ return fastboot_bbu;
+}
+
+const char *get_fastboot_partitions(void)
+{
+ return fastboot_partitions;
+}
+
static int fastboot_globalvars_init(void)
{
if (IS_ENABLED(CONFIG_FASTBOOT_SPARSE))
- globalvar_add_simple_int("usbgadget.fastboot_max_download_size",
+ globalvar_add_simple_int("fastboot.max_download_size",
&fastboot_max_download_size, "%u");
+ globalvar_add_simple_bool("fastboot.bbu", &fastboot_bbu);
+ globalvar_add_simple_string("fastboot.partitions",
+ &fastboot_partitions);
+
+ globalvar_alias_deprecated("usbgadget.fastboot_function",
+ "fastboot.partitions");
+ globalvar_alias_deprecated("usbgadget.fastboot_bbu",
+ "fastboot.bbu");
+ globalvar_alias_deprecated("usbgadget.fastboot_max_download_size",
+ "fastboot.max_download_size");
return 0;
}
device_initcall(fastboot_globalvars_init);
-BAREBOX_MAGICVAR_NAMED(global_usbgadget_fastboot_max_download_size,
- global.usbgadget.fastboot_max_download_size,
+BAREBOX_MAGICVAR_NAMED(global_fastboot_max_download_size,
+ global.fastboot.max_download_size,
"Fastboot maximum download size");
+BAREBOX_MAGICVAR_NAMED(global_fastboot_partitions,
+ global.fastboot.partitions,
+ "Partitions exported for update via fastboot");
+BAREBOX_MAGICVAR_NAMED(global_fastboot_bbu,
+ global.fastboot.bbu,
+ "Export barebox update handlers via fastboot");