summaryrefslogtreecommitdiffstats
path: root/firmware/amd_seattle/upBIOS
blob: d782cb5810454a3eb3f897833b7ef9fdc936e365 (plain)
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
#!/bin/bash

# Description : This script will copy and setup the ROM to be 
#               flashed on next boot.
#
#
# Create Date : Thu Nov 13 13:16:11 PST 2014
#
# Author      : Kim Naru (kim.naru@amd.com)
#
# Bug Fixs : 
#
#
#Thu Sep 10 15:02:32 PDT 2015
#	Improved usage message. More error checking. SsiFalshARM64.EFI check
#       was in the wrong spot, fixed.
#
# Mon Aug 31 18:10:19 EDT 2015
#        Do not assume SsiFlashARM64.EFI is in the EFI dir. Copy
#        it over.
#          
# Mon Apr 13 12:43:37 PDT 2015
#        Cleaned up comments and fixed a bug.
#        Mon Apr 13 12:43:37 PDT 2015
#           
# Thu Apr  9 11:58:55 EDT 2015
# 	 Changed named from go72 upBIOS which is more generic. Also
#        since the location of the rom file changes on weekly needed
#        to change paths
#
# Fri Nov 14 14:39:55 PST 2014
#	Was not getting the right path to efi grub  command.
#       Fixed for Fedora and Acadia
#        
#
#
# NOTE: If a zip file has a name similar the following 
#
#	Overdrive_AMI_UEFI-VerROD0084E_0378-NDA.zip
#
#       then you will first have to unzip it before running this script. The reason
#	being there is a zip file within a zip file.

bios=$1
file="$bios"
zipFile="$file.zip"
#romFile="./$file/Binaries/$bios.rom"
romFile="./$bios.rom"
logFile="./$bios.log"
efiDir="/boot/efi"
osrel="/etc/os-release"
unzip="/usr/bin/unzip"

if [ $# -ne 1 ]
then
	echo "Usage : $0 BIOS"
	echo "Example: If the BIOS version is ROD0084E then: $0 ROD0084E"
	exit 1
fi

if [ ! -f "$zipFile" ]
then
	echo "$zipFile is missing exiting..."
	exit 2
fi


grep -i red $osrel > /dev/null 2>&1
status=$?

if [ $status -eq 0 ]
then
	# Acadia
	grub="FS0:\EFI\redhat\grubaa64.efi"
fi

grep -i fedora $osrel > /dev/null 2>&1
status=$?
if [ $status -eq 0 ]
then
	# Fedora
	grub="FS0:\EFI\fedora\grubaa64.efi"
fi


SsiFlash="FS0:\SsiFlashARM64.EFI FS0:\\$romFile /U "


if [ ! -f $unzip ]
then
	echo "$unzip is missing,installing..."
	yum install unzip
fi


if [ ! -f  $zipFile ]
then
	echo "[$zipFile] not found..exiting"
	echo
	exit 3
else
	# If files exist unzip prompts which we do not want
	/bin/rm -f SsiFlashARM64.EFI
	/bin/rm -f $romFile
	/bin/rm -f $logFile
	$unzip $zipFile > /dev/null 2>&1
fi

# Force copy the utility.
if [ ! -f SsiFlashARM64.EFI ]
then 
	echo "SsiFlashARM64.EFI is missing  exiting..."
	exit 4
else
	cp -f SsiFlashARM64.EFI $efiDir
fi


if [ ! -f  $romFile ]
then
	echo "[$romFile] not found..exiting"
	echo
	exit 5
fi

if [ ! -d $efiDir ]
then
	echo "[/boot/efi] does not exist..exiting\n"
	echo
        exit 6
fi

cp $romFile $efiDir
echo "Copied $romFile to $efiDir"
rm -f $efiDir/flashed

#backup original startup.nsh.

if [ -f $efiDir/startup.nsh ]
then
	cp $efiDir/startup.nsh $efiDir/startup.nsh.bak
fi

# -----------------------------------------------------------------
# Create UEFI boot script startup.nsh based on variables above
# and place it in the UEFI partition.
# -----------------------------------------------------------------
cat << EOF > $efiDir/startup.nsh
# If fs0:\flashed doesn't exit it will assume the system needs to be flashed.
# Subsequent boots will not reflash. To force a reflash do :
# del fs0:\flashed.
#
# kim naru(kim.naru@amd.com)  
# `date`

@echo -off

if exist fs0:\flashed then
echo System has already been flashed with $bios
goto FOUND
endif

echo Flashing system with $bios.
$SsiFlash
echo $bios > fs0:\flashed
echo Flashing completed.

:REBOOT
echo "System has been flashed. Please power cycle."
goto END

:FOUND
$grub

:END
EOF
echo "Installation complete, please reboot your system. "
echo
# -----------------------------------------------------------------
# End
# -----------------------------------------------------------------