diff options
author | Michael Olbrich <m.olbrich@pengutronix.de> | 2011-03-21 10:06:11 +0100 |
---|---|---|
committer | Michael Olbrich <m.olbrich@pengutronix.de> | 2011-03-28 11:11:42 +0200 |
commit | a9b333f262175c8dd2fca0b75bd41f8b2a6c0f27 (patch) | |
tree | d2b33a75c309cdc7cc1c33f9f822fd208896d898 | |
parent | 4accb167e80929356d0b200c1ca8db955dec38cd (diff) | |
download | ptxdist-a9b333f262175c8dd2fca0b75bd41f8b2a6c0f27.tar.gz ptxdist-a9b333f262175c8dd2fca0b75bd41f8b2a6c0f27.tar.xz |
barebox: improve installing barebox on x86
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
-rw-r--r-- | scripts/lib/ptxd_make_bootable.sh | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/scripts/lib/ptxd_make_bootable.sh b/scripts/lib/ptxd_make_bootable.sh index ed9bc31fd..e53110af9 100644 --- a/scripts/lib/ptxd_make_bootable.sh +++ b/scripts/lib/ptxd_make_bootable.sh @@ -51,6 +51,28 @@ ptxd_make_dd_bootloader() { } export -f ptxd_make_dd_bootloader +# +# Install barebox on x86 systems. +# barebox is installed in the first sector and at the end of the free space. +# The space between is used for the barebox environment. +# +# $1 the image to modify +# $2 number of free sectors at the start of the image +# $3 the barebox image +# +ptxd_make_x86_boot_barebox() { + local image="$1" + local sectors="$2" + local barebox="$3" + local needed="$(stat --printf="%s" "${barebox}")" + # round to the next sector + needed=$(((${needed}-1)/512+1)) + if [ "${needed}" -gt "${sectors}" ]; then + ptxd_bailout "Not enough space to write barebox: available: ${sectors} needed: ${needed} (sectors)" + fi + setupmbr -s $((${sectors}-${needed})) -m "${barebox}" -d "${image}" +} +export -f ptxd_make_x86_boot_barebox # # Make a disk image bootable. What exactly happens depends on the selected @@ -83,7 +105,7 @@ ptxd_make_bootable() { echo "--------------------------------------" stage1="${ptx_image_dir}/barebox-image" if ptxd_get_ptxconf PTXCONF_ARCH_X86 > /dev/null; then - setupmbr -s 32 -m "${stage1}" -d "${image}" + ptxd_make_x86_boot_barebox "${image}" "${sectors}" "${stage1}" return fi fi |