diff options
author | Pali Rohár <pali@kernel.org> | 2021-11-08 18:12:43 +0100 |
---|---|---|
committer | Stefan Roese <sr@denx.de> | 2021-11-10 12:08:06 +0100 |
commit | d1547b367267020a48bc95ed1f00a0c58de278b9 (patch) | |
tree | 3cb6601ac925c498fe6a333298a45dede1733894 /tools | |
parent | 01bdac6df6815b9f0b5d69b7e0b543923cfe4c15 (diff) | |
download | u-boot-d1547b367267020a48bc95ed1f00a0c58de278b9.zip u-boot-d1547b367267020a48bc95ed1f00a0c58de278b9.tar.gz u-boot-d1547b367267020a48bc95ed1f00a0c58de278b9.tar.bz2 |
tools: kwbimage: Set BOOT_FROM by default to SPI
kwbimage must have valid blockid member instead of zero value. Thus if
config file does not contain BOOT_FROM command, use by default the value
for SPI booting (which is probably the most common).
Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/kwbimage.c | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/tools/kwbimage.c b/tools/kwbimage.c index d29f2cf..38b6e2f 100644 --- a/tools/kwbimage.c +++ b/tools/kwbimage.c @@ -266,6 +266,18 @@ static bool image_get_spezialized_img(void) return e->sec_specialized_img; } +static int image_get_bootfrom(void) +{ + struct image_cfg_element *e; + + e = image_find_option(IMAGE_CFG_BOOT_FROM); + if (!e) + /* fallback to SPI if no BOOT_FROM is not provided */ + return IBR_HDR_SPI_ID; + + return e->bootfrom; +} + /* * Compute a 8-bit checksum of a memory area. This algorithm follows * the requirements of the Marvell SoC BootROM specifications. @@ -884,10 +896,8 @@ static void *image_create_v0(size_t *imagesz, struct image_tool_params *params, main_hdr->version = 0; main_hdr->destaddr = cpu_to_le32(params->addr); main_hdr->execaddr = cpu_to_le32(params->ep); + main_hdr->blockid = image_get_bootfrom(); - e = image_find_option(IMAGE_CFG_BOOT_FROM); - if (e) - main_hdr->blockid = e->bootfrom; e = image_find_option(IMAGE_CFG_NAND_ECC_MODE); if (e) main_hdr->nandeccmode = e->nandeccmode; @@ -1232,9 +1242,8 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params, main_hdr->srcaddr = cpu_to_le32(headersz); main_hdr->ext = hasext; main_hdr->version = 1; - e = image_find_option(IMAGE_CFG_BOOT_FROM); - if (e) - main_hdr->blockid = e->bootfrom; + main_hdr->blockid = image_get_bootfrom(); + e = image_find_option(IMAGE_CFG_NAND_BLKSZ); if (e) main_hdr->nandblocksize = e->nandblksz / (64 * 1024); @@ -1559,17 +1568,6 @@ static int image_get_version(void) return e->version; } -static int image_get_bootfrom(void) -{ - struct image_cfg_element *e; - - e = image_find_option(IMAGE_CFG_BOOT_FROM); - if (!e) - return -1; - - return e->bootfrom; -} - static void kwbimage_set_header(void *ptr, struct stat *sbuf, int ifd, struct image_tool_params *params) { |