This repository has been archived by the owner on Jun 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild_uefi.sh
executable file
·100 lines (84 loc) · 3.58 KB
/
build_uefi.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/bin/bash
# Function to display Help Message
function _help(){
echo "Usage: ./build_uefi.sh -d <Codename> [-r <Build Mode>]"
echo
echo "Build Project Mu UEFI for Nvidia Tegra Platforms."
echo
echo "Options:"
echo " --device <Codename>, -d <Codename>: Build a Device."
echo " --release <Build Mode>, -r <Build Mode>: Release mode for building, 'RELEASE' is the default or use 'DEBUG' alternatively."
echo " --help, -h: Shows this Help."
echo
echo "MainPage: https://github.com/Robotix22/Mu-Tegra"
exit 1
}
# Functions to display the Message Type (Error or Warning)
function _error(){ echo -e "\033[1;31m${@}\033[0m" >&2;exit 1; }
function _warn(){ echo -e "\033[0;33m${@}\033[0m" >&2; }
# Set Default Defines
TARGET_BUILD_MODE="RELEASE"
TOOL_CHAIN_TAG="CLANG38"
# Check if any args were given
OPTS="$(getopt -o d:hfabcACDO:r: -l device:,help,release: -n 'build_uefi.sh' -- "$@")"||exit 1
eval set -- "${OPTS}"
while true
do case "${1}" in
-d|--device) TARGET_DEVICE="${2}";shift 2;;
-h|--help) _help 0;shift;;
-r|--release) TARGET_BUILD_MODE="${2}";shift 2;;
--) shift;break;;
*) _help 1;;
esac
done
# If no Device arg is present, Display the Help Message
if [ -z ${TARGET_DEVICE} ]
then _help
fi
# Set Release Type of UEFI
case "${TARGET_BUILD_MODE}" in
RELEASE) _TARGET_BUILD_MODE=RELEASE;;
*) _TARGET_BUILD_MODE=DEBUG;;
esac
# Include Device Config if it exists
if [ -f "configs/${TARGET_DEVICE}.conf" ]
then source "configs/${TARGET_DEVICE}.conf"
else _error "\nDevice configuration not found!\nCheck if your .conf File is in the 'configs' Folder\n"
fi
# Delete Output Files if present
rm ./BootShim/BootShim.bin &> /dev/null
rm ./BootShim/BootShim.elf &> /dev/null
rm Mu-${TARGET_DEVICE}.bin &> /dev/null
# Compile BootShim
cd BootShim
make UEFI_BASE=${TARGET_FD_BASE} UEFI_SIZE=${TARGET_FD_SIZE}||_error "\nFailed to Compile BootShim!\n"
cd ..
# Apply Project Mu Patches
cp ./MuPatches/Compile.patch ./Mu_Basecore/
cd Mu_Basecore
git apply Compile.patch
cd ..
# Start the Real Build of the UEFI
stuart_setup -c "Platforms/${TARGET_DEVICE_VENDOR}/${TARGET_DEVICE}Pkg/PlatformBuild.py" "TOOL_CHAIN_TAG=${TOOL_CHAIN_TAG}"||_error "\nFailed to Setup UEFI Env!\n"
stuart_update -c "Platforms/${TARGET_DEVICE_VENDOR}/${TARGET_DEVICE}Pkg/PlatformBuild.py" "TOOL_CHAIN_TAG=${TOOL_CHAIN_TAG}"||_error "\nFailed to Update UEFI Env!\n"
stuart_build -c "Platforms/${TARGET_DEVICE_VENDOR}/${TARGET_DEVICE}Pkg/PlatformBuild.py" "TOOL_CHAIN_TAG=${TOOL_CHAIN_TAG}" "TARGET=${_TARGET_BUILD_MODE}" "FD_BASE=${TARGET_FD_BASE}" "FD_SIZE=${TARGET_FD_SIZE}" "FD_BLOCKS=${TARGET_FD_BLOCKS}"||_error "\nFailed to Compile UEFI!\n"
# Copy UEFI FD File to root as Payload
cat ./BootShim/BootShim.bin "./Build/${TARGET_DEVICE}Pkg/${_TARGET_BUILD_MODE}_CLANG38/FV/${TARGET_DEVICE^^}_UEFI.fd" > "./Mu-${TARGET_DEVICE}.bin"||_error "\nFailed to Copy UEFI Payload!\n"
if [ ${TARGET_SOC} == "Tegra30" ]; then
# Delete Old File
rm UEFILoader.efi &> /dev/null
# Copy UEFI Loader Application to root
cp "./Build/${TARGET_DEVICE}Pkg/${_TARGET_BUILD_MODE}_CLANG38/ARM/UEFILoader.efi" ./UEFILoader.efi||exit 1
fi
if [[ ${STATUS} != "STABLE" ]]; then
if [[ ${STATUS} == "UNSTABLE" ]];
then _warn "\n${TARGET_DEVICE} is marked as Unstable.\nThings are expected to be broken.\n"
elif [[ ${STATUS} == "LIMITED" ]];
then _warn "\n${TARGET_DEVICE} is marked as Limited.\nIt's stable but does not have much functionality\n"
fi
fi
git fetch &> /dev/null
UPDATE_CHECK=$(git status)
if [[ ${UPDATE_CHECK} == *"git pull"* ]];
then _warn "\nYou are using an old Version of Mu-Tegra.\nThis Image may be unstable.\n"
fi