diff options
author | fang hui <hui.fang@freescale.com> | 2016-05-31 08:58:30 +0800 |
---|---|---|
committer | fang hui <hui.fang@freescale.com> | 2016-05-31 12:42:16 +0800 |
commit | 435e509a30cab0e976b68b4818e1f3dafb785fbc (patch) | |
tree | 8313d0cb7192524dd7db50f8c9e857bb4a3ea786 /drivers | |
parent | 4fe36fa14e5d76717927e676d30de99bd4544ab4 (diff) | |
download | u-boot-imx-435e509a30cab0e976b68b4818e1f3dafb785fbc.zip u-boot-imx-435e509a30cab0e976b68b4818e1f3dafb785fbc.tar.gz u-boot-imx-435e509a30cab0e976b68b4818e1f3dafb785fbc.tar.bz2 |
MA-8226 - [brillo] Invalid current slot if no chance to load kernel
Due to "Brillo Boot Loader Requirements", if kernel is not valid
or authentic, should invalid current slot. So can try other slot.
This fix the failure of pts case
brillo_BootLoader:check_bootloader_fallback_on_invalid
Signed-off-by: fang hui <hui.fang@freescale.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/usb/gadget/bootctrl.c | 29 | ||||
-rw-r--r-- | drivers/usb/gadget/bootctrl.h | 1 | ||||
-rw-r--r-- | drivers/usb/gadget/f_fastboot.c | 32 |
3 files changed, 59 insertions, 3 deletions
diff --git a/drivers/usb/gadget/bootctrl.c b/drivers/usb/gadget/bootctrl.c index 943a59a..f269fd9 100644 --- a/drivers/usb/gadget/bootctrl.c +++ b/drivers/usb/gadget/bootctrl.c @@ -205,6 +205,35 @@ char *select_slot(void) return FASTBOOT_PARTITION_BOOT_B; } + +int invalid_curslot(void) +{ + int ret = 0; + struct boot_ctl t_bootctl; + unsigned int slot = g_slot_selected; + + printf("invalid_curslot %d\n", slot); + + if (slot >= SLOT_NUM) + return -1; + + ret = read_bootctl(&t_bootctl); + if (ret) { + printf("invalid_slot failed, ret %d\n", ret); + return -1; + } + + t_bootctl.a_slot_meta[slot].priority = 0; + ret = write_bootctl(&t_bootctl); + if (ret) { + printf("!!! write_bootctl failed, ret %d\n", ret); + return -1; + } + + return 0; +} + + static unsigned int slotidx_from_suffix(char *suffix) { unsigned int slot = -1; diff --git a/drivers/usb/gadget/bootctrl.h b/drivers/usb/gadget/bootctrl.h index 7712f75..9ec0bcd 100644 --- a/drivers/usb/gadget/bootctrl.h +++ b/drivers/usb/gadget/bootctrl.h @@ -30,6 +30,7 @@ struct boot_ctl { u8 recovery_tryremain; }; char *select_slot(void); +int invalid_curslot(void); bool is_sotvar(char *cmd); void get_slotvar(char *cmd, char *response, size_t chars_left); void cb_set_active(struct usb_ep *ep, struct usb_request *req); diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index d641ebd..b9711ad 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -1628,15 +1628,18 @@ int do_boota(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) else addr = simple_strtoul(argv[1], NULL, 16); + if (argc > 2) ptn = argv[2]; #ifdef CONFIG_BRILLO_SUPPORT else { +slot_select: ptn = select_slot(); if (ptn == NULL) { printf("no valid slot found, enter to recovery\n"); ptn = "recovery"; } +use_given_ptn: printf("use slot %s\n", ptn); } #endif @@ -1867,11 +1870,34 @@ int do_boota(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return 1; fail: -#ifdef CONFIG_FSL_FASTBOOT + +#if defined(CONFIG_BRILLO_SUPPORT) + if (argc > 2) + return -1; + + if (0 == strcmp(ptn, "recovery")) { + printf("boot recovery partition failed\n"); + return -1; + } + + printf("invalid slot %s\n", ptn); + + int ret = 0; + ret = invalid_curslot(); + if (ret == 0) { + goto slot_select; + } else { + ptn = "recovery"; + goto use_given_ptn; + } + +#elif defined(CONFIG_FSL_FASTBOOT) return run_command("fastboot", 0); -#else /*! CONFIG_FSL_FASTBOOT*/ +#else return -1; -#endif /*! CONFIG_FSL_FASTBOOT*/ + +#endif + } U_BOOT_CMD( |