adding local boot support for uboot arm arch

Once pxe image is booted. The boot.scr file should be
able to boot from local file system. kernel and ramdisk
address are provided by environment variables set on
arm board.

Change-Id: I4ad523f85baf488e50a9bc64a926830d4d749195
This commit is contained in:
lokesh 2014-07-14 15:55:56 +05:30
parent f3fce641c4
commit c92822e712
5 changed files with 108 additions and 68 deletions

View File

@ -1,7 +1,21 @@
Installs grub boot loader from packages.
Set up grub boot loader on the disk using os-refresh-config when system boot
up and enables boot from HDD. This needs at least one PXE boot after deployment
to work properly.
If you want to build an image with localboot for non arm architecture:
In case Grub serial terminal support is needed, use serial-console element.
* Set up grub boot loader on the disk using os-refresh-config when system boot
up and enables boot from HDD. This needs at least one PXE boot after deployment
to work properly.
In case Grub serial terminal support is needed, use serial-console element.
If you want to build an image with localboot for uboot arm boards:
* uboot (when set to boot from the disk) looks on the first disk partition
for a file named boot.scr in / or /boot. This is a uboot
script file, packaged in the special uboot format (like uImage and uInitrd)
by the mkimage command, that tells uboot where the kernel and initrd are, and
what the kernel boot arguments. This file is created by mkimage command
using the flash-kernel script, provided by the u-boot-tools package.
* The user must provide a uboot script file which contains kernel, initrd and console
parameters. This file path is read from an environment variable named
UBOOT\_SCRIPT\_FILE\_PATH.

View File

@ -0,0 +1,19 @@
#!/bin/bash
set -eux
set -o pipefail
if [ "$ARCH" == "amd64" -o "$ARCH" == "i386" ]; then
install-packages grub-pc
elif [ "$ARCH" == "aarch64" -o "$ARCH" == "armhf" ]; then
install-package u-boot-tools
#This copies uboot scripts to boot folder
if [ -f "$UBOOT_SCRIPT_FILE_PATH" ] ; then
cp "$UBOOT_SCRIPT_FILE_PATH" "$TARGET_ROOT/boot/boot.cmd"
fi
else
echo "ERROR: localboot is not supported for $ARCH architectures."
exit 1
fi

View File

@ -1,11 +0,0 @@
#!/bin/bash
set -eux
set -o pipefail
if [ "$ARCH" == "amd64" -o "$ARCH" == "i386" ]; then
install-packages grub-pc
else
echo "ERROR: localboot is not supported for $ARCH architectures."
exit 1
fi

View File

@ -0,0 +1,71 @@
#!/bin/bash
#
# Copyright 2014 Hewlett-Packard Development Company, L.P.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
set -eu
set -o pipefail
echo Installing Boot Loader
if [[ "aarch64 armhf" =~ "$(uname -m)" ]]; then
KERNEL_RELEASE="$(uname -r)"
KERNEL="/boot/vmlinuz-$KERNEL_RELEASE"
RAMDISK="/boot/initrd.img-$KERNEL_RELEASE"
FILE="/boot/boot.cmd"
#this file will contain script with boot parameters like ramdisk and kernel
#address and console parameters. This varies from arm board to board, User
#will provide boot script.
if [ -f "$FILE" ] ; then
#boot.scr file is created by below command which requires u-boot-tools package.
mkimage -C none -A arm -T script -d "$FILE" /boot/boot.scr
else
echo "$FILE file not found to generate boot.scr"
fi
else
grub_bin=$(which grub)
if [ -n "$grub_bin" ] ; then
grub_ver="$($grub_bin --version | grep 0\.97)"
if [ -n "$grub_ver" ] ; then
echo "Legacy grub 0.97 found"
$grub_bin --batch << EOF
root (hd0,0)
setup (hd0)
EOF
else
echo "unknown legacy grub version"
fi
else
# Some distros have grub2 binaries named as grub2-install, grub2-mkconfig, etc.
# Others have grub-install, grub-mkconfig, etc..
grub_bin_prefix="grub"
grub_bin="$(which ${grub_bin_prefix}-mkconfig)"
if [ -n "${grub_bin}" ] ; then
grub_bin_prefix="grub2"
grub_bin="$(which ${grub_bin_prefix}-mkconfig)"
fi
if [ -n "$grub_bin" ] ; then
grub_ver="$($grub_bin --version | grep 2\...)"
if [ -n "$grub_ver" ] ; then
echo "GRUB 2.xx found"
${grub_bin_prefix}-mkconfig -o /boot/${grub_bin_prefix}/grub.cfg
${grub_bin_prefix}-install --force /dev/sda
else
echo "unknown grub version"
fi
fi
fi
fi

View File

@ -1,53 +0,0 @@
#!/bin/bash
#
# Copyright 2014 Hewlett-Packard Development Company, L.P.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
set -eu
set -o pipefail
echo Installing Boot Loader
grub_bin=`which grub`
if [ -n "$grub_bin" ] ; then
grub_ver=`$grub_bin --version | grep 0\.97`
if [ -n "$grub_ver" ] ; then
echo Legacy grub 0.97 found
$grub_bin --batch << EOF
root (hd0,0)
setup (hd0)
EOF
else
echo "unknown legacy grub version"
fi
else
# Some distros have grub2 binaries named as grub2-install, grub2-mkconfig, etc.
# Others have grub-install, grub-mkconfig, etc..
grub_bin_prefix="grub"
grub_bin=`which ${grub_bin_prefix}-mkconfig`
if [ "" == "${grub_bin}" ] ; then
grub_bin_prefix="grub2"
grub_bin=`which ${grub_bin_prefix}-mkconfig`
fi
if [ -n "$grub_bin" ] ; then
grub_ver=`$grub_bin --version | grep 2\...`
if [ -n "$grub_ver" ] ; then
echo GRUB 2.xx found
${grub_bin_prefix}-mkconfig -o /boot/${grub_bin_prefix}/grub.cfg
${grub_bin_prefix}-install --force /dev/sda
else
echo "unknown grub version"
fi
fi
fi