From: 陈健洪 <chenjh@rock-chips.com>
To: trini <trini@konsulko.com>, PaliRohár <pali@kernel.org>
Cc: sjg <sjg@chromium.org>,
"Alexandru Gagniuc" <mr.nuke.me@gmail.com>,
"Yann Dirson" <yann@blade-group.com>, "Stefan Roese" <sr@denx.de>,
MarekBehún <marek.behun@nic.cz>, u-boot <u-boot@lists.denx.de>,
"kever.yang" <kever.yang@rock-cihps.com>
Subject: Re: Re: [PATCH v2] tools: mkimage: Call verify_header after writing image to disk
Date: Mon, 14 Mar 2022 09:51:47 +0800 [thread overview]
Message-ID: <202203140951467358388@rock-chips.com> (raw)
In-Reply-To: 20220308134206.GN5020@bill-the-cat
Hi,
The rk3568 uses V2 IDB structrure and the rkcommon_verify_header() has not cover V2.
My teammate will fix it these days and kever.yang will submit his patch to mainline.
陈健洪 (Joseph Chen)
E-mail:chenjh@rock-chips.com
瑞芯微电子股份有限公司
Rockchip Electronics Co.Ltd
福建省福州市铜盘路软件大道89号软件园A区21号楼 (350003)
No. 21 Building, A District, No.89,software Boulevard Fuzhou,Fujian,PRC
TEL:0591-83991906/07-8573
From: Tom Rini
Date: 2022-03-08 21:42
To: PaliRohár; Joseph Chen
CC: Simon Glass; Alexandru Gagniuc; Yann Dirson; Stefan Roese; MarekBehún; u-boot
Subject: Re: [PATCH v2] tools: mkimage: Call verify_header after writing image to disk
On Fri, Jan 14, 2022 at 06:34:43PM +0100, Pali Rohár wrote:
> If image backend provides verify_header callback then call it after writing
> image to disk. This ensures that written image is correct.
>
> Signed-off-by: Pali Rohár <pali@kernel.org>
> Reviewed-by: Stefan Roese <sr@denx.de>
> Reviewed-by: Simon Glass <sjg@chromium.org>
> ---
> tools/mkimage.c | 41 +++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 41 insertions(+)
>
> diff --git a/tools/mkimage.c b/tools/mkimage.c
> index fbe883ce3620..d5ad0925225c 100644
> --- a/tools/mkimage.c
> +++ b/tools/mkimage.c
> @@ -336,6 +336,44 @@ static void process_args(int argc, char **argv)
> usage("Missing output filename");
> }
>
> +static void verify_image(const struct image_type_params *tparams)
> +{
> + struct stat sbuf;
> + void *ptr;
> + int ifd;
> +
> + ifd = open(params.imagefile, O_RDONLY | O_BINARY);
> + if (ifd < 0) {
> + fprintf(stderr, "%s: Can't open %s: %s\n",
> + params.cmdname, params.imagefile,
> + strerror(errno));
> + exit(EXIT_FAILURE);
> + }
> +
> + if (fstat(ifd, &sbuf) < 0) {
> + fprintf(stderr, "%s: Can't stat %s: %s\n",
> + params.cmdname, params.imagefile, strerror(errno));
> + exit(EXIT_FAILURE);
> + }
> + params.file_size = sbuf.st_size;
> +
> + ptr = mmap(0, params.file_size, PROT_READ, MAP_SHARED, ifd, 0);
> + if (ptr == MAP_FAILED) {
> + fprintf(stderr, "%s: Can't map %s: %s\n",
> + params.cmdname, params.imagefile, strerror(errno));
> + exit(EXIT_FAILURE);
> + }
> +
> + if (tparams->verify_header((unsigned char *)ptr, params.file_size, ¶ms) != 0) {
> + fprintf(stderr, "%s: Failed to verify header of %s\n",
> + params.cmdname, params.imagefile);
> + exit(EXIT_FAILURE);
> + }
> +
> + (void)munmap(ptr, params.file_size);
> + (void)close(ifd);
> +}
> +
> int main(int argc, char **argv)
> {
> int ifd = -1;
> @@ -698,6 +736,9 @@ int main(int argc, char **argv)
> exit (EXIT_FAILURE);
> }
>
> + if (tparams->verify_header)
> + verify_image(tparams);
> +
> exit (EXIT_SUCCESS);
> }
I've added Joseph Chen to the thread as with this patch applied,
evb-rk3568 fails to build now with:
./tools/mkimage: Failed to verify header of idbloader.img
which is another issue to resolve.
--
Tom
next prev parent reply other threads:[~2022-03-14 1:52 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-13 14:42 [PATCH] mkimage: Call verify_header after writing image to disk Pali Rohár
2022-01-13 19:30 ` Simon Glass
2022-01-14 17:34 ` [PATCH v2] tools: " Pali Rohár
2022-01-15 9:46 ` Stefan Roese
2022-01-15 18:01 ` Simon Glass
2022-01-21 21:21 ` Tom Rini
2022-01-22 1:44 ` Pali Rohár
2022-01-22 2:15 ` Tom Rini
2022-01-22 16:31 ` Pali Rohár
2022-01-22 16:34 ` Pali Rohár
2022-01-22 16:35 ` Tom Rini
2022-02-02 9:06 ` Priyanka Jain
2022-02-15 19:52 ` Pali Rohár
2022-02-16 9:33 ` Priyanka Jain
2022-02-16 14:17 ` Z.Q. Hou
2022-03-06 11:50 ` Pali Rohár
2022-03-06 13:58 ` Tom Rini
2022-03-08 13:42 ` Tom Rini
2022-03-14 1:51 ` 陈健洪 [this message]
2022-03-14 1:54 ` 陈健洪
2022-04-06 15:55 ` Tom Rini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=202203140951467358388@rock-chips.com \
--to=chenjh@rock-chips.com \
--cc=kever.yang@rock-cihps.com \
--cc=marek.behun@nic.cz \
--cc=mr.nuke.me@gmail.com \
--cc=pali@kernel.org \
--cc=sjg@chromium.org \
--cc=sr@denx.de \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
--cc=yann@blade-group.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.