3 # Copyright (c) 2010-2012 Haiku, Inc.
4 # Distributed under the terms of the MIT License.
7 # Matt Madia, mattmadia@gmail.com
10 # Provide a mechanism for end-users to install various firmwares for wireless
11 # network cards in a manner that complies with their individual licenses.
15 # Intel ipw2200/2225/2915
20 MESSAGE
="This script will install firmware for various wireless network cards.
21 The Broadcom 43xx and Marvell 88W8335 require an active network connection
22 to download additional files before installation. In the absence of internet
23 access, only Intel's ipw2100 and ipw2200 will be installed.
25 If you do not have internet access and need to install the other firmwares,
26 goto http://www.haiku-os.org/guides/dailytasks/wireless. This page has
27 instructions on which files to manually download and where to copy them into
28 this OS. It also has different script that can be run on another OS and will
29 prepare a zip archive for easy install. After that, re-run this script."
31 ABORT
='Abort installation'
32 OK
='I agree to the licenses. Install firmwares.'
34 baseURL
='http://www.haiku-files.org/files/wifi-firmwares'
35 firmwareDir
=`finddir B_SYSTEM_DATA_DIRECTORY`/firmware
36 tempDir
=`finddir B_SYSTEM_TEMP_DIRECTORY`/wifi-firmwares
37 driversDir
=`finddir B_SYSTEM_ADDONS_DIRECTORY`/kernel
/drivers
38 tempFirmwareDir
=`finddir B_SYSTEM_TEMP_DIRECTORY`/package_me
"$firmwareDir"
39 intelLicense
='/boot/system/data/licenses/Intel (2xxx firmware)'
42 function DisplayAlert
()
44 local result
=`alert --stop "$MESSAGE" "$VIEW" "$ABORT" "$OK"`
60 function ViewLicenses
()
62 license
="$tempDir/Wifi_Firmware_Licenses"
65 +-----------------------------------------------------------------------------+
67 | Copyright and licensing information of the various wireless firmwares |
69 | Firmware for broadcom43xx is under the Copyright of Broadcom Corporation(R) |
70 | Firmware for marvell88w8335 is under the Copyright of Marvell Technology(R) |
71 | ipw2100,iprowifi2200 firmware is covered by the following Intel(R) license: |
73 +-----------------------------------------------------------------------------+
76 cat "$intelLicense" >> $license
82 function InstallAllFirmwares
()
92 function UnlinkDriver
()
94 # remove the driver's symlink
95 #rm -f "${driversDir}/dev/net/${driver}"
96 echo "TODO: UnlinkDriver"
100 function SymlinkDriver
()
102 # restore the driver's symlink
103 #cd "${driversDir}/dev/net/"
104 #ln -sf "../../bin/${driver}" "${driver}"
105 echo "TODO: SymlinkDriver"
109 function DownloadFileIfNotCached
()
111 # DownloadFileIfNotCached <url> <filename> <destination dir>
117 if [ ! -e $dir/$file ] ; then
118 echo "Downloading $url ..."
119 wget
-nv -O $dir/$file $url
122 if [ $result -gt 0 ]; then
123 local error
="Failed to download $url."
124 local msg
="As a result, ${driver}'s firmware will not be installed."
125 alert
--warning "$error $msg"
130 function SetFirmwarePermissions
()
132 cd ${tempFirmwareDir}/${driver}/
134 if [ "$file" != "$driver" ] && [ -f "$file" ] ; then
141 function CleanTemporaryFiles
()
148 function PreFirmwareInstallation
()
150 echo "Acquiring firmware for ${driver} ..."
151 mkdir
-p "${tempFirmwareDir}/${driver}"
156 function PostFirmwareInstallation
()
158 SetFirmwarePermissions
161 echo "... firmware for ${driver} will be installed."
165 function InstallIpw2100
()
167 driver
='iprowifi2100'
168 PreFirmwareInstallation
170 # Prepare firmware archive for extraction.
171 local file='ipw2100-fw-1.3.tgz'
172 local url
="${baseURL}/intel/${file}"
173 local dir
="${tempFirmwareDir}/${driver}"
174 cp "${firmwareDir}/${driver}/${file}" "${dir}"
175 DownloadFileIfNotCached
$url $file $dir
177 # Extract the firmware & license file in place.
178 cd "${tempFirmwareDir}/${driver}"
179 gunzip
< "$file" |
tar xf
-
181 rm "${tempFirmwareDir}/${driver}/${file}"
182 PostFirmwareInstallation
186 function InstallIprowifi2200
()
188 driver
='iprowifi2200'
189 PreFirmwareInstallation
191 # Prepare firmware archive for extraction.
192 local file='ipw2200-fw-3.1.tgz'
193 local url
="${baseURL}/intel/${file}"
194 local dir
="${tempFirmwareDir}/${driver}"
195 cp "${firmwareDir}/${driver}/${file}" "${dir}"
196 DownloadFileIfNotCached
$url $file $dir
198 # Extract the firmware & license file.
200 gunzip
< "${tempFirmwareDir}/${driver}/$file" |
tar xf
-
201 cd "${tempDir}/ipw2200-fw-3.1"
202 mv LICENSE.ipw2200-fw
"${tempFirmwareDir}/${driver}/"
203 mv ipw2200-ibss.fw
"${tempFirmwareDir}/${driver}/"
204 mv ipw2200-sniffer.fw
"${tempFirmwareDir}/${driver}/"
205 mv ipw2200-bss.fw
"${tempFirmwareDir}/${driver}/"
207 rm "${tempFirmwareDir}/${driver}/${file}"
208 PostFirmwareInstallation
212 function InstallBroadcom43xx
()
214 driver
='broadcom43xx'
215 PreFirmwareInstallation
217 BuildBroadcomFWCutter
219 if [ $returnCode -gt 0 ] ; then
220 echo "...failed. ${driver}'s firmware will not be installed."
224 CutAndInstallBroadcomFirmware
226 if [ $returnCode -gt 0 ] ; then
227 echo "...failed. ${driver}'s firmware will not be installed."
231 PostFirmwareInstallation
235 function InstallMarvell88w8335
()
237 driver
='marvell88w8335'
238 PreFirmwareInstallation
240 # Download firmware archive.
241 local file="malo-firmware-1.4.tgz"
242 local url
="${baseURL}/marvell/${file}"
243 local dir
="${tempFirmwareDir}/${driver}"
244 DownloadFileIfNotCached
$url $file "$dir"
245 if [ $result -gt 0 ]; then
246 echo "...failed. ${driver}'s firmware will not be installed."
252 tar xf
"${tempFirmwareDir}/${driver}/$file"
254 # Move firmware files to destination.
255 local sourceDir
="${tempDir}/share/examples/malo-firmware"
256 mv ${sourceDir}/malo8335-h "${tempFirmwareDir}/${driver}"
257 mv ${sourceDir}/malo8335-m "${tempFirmwareDir}/${driver}"
259 rm "${tempFirmwareDir}/${driver}/${file}"
260 PostFirmwareInstallation
264 function BuildBroadcomFWCutter
()
266 # Download & extract b43-fwcutter.
267 local file="b43-fwcutter-012.tar.bz2"
268 local dir
="${tempFirmwareDir}/${driver}/b43-fwcutter"
269 local url
="${baseURL}/b43/fwcutter/${file}"
270 DownloadFileIfNotCached
$url $file $dir
271 if [ $result -gt 0 ]; then
279 # Download additonal files for building b43-fwcutter.
281 local baseURL
='http://cgit.haiku-os.org/haiku/plain/src/system/libroot/posix/glibc'
282 DownloadFileIfNotCached
${baseURL}/string
/byteswap.h byteswap.h
$dir
283 if [ $result -gt 0 ]; then
286 DownloadFileIfNotCached
${baseURL}/include
/arch
/x86
/bits
/byteswap.h byteswap.h
$dir/bits
287 if [ $result -gt 0 ]; then
291 # Copy those files to working directory.
294 cp $dir/bits
/byteswap.h bits
/
296 # Build b43-fwcutter.
297 echo "Compiling b43-fwcutter for installing Broadcom's firmware ..."
298 make PREFIX
=/boot
/system CFLAGS
="-I. -Wall -D_BSD_SOURCE" > /dev
/null
2>&1
300 if [ $result -gt 0 ]; then
301 echo "... failed to compile b43-fwcutter."
303 echo "... successfully compiled b43-fwcutter."
305 if [ ! -e b43-fwcutter
] ; then
308 mv b43-fwcutter
"$tempDir"
310 cd "${tempFirmwareDir}/${driver}/b43-fwcutter"
311 rm b43-fwcutter-012.
tar.bz2
322 function CutAndInstallBroadcomFirmware
()
325 local file="wl_apsta-3.130.20.0.o"
326 local dir
="${tempFirmwareDir}/${driver}"
327 local url
="${baseURL}/b43/${file}"
328 DownloadFileIfNotCached
$url $file $dir
329 if [ $result -gt 0 ]; then
333 # Cut firmware in pieces.
334 cp "$dir/$file" "$tempDir"
336 b43-fwcutter
$file > /dev
/null
2>&1
340 for i
in $
(ls -1); do
341 newFileName
=$
(echo $i |
sed "s/\(.*\)\.fw$/bwi_v3_\1/g")
347 mv * ${tempFirmwareDir}/${driver}/
349 rm "${tempFirmwareDir}/${driver}/$file"
354 function makePackageInfo
()
356 cat << EOF > .PackageInfo
360 summary "Firmwares for various wireless network cards"
361 description "Installs firmwares for the following wireless network cards:
362 Broadcom 43xx, Intel ipw2100, Intel ipw2200, and Marvell 88W8335.
363 Firmware for broadcom43xx is under the Copyright of Broadcom Corporation(R).
364 Firmware for marvell88w8335 is under the Copyright of Marvell Technology(R).
365 ipw2100,iprowifi2200 firmware is covered by the Intel(R) license located in
366 /boot/system/data/licenses/Intel (2xxx firmware). The user is not granted a
367 license to use the package unless these terms are agreed to."
372 "Copyright of Broadcom Corporation(R)"
373 "Copyright of Intel(R) Corporation"
374 "Copyright of Marvell Technology(R)"
376 licenses "Intel (2xxx firmware)"
382 wifi_firmwares = 2013_10_06
394 cd "$tempFirmwareDir/../../.."
396 package create
-C system
-i .PackageInfo wifi_firmwares-1-any.hpkg
397 mv wifi_firmwares-1-any.hpkg
`finddir B_SYSTEM_PACKAGES_DIRECTORY`
398 rm -rf "`finddir B_SYSTEM_TEMP_DIRECTORY`/package_me"
404 mkdir
-p "$tempFirmwareDir"