public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [RFC] Booting Xen from a FIT - Additional discussion about a refactor
@ 2015-04-22 19:05 Karl Apsite
  2015-04-23  1:55 ` Simon Glass
  0 siblings, 1 reply; 9+ messages in thread
From: Karl Apsite @ 2015-04-22 19:05 UTC (permalink / raw)
  To: u-boot

Hi!

I work at DornerWorks with the Xen Hypervisor.  We work with a variety of
embedded systems, and we wanted to facilitate Xen's boot procedure through
U-boot's Flattened Image Tree (FIT) format.  I've already prototyped some of the
functionality we were hoping to see, so we thought it'd be prudent to begin a
discussion with denx to get your opinion on the matter,

First Objective: (Summary of what was prototyped)
A Flattened Image Tree is capable of holding all of the necessary binaries
already, so we only need to make a quick change to allow u-boot to load an extra
binary (in this case, a linux kernel) so that Xen can boot and load the kernel
when it's ready.  I started by simply adding a line in the configuration of my
tree-source (.its) to look like:

config at 1 {
    description = "Xen 4.6.0-unstable configuration";
    kernel = "xen_kernel at 1";
    fdt = "fdt at 1";
    gen_bin0 = "linux_kernel at 1";
};

I investigated what effort would be needed to load the additional binary.

Booting Xen is easy (only a kernel and fdt are required), but Xen will look at a
hard-coded memory address to try a load a linux kernel.  This has to be placed
in memory by u-boot.  The only major addition I needed, was to make u-boot care
about a config option named "generic-binary" and load it, no questions asked.  I
chose the name "generic binary" as I simply needed u-boot to load a [thing]
without any additional behavior.  I'm using it to specifically load a linux
kernel at a specific memory address in preparation for xen, but there could be
potential future uses, hence the ambiguous name.

The hack is pretty simple, as most everything was in place to boot xen, and it
took a little extra legwork to make u-boot care about my gen_bin.  I added the
necessary structure to load another object using ramdisk functions as examples.
 By loading a separate binary, Xen was able to boot, and successively boot Linux
as expected.  If you have any thoughts on this process overall, we'd like to
take your concerns into consideration.

For a little more fun, I extended out the configuration to be able to load N
number of generics.

Affected Files:
common/bootm.c
common/image-fit.c
common/image.c
doc/uImage.FIT/source_file_format.txt
include/configs/xilinx_zynqmp.h
include/image.h

Second Objective:
While I was there, I noticed that u-boot's binary loading logic isn't as modular
as I first expected.  Most objects eventually boil down to a boot_get_<thing>().
Example: boot_get_ramdisk() or boot_get_kernel().  These functions are all very
similar as they handle the various u-boot image types and load their specific
binary.  The functions appear to have grown similar in structure and operation
overtime.  I don't think it is too much to reduce the duplicated structure of
the functions into a common boot_get_object() function, while replacing some of
the extra function wrappings.

Some quick diagrams to explain what I mean
Initial:  http://i.imgur.com/H44dXmN.png (29KB)
Refactor: http://i.imgur.com/apEpyWz.png (24KB)

The refactor will likely effect the following files, several of which contain
trivial name changes, or small changes in a variable type.
arch/arm/lib/bootm.c
arch/avr32/lib/bootm.c
arch/microblaze/lib/bootm.c
arch/mips/lib/bootm.c
arch/nds32/lib/bootm.c
arch/nios2/lib/bootm.c
arch/openrisc/lib/bootm.c
arch/powerpc/lib/bootm.c
arch/sh/lib/bootm.c
arch/sparc/lib/bootm.c
arch/x86/lib/bootm.c
common/bootm.c
common/bootm_os.c
common/cmd_bootm.c
common/image-fdt.c
common/image.c
include/bootm.h
include/image.h

Summary
1.) RFC: What is the opinion on implementing a FIT configuration option to
permit a FIT to boot Xen
2.) RFC: What is the opinion on a potential refactor concerning the
image-loading functions (boot_get_ramdisk, boot_get_kernel, etc) in order to
unify them into one common boot_get_object() function.

^ permalink raw reply	[flat|nested] 9+ messages in thread
* [U-Boot] [RFC] Booting Xen from a FIT - Additional discussion about a refactor
@ 2015-05-01 16:21 Karl Apsite
  2015-05-04 21:40 ` Simon Glass
  2015-05-04 21:41 ` Simon Glass
  0 siblings, 2 replies; 9+ messages in thread
From: Karl Apsite @ 2015-05-01 16:21 UTC (permalink / raw)
  To: u-boot

Hi Simon,
I Added the email listed in the test script to this conversation

>>>
>>> Please do add tests for the new functionality - see test/image for
>>> some existing tests. Python is preferred if the test is non-trivial.
>>
>> Absolutely, I'll be sure to include some tests in the patch(es)..
>
> Great. This area of U-Boot has had a lot of undocumented or untested
> behaviour. It has got a bit better but your boot function sounds like
> another step in the right direction.

I took a look at the current set of tests, and I'm not sure what's required to
run them.  Is there an undocumented runner in the Makefile?  I can run the
specified make target to prepare for the tests it sounds like:
`make O=sandbox sandbox_config`

However trying to run the script just generated errors about missing images.

Do you know what's needed to run the script?

Log:
$ test/image/test-imagetools.sh

Building multi-file image...
# sandbox/tools/mkimage -A x86 -O linux -T multi -n "v1.0-test" -d
sandbox/boot/vmlinuz:sandbox/boot/initrd.img:sandbox/boot/System.map linux.img
test/image/test-imagetools.sh: line 73: sandbox/tools/mkimage: No such file or
directory
done.

Extracting multi-file image contents...
# sandbox/tools/dumpimage -T multi -i linux.img -p 0 vmlinuz
test/image/test-imagetools.sh: line 73: sandbox/tools/dumpimage: No such file or
directory
# sandbox/tools/dumpimage -T multi -i linux.img -p 1 initrd.img
test/image/test-imagetools.sh: line 73: sandbox/tools/dumpimage: No such file or
directory
# sandbox/tools/dumpimage -T multi -i linux.img -p 2 System.map
test/image/test-imagetools.sh: line 73: sandbox/tools/dumpimage: No such file or
directory
# sandbox/tools/dumpimage -T multi -i linux.img -p 2 System.map -o test_output
test/image/test-imagetools.sh: line 73: sandbox/tools/dumpimage: No such file or
directory
done.
diff: vmlinuz: No such file or directory
Failed.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2015-05-04 21:41 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-22 19:05 [U-Boot] [RFC] Booting Xen from a FIT - Additional discussion about a refactor Karl Apsite
2015-04-23  1:55 ` Simon Glass
2015-04-23 13:15   ` Karl Apsite
2015-04-23 17:06     ` Simon Glass
2015-04-23 21:39       ` Karl Apsite
2015-04-24 15:46         ` Simon Glass
  -- strict thread matches above, loose matches on Subject: below --
2015-05-01 16:21 Karl Apsite
2015-05-04 21:40 ` Simon Glass
2015-05-04 21:41 ` Simon Glass

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox