[PATCH v2 1/8] imx-image: Correctly fill image size in prepended header

Marc Kleine-Budde mkl at pengutronix.de
Sun May 3 15:34:20 PDT 2015


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   |

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: OpenPGP digital signature
URL: <http://lists.infradead.org/pipermail/barebox/attachments/20150504/76b108ea/attachment.sig>


More information about the barebox mailing list