
On Sat, Nov 11, 2023 at 08:49:55PM -0700, Simon Glass wrote:
The kernel_noload image type indicates that no loading is to be done by U-Boot. This works well when the image is uncompressed.
When the image is compressed, loading is of course required. The load address in the FIT is used for loading.
However a FIT built from Linux v6.6 supports about 990 boards. Each has a different memory arrangement, so no one load address is suitable. Therefore the 'load' address in the kernel node is not useful.
It would be better in this case to be able to omit the load address and have U-Boot choose something suitable. The kernel_addr_r environment variable seems to be a more reliable final address for the kernel. Use that as a backup when the load address is missing.
Similarly, use the load address as the entry address when the latter is omitted.
Update the FIT documentation accordingly.
Note that mkimage still requires each image in a FIT to have a load address, at least for now.
Another option would be to create a new Kconfig for this, or to use a region of memory known to be free, e.g. calculated from the DRAM banks. But in any case we should try to avoid conflicting with the kernel_addr_r variable. So the approach in this patch seems reasonable to me.
It might perhaps be useful to introduce an 'entry-offset' property which allows the entry to be set as an offset from the load address, whether that is explicit or calculated.
Signed-off-by: Simon Glass sjg@chromium.org
OK, so I dug out what I was trying to determine before, and while I might see if I can bisect down to when this regressed, it might be a little hard given that my previously functional image is from 2013.
What should happen in the case of kernel_noload, and why the later patch to fail on kernel_noload + compression, is that we don't move the kernel contents of the FIT. We don't need the load address to be set because we're using it where it is. What happened before in the case of the ramdisk, and more importantly device tree, is what I why I want to bisect down to when my image stopped working. But:
@@ -177,10 +177,17 @@ static int bootm_find_os(struct cmd_tbl *cmdtp, int flag, int argc, images.os.end = fit_get_end(images.fit_hdr_os);
if (fit_image_get_load(images.fit_hdr_os, images.fit_noffset_os,
&images.os.load)) {
puts("Can't get image load address!\n");
bootstage_error(BOOTSTAGE_ID_FIT_LOADADDR);
return 1;
&images.os.load)) {
ulong load;
load = env_get_hex("kernel_addr_r", -1UL);
if (load == -1UL) {
puts("Can't get image load address!\n");
bootstage_error(BOOTSTAGE_ID_FIT_LOADADDR);
return 1;
}
printf("Using kernel load address %lx\n", load);
images.os.load = load;
The load address shouldn't be what kernel_addr_r is set to, it should be where exactly the kernel portion is in memory, right now. We don't move it, it XIPs. That's what used to happen, and how we could avoid having to put in a load address. And so long as we then later ensure it's properly aligned for the underlying image, it should be fine. _That_ however might be the harder case to deal with and then we need to perhaps note-and-move (not warn, it'll be scary sounding for just a memmove) as it's probably not the case that we've got the Image itself, for aarch64, at a 2MiB aligned boundary. The FIT was probably loaded there rather than 2MiB-sizeof(FIT header). And we need to not overwrite other contents too.