]> git.proxmox.com Git - mirror_edk2.git/blob - Vlv2TbltDevicePkg/bld_vlv.sh
BaseTools: replace Sdict with OrderedDict in UPT
[mirror_edk2.git] / Vlv2TbltDevicePkg / bld_vlv.sh
1 #!/usr/bin/env bash
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 SpiLock=0
33
34 ## Clean up previous build files.
35 if [ -e $(pwd)/EDK2.log ]; then
36 rm $(pwd)/EDK2.log
37 fi
38
39 if [ -e $(pwd)/Unitool.log ]; then
40 rm $(pwd)/Unitool.log
41 fi
42
43 if [ -e $(pwd)/Conf/target.txt ]; then
44 rm $(pwd)/Conf/target.txt
45 fi
46
47 if [ -e $(pwd)/Conf/BiosId.env ]; then
48 rm $(pwd)/Conf/BiosId.env
49 fi
50
51 if [ -e $(pwd)/Conf/tools_def.txt ]; then
52 rm $(pwd)/Conf/tools_def.txt
53 fi
54
55 if [ -e $(pwd)/Conf/build_rule.txt ]; then
56 rm $(pwd)/Conf/build_rule.txt
57 fi
58
59
60 ## Setup EDK environment. Edksetup puts new copies of target.txt, tools_def.txt, build_rule.txt in WorkSpace\Conf
61 ## Also run edksetup as soon as possible to avoid it from changing environment variables we're overriding
62 . edksetup.sh BaseTools
63 make -C BaseTools
64
65 ## Define platform specific environment variables.
66 PLATFORM_PACKAGE=Vlv2TbltDevicePkg
67 config_file=$WORKSPACE/$PLATFORM_PACKAGE/PlatformPkgConfig.dsc
68 auto_config_inc=$WORKSPACE/$PLATFORM_PACKAGE/AutoPlatformCFG.txt
69
70 ## default ECP (override with /ECP flag)
71 EDK_SOURCE=$WORKSPACE/EdkCompatibilityPkg
72
73 ## create new AutoPlatformCFG.txt file
74 if [ -f "$auto_config_inc" ]; then
75 rm $auto_config_inc
76 fi
77 touch $auto_config_inc
78
79 ##**********************************************************************
80 ## Parse command line arguments
81 ##**********************************************************************
82
83 ## Optional arguments
84 for (( i=1; i<=$#; ))
85 do
86 if [ "$1" == "/?" ]; then
87 Usage
88 elif [ "$(echo $1 | tr 'a-z' 'A-Z')" == "/Q" ]; then
89 Build_Flags="$Build_Flags --quiet"
90 shift
91 elif [ "$(echo $1 | tr 'a-z' 'A-Z')" == "/L" ]; then
92 Build_Flags="$Build_Flags -j EKD2.log"
93 shift
94 elif [ "$(echo $1 | tr 'a-z' 'A-Z')" == "/C" ]; then
95 echo Removing previous build files ...
96 if [ -d "Build" ]; then
97 rm -r Build
98 fi
99 shift
100 elif [ "$(echo $1 | tr 'a-z' 'A-Z')" == "/ECP" ]; then
101 ECP_SOURCE=$WORKSPACE/EdkCompatibilityPkgEcp
102 EDK_SOURCE=$WORKSPACE/EdkCompatibilityPkgEcp
103 echo DEFINE ECP_BUILD_ENABLE = TRUE >> $auto_config_inc
104 shift
105 elif [ "$(echo $1 | tr 'a-z' 'A-Z')" == "/X64" ]; then
106 Arch=X64
107 shift
108 elif [ "$(echo $1 | tr 'a-z' 'A-Z')" == "/YL" ]; then
109 SpiLock=1
110 shift
111 else
112 break
113 fi
114 done
115
116
117
118
119
120 ## Required argument(s)
121 if [ "$2" == "" ]; then
122 Usage
123 fi
124
125 ## Remove the values for Platform_Type and Build_Target from BiosIdX.env and stage in Conf
126 if [ $Arch == "IA32" ]; then
127 cp $PLATFORM_PACKAGE/BiosIdR.env Conf/BiosId.env
128 echo DEFINE X64_CONFIG = FALSE >> $auto_config_inc
129 else
130 cp $PLATFORM_PACKAGE/BiosIdx64R.env Conf/BiosId.env
131 echo DEFINE X64_CONFIG = TRUE >> $auto_config_inc
132 fi
133 sed -i '/^BOARD_ID/d' Conf/BiosId.env
134 sed -i '/^BUILD_TYPE/d' Conf/BiosId.env
135
136
137
138 ## -- Build flags settings for each Platform --
139 ## AlpineValley (ALPV): SVP_PF_BUILD = TRUE, ENBDT_PF_BUILD = FALSE, TABLET_PF_BUILD = FALSE, BYTI_PF_BUILD = FALSE, IVI_PF_BUILD = FALSE
140 ## BayleyBay (BBAY): SVP_PF_BUILD = FALSE, ENBDT_PF_BUILD = TRUE, TABLET_PF_BUILD = FALSE, BYTI_PF_BUILD = FALSE, IVI_PF_BUILD = FALSE
141 ## BayLake (BLAK): SVP_PF_BUILD = FALSE, ENBDT_PF_BUILD = FALSE, TABLET_PF_BUILD = TRUE, BYTI_PF_BUILD = FALSE, IVI_PF_BUILD = FALSE
142 ## Bakersport (BYTI): SVP_PF_BUILD = FALSE, ENBDT_PF_BUILD = FALSE, TABLET_PF_BUILD = FALSE, BYTI_PF_BUILD = TRUE, IVI_PF_BUILD = FALSE
143 ## Crestview Hills (CVHS): SVP_PF_BUILD = FALSE, ENBDT_PF_BUILD = FALSE, TABLET_PF_BUILD = FALSE, BYTI_PF_BUILD = TRUE, IVI_PF_BUILD = TRUE
144 ## FFD8 (BLAK): SVP_PF_BUILD = FALSE, ENBDT_PF_BUILD = FALSE, TABLET_PF_BUILD = TRUE, BYTI_PF_BUILD = FALSE, IVI_PF_BUILD = FALSE
145 echo "Setting $1 platform configuration and BIOS ID..."
146 if [ "$(echo $1 | tr 'a-z' 'A-Z')" == "MNW2" ]; then
147 echo BOARD_ID = MNW2MAX >> Conf/BiosId.env
148 echo DEFINE ENBDT_PF_BUILD = TRUE >> $auto_config_inc
149 else
150 echo "Error - Unsupported PlatformType: $1"
151 Usage
152 fi
153
154 Platform_Type=$1
155
156 if [ "$(echo $2 | tr 'a-z' 'A-Z')" == "RELEASE" ]; then
157 TARGET=RELEASE
158 BUILD_TYPE=R
159 echo BUILD_TYPE = R >> Conf/BiosId.env
160 else
161 TARGET=DEBUG
162 BUILD_TYPE=D
163 echo BUILD_TYPE = D >> Conf/BiosId.env
164 fi
165
166
167 ##**********************************************************************
168 ## Additional EDK Build Setup/Configuration
169 ##**********************************************************************
170 echo "Ensuring correct build directory is present for GenBiosId..."
171
172 echo Modifing Conf files for this build...
173 ## Remove lines with these tags from target.txt
174 sed -i '/^ACTIVE_PLATFORM/d' Conf/target.txt
175 sed -i '/^TARGET /d' Conf/target.txt
176 sed -i '/^TARGET_ARCH/d' Conf/target.txt
177 sed -i '/^TOOL_CHAIN_TAG/d' Conf/target.txt
178 sed -i '/^MAX_CONCURRENT_THREAD_NUMBER/d' Conf/target.txt
179
180 gcc_version=$(gcc -v 2>&1 | tail -1 | awk '{print $3}')
181 case $gcc_version in
182 4.9.*|4.1[0-9].*|5.*.*|6.*.*)
183 TARGET_TOOLS=GCC49
184 ;;
185 *)
186 TARGET_TOOLS=GCC48
187 ;;
188 esac
189
190 ACTIVE_PLATFORM=$PLATFORM_PACKAGE/PlatformPkgGcc"$Arch".dsc
191 TOOL_CHAIN_TAG=$TARGET_TOOLS
192 MAX_CONCURRENT_THREAD_NUMBER=1
193 echo ACTIVE_PLATFORM = $ACTIVE_PLATFORM >> Conf/target.txt
194 echo TARGET = $TARGET >> Conf/target.txt
195 echo TOOL_CHAIN_TAG = $TOOL_CHAIN_TAG >> Conf/target.txt
196 echo MAX_CONCURRENT_THREAD_NUMBER = $MAX_CONCURRENT_THREAD_NUMBER >> Conf/target.txt
197 if [ $Arch == "IA32" ]; then
198 echo TARGET_ARCH = IA32 >> Conf/target.txt
199 else
200 echo TARGET_ARCH = IA32 X64 >> Conf/target.txt
201 fi
202
203 ##**********************************************************************
204 ## Build BIOS
205 ##**********************************************************************
206 echo Skip "Running UniTool..."
207 echo "Make GenBiosId Tool..."
208 BUILD_PATH=Build/$PLATFORM_PACKAGE/"$TARGET"_"$TOOL_CHAIN_TAG"
209 if [ ! -d "$BUILD_PATH/$Arch" ]; then
210 mkdir -p $BUILD_PATH/$Arch
211 fi
212 if [ -e "$BUILD_PATH/$Arch/BiosId.bin" ]; then
213 rm -f $BUILD_PATH/$Arch/BiosId.bin
214 fi
215
216
217 ./$PLATFORM_PACKAGE/GenBiosId -i Conf/BiosId.env -o $BUILD_PATH/$Arch/BiosId.bin
218
219
220 echo "Invoking EDK2 build..."
221 build
222
223 if [ $SpiLock == "1" ]; then
224 IFWI_HEADER_FILE=./$PLATFORM_PACKAGE/Stitch/IFWIHeader/IFWI_HEADER_SPILOCK.bin
225 else
226 IFWI_HEADER_FILE=./$PLATFORM_PACKAGE/Stitch/IFWIHeader/IFWI_HEADER.bin
227 fi
228
229 echo $IFWI_HEADER_FILE
230
231 ##**********************************************************************
232 ## Post Build processing and cleanup
233 ##**********************************************************************
234
235 echo Skip "Running fce..."
236
237 echo Skip "Running KeyEnroll..."
238
239 ## Set the Board_Id, Build_Type, Version_Major, and Version_Minor environment variables
240 VERSION_MAJOR=$(grep '^VERSION_MAJOR' Conf/BiosId.env | cut -d ' ' -f 3 | cut -c 1-4)
241 VERSION_MINOR=$(grep '^VERSION_MINOR' Conf/BiosId.env | cut -d ' ' -f 3 | cut -c 1-2)
242 BOARD_ID=$(grep '^BOARD_ID' Conf/BiosId.env | cut -d ' ' -f 3 | cut -c 1-7)
243 BIOS_Name="$BOARD_ID"_"$Arch"_"$BUILD_TYPE"_"$VERSION_MAJOR"_"$VERSION_MINOR".ROM
244 BIOS_ID="$BOARD_ID"_"$Arch"_"$BUILD_TYPE"_"$VERSION_MAJOR"_"$VERSION_MINOR"_GCC.bin
245 cp -f $BUILD_PATH/FV/VLV.fd $WORKSPACE/$BIOS_Name
246 SEC_VERSION=1.0.2.1060v5
247 cat $IFWI_HEADER_FILE ./Vlv2MiscBinariesPkg/SEC/$SEC_VERSION/VLV_SEC_REGION.bin ./Vlv2MiscBinariesPkg/SEC/$SEC_VERSION/Vacant.bin $BIOS_Name > ./$PLATFORM_PACKAGE/Stitch/$BIOS_ID
248
249
250 echo Skip "Running BIOS_Signing ..."
251
252 echo
253 echo Build location: $BUILD_PATH
254 echo BIOS ROM Created: $BIOS_Name
255 echo
256 echo -------------------- The EDKII BIOS build has successfully completed. --------------------
257 echo