diff options
author | Winter Wang <wente.wang@nxp.com> | 2016-11-17 16:55:26 +0800 |
---|---|---|
committer | Winter Wang <wente.wang@nxp.com> | 2016-11-18 12:52:19 +0800 |
commit | 9eeacefe0d235c0d8c9c48fc27e60ae17ac92c75 (patch) | |
tree | 6866804bd5cd3abea0f8e018d79fe0687cef09f2 | |
parent | a5a753d62da1c6352235845629470e5337f4f347 (diff) | |
download | u-boot-imx-9eeacefe0d235c0d8c9c48fc27e60ae17ac92c75.zip u-boot-imx-9eeacefe0d235c0d8c9c48fc27e60ae17ac92c75.tar.gz u-boot-imx-9eeacefe0d235c0d8c9c48fc27e60ae17ac92c75.tar.bz2 |
MA-9027 fastboot: support set_active to 'a' 'b'
new version of fastboot set_active sends 'a'/'b'
instead of '_a'/'_b'
Change-Id: I1c56f9401e82cba6801e4eff59d413ce5a2617c7
Signed-off-by: Winter Wang <wente.wang@nxp.com>
-rw-r--r-- | drivers/usb/gadget/bootctrl.c | 6 | ||||
-rw-r--r-- | drivers/usb/gadget/f_fastboot.c | 9 | ||||
-rw-r--r-- | lib/libavb/fsl/fsl_avb.h | 6 | ||||
-rw-r--r-- | lib/libavb/fsl/fsl_bootctl.c | 18 |
4 files changed, 23 insertions, 16 deletions
diff --git a/drivers/usb/gadget/bootctrl.c b/drivers/usb/gadget/bootctrl.c index 5528179..6f19418 100644 --- a/drivers/usb/gadget/bootctrl.c +++ b/drivers/usb/gadget/bootctrl.c @@ -272,9 +272,11 @@ static unsigned int slotidx_from_suffix(char *suffix) { unsigned int slot = -1; - if (!strcmp(suffix, "_a")) + if (!strcmp(suffix, "_a") || + !strcmp(suffix, "a")) slot = 0; - else if (!strcmp(suffix, "_b")) + else if (!strcmp(suffix, "_b") || + !strcmp(suffix, "b")) slot = 1; return slot; diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index 00b6c8e..0a685d2 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -3112,11 +3112,10 @@ static void cb_erase(struct usb_ep *ep, struct usb_request *req) #endif #ifdef CONFIG_AVB_SUPPORT -static const char *slot_suffix[2] = {"_a", "_b"}; static void cb_set_active_avb(struct usb_ep *ep, struct usb_request *req) { AvbIOResult ret; - unsigned int slot = 0; + int slot = 0; char *cmd = req->buf; strsep(&cmd, ":"); @@ -3126,11 +3125,9 @@ static void cb_set_active_avb(struct usb_ep *ep, struct usb_request *req) return; } - for (slot = 0; slot < 2; slot ++) - if (!strcmp(cmd, slot_suffix[slot])) - break; + slot = slotidx_from_suffix(cmd); - if (slot >= 2) { + if (slot < 0) { fastboot_tx_write_str("FAILerr slot suffix"); return; } diff --git a/lib/libavb/fsl/fsl_avb.h b/lib/libavb/fsl/fsl_avb.h index d3f26c7..539c5f6 100644 --- a/lib/libavb/fsl/fsl_avb.h +++ b/lib/libavb/fsl/fsl_avb.h @@ -142,6 +142,12 @@ AvbIOResult fsl_get_unique_guid_for_partition(AvbOps* ops, * */ bool is_slotvar_avb(char *cmd); +/* return 0 for the first slot + * return 1 for the second slot + * return -1 for not supported slot + * */ +int slotidx_from_suffix(char *suffix); + /* return fastboot's getvar cmd response * cmd is the fastboot getvar's cmd in * response is bootctl's slot var out diff --git a/lib/libavb/fsl/fsl_bootctl.c b/lib/libavb/fsl/fsl_bootctl.c index ab08d70..c112248 100644 --- a/lib/libavb/fsl/fsl_bootctl.c +++ b/lib/libavb/fsl/fsl_bootctl.c @@ -26,12 +26,14 @@ static bool slot_is_bootable(AvbABSlotData* slot) { (slot->successful_boot || (slot->tries_remaining > 0)); } -static unsigned int slotidx_from_suffix(char *suffix) { - unsigned int slot = ~0; +int slotidx_from_suffix(char *suffix) { + int slot = -1; - if (!strcmp(suffix, "_a")) + if (!strcmp(suffix, "_a") || + !strcmp(suffix, "a")) slot = 0; - else if (!strcmp(suffix, "_b")) + else if (!strcmp(suffix, "_b") || + !strcmp(suffix, "b")) slot = 1; return slot; @@ -69,7 +71,7 @@ void get_slotvar_avb(AvbOps *ops, char *cmd, char *response, size_t chars_left) AvbABData ab_data; AvbABSlotData *slot_data; - unsigned int slot; + int slot; assert(ops != NULL && cmd != NULL && response != NULL); @@ -100,7 +102,7 @@ void get_slotvar_avb(AvbOps *ops, char *cmd, char *response, size_t chars_left) } else if (!strcmp_l1("slot-successful:", cmd)) { char *suffix = strchr(cmd, ':') + 1; slot = slotidx_from_suffix(suffix); - if (slot >= SLOT_NUM) { + if (slot < 0) { strncat(response, "no such slot", chars_left); } else { slot_data = &ab_data.slots[slot]; @@ -111,7 +113,7 @@ void get_slotvar_avb(AvbOps *ops, char *cmd, char *response, size_t chars_left) } else if (!strcmp_l1("slot-unbootable:", cmd)) { char *suffix = strchr(cmd, ':') + 1; slot = slotidx_from_suffix(suffix); - if (slot >= SLOT_NUM) { + if (slot < 0) { strncat(response, "no such slot", chars_left); } else { slot_data = &ab_data.slots[slot]; @@ -122,7 +124,7 @@ void get_slotvar_avb(AvbOps *ops, char *cmd, char *response, size_t chars_left) } else if (!strcmp_l1("slot-retry-count:", cmd)) { char *suffix = strchr(cmd, ':') + 1; slot = slotidx_from_suffix(suffix); - if (slot >= SLOT_NUM) + if (slot < 0) strncat(response, "no such slot", chars_left); else { slot_data = &ab_data.slots[slot]; |