Bug 9384

Summary: wic should write startup.nsh for bootimg-efi
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Christopher Larson <kergoth>
Component: Scripts and ToolsAssignee: Christopher Larson <kergoth>
Status: RESOLVED INVALID QA Contact:
Severity: enhancement    
Priority: Medium CC: eduard.bartosh, ross.burton
Version: unspecified   
Target Milestone: 2.2   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: Don't know

Description Christopher Larson 2016-04-04 20:42:18 UTC
I think the user will expect their device to boot on its own without having to manually input commands at the EFI boot prompt. I have this applied locally, but I'm not sure it's ideal, so would like to discuss with folks more familiar with wic and/or EFI, as I'm not an expert at either:

diff --git i/scripts/lib/wic/plugins/source/bootimg-efi.py w/scripts/lib/wic/plugins/source/bootimg-efi.py
index a4734c9..960c672 100644
--- i/scripts/lib/wic/plugins/source/bootimg-efi.py
+++ w/scripts/lib/wic/plugins/source/bootimg-efi.py
@@ -24,6 +24,7 @@
 # Tom Zanussi <tom.zanussi (at] linux.intel.com>
 #
 
+import glob
 import os
 import shutil
 
@@ -197,6 +198,12 @@ class BootimgEFIPlugin(SourcePlugin):
         except KeyError:
             msger.error("bootimg-efi requires a loader, none specified")
 
+        # Auto startup for /EFI/BOOT/boot*.efi
+        bootfiles = glob.glob('%s/EFI/BOOT/boot*.efi' % hdddir)
+        if bootfiles and len(bootfiles) == 1:
+            with open('%s/startup.nsh' % hdddir, 'w') as f:
+                f.write('fs0:\\EFI\\BOOT\\%s\n' % os.path.basename(bootfiles[0]))
+
         du_cmd = "du -bks %s" % hdddir
         out = exec_cmd(du_cmd)
         blocks = int(out.split()[0])
Comment 1 Christopher Larson 2016-04-13 17:11:38 UTC
Any thoughts on this, Ed? Is this the right direction for this, or is there a better way to resolve this? This will align the behavior of wic with that of mkefidisk.sh.
Comment 2 Ed Bartosh 2016-04-14 09:12:07 UTC
I like your idea. Need to find time to play with it. I'm not familiar with EFI enough to say if it's going to work on all EFI hardware or we need to do it differently.

BTW, which hardware did you test it on? I can try if it works on Minnowboard max if needed.
Comment 3 Christopher Larson 2016-04-14 15:29:09 UTC
Yeah, I don't know enough about EFI either, just copied the bits from mkefidisk / bootimg :) It's only tested on MinnowMax thus far.
Comment 4 Ed Bartosh 2016-04-25 09:55:53 UTC
I think it's better to include startup.nsh into efi bootloader package. This way wic will just put it into boot partition as it does for other bootloader components.

Cristopher, does it make sense for you?
Comment 5 Christopher Larson 2016-04-25 16:58:59 UTC
That seems reasonable to me, thanks.
Comment 6 Ed Bartosh 2016-04-28 09:58:58 UTC
Should we close this bug then?
Comment 7 Christopher Larson 2016-04-28 16:22:03 UTC
Yeah, I'll open a new bug to track adding it to the efi bootloader(s). Thanks again.