Re: [PATCH 06/11] ARM: i.MX: xload-esdhc: Allow patching first word of the image

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Jul 1, 2018 at 11:20 PM Sascha Hauer <s.hauer@xxxxxxxxxxxxxx> wrote:
>
> On Fri, Jun 29, 2018 at 08:48:55PM -0700, Andrey Smirnov wrote:
> > Depending on how SD card/eMMC was programmed first byte of the image
> > ther may or may not have appropriate branch instruction. Extend
> > esdhc_start_image() to allow passing a custom callback that would
> > patch the first instruction in memory to correctly redirect the CPU to
> > the resto of the code.
> >
> > Signed-off-by: Andrey Smirnov <andrew.smirnov@xxxxxxxxx>
> > ---
> >  arch/arm/mach-imx/xload-esdhc.c | 18 +++++++++++++++---
> >  1 file changed, 15 insertions(+), 3 deletions(-)
> >
> > diff --git a/arch/arm/mach-imx/xload-esdhc.c b/arch/arm/mach-imx/xload-esdhc.c
> > index 98ebdfcf7..c017a8b10 100644
> > --- a/arch/arm/mach-imx/xload-esdhc.c
> > +++ b/arch/arm/mach-imx/xload-esdhc.c
> > @@ -219,7 +219,8 @@ static int esdhc_read_blocks(struct esdhc *esdhc, void *dst, size_t len)
> >  }
> >
> >  static int
> > -esdhc_start_image(struct esdhc *esdhc, ptrdiff_t address, u32 offset)
> > +esdhc_start_image(struct esdhc *esdhc, ptrdiff_t address, u32 offset,
> > +               u32 (*opcode_b)(u32))
> >  {
> >       void *buf = (void *)address;
> >       u32 *ivt = buf + offset + SZ_1K;
> > @@ -254,6 +255,9 @@ esdhc_start_image(struct esdhc *esdhc, ptrdiff_t address, u32 offset)
> >
> >       bb = buf + ofs;
> >
> > +     if (opcode_b)
> > +             *(u32 *)buf = opcode_b(ofs);
> > +
>
> If I understand correctly this is to make sure that the bl31 binary
> which jumps to MX8MQ_ATF_BL33_BASE_ADDR jumps over the imx header
> to the barebox image, right?
>

That's right.

> Maybe we should memmove the barebox image to MX8MQ_ATF_BL33_BASE_ADDR
> instead of inserting handweaved assembly into the binary.
>

Yeah good point, I haven't thought about that. We definitely should be
able to do this. But now that I think of it, it should be possible to
make second esdhc_read_blocks() call such that the image is placed the
way we want it without extra memmove(). I'll give both a try and will
update in v2 according to the results.

Thanks,
Andrey Smirnov.

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



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux