Commit Graph

36 Commits

Author SHA1 Message Date
Saul Wold 1382d6ccce mkefidsk: fix bash/dash shell quoting problem
mkefidsk currently writes a startup.nsh with embedded control characters.
This happens because \b etc are control sequences to the shell echo
command when using dash. The resulting startup.nsh causes the bootup
to fail, and the user is dropped into the EFI shell to manually run
startup.nsh.

Patch originally provided by Troy D. Hanson <troy.hanson@jhuapl.edu>

[YOCTO #9665]

(From OE-Core rev: 359722a86580128aeccd05531eff0da4e6971721)

Signed-off-by: Saul Wold <sgw@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit 008d6cb5bb4969f53a228893c502be8c9420ecb0)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2017-07-12 00:26:27 +01:00
Alejandro Hernandez 2dce2648e3 gummiboot: Remove/change gummiboot references with systemd-boot
After systemd-boot was introduced, its been tested for a while with no major
issues being found until now, this patch completely replaces all gummiboot
instances with systemd-boot ones, taking the next step into cleaning
up systemd-boot/gummiboot.

[YOCTO #10332]

(From OE-Core rev: f9a61d3400ad9068a6d83b8eb6aefe3098c58e68)

Signed-off-by: Alejandro Hernandez <alejandro.hernandez@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2017-01-09 13:39:11 +00:00
Ed Bartosh 2d4778b1c8 mkefidisk.sh: add deprecation warning to the output
mkefidisk.sh will soon be deprecated in favor of .wic images.

Added deprecation warning to the script to inform users that
this script will soon be removed from the codebase.

(From OE-Core rev: ccef84fac7b20d483df87aac8c620459fe31b6af)

Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-11-06 23:35:32 +00:00
Raymond Tan 37abaa362c mkefidisk.sh: mount images as read-only
Mount the hddimg and rootfs.img as read-only when creating the bootable
image on the medium. Otherwise, the md5 checksum values of the hddimg will
be altered. As this changed checksum value might cause issue for users
whom would reuse the hddimg.

(From OE-Core rev: a1391c8a603f0ed972ee0bcc8c74999f5f43be43)

Signed-off-by: Raymond Tan <raymond.tan@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-05-19 09:05:18 +01:00
Trevor Woerner b68d947e7c mkefidisk.sh: add boot log on console
Hooking up a serial console is a "developer mode", the chances are pretty good
developers are interested in watching the kernel boot log on the console so
they can spot any problems or diagnose any failed boots (e.g. can't find root
fs).

(From OE-Core rev: d03e399623b9320268a2b56e4928bb7effa9146c)

Signed-off-by: Trevor Woerner <twoerner@gmail.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-01-07 13:40:17 +00:00
Trevor Woerner 62d7c97912 mkefidisk.sh: add startup script for automated boot
Regardless of which image is built using which layers, try to ensure the image
on the SD device being prepared is the one that is booted automatically when
the board is powered.

(From OE-Core rev: 51dc79d55d0985e64838a08d39a22e8cd3fcd59a)

Signed-off-by: Trevor Woerner <twoerner@gmail.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-01-07 13:40:17 +00:00
Bruno Bottazzini 935a8bd1d9 mkefidisk: Create interactive menu for the script
If it is passed only the image parameter, it will show some interactive
options to help to conclude the script.

With this patch it will detect devices available in the machine, asking
to choose what it is wanted to be flashed.

it will suggest the target device. If it is a SD card the suggestion
is /dev/mmcblk0. If it is a pendrive it will suggest to use /dev/sda.

(From OE-Core rev: 768fb686b8dfd47ff4cb4833ce166c213502f419)

Signed-off-by: Bruno Bottazzini <bruno.bottazzini@intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-09-18 09:05:26 +01:00
Paul Eggleton 3ddd99d2c8 mkefidisk.sh: be more explicit with device error
* Specify whether the device can't be found or can't be written to
* Give a hint to use sudo

(From OE-Core rev: 92b58e1c789ee412d936285144e8e549c99ff979)

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-04-27 15:20:38 +01:00
Paul Eggleton 50623fd78c mkefidisk.sh: fix hanging on non-writeable device
If cleanup() is called early on, as happens when the device isn't
writeable, then none of the mount point variables are set; thus the
script was calling grep with only one argument and appeared to hang
since it was waiting for input on stdin.

(From OE-Core rev: cf4a18eec2a65d840352d1a2862242d116e8a409)

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-04-27 15:20:38 +01:00
Paul Eggleton 4d5c875810 mkefidisk.sh: use script mode when running parted
This avoids parted showing prompts and thus effectively hanging the
script in in the case of initially malformed disks.

(From OE-Core rev: 8f6eb9a86ce64b4c534342fe315069eb4064de88)

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-04-27 15:20:38 +01:00
Darren Hart cfa23a21d4 mkefidisk.sh: Add signal handling
Add basic signal handling to unmount and remove any temporary files.
Correct a quoting issue with the die() function caught testing signal
handling.
Fix a minor typo in "formatting" output.

(From OE-Core rev: a085cdf0e2dcf6543f61a8bdf68f83bcf8006373)

Signed-off-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2014-07-23 21:59:14 +01:00
Darren Hart ce3857994a mkefidisk.sh: Fix redirection to 1
The current script intends to redirect stderr to stdout, but instead
redirects to a file named 1. No doubt a regex replace error.

Replace all instances of 2>1 with 2>&1.

(From OE-Core rev: 1864ca9751c28cca248cfba77a3d23fc58ff43bb)

Signed-off-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2014-07-23 21:59:14 +01:00
Darren Hart c294bbe520 mkefidisk.sh: Remove initrd entry for gummiboot
My previous patch adding gummiboot support was missing the line to
remove the initrd line from the boot config. This was an oversight in
copying over the grub setup to gummiboot. Add the necessary logic to
remove it.

(From OE-Core rev: c7355550dc21a1ef3c2e828ed5f51e94e12fac5f)

Signed-off-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2014-07-23 21:59:13 +01:00
Darren Hart 172c5601d4 mkefidisk.sh: Reduce output and add verbose flag
Remove superfluous output from commands, add a -v verbose flag, and
cleanup output.

(From OE-Core rev: 0742bcd437362eb31b40e35f7331f191a1e070d0)

Signed-off-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2014-07-19 00:09:00 +01:00
Darren Hart 049100a9a7 mkefidisk.sh: Make the rootfs copy the last step
Copying the rootfs is the most time intensive task. Move it last so if
we are to encounter other errors, we do so quickly and error out.

(From OE-Core rev: 38a485aabfb57d42fa4663386c22aa9260d0a944)

Signed-off-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2014-07-19 00:09:00 +01:00
Darren Hart db162c6f56 mkefidisk.sh: Add die() and cleanup() routines
Currently the script will attempt to continue even after a fatal error.
Add a die() routine which will abort in the case of a fatal error and
call a cleanup() routine to unmount any images or devices and remove the
TMPDIR.

Move the variable assignment and directory creation earlier in the
script, making it more obvious what we need to clean up.

(From OE-Core rev: 40fe82fecf7a94b24893862ac17ee2bc749fc5e8)

Signed-off-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2014-07-19 00:09:00 +01:00
Darren Hart fd8a230e1a mkefidisk.sh: Improve logging
Add logging functions: error, warn, info, and success, using tput to add
color highlighting.

Use these routines throughout the script, replacing echo statements and
adding "|| error" in several places to eliminate silent failures. Add a
simple exit block which checks for issues encountered while running.

(From OE-Core rev: b5a3f6465a7fd8e821b81da053bf7e11535f1652)

Signed-off-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2014-07-19 00:09:00 +01:00
Darren Hart da682642ba mkefidisk.sh: Copy the EFI dir recursively
Rather than only copying the EFI/BOOT dir, copy the entire EFI dir
recursively. This allows for custom configurations to be enabled
implicitly with no extra work required.

(From OE-Core rev: f6f243bff4fa7c0e876a506a7013c86e0141556c)

Signed-off-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2014-07-19 00:09:00 +01:00
Darren Hart 88045c9db7 mkefidisk.sh: Add gummiboot support
Fixes [YOCTO 6295]

Add gummiboot support for images built using:

EFI_PROVIDER="gummiboot"

Add conditional configuration for GRUB and gummiboot. Provide some
messaging about which is being performed.

(From OE-Core rev: b0c86d8149dffd72d0dbd2451031f30953e36dc7)

Signed-off-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2014-07-19 00:09:00 +01:00
Darren Hart 7f595ea896 mkefidisk.sh: Add mount error checking
Provide reasonable feedabck if the mount commands fail.

(From OE-Core rev: 07cf8cfb843311d7f868c502d542af51f64d71bd)

Signed-off-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2014-07-19 00:09:00 +01:00
Darren Hart 3213ab465c mkefidisk.sh: Use all caps for volume names
Avoid some mkfs warnings by using all caps in the volume names.

(From OE-Core rev: d80d730a5fa84d3a036d1fc8290620e90d5db460)

Signed-off-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2014-07-19 00:09:00 +01:00
Darren Hart d340865284 mkefidisk.sh: Allow symlink for device
Allow the user to specify a symlink as the host device. If a link is
used, mkefidisk will now dereference it and use the link target when
looking for sysfs information.

(From OE-Core rev: 67bbfac55555c4e35ed9a84409aedb9b278b3de9)

Signed-off-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2014-06-24 19:54:11 +01:00
Jason Wessel cf2ebed2ff mkefidisk.sh: Allow using a loopback mounted file
It should be possible to generate a disk to a file using a loopback
device with mkefidisk.sh, which is useful for booting simulators.  To
make this possible the partitions for the loop back need to work
similarly to the mmc devices.  The mkfs.vfat also requires and
additional argument to force it to write to something other then a
real disk.

Example:
  qemu-img create -f raw bigdisk 4G
  dev=`sudo losetup -f`
  sudo losetup $dev bigdisk
  mkefidisk.sh $dev tmp-eglibc/deploy/images/qemux86/core-image-minimal-qemux86.hddimg /dev/sda
  sudo losetup -d $dev

Note:
  Also a bug was fixed in the mkefidisk.sh where if the disk you are
  writing to initially has an invalid label the size of the first
  partition will be computed incorrectly.  For the simulator disk
  creation this is generally always the case, but this can happen with
  real hardware as well.

(From OE-Core rev: 254899824900f2e8c6a34d2ad1b8cbea91acb4ae)

Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
Signed-off-by: Saul Wold <sgw@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-09-30 22:11:58 +01:00
Chen Qi d55d458734 scripts/contrib/mkefidisk.sh: fix bashism
Remove the function keyword.

(From OE-Core rev: 0eb9dd29b89449e2b9a10bf57f34c09a8bed40bc)

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
Signed-off-by: Saul Wold <sgw@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-08-06 12:39:52 +01:00
Paul Eggleton 7156f30ac3 scripts/contrib/*: fix arithmetic bashism
Apparently $[...] isn't valid in dash, so use $((...)) instead for
mkefidisk.sh and ddimage that both start with $!/bin/sh.

(From OE-Core rev: d509739ca54e6b70f2dcc216b831fc02c64293a6)

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Saul Wold <sgw@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-07-18 21:25:35 +01:00
Darren Hart c09866b4cf mkefidisk: Unmount after partitioning
Some automounters are rather overzealous and like to mount things
immediately after partitioning. This can happen if the disk is being
reused and the partitions align exactly with the existing partitions
which have already been formatted. Move the unmount code into a function
and call it before and after partitioning.

(From OE-Core rev: f1854e458e5e77806b1fc837033500fa91272261)

Signed-off-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Saul Wold <sgw@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-05-02 17:41:55 +01:00
Darren Hart d853d5b6d0 mkefidisk: Attempt to automatically unmount target device
With automounters abounding it makes more sense to attempt to unmount
the device rather than abort, just like ddimage does.

(From OE-Core rev: f522ff19ba4b80788d66a2c58ee50b86fdfea15f)

Signed-off-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Saul Wold <sgw@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-04-29 14:45:06 +01:00
Darren Hart acc5f0d94b mkefidisk: Use msdos partition tables
While GPT works fine when writing to actual media, it cannot be reliably
used for distributing disk images as it requires the backup table to be
on the last block on the device, which of course varies from device to
device. Use MSDOS tables instead.

Use mkfs to label the filesystems as msdos tables do not support
partition labeling.

(From OE-Core rev: 049ea1e0a6a1017a5020de38bd7ce93515bd62f4)

Signed-off-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-03-22 16:54:38 +00:00
Darren Hart 663c39dc1e mkefidisk: Remove startup.nsh
Most firmware implementations use the EFI specified
EFI/BOOT/bootia32.efi (and similar) boot paths. Only broken firmware
uses different paths for removable media. In those cases, the user can
add their own startup.nsh.

For the compliant case, selecting "Shell" from the EFI boot menu should
go to the shell.

(From OE-Core rev: d031cdbf40231b8c103d78c69252bf9d584d0605)

Signed-off-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-03-22 16:54:38 +00:00
Darren Hart d20eea7830 mkefidisk: Always use rootwait and document kernel parameters used
Without a reliable way of knowing if the target device with be an
asyncronous block device on the target (MMC or USB), err on the side of
caution of always specifcy "rootwait", ensuring the kernel will wait for
the device to appear and not abort if it hasn't appeared in time for
mount.

Document the remaining kernel parameters added by this script on the
same line as rootwait.

(From OE-Core rev: 5b6a6a3872fd341cf978be40c69707223e3c29df)

Signed-off-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-03-22 16:54:38 +00:00
Darren Hart 24cd3ddeb7 mkefidisk: Boot with ro kernel parameter instead of rw
There is no need to boot with "rw". Booting with "ro" will allow for
fsck to be run during boot, and a proper /etc/fstab will still ensure
the rootfs is "rw" by the time the user can interact with the system.

Change the "rw" to "ro" in the kernel parameters specified in the
generated grub.cfg file.

Fixes [YOCTO 4036] mkefidisk.sh hardcodes 'rw' as root mount option

(From OE-Core rev: 960f0cbf85a4124adbc74d8b2ceb09a7d39ecc04)

Signed-off-by: Darren Hart <dvhart@linux.intel.com>
Cc: Koen Kooi <koen@dominion.thruhere.net>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-03-22 16:54:38 +00:00
Darren Hart ca67cd9334 mkefidisk: Cleanup comment length
Keep comments under 80 characters in length.

(From OE-Core rev: 1fbab279edd0057193900646cf9f66323698e774)

Signed-off-by: Darren Hart <dvhart@linux.intel.com>
Cc: Koen Kooi <koen@dominion.thruhere.net>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-03-22 16:54:38 +00:00
Darren Hart c38da2675b mkefidisk: Always specify a root= kernel parameter
The current script only replaces an existing root= kernel parameter
which can result images created without a root= paremeter, even though
the script expects a target rootfs parameter.

Rather than replacing the root= parameter, delete the root= parameter if
it exists, then append an appropriate root= parameter.

Fixes [YOCTO 4035] mkefidisk.sh forgets to add root= parameter

(From OE-Core rev: e5dbec7e7d3bb29676280823b0337ad429c75120)

Signed-off-by: Darren Hart <dvhart@linux.intel.com>
Cc: Koen Kooi <koen@dominion.thruhere.net>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-03-22 16:54:38 +00:00
Koen Kooi 95bb9de25d mkefidisk.sh: create a proper ESP
The script was creating a FAT fs with EFI files in it, but wasn't setting the GPT GUID.

Using 'gummiboot install' natively failed because of the missing GPT GUID, so fix that. While we're there also set the name to "EFI System Partition".

(From OE-Core rev: 203ca80ee27948e2c68aab8ea48e51ff1c1157d5)

Signed-off-by: Koen Kooi <koen@dominion.thruhere.net>
Acked-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Saul Wold <sgw@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-03-18 21:42:24 +00:00
Koen Kooi 5848c5c745 mkefidisk.sh: Cope with translations and modelnames with 'Disk' in it.
The script greps for 'Disk', which doesn't work when your crazy Dutch distro has parted call it 'Schijf', so force LANG=C.

The second problem is that 'Disk' might be a substring in the Model entry:

[root@Angstrom-F16-vm-rpm contrib] # parted /dev/sdc  unit mb print
Model: SanDisk SDDR-113 (scsi)
Disk /dev/sdc: 3905MB

(From OE-Core rev: 2e404930f6fc7d818d2f429793e84bce77163afd)

Signed-off-by: Koen Kooi <koen@dominion.thruhere.net>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-03-10 04:36:50 +00:00
Darren Hart faa2a29a2d mkefidisk.sh: Add script to do an EFI install on the host
Sometimes it is convenient to prepare a bootable image from the
host rather than using a live-image to install to a disk on the
target.

This script takes a live image as input, partitions a device, and
performs the installation just as the installer would if run on
the target.

(From OE-Core rev: 7225c6739f9f1e51741a42437692868165aa1dfe)

Signed-off-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Saul Wold <sgw@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-09-21 11:10:18 +01:00