Add x86 network boot support to make_netboot.sh

Current make_netboot.sh only supports ARM. As we are using network boot
for x86 now, let's fix make_netboot.sh to support both.

BUG=chrome-os-partner:9805
TEST=Generates images and network boot install shim.

Change-Id: Ib445f68255fe8e8a1ee6b7901c9bd67a4a36636d
Reviewed-on: https://gerrit.chromium.org/gerrit/23010
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
Commit-Ready: Vic Yang <victoryang@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
This commit is contained in:
Vic Yang 2012-05-18 11:57:06 +08:00 committed by Gerrit
parent 05780783a9
commit 3450deb3ea

View File

@ -28,6 +28,9 @@ DEFINE_string image "" "Path to the image to use"
FLAGS "$@" || exit 1
eval set -- "${FLAGS_ARGV}"
. "${SCRIPT_ROOT}/build_library/build_common.sh" || exit 1
. "${BUILD_LIBRARY_DIR}/board_options.sh" || exit 1
switch_to_strict_mode
# build_packages artifact output.
SYSROOT="${GCLIENT_ROOT}/chroot/build/${FLAGS_board}"
@ -86,9 +89,50 @@ sudo mount -o loop part_3 r
sudo mount -o loop part_1 s
echo "Mount install shim rootfs (partition 3)"
if [ "${ARCH}" = "arm" ]; then
export MKIMAGE_ARCH="arm"
else
export MKIMAGE_ARCH="x86" # including amd64
fi
# Get netboot kernel.
echo "Generating netboot kernel vmlinux.uimg"
cp "r/boot/vmlinux.uimg" "netboot"
if [ "${ARCH}" = "arm" ]; then
# Currently we don't use initramfs for ARM. Someday we would probably want
# initramfs for USB factory installation.
# TODO: Converge build processes of ARM and x86.
echo "Generating netboot kernel vmlinux.uimg"
cp "r/boot/vmlinux.uimg" "netboot"
else
echo "Building kernel"
# Create temporary emerge root
temp_build_path="$(mktemp -d bk_XXXXXXXX)"
if ! [ -d "${temp_build_path}" ]; then
echo "Failed to create temporary directory."
exit 1
fi
# Emerge network boot kernel
# We don't want to build whole install shim everytime we run this script,
# and thus we only build kernel here. If this script is run against install
# shim with different kernel version, this might not work. But as we don't
# upgrade kernel so often, this is probably fine.
export USE='netboot'
export EMERGE_BOARD_CMD="emerge-${FLAGS_board}"
emerge_custom_kernel ${temp_build_path}
# Generate kernel uImage
echo "Generating netboot kernel vmlinux.uimg"
# U-boot put kernel image at 0x100000. We load it at 0x3000000 because
# 0x3000000 is safe enough not to overlap with image at 0x100000.
mkimage -A "${MKIMAGE_ARCH}" -O linux -T kernel -n "Linux kernel" -C none \
-d "${temp_build_path}"/boot/vmlinuz \
-a 0x03000000 -e 0x03000000 netboot/vmlinux.uimg
# Clean up temporary emerge root
sudo rm -rf "${temp_build_path}"
fi
echo "Add lsb-factory"
# Copy factory config file.
@ -108,7 +152,7 @@ echo "Generating netboot rootfs initrd.uimg"
# U-boot's uimg wrapper specifies where we will load the blob into memory.
# tftp boot's default root address is set to 0x12008000 in legacy_image.bin,
# so we want to unpack it there.
mkimage -A arm -O linux -T ramdisk -a 0x12008000 \
mkimage -A "${MKIMAGE_ARCH}" -O linux -T ramdisk -a 0x12008000 \
-n "Factory Install RootFS" -C gzip -d ext2_rootfs.gz \
netboot/initrd.uimg