From a9b333f262175c8dd2fca0b75bd41f8b2a6c0f27 Mon Sep 17 00:00:00 2001 From: Michael Olbrich Date: Mon, 21 Mar 2011 10:06:11 +0100 Subject: barebox: improve installing barebox on x86 Signed-off-by: Michael Olbrich --- scripts/lib/ptxd_make_bootable.sh | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'scripts') 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 -- cgit v1.2.3