Bruce Cran | d550b88 | 2015-02-26 06:49:31 +0000 | [diff] [blame] | 1 | #!/usr/bin/env bash |
David Wei | 3cbfba0 | 2015-01-12 09:37:20 +0000 | [diff] [blame] | 2 | ##********************************************************************** |
| 3 | ## Function define |
| 4 | ##********************************************************************** |
| 5 | function Usage() { |
| 6 | echo |
| 7 | echo "***************************************************************************" |
| 8 | echo "Build BIOS rom for VLV platforms." |
| 9 | echo |
| 10 | echo "Usage: bld_vlv.bat PlatformType [Build Target]" |
| 11 | echo |
| 12 | echo |
| 13 | echo " Platform Types: MNW2" |
| 14 | echo " Build Targets: Debug, Release (default: Debug)" |
| 15 | echo |
| 16 | echo "***************************************************************************" |
| 17 | echo "Press any key......" |
| 18 | read |
| 19 | exit 0 |
| 20 | } |
| 21 | |
| 22 | |
| 23 | echo -e $(date) |
| 24 | ##********************************************************************** |
| 25 | ## Initial Setup |
| 26 | ##********************************************************************** |
| 27 | #WORKSPACE=$(pwd) |
| 28 | #build_threads=($NUMBER_OF_PROCESSORS)+1 |
| 29 | Build_Flags= |
| 30 | exitCode=0 |
| 31 | Arch=X64 |
| 32 | |
| 33 | ## Clean up previous build files. |
| 34 | if [ -e $(pwd)/EDK2.log ]; then |
| 35 | rm $(pwd)/EDK2.log |
| 36 | fi |
| 37 | |
| 38 | if [ -e $(pwd)/Unitool.log ]; then |
| 39 | rm $(pwd)/Unitool.log |
| 40 | fi |
| 41 | |
| 42 | if [ -e $(pwd)/Conf/target.txt ]; then |
| 43 | rm $(pwd)/Conf/target.txt |
| 44 | fi |
| 45 | |
| 46 | if [ -e $(pwd)/Conf/BiosId.env ]; then |
| 47 | rm $(pwd)/Conf/BiosId.env |
| 48 | fi |
| 49 | |
| 50 | if [ -e $(pwd)/Conf/tools_def.txt ]; then |
| 51 | rm $(pwd)/Conf/tools_def.txt |
| 52 | fi |
| 53 | |
| 54 | if [ -e $(pwd)/Conf/build_rule.txt ]; then |
| 55 | rm $(pwd)/Conf/build_rule.txt |
| 56 | fi |
| 57 | |
| 58 | |
| 59 | ## Setup EDK environment. Edksetup puts new copies of target.txt, tools_def.txt, build_rule.txt in WorkSpace\Conf |
| 60 | ## Also run edksetup as soon as possible to avoid it from changing environment variables we're overriding |
Tim He | bfed5d8 | 2015-01-23 08:14:39 +0000 | [diff] [blame] | 61 | . edksetup.sh BaseTools |
David Wei | 3cbfba0 | 2015-01-12 09:37:20 +0000 | [diff] [blame] | 62 | make -C BaseTools |
| 63 | |
| 64 | ## Define platform specific environment variables. |
| 65 | PLATFORM_PACKAGE=Vlv2TbltDevicePkg |
| 66 | config_file=$WORKSPACE/$PLATFORM_PACKAGE/PlatformPkgConfig.dsc |
| 67 | auto_config_inc=$WORKSPACE/$PLATFORM_PACKAGE/AutoPlatformCFG.txt |
| 68 | |
| 69 | ## default ECP (override with /ECP flag) |
| 70 | EDK_SOURCE=$WORKSPACE/EdkCompatibilityPkg |
| 71 | |
| 72 | ## create new AutoPlatformCFG.txt file |
| 73 | if [ -f "$auto_config_inc" ]; then |
| 74 | rm $auto_config_inc |
| 75 | fi |
| 76 | touch $auto_config_inc |
| 77 | |
| 78 | ##********************************************************************** |
| 79 | ## Parse command line arguments |
| 80 | ##********************************************************************** |
| 81 | |
| 82 | ## Optional arguments |
| 83 | for (( i=1; i<=$#; )) |
| 84 | do |
| 85 | if [ "$1" == "/?" ]; then |
| 86 | Usage |
| 87 | elif [ "$(echo $1 | tr 'a-z' 'A-Z')" == "/Q" ]; then |
| 88 | Build_Flags="$Build_Flags --quiet" |
| 89 | shift |
| 90 | elif [ "$(echo $1 | tr 'a-z' 'A-Z')" == "/L" ]; then |
| 91 | Build_Flags="$Build_Flags -j EKD2.log" |
| 92 | shift |
| 93 | elif [ "$(echo $1 | tr 'a-z' 'A-Z')" == "/C" ]; then |
| 94 | echo Removing previous build files ... |
| 95 | if [ -d "Build" ]; then |
| 96 | rm -r Build |
| 97 | fi |
| 98 | shift |
| 99 | elif [ "$(echo $1 | tr 'a-z' 'A-Z')" == "/ECP" ]; then |
| 100 | ECP_SOURCE=$WORKSPACE/EdkCompatibilityPkgEcp |
| 101 | EDK_SOURCE=$WORKSPACE/EdkCompatibilityPkgEcp |
| 102 | echo DEFINE ECP_BUILD_ENABLE = TRUE >> $auto_config_inc |
| 103 | shift |
| 104 | elif [ "$(echo $1 | tr 'a-z' 'A-Z')" == "/X64" ]; then |
| 105 | Arch=X64 |
| 106 | shift |
| 107 | else |
| 108 | break |
| 109 | fi |
| 110 | done |
| 111 | |
| 112 | |
| 113 | |
| 114 | |
| 115 | |
| 116 | ## Required argument(s) |
| 117 | if [ "$2" == "" ]; then |
| 118 | Usage |
| 119 | fi |
| 120 | |
| 121 | ## Remove the values for Platform_Type and Build_Target from BiosIdX.env and stage in Conf |
| 122 | if [ $Arch == "IA32" ]; then |
| 123 | cp $PLATFORM_PACKAGE/BiosIdR.env Conf/BiosId.env |
| 124 | echo DEFINE X64_CONFIG = FALSE >> $auto_config_inc |
| 125 | else |
| 126 | cp $PLATFORM_PACKAGE/BiosIdx64R.env Conf/BiosId.env |
| 127 | echo DEFINE X64_CONFIG = TRUE >> $auto_config_inc |
| 128 | fi |
| 129 | sed -i '/^BOARD_ID/d' Conf/BiosId.env |
| 130 | sed -i '/^BUILD_TYPE/d' Conf/BiosId.env |
| 131 | |
| 132 | |
| 133 | |
| 134 | ## -- Build flags settings for each Platform -- |
| 135 | ## AlpineValley (ALPV): SVP_PF_BUILD = TRUE, ENBDT_PF_BUILD = FALSE, TABLET_PF_BUILD = FALSE, BYTI_PF_BUILD = FALSE, IVI_PF_BUILD = FALSE |
| 136 | ## BayleyBay (BBAY): SVP_PF_BUILD = FALSE, ENBDT_PF_BUILD = TRUE, TABLET_PF_BUILD = FALSE, BYTI_PF_BUILD = FALSE, IVI_PF_BUILD = FALSE |
| 137 | ## BayLake (BLAK): SVP_PF_BUILD = FALSE, ENBDT_PF_BUILD = FALSE, TABLET_PF_BUILD = TRUE, BYTI_PF_BUILD = FALSE, IVI_PF_BUILD = FALSE |
| 138 | ## Bakersport (BYTI): SVP_PF_BUILD = FALSE, ENBDT_PF_BUILD = FALSE, TABLET_PF_BUILD = FALSE, BYTI_PF_BUILD = TRUE, IVI_PF_BUILD = FALSE |
| 139 | ## Crestview Hills (CVHS): SVP_PF_BUILD = FALSE, ENBDT_PF_BUILD = FALSE, TABLET_PF_BUILD = FALSE, BYTI_PF_BUILD = TRUE, IVI_PF_BUILD = TRUE |
| 140 | ## FFD8 (BLAK): SVP_PF_BUILD = FALSE, ENBDT_PF_BUILD = FALSE, TABLET_PF_BUILD = TRUE, BYTI_PF_BUILD = FALSE, IVI_PF_BUILD = FALSE |
| 141 | echo "Setting $1 platform configuration and BIOS ID..." |
| 142 | if [ "$(echo $1 | tr 'a-z' 'A-Z')" == "MNW2" ]; then |
| 143 | echo BOARD_ID = MNW2MAX >> Conf/BiosId.env |
| 144 | echo DEFINE ENBDT_PF_BUILD = TRUE >> $auto_config_inc |
| 145 | else |
| 146 | echo "Error - Unsupported PlatformType: $1" |
| 147 | Usage |
| 148 | fi |
| 149 | |
| 150 | Platform_Type=$1 |
| 151 | |
| 152 | if [ "$(echo $2 | tr 'a-z' 'A-Z')" == "RELEASE" ]; then |
| 153 | TARGET=RELEASE |
| 154 | BUILD_TYPE=R |
| 155 | echo BUILD_TYPE = R >> Conf/BiosId.env |
| 156 | else |
| 157 | TARGET=DEBUG |
| 158 | BUILD_TYPE=D |
| 159 | echo BUILD_TYPE = D >> Conf/BiosId.env |
| 160 | fi |
| 161 | |
| 162 | |
| 163 | ##********************************************************************** |
| 164 | ## Additional EDK Build Setup/Configuration |
| 165 | ##********************************************************************** |
| 166 | echo "Ensuring correct build directory is present for GenBiosId..." |
| 167 | |
| 168 | echo Modifing Conf files for this build... |
| 169 | ## Remove lines with these tags from target.txt |
| 170 | sed -i '/^ACTIVE_PLATFORM/d' Conf/target.txt |
| 171 | sed -i '/^TARGET /d' Conf/target.txt |
| 172 | sed -i '/^TARGET_ARCH/d' Conf/target.txt |
| 173 | sed -i '/^TOOL_CHAIN_TAG/d' Conf/target.txt |
| 174 | sed -i '/^MAX_CONCURRENT_THREAD_NUMBER/d' Conf/target.txt |
| 175 | |
| 176 | ACTIVE_PLATFORM=$PLATFORM_PACKAGE/PlatformPkgGcc"$Arch".dsc |
| 177 | TOOL_CHAIN_TAG=GCC46 |
| 178 | MAX_CONCURRENT_THREAD_NUMBER=1 |
| 179 | echo ACTIVE_PLATFORM = $ACTIVE_PLATFORM >> Conf/target.txt |
| 180 | echo TARGET = $TARGET >> Conf/target.txt |
| 181 | echo TOOL_CHAIN_TAG = $TOOL_CHAIN_TAG >> Conf/target.txt |
| 182 | echo MAX_CONCURRENT_THREAD_NUMBER = $MAX_CONCURRENT_THREAD_NUMBER >> Conf/target.txt |
| 183 | if [ $Arch == "IA32" ]; then |
| 184 | echo TARGET_ARCH = IA32 >> Conf/target.txt |
| 185 | else |
| 186 | echo TARGET_ARCH = IA32 X64 >> Conf/target.txt |
| 187 | fi |
| 188 | |
| 189 | ##********************************************************************** |
| 190 | ## Build BIOS |
| 191 | ##********************************************************************** |
| 192 | echo Skip "Running UniTool..." |
| 193 | echo "Make GenBiosId Tool..." |
| 194 | BUILD_PATH=Build/$PLATFORM_PACKAGE/"$TARGET"_"$TOOL_CHAIN_TAG" |
| 195 | if [ ! -d "$BUILD_PATH/$Arch" ]; then |
| 196 | mkdir -p $BUILD_PATH/$Arch |
| 197 | fi |
| 198 | if [ -e "$BUILD_PATH/$Arch/BiosId.bin" ]; then |
| 199 | rm -f $BUILD_PATH/$Arch/BiosId.bin |
| 200 | fi |
| 201 | |
| 202 | |
| 203 | ./$PLATFORM_PACKAGE/GenBiosId -i Conf/BiosId.env -o $BUILD_PATH/$Arch/BiosId.bin |
| 204 | |
| 205 | |
| 206 | echo "Invoking EDK2 build..." |
| 207 | build |
| 208 | |
| 209 | |
| 210 | ##********************************************************************** |
| 211 | ## Post Build processing and cleanup |
| 212 | ##********************************************************************** |
| 213 | |
| 214 | echo Skip "Running fce..." |
| 215 | |
| 216 | echo Skip "Running KeyEnroll..." |
| 217 | |
| 218 | ## Set the Board_Id, Build_Type, Version_Major, and Version_Minor environment variables |
| 219 | VERSION_MAJOR=$(grep '^VERSION_MAJOR' Conf/BiosId.env | cut -d ' ' -f 3 | cut -c 1-4) |
| 220 | VERSION_MINOR=$(grep '^VERSION_MINOR' Conf/BiosId.env | cut -d ' ' -f 3 | cut -c 1-2) |
| 221 | BOARD_ID=$(grep '^BOARD_ID' Conf/BiosId.env | cut -d ' ' -f 3 | cut -c 1-7) |
| 222 | BIOS_Name="$BOARD_ID"_"$Arch"_"$BUILD_TYPE"_"$VERSION_MAJOR"_"$VERSION_MINOR".ROM |
| 223 | BIOS_ID="$BOARD_ID"_"$Arch"_"$BUILD_TYPE"_"$VERSION_MAJOR"_"$VERSION_MINOR"_GCC.bin |
| 224 | cp -f $BUILD_PATH/FV/VLV.fd $WORKSPACE/$BIOS_Name |
David Wei | c01934f | 2015-03-10 03:11:24 +0000 | [diff] [blame] | 225 | SEC_VERSION=1.0.2.1067 |
David Wei | 3cbfba0 | 2015-01-12 09:37:20 +0000 | [diff] [blame] | 226 | cat ./$PLATFORM_PACKAGE/Stitch/IFWIHeader/IFWI_HEADER.bin ./Vlv2MiscBinariesPkg/SEC/$SEC_VERSION/VLV_SEC_REGION.bin ./$PLATFORM_PACKAGE/Stitch/IFWIHeader/Vacant.bin $BIOS_Name > ./$PLATFORM_PACKAGE/Stitch/$BIOS_ID |
| 227 | |
| 228 | |
| 229 | echo Skip "Running BIOS_Signing ..." |
| 230 | |
| 231 | echo |
| 232 | echo Build location: $BUILD_PATH |
| 233 | echo BIOS ROM Created: $BIOS_Name |
| 234 | echo |
| 235 | echo -------------------- The EDKII BIOS build has successfully completed. -------------------- |
| 236 | echo |