On Wed, 15 Apr 2020 at 22:16, Manish Pandey2 <Manish.Pandey2@arm.com> wrote:


> -----Original Message-----
> From: François Ozog <francois.ozog@linaro.org>
> Sent: 15 April 2020 17:16
> To: Manish Pandey2 <Manish.Pandey2@arm.com>
> Cc: tf-a@lists.trustedfirmware.org
> Subject: Re: [TF-A] Linux as BL33
>
> On Wed, 15 Apr 2020 at 15:04, Manish Pandey2 <Manish.Pandey2@arm.com>
> wrote:
> >
> > As of now ARM_LINUX_KERNEL_AS_BL33 is only supported when
> RESET_TO_BL31=1, along with it you need to pass PRELOADED_BL33_BASE as
> well as ARM_PRELOADED_DTB_BASE.
> > AFAIK This feature is not tested for platforms which uses all the BL(1/2/31)
> stages from TF-A . The most likely reason for this is loading and
> authentication of Linux Image.
> > BL2 which is responsible for loading of various images, does not have
> support to load linux image.
> > With platforms having RESET_TO_BL31, TF-A relies on prior loader which
> loads kernel and device tree blobs at respective address.
> >
> > In short, if your platform has RESET_TO_BL31=1, it will be quite easy else
> you need to understand the BL2 loading mechanism and see if you can
> extend it for loading Linux and DTB.
> >
> If I say things differently, ARM_LINUX_KERNEL_AS_BL33 currently works on
> virtual platforms that can position the kernel and the DTB where they need
> to be so that TFA can just execute what was positioned before by the
> virtualization technology.
Yes that's correct.

> If I understand properly, the Macchiatobin BL2 actually loads a FIP into
> memory.  That fip currently has a U-Boot as a BL33 payload and the DTB. So I
> assume can replace that payload with a Kernel.
I think that should work, worth giving a try.

> I'll need to change the ARM_LINUX_KERNEL_AS_BL33  behavior in TFA so
> that it does not need RESET_TO_BL31=1,PRELOADED_BL33_BASE  and
> ARM_PRELOADED_DTB_BASE.
> Find the start address from the FIP and set x0 with the DTB of the FIP.
The only thing ARM_LINUX_KERNEL_AS_BL33 implementation does is setting x0 with DTB base.( plat/arm/common/arm_bl31_setup.c +133)
Since you are setting X0 anyways, You can give a quick try without enabling ARM_LINUX_KERNEL_AS_BL33.
> Does it look feasible?
Certainly it does, at first you might need some hacks to get it working but we can certainly improve it later.

I was able to add the DTB in the FIP as --nt-fw-config and have it properly loaded (at 0, 0x10000 64KB reservation)
Have U-boot move to 0x10000 (64KB)  and get the whole thing boot properly. A lot to learn to get that done.
Chained list of executable images is not really clear ;-)

Now, I changed U-Boot to Image, added code to ensure arg0 is 0 (DTB) but Linux does not start (zero printk visible).
I don't find kernel text base anymore, may be it disappeared: any suggestion to get the kernel start when loaded at 64KB offset?
the kernel image with embedded initrd is 10MB, SRAM is at 64MB so there should be enough space to decompress initrd...
Any suggestion?

> >
> > Kernel Output format zImage/Image should work.
> >
> > Hope this helps!
> > ________________________________
> > From: TF-A <tf-a-bounces@lists.trustedfirmware.org> on behalf of
> > François Ozog via TF-A <tf-a@lists.trustedfirmware.org>
> > Sent: 15 April 2020 13:31
> > To: tf-a@lists.trustedfirmware.org <tf-a@lists.trustedfirmware.org>
> > Subject: [TF-A] Linux as BL33
> >
> > I want to use Linux as BL33 on a Marvell Macchiatobin.
> >
> > Currently I have the successful boot flow:
> > TFA (mainline v2.2) -> U-Boot (Mainline 2020.04rc5) -> Kernel (5.6.3)
> > with U-root initrd (6.0.0, https://github.com/u-root/u-root ) ->
> > Ubuntu 19.10
> >
> > The 5.6.3 "intermediary" kernel is 5.5MB uncompressed , u-root initrd
> > is 3.5MB compressed (some form of golang based busybox).
> >
> > I was pointed to the ARM_LINUX_KERNEL_AS_BL33 option which is not
> > supported on the Macchiatobin.
> >
> > It does not look too difficult to add, but I'd like to have some
> > feedback/guidance on how to do it:
> > - how to add the option to the TFA platform
> > - how to generate a usable kernel (compile options? non relocatable
> > kernel? output format, i.e. Image, zImage, uImage...)
> >
> > Thanks for your help
> >
> > -FF
> > --
> > TF-A mailing list
> > TF-A@lists.trustedfirmware.org
> > https://lists.trustedfirmware.org/mailman/listinfo/tf-a
> > IMPORTANT NOTICE: The contents of this email and any attachments are
> confidential and may also be privileged. If you are not the intended recipient,
> please notify the sender immediately and do not disclose the contents to any
> other person, use it for any purpose, or store or copy the information in any
> medium. Thank you.
>
>
>
> --
> François-Frédéric Ozog | Director Linaro Edge & Fog Computing Group
> T: +33.67221.6485
> francois.ozog@linaro.org | Skype: ffozog
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.


--
François-Frédéric Ozog | Director Linaro Edge & Fog Computing Group
T: +33.67221.6485
francois.ozog@linaro.org | Skype: ffozog