From: Jaehoon Chung Date: Thu, 20 Oct 2016 06:55:11 +0000 (+0900) Subject: cmd: usbdown: support the checking signature feature X-Git-Tag: submit/tizen/20170414.042831~15 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3b01f4e6793494e149dcea50818607a2727db56f;p=platform%2Fkernel%2Fu-boot.git cmd: usbdown: support the checking signature feature Added the checking signature feature for preventing to flash wrong image. This funcionality does the same behavior with thor. Change-Id: I2645cd8e506ea412be39186952a0860fe64bdaf3 Signed-off-by: Jaehoon Chung --- diff --git a/cmd/usbdown.c b/cmd/usbdown.c index 4046254050..3d54034355 100644 --- a/cmd/usbdown.c +++ b/cmd/usbdown.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -370,6 +371,24 @@ int do_update(cmd_tbl_t *cmdtp, int flags, int argc, char * const argv[]) return -EINVAL; } +#ifdef CONFIG_SIG + /* It needs to check the signature about only u-boot image */ + if (!strncmp(usbdown->name, "u-boot", strlen(usbdown->name))) { + if (fs_set_blk_dev(from, argv[1], FS_TYPE_ANY)) + return CMD_RET_FAILURE; + + ret = fs_read(filename, (phys_addr_t)addr, 0, + size, &len_read); + if (ret) + return CMD_RET_FAILURE; + + ret = check_board_signature("u-boot-mmc.bin", + (phys_addr_t)addr, (phys_addr_t)size); + if (ret) + return CMD_RET_FAILURE; + } +#endif + if (usbdown->layout == FS_FAT) { /* loading File */ fsname = "fat"; @@ -514,7 +533,9 @@ int do_usb_down(cmd_tbl_t *cmdtp, int flags, int argc, char * const argv[]) sprintf(cmd_buf, "%s %s %s %s", cmd, part, interface, dir); sprintf(cmd_buf + strlen(cmd_buf), "/%s", name[i]); - run_command(cmd_buf, 0); + ret = run_command(cmd_buf, 0); + if (ret == CMD_RET_FAILURE) + return ret; printf("\n"); }