Hi Olivier/Steve/Leif/whoever is interested,

I have a problem I'm trying to solve and I don't think there is a proper
solution using the current ARM BDS.

Basically, some of Linaro's releases are failing to boot "out of the box"
due to incorrect default BDS config.  The default assumes that the image
has an initrd.

Android (the main focus of our releases) and Ubuntu images use an initrd.
OpenEmbedded images do not.

I'd like a single UEFI binary that can work on all three without
reconfiguration.

The obvious solutions are:
1) there is no default config that always works and the user should
configure the board
   themselves each time they want to boot a different image type.
   Our LAVA automated test environment and people like myself who boot test
many images
  daily don't favour this option.

2) change OpenEmbedded to use an initrd
   It's not my image to change and the owners don't want to do that because
it's also wrong.

3) Have different UEFI binaries for each image type
   This isn't ideal because I (and LAVA) would be forever reflashing UEFI.

4) Make BDS continue if it can't load the initrd
   This isn't ideal because if there is no initrd, it could be for a bad
reason.  By continuing, we
   aren't giving the user the change to immediately correct the config.
   However, the likelihood of the initrd being completely missing, whilst a
valid kernel and FDT
   is provided seems slim.  If it is missing, it's most likely on purpose.

Of the options above, I prefer #4 and have provided a patch below for
discussion.  I suspect that if it's not going to cause other problems, it
could be like my other BDS hacks, fixes and improvements and only live in
the Linaro tree, which would be fine with me too.

Opinions on a way forward and/or this patch?

Regards,
Ryan.

note: the patch looks a little larger than it should because I had to
indent the section beginning with the comment "// Check if the initrd is a
uInitrd", although that section is unmodified otherwise.


>From aaec8cb3f386a9a128f57a2d0fcbb4396a101ec4 Mon Sep 17 00:00:00 2001
From: Ryan Harkin <ryan.har...@linaro.org>
Date: Tue, 19 Nov 2013 08:10:00 +0000
Subject: [PATCH] ARM/BDS: skip initrd if not found

When loading a Linux image, if the initrd is not found, we will display
an error, but attempt to load the kernel anyway.

Previous behaviour dropped the user back to the menu, thus allowing them
to update the config.  However, this does not suit booting in automated
environments where test images may or may not have an initrd.  Example,
Ubuntu and Android images require an initrd; OpenEmbedded images do not.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ryan Harkin <ryan.har...@linaro.org>
---
 ArmPkg/Library/BdsLib/Arm/BdsLinuxLoader.c |   26
+++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/ArmPkg/Library/BdsLib/Arm/BdsLinuxLoader.c
b/ArmPkg/Library/BdsLib/Arm/BdsLinuxLoader.c
index d0eb075..d2a161a 100644
--- a/ArmPkg/Library/BdsLib/Arm/BdsLinuxLoader.c
+++ b/ArmPkg/Library/BdsLib/Arm/BdsLinuxLoader.c
@@ -258,19 +258,20 @@ BdsBootLinuxFdt (
       Status = BdsLoadImage (InitrdDevicePath, AllocateAnyPages,
&InitrdImageBase, &InitrdImageBaseSize);
     }
     if (EFI_ERROR(Status)) {
-      Print (L"ERROR: Did not find initrd image.\n");
-      goto EXIT_FREE_LINUX;
-    }
-
-    // Check if the initrd is a uInitrd
-    if (*(UINT32*)((UINTN)InitrdImageBase) == LINUX_UIMAGE_SIGNATURE) {
-      // Skip the 64-byte image header
-      InitrdImage = (EFI_PHYSICAL_ADDRESS)((UINTN)InitrdImageBase + 64);
-      InitrdImageSize = InitrdImageBaseSize - 64;
-    } else {
-      InitrdImage = InitrdImageBase;
-      InitrdImageSize = InitrdImageBaseSize;
+      Print (L"ERROR: Did not find initrd image, you may need to update
your config. Attempting to continue without it.\n");
+      InitrdImageBase = 0;
     }
+    else {
+      // Check if the initrd is a uInitrd
+      if (*(UINT32*)((UINTN)InitrdImageBase) == LINUX_UIMAGE_SIGNATURE) {
+        // Skip the 64-byte image header
+        InitrdImage = (EFI_PHYSICAL_ADDRESS)((UINTN)InitrdImageBase + 64);
+        InitrdImageSize = InitrdImageBaseSize - 64;
+      } else {
+        InitrdImage = InitrdImageBase;
+        InitrdImageSize = InitrdImageBaseSize;
+      }
+    }
   }

   // Load the FDT binary from a device path. The FDT will be reloaded
later to a more appropriate location for the Linux kernel.
@@ -299,7 +300,6 @@ EXIT_FREE_INITRD:
     gBS->FreePages (InitrdImageBase, EFI_SIZE_TO_PAGES
(InitrdImageBaseSize));
   }

-EXIT_FREE_LINUX:
   gBS->FreePages (LinuxImage, EFI_SIZE_TO_PAGES (LinuxImageSize));

   return Status;
-- 
1.7.9.5
------------------------------------------------------------------------------
Shape the Mobile Experience: Free Subscription
Software experts and developers: Be at the forefront of tech innovation.
Intel(R) Software Adrenaline delivers strategic insight and game-changing 
conversations that shape the rapidly evolving mobile landscape. Sign up now. 
http://pubads.g.doubleclick.net/gampad/clk?id=63431311&iu=/4140/ostg.clktrk
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to