* [U-Boot] [PATCH] imximage: Check the IVT offset in the correct location
@ 2018-03-08 20:40 Fabio Estevam
2018-03-08 20:53 ` Breno Matheus Lima
0 siblings, 1 reply; 6+ messages in thread
From: Fabio Estevam @ 2018-03-08 20:40 UTC (permalink / raw)
To: u-boot
From: Fabio Estevam <fabio.estevam@nxp.com>
Sometimes imximage throws the following error:
CFGS board/freescale/vf610twr/imximage.cfg.cfgtmp
CFGS board/freescale/vf610twr/imximage.cfg.cfgtmp
MKIMAGE u-boot-dtb.imx
Error: No BOOT_FROM tag in board/freescale/vf610twr/imximage.cfg.cfgtmp
arch/arm/mach-imx/Makefile:100: recipe for target 'u-boot-dtb.imx' failed
This problem happens because imximage_ivt_offset is being checked
at un unsafe point, and in some cases it can be checked prior to
its assignment.
Fix this issue by only checking imximage_ivt_offset after its
assignment has really occurred.
Introduce a check_ivt_offset() function to help on this task.
Reported-by: Breno Lima <breno.lima@nxp.com>
Reported-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
---
tools/imximage.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/tools/imximage.c b/tools/imximage.c
index eb7e682..26339ee 100644
--- a/tools/imximage.c
+++ b/tools/imximage.c
@@ -592,6 +592,15 @@ static void copy_plugin_code(struct imx_header *imxhdr, char *plugin_file)
imxhdr->header.hdr_v2.boot_data.plugin = 1;
}
+static void check_ivt_offset(uint32_t offset)
+{
+ /* Exit if there is no field specifying the flash_offset */
+ if (offset == FLASH_OFFSET_UNDEFINED) {
+ fprintf(stderr, "Error: No boot offset specified");
+ exit(EXIT_FAILURE);
+ }
+}
+
static void parse_cfg_cmd(struct imx_header *imxhdr, int32_t cmd, char *token,
char *name, int lineno, int fld, int dcd_len)
{
@@ -613,6 +622,7 @@ static void parse_cfg_cmd(struct imx_header *imxhdr, int32_t cmd, char *token,
case CMD_BOOT_FROM:
imximage_ivt_offset = get_table_entry_id(imximage_boot_offset,
"imximage boot option", token);
+ check_ivt_offset(imximage_ivt_offset);
if (imximage_ivt_offset == -1) {
fprintf(stderr, "Error: %s[%d] -Invalid boot device"
"(%s)\n", name, lineno, token);
@@ -641,6 +651,7 @@ static void parse_cfg_cmd(struct imx_header *imxhdr, int32_t cmd, char *token,
break;
case CMD_BOOT_OFFSET:
imximage_ivt_offset = get_cfg_value(token, name, lineno);
+ check_ivt_offset(imximage_ivt_offset);
if (unlikely(cmd_ver_first != 1))
cmd_ver_first = 0;
break;
@@ -777,11 +788,6 @@ static uint32_t parse_cfg_file(struct imx_header *imxhdr, char *name)
(*set_dcd_rst)(imxhdr, dcd_len, name, lineno);
fclose(fd);
- /* Exit if there is no BOOT_FROM field specifying the flash_offset */
- if (imximage_ivt_offset == FLASH_OFFSET_UNDEFINED) {
- fprintf(stderr, "Error: No BOOT_FROM tag in %s\n", name);
- exit(EXIT_FAILURE);
- }
return dcd_len;
}
--
2.7.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH] imximage: Check the IVT offset in the correct location
2018-03-08 20:40 [U-Boot] [PATCH] imximage: Check the IVT offset in the correct location Fabio Estevam
@ 2018-03-08 20:53 ` Breno Matheus Lima
2018-03-08 21:31 ` Stefano Babic
2018-03-08 22:03 ` Troy Kisky
0 siblings, 2 replies; 6+ messages in thread
From: Breno Matheus Lima @ 2018-03-08 20:53 UTC (permalink / raw)
To: u-boot
Hi Fabio,
2018-03-08 17:40 GMT-03:00 Fabio Estevam <festevam@gmail.com>:
> From: Fabio Estevam <fabio.estevam@nxp.com>
>
> Sometimes imximage throws the following error:
>
> CFGS board/freescale/vf610twr/imximage.cfg.cfgtmp
> CFGS board/freescale/vf610twr/imximage.cfg.cfgtmp
> MKIMAGE u-boot-dtb.imx
> Error: No BOOT_FROM tag in board/freescale/vf610twr/imximage.cfg.cfgtmp
> arch/arm/mach-imx/Makefile:100: recipe for target 'u-boot-dtb.imx' failed
>
> This problem happens because imximage_ivt_offset is being checked
> at un unsafe point, and in some cases it can be checked prior to
> its assignment.
>
> Fix this issue by only checking imximage_ivt_offset after its
> assignment has really occurred.
>
> Introduce a check_ivt_offset() function to help on this task.
>
> Reported-by: Breno Lima <breno.lima@nxp.com>
> Reported-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
> Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
Tested-by: Breno Lima <breno.lima@nxp.com>
Thanks,
Breno Lima
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH] imximage: Check the IVT offset in the correct location
2018-03-08 20:53 ` Breno Matheus Lima
@ 2018-03-08 21:31 ` Stefano Babic
2018-03-08 22:03 ` Troy Kisky
1 sibling, 0 replies; 6+ messages in thread
From: Stefano Babic @ 2018-03-08 21:31 UTC (permalink / raw)
To: u-boot
On 08/03/2018 21:53, Breno Matheus Lima wrote:
> Hi Fabio,
>
> 2018-03-08 17:40 GMT-03:00 Fabio Estevam <festevam@gmail.com>:
>> From: Fabio Estevam <fabio.estevam@nxp.com>
>>
>> Sometimes imximage throws the following error:
>>
>> CFGS board/freescale/vf610twr/imximage.cfg.cfgtmp
>> CFGS board/freescale/vf610twr/imximage.cfg.cfgtmp
>> MKIMAGE u-boot-dtb.imx
>> Error: No BOOT_FROM tag in board/freescale/vf610twr/imximage.cfg.cfgtmp
>> arch/arm/mach-imx/Makefile:100: recipe for target 'u-boot-dtb.imx' failed
>>
>> This problem happens because imximage_ivt_offset is being checked
>> at un unsafe point, and in some cases it can be checked prior to
>> its assignment.
>>
>> Fix this issue by only checking imximage_ivt_offset after its
>> assignment has really occurred.
>>
>> Introduce a check_ivt_offset() function to help on this task.
>>
>> Reported-by: Breno Lima <breno.lima@nxp.com>
>> Reported-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
>> Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
>
> Tested-by: Breno Lima <breno.lima@nxp.com>
Thanks both - I apply it.
Best regards,
Stefano
--
=====================================================================
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH] imximage: Check the IVT offset in the correct location
2018-03-08 20:53 ` Breno Matheus Lima
2018-03-08 21:31 ` Stefano Babic
@ 2018-03-08 22:03 ` Troy Kisky
2018-03-08 22:24 ` Fabio Estevam
1 sibling, 1 reply; 6+ messages in thread
From: Troy Kisky @ 2018-03-08 22:03 UTC (permalink / raw)
To: u-boot
On 3/8/2018 12:53 PM, Breno Matheus Lima wrote:
> Hi Fabio,
>
> 2018-03-08 17:40 GMT-03:00 Fabio Estevam <festevam@gmail.com>:
>> From: Fabio Estevam <fabio.estevam@nxp.com>
>>
>> Sometimes imximage throws the following error:
>>
>> CFGS board/freescale/vf610twr/imximage.cfg.cfgtmp
>> CFGS board/freescale/vf610twr/imximage.cfg.cfgtmp
>> MKIMAGE u-boot-dtb.imx
>> Error: No BOOT_FROM tag in board/freescale/vf610twr/imximage.cfg.cfgtmp
>> arch/arm/mach-imx/Makefile:100: recipe for target 'u-boot-dtb.imx' failed
>>
>> This problem happens because imximage_ivt_offset is being checked
>> at un unsafe point, and in some cases it can be checked prior to
>> its assignment.
>>
>> Fix this issue by only checking imximage_ivt_offset after its
>> assignment has really occurred.
>>
>> Introduce a check_ivt_offset() function to help on this task.
>>
>> Reported-by: Breno Lima <breno.lima@nxp.com>
>> Reported-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
>> Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
>
> Tested-by: Breno Lima <breno.lima@nxp.com>
>
> Thanks,
> Breno Lima
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> https://lists.denx.de/listinfo/u-boot
>
Did you test that an image without BOOT_FROM still gets an error message ?
BR
Troy
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH] imximage: Check the IVT offset in the correct location
2018-03-08 22:03 ` Troy Kisky
@ 2018-03-08 22:24 ` Fabio Estevam
2018-03-08 23:24 ` Fabio Estevam
0 siblings, 1 reply; 6+ messages in thread
From: Fabio Estevam @ 2018-03-08 22:24 UTC (permalink / raw)
To: u-boot
Hi Troy,
On Thu, Mar 8, 2018 at 7:03 PM, Troy Kisky
<troy.kisky@boundarydevices.com> wrote:
> Did you test that an image without BOOT_FROM still gets an error message ?
Good point! It is not properly detecting such case.
Will need to rework the patch, thanks.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH] imximage: Check the IVT offset in the correct location
2018-03-08 22:24 ` Fabio Estevam
@ 2018-03-08 23:24 ` Fabio Estevam
0 siblings, 0 replies; 6+ messages in thread
From: Fabio Estevam @ 2018-03-08 23:24 UTC (permalink / raw)
To: u-boot
On Thu, Mar 8, 2018 at 7:24 PM, Fabio Estevam <festevam@gmail.com> wrote:
> Hi Troy,
>
> On Thu, Mar 8, 2018 at 7:03 PM, Troy Kisky
> <troy.kisky@boundarydevices.com> wrote:
>
>> Did you test that an image without BOOT_FROM still gets an error message ?
>
> Good point! It is not properly detecting such case.
>
> Will need to rework the patch, thanks.
I am back to the original mainline code plus this debug line:
--- a/tools/imximage.c
+++ b/tools/imximage.c
@@ -778,6 +778,7 @@ static uint32_t parse_cfg_file(struct imx_header
*imxhdr, char *name)
fclose(fd);
/* Exit if there is no BOOT_FROM field specifying the flash_offset */
+ fprintf(stderr, "******* offset is 0x%x\n", imximage_ivt_offset);
if (imximage_ivt_offset == FLASH_OFFSET_UNDEFINED) {
fprintf(stderr, "Error: No BOOT_FROM tag in %s\n", name);
exit(EXIT_FAILURE);
This is what I get after a 'make mrproper; make vf610twr_defconfig; make -j4'
SHIPPED dts/dt.dtb
FDTGREP dts/dt-spl.dtb
CAT u-boot-dtb.bin
COPY u-boot.dtb
COPY u-boot.bin
CFGS board/freescale/vf610twr/imximage.cfg.cfgtmp
CFGS board/freescale/vf610twr/imximage.cfg.cfgtmp
MKIMAGE u-boot-dtb.imx
******* offset is 0xffffffff
Error: No BOOT_FROM tag in board/freescale/vf610twr/imximage.cfg.cfgtmp
arch/arm/mach-imx/Makefile:100: recipe for target 'u-boot-dtb.imx' failed
make[1]: *** [u-boot-dtb.imx] Error 1
Makefile:911: recipe for target 'u-boot-dtb.imx' failed
make: *** [u-boot-dtb.imx] Error 2
make: *** Waiting for unfinished jobs....
MKIMAGE u-boot.imx
******* offset is 0x400
******* offset is 0x400
rm u-boot.imx
If I run with -j1 I see:
OBJCOPY u-boot-nodtb.bin
DTC arch/arm/dts/vf500-colibri.dtb
DTC arch/arm/dts/vf610-colibri.dtb
DTC arch/arm/dts/vf610-twr.dtb
DTC arch/arm/dts/pcm052.dtb
DTC arch/arm/dts/bk4r1.dtb
make[2]: 'arch/arm/dts/vf610-twr.dtb' is up to date.
SHIPPED dts/dt.dtb
FDTGREP dts/dt-spl.dtb
CAT u-boot-dtb.bin
CFGS board/freescale/vf610twr/imximage.cfg.cfgtmp
MKIMAGE u-boot-dtb.imx
******* offset is 0x400
******* offset is 0x400
COPY u-boot.bin
MKIMAGE u-boot.imx
******* offset is 0x400
******* offset is 0x400
MKIMAGE u-boot.vyb
OBJCOPY u-boot.srec
SYM u-boot.sym
COPY u-boot.dtb
CHK include/config.h
CFG u-boot.cfg
CFGCHK u-boot.cfg
rm u-boot.imx
It seems we need to rework the logic in arch/arm/mach-imx/Makefile to
not call the cfg parser twice one (one for u-boot-dtb.imx and another
one for u-boot.imx).
Any ideas?
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-03-08 23:24 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-08 20:40 [U-Boot] [PATCH] imximage: Check the IVT offset in the correct location Fabio Estevam
2018-03-08 20:53 ` Breno Matheus Lima
2018-03-08 21:31 ` Stefano Babic
2018-03-08 22:03 ` Troy Kisky
2018-03-08 22:24 ` Fabio Estevam
2018-03-08 23:24 ` Fabio Estevam
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.