2010-03-18 03:36:52 +01:00
|
|
|
#! /bin/sh
|
|
|
|
|
|
|
|
## @file
|
|
|
|
#
|
2010-04-28 14:39:50 +02:00
|
|
|
# Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
|
2010-03-18 03:36:52 +01:00
|
|
|
#
|
|
|
|
# This program and the accompanying materials
|
|
|
|
# are licensed and made available under the terms and conditions of the BSD License
|
|
|
|
# which accompanies this distribution. The full text of the license may be found at
|
|
|
|
# http://opensource.org/licenses/bsd-license.php
|
|
|
|
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|
|
|
#
|
|
|
|
#
|
|
|
|
##
|
2009-03-03 07:27:07 +01:00
|
|
|
|
|
|
|
# Set up environment at fisrt.
|
2010-03-18 03:36:52 +01:00
|
|
|
|
2010-10-16 20:50:43 +02:00
|
|
|
if [ -z "$EDK_TOOLS_PATH" ]
|
|
|
|
then
|
2009-09-17 04:16:30 +02:00
|
|
|
export BASETOOLS_DIR=$WORKSPACE/Conf/BaseToolsSource/Source/C/bin
|
2010-10-16 20:50:43 +02:00
|
|
|
else
|
|
|
|
export BASETOOLS_DIR=$EDK_TOOLS_PATH/Source/C/bin
|
|
|
|
fi
|
|
|
|
|
2009-06-22 05:01:53 +02:00
|
|
|
export BOOTSECTOR_BIN_DIR=$WORKSPACE/DuetPkg/BootSector/bin
|
2009-03-03 07:27:07 +01:00
|
|
|
export DISK_LABEL=DUET
|
2009-03-31 08:38:37 +02:00
|
|
|
export PROCESS_MARK=TRUE
|
2009-03-03 07:27:07 +01:00
|
|
|
|
|
|
|
if [ \
|
|
|
|
-z "$*" -o \
|
|
|
|
"$*" = "-?" -o \
|
|
|
|
"$*" = "-h" -o \
|
|
|
|
"$*" = "--help" \
|
|
|
|
]
|
|
|
|
then
|
2010-10-16 20:50:43 +02:00
|
|
|
echo "Usage: CreateBootDisk [usb|floppy|ide|file] MediaPath DevicePath [FAT12|FAT16|FAT32] [IA32|X64] [GCC44|UNIXGCC]"
|
2010-01-19 09:28:28 +01:00
|
|
|
echo "e.g. : CreateBootDisk floppy /media/floppy0 /dev/fd0 FAT12 IA32"
|
2009-03-31 08:38:37 +02:00
|
|
|
PROCESS_MARK=FALSE
|
2009-03-03 07:27:07 +01:00
|
|
|
fi
|
|
|
|
|
2010-03-18 03:36:52 +01:00
|
|
|
case "$5" in
|
|
|
|
IA32)
|
|
|
|
export PROCESSOR=IA32
|
|
|
|
;;
|
|
|
|
X64)
|
|
|
|
export PROCESSOR=X64
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo Invalid Architecture string, should be only IA32 or X64
|
|
|
|
return 1
|
|
|
|
esac
|
|
|
|
|
2010-10-16 20:50:43 +02:00
|
|
|
if [ -z "$6" ]
|
|
|
|
then
|
|
|
|
TOOLCHAIN=GCC44
|
|
|
|
else
|
|
|
|
TOOLCHAIN=$6
|
|
|
|
fi
|
|
|
|
|
|
|
|
export BUILD_DIR=$WORKSPACE/Build/DuetPkg$PROCESSOR/DEBUG_$TOOLCHAIN
|
2010-03-18 03:36:52 +01:00
|
|
|
|
|
|
|
|
2009-03-24 10:23:21 +01:00
|
|
|
export EFI_BOOT_MEDIA=$2
|
|
|
|
export EFI_BOOT_DEVICE=$3
|
2009-03-03 07:27:07 +01:00
|
|
|
|
2009-03-31 08:38:37 +02:00
|
|
|
if [ "$PROCESS_MARK" = TRUE ]
|
|
|
|
then
|
|
|
|
case "$1" in
|
|
|
|
floppy)
|
|
|
|
if [ "$4" = FAT12 ]
|
|
|
|
then
|
|
|
|
echo Start to create floppy boot disk ...
|
|
|
|
echo Format $EFI_BOOT_MEDIA ...
|
|
|
|
## Format floppy disk
|
|
|
|
umount $EFI_BOOT_MEDIA
|
|
|
|
mkfs.msdos $EFI_BOOT_DEVICE
|
|
|
|
mount $EFI_BOOT_DEVICE $EFI_BOOT_MEDIA
|
|
|
|
echo Create boot sector ...
|
|
|
|
## Linux version of GenBootSector has not pass build yet.
|
|
|
|
$BASETOOLS_DIR/GnuGenBootSector -i $EFI_BOOT_DEVICE -o FDBs.com
|
2014-07-09 10:28:05 +02:00
|
|
|
cp $BOOTSECTOR_BIN_DIR/bootsect.com FDBs-1.com
|
|
|
|
$BASETOOLS_DIR/BootSectImage -g FDBs.com FDBs-1.com -f
|
|
|
|
$BASETOOLS_DIR/GnuGenBootSector -o $EFI_BOOT_DEVICE -i FDBs-1.com
|
|
|
|
rm FDBs-1.com
|
2009-03-31 08:38:37 +02:00
|
|
|
cp $BUILD_DIR/FV/Efildr $EFI_BOOT_MEDIA
|
2009-03-24 10:23:21 +01:00
|
|
|
|
2009-03-31 08:38:37 +02:00
|
|
|
mkdir -p $EFI_BOOT_MEDIA/efi
|
|
|
|
mkdir -p $EFI_BOOT_MEDIA/efi/boot
|
2010-01-19 09:28:28 +01:00
|
|
|
if [ "$5" = IA32 ]
|
|
|
|
then
|
|
|
|
cp $WORKSPACE/EdkShellBinPkg/MinimumShell/Ia32/Shell.efi $EFI_BOOT_MEDIA/efi/boot/bootia32.efi
|
|
|
|
else
|
|
|
|
if [ "$5" = X64 ]
|
|
|
|
then
|
|
|
|
cp $WORKSPACE/EdkShellBinPkg/MinimumShell/X64/Shell.efi $EFI_BOOT_MEDIA/efi/boot/bootx64.efi
|
|
|
|
else
|
|
|
|
echo Wrong Arch!
|
|
|
|
fi
|
|
|
|
fi
|
2009-03-31 08:38:37 +02:00
|
|
|
echo Done.
|
|
|
|
else
|
|
|
|
echo "Wrong FAT type $4 for floppy!"
|
|
|
|
fi
|
|
|
|
;;
|
2009-03-03 07:27:07 +01:00
|
|
|
|
2009-03-31 08:38:37 +02:00
|
|
|
file) # CreateFile
|
|
|
|
if [ "$4" = FAT12 ]
|
|
|
|
then
|
|
|
|
echo "Start to create file boot disk ..."
|
2010-10-16 20:50:43 +02:00
|
|
|
dd bs=512 count=2880 if=/dev/zero of=$EFI_BOOT_MEDIA
|
|
|
|
mkfs.msdos -F 12 $EFI_BOOT_MEDIA
|
|
|
|
|
|
|
|
mcopy -i $EFI_BOOT_MEDIA $BUILD_DIR/FV/Efildr ::/Efildr
|
|
|
|
mmd -i $EFI_BOOT_MEDIA ::/efi ::/efi/boot
|
|
|
|
if [ "$5" = IA32 ]
|
|
|
|
then
|
|
|
|
mcopy -i $EFI_BOOT_MEDIA $WORKSPACE/EdkShellBinPkg/MinimumShell/Ia32/Shell.efi ::/efi/boot/bootia32.efi
|
|
|
|
elif [ "$5" = X64 ]
|
|
|
|
then
|
|
|
|
mcopy -i $EFI_BOOT_MEDIA $WORKSPACE/EdkShellBinPkg/MinimumShell/X64/Shell.efi ::/efi/boot/bootx64.efi
|
|
|
|
else
|
|
|
|
echo Wrong Arch!
|
|
|
|
fi
|
|
|
|
mdir -i $EFI_BOOT_MEDIA -s ::
|
|
|
|
|
2009-03-31 08:38:37 +02:00
|
|
|
## Linux version of GenBootSector has not pass build yet.
|
2010-10-16 20:50:43 +02:00
|
|
|
$BASETOOLS_DIR/GnuGenBootSector -i $EFI_BOOT_MEDIA -o $EFI_BOOT_MEDIA.bs0
|
2010-12-06 07:06:54 +01:00
|
|
|
cp $BOOTSECTOR_BIN_DIR/bootsect.com $EFI_BOOT_MEDIA.bs1
|
|
|
|
$BASETOOLS_DIR/BootSectImage -g $EFI_BOOT_MEDIA.bs0 $EFI_BOOT_MEDIA.bs1
|
|
|
|
$BASETOOLS_DIR/GnuGenBootSector -o $EFI_BOOT_MEDIA -i $EFI_BOOT_MEDIA.bs1
|
|
|
|
rm $EFI_BOOT_MEDIA.bs[0-1]
|
2009-03-31 08:38:37 +02:00
|
|
|
echo Done.
|
|
|
|
else
|
|
|
|
echo "Wrong FAT type" $4 "for floppy!"
|
|
|
|
fi
|
|
|
|
;;
|
2009-03-03 07:27:07 +01:00
|
|
|
|
2009-03-31 08:38:37 +02:00
|
|
|
usb) # CreateUsb
|
2009-03-03 07:27:07 +01:00
|
|
|
|
2009-03-31 08:38:37 +02:00
|
|
|
if [ "$4" = FAT16 ]
|
2009-03-03 07:27:07 +01:00
|
|
|
then
|
2010-01-19 09:28:28 +01:00
|
|
|
if [ "$6" = step2 ]
|
2009-03-31 08:38:37 +02:00
|
|
|
then
|
|
|
|
cp $BUILD_DIR/FV/Efildr16 $EFI_BOOT_MEDIA
|
|
|
|
mkdir $EFI_BOOT_MEDIA/efi/boot
|
2010-01-19 09:28:28 +01:00
|
|
|
if [ "$5" = IA32 ]
|
|
|
|
then
|
|
|
|
cp $WORKSPACE/EdkShellBinPkg/MinimumShell/Ia32/Shell.efi $EFI_BOOT_MEDIA/efi/boot/bootia32.efi
|
|
|
|
else
|
|
|
|
if [ "$5" = X64 ]
|
|
|
|
then
|
|
|
|
cp $WORKSPACE/EdkShellBinPkg/MinimumShell/X64/Shell.efi $EFI_BOOT_MEDIA/efi/boot/bootx64.efi
|
|
|
|
else
|
|
|
|
echo Wrong Arch!
|
|
|
|
fi
|
|
|
|
fi
|
2009-03-31 08:38:37 +02:00
|
|
|
echo "step2 Done!"
|
|
|
|
else
|
|
|
|
echo Format $EFI_BOOT_DEVICE ...
|
|
|
|
#Do format command.
|
|
|
|
echo Create boot sector ...
|
|
|
|
## Linux version of GenBootSector & Bootsectimage has not pass build yet.
|
|
|
|
$BASETOOLS_DIR/GnuGenBootSector -i $EFI_BOOT_DEVICE -o UsbBs16.com
|
2014-07-09 10:28:05 +02:00
|
|
|
cp $BOOTSECTOR_BIN_DIR/bs16.com Bs16-1.com
|
|
|
|
$BASETOOLS_DIR/BootSectImage -g UsbBs16.com Bs16-1.com -f
|
|
|
|
$BASETOOLS_DIR/GnuGenBootSector -o $EFI_BOOT_DEVICE -i Bs16-1.com
|
|
|
|
rm Bs16-1.com
|
2009-06-22 05:01:53 +02:00
|
|
|
$BASETOOLS_DIR/GnuGenBootSector -m -o $EFI_BOOT_DEVICE -i $BOOTSECTOR_BIN_DIR/Mbr.com
|
2009-03-31 08:38:37 +02:00
|
|
|
echo Done.
|
|
|
|
echo PLEASE UNPLUG USB, THEN PLUG IT AGAIN TO DO STEP2!
|
|
|
|
fi
|
|
|
|
elif [ "$4" = FAT32 ]
|
|
|
|
then
|
2010-01-19 09:28:28 +01:00
|
|
|
if [ "$6" = step2 ]
|
2009-03-31 08:38:37 +02:00
|
|
|
then
|
|
|
|
cp $BUILD_DIR/FV/Efildr20 $EFI_BOOT_MEDIA
|
|
|
|
mkdir $EFI_BOOT_MEDIA/efi/boot
|
2010-01-19 09:28:28 +01:00
|
|
|
if [ "$5" = IA32 ]
|
|
|
|
then
|
|
|
|
cp $WORKSPACE/EdkShellBinPkg/MinimumShell/Ia32/Shell.efi $EFI_BOOT_MEDIA/efi/boot/bootia32.efi
|
|
|
|
else
|
|
|
|
if [ "$5" = X64 ]
|
|
|
|
then
|
|
|
|
cp $WORKSPACE/EdkShellBinPkg/MinimumShell/X64/Shell.efi $EFI_BOOT_MEDIA/efi/boot/bootx64.efi
|
|
|
|
else
|
|
|
|
echo Wrong Arch!
|
|
|
|
fi
|
|
|
|
fi
|
2009-03-31 08:38:37 +02:00
|
|
|
echo "step2 Done!"
|
|
|
|
else
|
|
|
|
echo Format $EFI_BOOT_DEVICE ...
|
|
|
|
#Do format command.
|
|
|
|
echo Create boot sector ...
|
|
|
|
## Linux version of GenBootSector & Bootsectimage has not pass build yet.
|
|
|
|
$BASETOOLS_DIR/GnuGenBootSector -i $EFI_BOOT_DEVICE -o UsbBs32.com
|
2014-07-09 10:28:05 +02:00
|
|
|
cp $BOOTSECTOR_BIN_DIR/bs32.com Bs32-1.com
|
|
|
|
$BASETOOLS_DIR/BootSectImage -g UsbBs32.com Bs32-1.com -f
|
|
|
|
$BASETOOLS_DIR/GnuGenBootSector -o $EFI_BOOT_DEVICE -i Bs32-1.com
|
|
|
|
rm Bs32-1.com
|
2009-06-22 05:01:53 +02:00
|
|
|
$BASETOOLS_DIR/GnuGenBootSector -m -o $EFI_BOOT_DEVICE -i $BOOTSECTOR_BIN_DIR/Mbr.com
|
2009-03-31 08:38:37 +02:00
|
|
|
echo Done.
|
|
|
|
echo PLEASE UNPLUG USB, THEN PLUG IT AGAIN TO DO STEP2!
|
|
|
|
fi
|
2009-03-03 07:27:07 +01:00
|
|
|
else
|
2009-03-31 08:38:37 +02:00
|
|
|
echo "Wrong FAT type $1 for floppy!"
|
2009-03-03 07:27:07 +01:00
|
|
|
fi
|
|
|
|
|
2009-03-31 08:38:37 +02:00
|
|
|
;;
|
2009-03-03 07:27:07 +01:00
|
|
|
|
2009-03-31 08:38:37 +02:00
|
|
|
ide) # CreateIde
|
|
|
|
echo "Not support yet!"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Arg1 should be [floppy | file | usb | ide] !"
|
2009-03-03 07:27:07 +01:00
|
|
|
|
2009-03-31 08:38:37 +02:00
|
|
|
esac
|
|
|
|
fi
|