mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Marc Kleine-Budde <mkl@pengutronix.de>
To: Andrey Smirnov <andrew.smirnov@gmail.com>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH v2 1/8] imx-image: Correctly fill image size in prepended header
Date: Mon, 4 May 2015 00:34:20 +0200	[thread overview]
Message-ID: <5546A26C.6020204@pengutronix.de> (raw)
In-Reply-To: <CAHQ1cqEoL1PD4Cg7G52YvosXmsmcg1jckGL9-65_J-=qHc3XvA@mail.gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 1888 bytes --]

On 05/04/2015 12:24 AM, Andrey Smirnov wrote:
[...]
>> > @@ -178,8 +183,11 @@ static int add_header_v2(void *buf, int offset,
> uint32_t loadaddr, uint32_t imag
>> >       struct imx_flash_header_v2 *hdr;
>> >       int dcdsize = curdcd * sizeof(uint32_t);
>> >
>> > -     if (add_barebox_header)
>> > +     if (add_barebox_header) {
>> > +             uint32_t *psize = buf + ARM_HEAD_SIZE_OFFSET;
>> >               memcpy(buf, bb_header, sizeof(bb_header));
>> > +             *psize = imagesize;
>> > +     }
>>
>> In the HAB case, the resulting image will be CSF_LEN bytes bigger, see:
>> "if (prepare_sign)" below. (A signature + padding will be appended to
>> the barebox image.)
>>
>> What does the size in the barebox header mean exactly?
> 
> I am not aware of all the use-cases, but one of them is in bootstrap
> code where the value of that field is used to determine the size of an
> image to be read from a raw character device.
> 
> Is that information(CSF) needed by barebox itself and not only mask ROM
> code? If not I think there would be no harm in not including those bytes
> in the length field.

When booting the imx6 in HAB mode from SPI-NOR (my usecase for now), the
ROM code sets up the RAM according to the DCD table, copies everything
into the RAM (hdr->boot_data.start hdr->boot_data.size) does some crypto
magic and jumps into the entry point. I think the first 1k if the image
is copied, maybe check summed, but otherwise ignored.

You can move the if (add_barebox_header) block below the if
(prepare_sign) and use hdr->boot_data.size.

Marc

-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

[-- Attachment #2: Type: text/plain, Size: 149 bytes --]

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2015-05-03 22:34 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-03 21:55 Andrey Smirnov
2015-05-03 21:55 ` [PATCH v2 3/8] bootstrap_read_devfs(): Check for errors from devfs_add_partition() Andrey Smirnov
2015-05-03 21:55 ` [PATCH v2 5/8] bootstrap_read_devfs(): Fix potential memory leak Andrey Smirnov
2015-05-03 21:55 ` [PATCH v2 7/8] bootstrap_read_devfs(): Remove all partitions upon function completion Andrey Smirnov
2015-05-03 22:05 ` [PATCH v2 1/8] imx-image: Correctly fill image size in prepended header Marc Kleine-Budde
     [not found]   ` <CAHQ1cqEoL1PD4Cg7G52YvosXmsmcg1jckGL9-65_J-=qHc3XvA@mail.gmail.com>
2015-05-03 22:34     ` Marc Kleine-Budde [this message]
2015-05-04  7:41 ` Sascha Hauer

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=5546A26C.6020204@pengutronix.de \
    --to=mkl@pengutronix.de \
    --cc=andrew.smirnov@gmail.com \
    --cc=barebox@lists.infradead.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox