2010-01-19 13:17:33 +03:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
2012-06-18 00:29:38 +04:00
|
|
|
# Copyright (c) 2010-2012 Haiku, Inc.
|
2010-01-19 13:17:33 +03:00
|
|
|
# Distributed under the terms of the MIT License.
|
|
|
|
#
|
|
|
|
# Authors:
|
|
|
|
# Matt Madia, mattmadia@gmail.com
|
|
|
|
#
|
|
|
|
# Synopsis:
|
|
|
|
# Provide a mechanism for end-users to install various firmwares for wireless
|
2010-04-29 20:04:29 +04:00
|
|
|
# network cards in a manner that complies with their individual licenses.
|
|
|
|
#
|
2010-01-19 13:17:33 +03:00
|
|
|
# Supported chipsets:
|
|
|
|
# Intel ipw2100
|
|
|
|
# Intel ipw2200/2225/2915
|
|
|
|
# Broadcom 43xx
|
|
|
|
# Marvell 88W8335
|
|
|
|
|
|
|
|
|
|
|
|
MESSAGE="This script will install firmware for various wireless network cards.
|
|
|
|
The Broadcom 43xx and Marvell 88W8335 require an active network connection
|
|
|
|
to download additional files before installation. In the absence of internet
|
2010-05-20 18:13:01 +04:00
|
|
|
access, only Intel's ipw2100 and ipw2200 will be installed.
|
|
|
|
|
|
|
|
If you do not have internet access and need to install the other firmwares,
|
|
|
|
goto http://www.haiku-os.org/guides/dailytasks/wireless. This page has
|
|
|
|
instructions on which files to manually download and where to copy them into
|
|
|
|
this OS. It also has different script that can be run on another OS and will
|
|
|
|
prepare a zip archive for easy install. After that, re-run this script."
|
2010-01-19 13:17:33 +03:00
|
|
|
VIEW='View licenses'
|
|
|
|
ABORT='Abort installation'
|
|
|
|
OK='I agree to the licenses. Install firmwares.'
|
|
|
|
|
2012-06-17 23:49:44 +04:00
|
|
|
baseURL='http://www.haiku-files.org/files/wifi-firmwares'
|
2010-01-19 13:17:33 +03:00
|
|
|
firmwareDir=`finddir B_SYSTEM_DATA_DIRECTORY`/firmware
|
2013-10-07 05:33:14 +04:00
|
|
|
tempDir=`finddir B_SYSTEM_TEMP_DIRECTORY`/wifi-firmwares
|
2010-01-19 13:17:33 +03:00
|
|
|
driversDir=`finddir B_SYSTEM_ADDONS_DIRECTORY`/kernel/drivers
|
2013-10-07 05:33:14 +04:00
|
|
|
tempFirmwareDir=`finddir B_SYSTEM_TEMP_DIRECTORY`/package_me"$firmwareDir"
|
2010-01-19 13:17:33 +03:00
|
|
|
intelLicense='/boot/system/data/licenses/Intel (2xxx firmware)'
|
|
|
|
|
|
|
|
|
|
|
|
function DisplayAlert()
|
|
|
|
{
|
|
|
|
local result=`alert --stop "$MESSAGE" "$VIEW" "$ABORT" "$OK"`
|
|
|
|
case "${result}" in
|
|
|
|
"$VIEW")
|
|
|
|
ViewLicenses ;
|
2010-04-29 20:04:29 +04:00
|
|
|
DisplayAlert ;
|
2010-01-19 13:17:33 +03:00
|
|
|
;;
|
|
|
|
"$ABORT")
|
|
|
|
exit 0 ;;
|
2010-04-29 20:04:29 +04:00
|
|
|
"$OK")
|
2010-01-19 13:17:33 +03:00
|
|
|
InstallAllFirmwares ;
|
|
|
|
exit 0 ;
|
|
|
|
;;
|
2010-04-29 20:04:29 +04:00
|
|
|
esac
|
2010-01-19 13:17:33 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function ViewLicenses()
|
|
|
|
{
|
|
|
|
license="$tempDir/Wifi_Firmware_Licenses"
|
|
|
|
cat << EOF > $license
|
|
|
|
|
|
|
|
+-----------------------------------------------------------------------------+
|
|
|
|
| |
|
|
|
|
| Copyright and licensing information of the various wireless firmwares |
|
|
|
|
| |
|
|
|
|
| Firmware for broadcom43xx is under the Copyright of Broadcom Corporation(R) |
|
|
|
|
| Firmware for marvell88w8335 is under the Copyright of Marvell Technology(R) |
|
|
|
|
| ipw2100,iprowifi2200 firmware is covered by the following Intel(R) license: |
|
|
|
|
| |
|
|
|
|
+-----------------------------------------------------------------------------+
|
|
|
|
|
|
|
|
EOF
|
|
|
|
cat "$intelLicense" >> $license
|
2010-04-29 20:04:29 +04:00
|
|
|
|
2010-01-19 13:17:33 +03:00
|
|
|
open $license
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function InstallAllFirmwares()
|
|
|
|
{
|
|
|
|
InstallIpw2100
|
|
|
|
InstallIprowifi2200
|
|
|
|
InstallBroadcom43xx
|
|
|
|
InstallMarvell88w8335
|
2013-10-07 05:17:39 +04:00
|
|
|
MakeHPKG
|
2010-01-19 13:17:33 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function UnlinkDriver()
|
|
|
|
{
|
|
|
|
# remove the driver's symlink
|
2013-10-07 05:17:39 +04:00
|
|
|
#rm -f "${driversDir}/dev/net/${driver}"
|
|
|
|
echo "TODO: UnlinkDriver"
|
2010-01-19 13:17:33 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function SymlinkDriver()
|
|
|
|
{
|
|
|
|
# restore the driver's symlink
|
2013-10-07 05:17:39 +04:00
|
|
|
#cd "${driversDir}/dev/net/"
|
|
|
|
#ln -sf "../../bin/${driver}" "${driver}"
|
|
|
|
echo "TODO: SymlinkDriver"
|
2010-01-19 13:17:33 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function DownloadFileIfNotCached()
|
|
|
|
{
|
|
|
|
# DownloadFileIfNotCached <url> <filename> <destination dir>
|
|
|
|
local url=$1
|
|
|
|
local file=$2
|
|
|
|
local dir=$3
|
|
|
|
|
|
|
|
mkdir -p "$dir"
|
|
|
|
if [ ! -e $dir/$file ] ; then
|
|
|
|
echo "Downloading $url ..."
|
2010-03-03 15:07:59 +03:00
|
|
|
wget -nv -O $dir/$file $url
|
2010-01-19 13:17:33 +03:00
|
|
|
fi
|
|
|
|
result=$?
|
|
|
|
if [ $result -gt 0 ]; then
|
|
|
|
local error="Failed to download $url."
|
|
|
|
local msg="As a result, ${driver}'s firmware will not be installed."
|
|
|
|
alert --warning "$error $msg"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function SetFirmwarePermissions()
|
|
|
|
{
|
2013-10-07 05:17:39 +04:00
|
|
|
cd ${tempFirmwareDir}/${driver}/
|
2010-01-19 13:17:33 +03:00
|
|
|
for file in * ; do
|
2012-06-18 00:24:41 +04:00
|
|
|
if [ "$file" != "$driver" ] && [ -f "$file" ] ; then
|
2010-01-19 13:17:33 +03:00
|
|
|
chmod a=r $file
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function CleanTemporaryFiles()
|
|
|
|
{
|
|
|
|
rm -rf "$tempDir"
|
|
|
|
mkdir -p "$tempDir"
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function PreFirmwareInstallation()
|
|
|
|
{
|
2010-07-22 03:07:52 +04:00
|
|
|
echo "Installing firmware for ${driver} ..."
|
2013-10-07 05:17:39 +04:00
|
|
|
mkdir -p "${tempFirmwareDir}/${driver}"
|
2010-01-19 13:17:33 +03:00
|
|
|
UnlinkDriver
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function PostFirmwareInstallation()
|
|
|
|
{
|
|
|
|
SetFirmwarePermissions
|
|
|
|
SymlinkDriver
|
|
|
|
CleanTemporaryFiles
|
2010-07-22 03:07:52 +04:00
|
|
|
echo "... firmware for ${driver} has been installed."
|
2010-01-19 13:17:33 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function InstallIpw2100()
|
|
|
|
{
|
2012-06-02 00:29:26 +04:00
|
|
|
driver='iprowifi2100'
|
2010-01-19 13:17:33 +03:00
|
|
|
PreFirmwareInstallation
|
|
|
|
|
|
|
|
# Extract contents.
|
|
|
|
local file='ipw2100-fw-1.3.tgz'
|
2012-06-17 23:49:44 +04:00
|
|
|
local url="${baseURL}/intel/${file}"
|
2013-10-07 05:17:39 +04:00
|
|
|
local dir="${tempFirmwareDir}/${driver}"
|
2012-06-17 23:49:44 +04:00
|
|
|
DownloadFileIfNotCached $url $file $dir
|
2010-01-19 13:17:33 +03:00
|
|
|
|
|
|
|
# Install the firmware & license file by extracting in place.
|
2013-10-07 05:17:39 +04:00
|
|
|
cd "${tempFirmwareDir}/${driver}"
|
2010-01-19 13:17:33 +03:00
|
|
|
gunzip < "$file" | tar xf -
|
|
|
|
|
2013-10-07 05:17:39 +04:00
|
|
|
rm "${tempFirmwareDir}/${driver}/${file}"
|
2010-01-19 13:17:33 +03:00
|
|
|
PostFirmwareInstallation
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function InstallIprowifi2200()
|
|
|
|
{
|
|
|
|
driver='iprowifi2200'
|
|
|
|
PreFirmwareInstallation
|
|
|
|
|
|
|
|
# Extract contents.
|
|
|
|
local file='ipw2200-fw-3.1.tgz'
|
2012-06-17 23:49:44 +04:00
|
|
|
local url="${baseURL}/intel/${file}"
|
2013-10-07 05:17:39 +04:00
|
|
|
local dir="${tempFirmwareDir}/${driver}"
|
2012-06-17 23:49:44 +04:00
|
|
|
DownloadFileIfNotCached $url $file $dir
|
2010-01-19 13:17:33 +03:00
|
|
|
|
|
|
|
cd "$tempDir"
|
2013-10-07 05:17:39 +04:00
|
|
|
gunzip < "${tempFirmwareDir}/${driver}/$file" | tar xf -
|
2010-01-19 13:17:33 +03:00
|
|
|
|
|
|
|
# Install the firmware & license file.
|
2010-04-29 20:04:29 +04:00
|
|
|
cd "${tempDir}/ipw2200-fw-3.1"
|
2013-10-07 05:17:39 +04:00
|
|
|
mv LICENSE.ipw2200-fw "${tempFirmwareDir}/${driver}/"
|
|
|
|
mv ipw2200-ibss.fw "${tempFirmwareDir}/${driver}/"
|
|
|
|
mv ipw2200-sniffer.fw "${tempFirmwareDir}/${driver}/"
|
|
|
|
mv ipw2200-bss.fw "${tempFirmwareDir}/${driver}/"
|
2010-01-19 13:17:33 +03:00
|
|
|
|
2013-10-07 05:17:39 +04:00
|
|
|
rm "${tempFirmwareDir}/${driver}/${file}"
|
2010-01-19 13:17:33 +03:00
|
|
|
PostFirmwareInstallation
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function InstallBroadcom43xx()
|
|
|
|
{
|
|
|
|
driver='broadcom43xx'
|
|
|
|
PreFirmwareInstallation
|
|
|
|
|
|
|
|
BuildBroadcomFWCutter
|
2010-03-02 00:58:27 +03:00
|
|
|
returnCode=$?
|
|
|
|
if [ $returnCode -gt 0 ] ; then
|
2010-01-19 13:17:33 +03:00
|
|
|
echo "...failed. ${driver}'s firmware will not be installed."
|
2010-03-02 00:58:27 +03:00
|
|
|
return $returnCode
|
2010-01-19 13:17:33 +03:00
|
|
|
fi
|
|
|
|
|
|
|
|
CutAndInstallBroadcomFirmware
|
2010-03-02 00:58:27 +03:00
|
|
|
returnCode=$?
|
|
|
|
if [ $returnCode -gt 0 ] ; then
|
2010-01-19 13:17:33 +03:00
|
|
|
echo "...failed. ${driver}'s firmware will not be installed."
|
2010-03-02 00:58:27 +03:00
|
|
|
return $returnCode
|
2010-01-19 13:17:33 +03:00
|
|
|
fi
|
|
|
|
|
|
|
|
PostFirmwareInstallation
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function InstallMarvell88w8335()
|
|
|
|
{
|
|
|
|
driver='marvell88w8335'
|
|
|
|
PreFirmwareInstallation
|
|
|
|
|
|
|
|
# Download firmware archive.
|
|
|
|
local file="malo-firmware-1.4.tgz"
|
2012-06-17 23:49:44 +04:00
|
|
|
local url="${baseURL}/marvell/${file}"
|
2013-10-07 05:17:39 +04:00
|
|
|
local dir="${tempFirmwareDir}/${driver}"
|
2010-01-19 13:17:33 +03:00
|
|
|
DownloadFileIfNotCached $url $file "$dir"
|
|
|
|
if [ $result -gt 0 ]; then
|
|
|
|
echo "...failed. ${driver}'s firmware will not be installed."
|
|
|
|
return $result
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Extract archive.
|
|
|
|
cd "$tempDir"
|
2013-10-07 05:17:39 +04:00
|
|
|
tar xf "${tempFirmwareDir}/${driver}/$file"
|
2010-01-19 13:17:33 +03:00
|
|
|
|
|
|
|
# Move firmware files to destination.
|
|
|
|
local sourceDir="${tempDir}/share/examples/malo-firmware"
|
2013-10-07 05:17:39 +04:00
|
|
|
mv ${sourceDir}/malo8335-h "${tempFirmwareDir}/${driver}"
|
|
|
|
mv ${sourceDir}/malo8335-m "${tempFirmwareDir}/${driver}"
|
|
|
|
|
|
|
|
rm "${tempFirmwareDir}/${driver}/${file}"
|
2010-01-19 13:17:33 +03:00
|
|
|
PostFirmwareInstallation
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function BuildBroadcomFWCutter()
|
|
|
|
{
|
|
|
|
# Download & extract b43-fwcutter.
|
|
|
|
local file="b43-fwcutter-012.tar.bz2"
|
2013-10-07 05:17:39 +04:00
|
|
|
local dir="${tempFirmwareDir}/${driver}/b43-fwcutter"
|
2012-06-17 23:49:44 +04:00
|
|
|
local url="${baseURL}/b43/fwcutter/${file}"
|
2010-01-19 13:17:33 +03:00
|
|
|
DownloadFileIfNotCached $url $file $dir
|
|
|
|
if [ $result -gt 0 ]; then
|
|
|
|
return $result
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Extract archive.
|
|
|
|
cd "$tempDir"
|
|
|
|
tar xjf "$dir/$file"
|
|
|
|
|
|
|
|
# Download additonal files for building b43-fwcutter.
|
|
|
|
cd b43-fwcutter-012
|
2012-02-16 03:25:13 +04:00
|
|
|
local baseURL='http://cgit.haiku-os.org/haiku/plain/src/system/libroot/posix/glibc'
|
2010-01-19 13:17:33 +03:00
|
|
|
DownloadFileIfNotCached ${baseURL}/string/byteswap.h byteswap.h $dir
|
|
|
|
if [ $result -gt 0 ]; then
|
|
|
|
return $result
|
|
|
|
fi
|
|
|
|
DownloadFileIfNotCached ${baseURL}/include/arch/x86/bits/byteswap.h byteswap.h $dir/bits
|
|
|
|
if [ $result -gt 0 ]; then
|
|
|
|
return $result
|
2010-04-29 20:04:29 +04:00
|
|
|
fi
|
2010-01-19 13:17:33 +03:00
|
|
|
|
|
|
|
# Copy those files to working directory.
|
|
|
|
mkdir -p bits
|
|
|
|
cp $dir/byteswap.h .
|
|
|
|
cp $dir/bits/byteswap.h bits/
|
|
|
|
|
|
|
|
# Build b43-fwcutter.
|
|
|
|
echo "Compiling b43-fwcutter for installing Broadcom's firmware ..."
|
2013-09-30 00:09:00 +04:00
|
|
|
make PREFIX=/boot/system CFLAGS="-I. -Wall -D_BSD_SOURCE" > /dev/null 2>&1
|
2010-07-22 03:07:52 +04:00
|
|
|
result=$?
|
|
|
|
if [ $result -gt 0 ]; then
|
|
|
|
echo "... failed to compile b43-fwcutter."
|
|
|
|
else
|
|
|
|
echo "... successfully compiled b43-fwcutter."
|
|
|
|
fi
|
2010-01-19 13:17:33 +03:00
|
|
|
if [ ! -e b43-fwcutter ] ; then
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
mv b43-fwcutter "$tempDir"
|
|
|
|
|
2013-10-07 05:17:39 +04:00
|
|
|
cd "${tempFirmwareDir}/${driver}/b43-fwcutter"
|
|
|
|
rm b43-fwcutter-012.tar.bz2
|
|
|
|
rm byteswap.h
|
|
|
|
rm bits/byteswap.h
|
|
|
|
rmdir bits
|
|
|
|
cd ..
|
|
|
|
rmdir b43-fwcutter
|
|
|
|
|
2010-01-19 13:17:33 +03:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function CutAndInstallBroadcomFirmware()
|
|
|
|
{
|
|
|
|
# Download firmware.
|
|
|
|
local file="wl_apsta-3.130.20.0.o"
|
2013-10-07 05:17:39 +04:00
|
|
|
local dir="${tempFirmwareDir}/${driver}"
|
2012-06-17 23:49:44 +04:00
|
|
|
local url="${baseURL}/b43/${file}"
|
2010-05-04 00:07:54 +04:00
|
|
|
DownloadFileIfNotCached $url $file $dir
|
2010-01-19 13:17:33 +03:00
|
|
|
if [ $result -gt 0 ]; then
|
|
|
|
return $result
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Cut firmware in pieces.
|
2010-05-04 00:07:54 +04:00
|
|
|
cp "$dir/$file" "$tempDir"
|
2010-01-19 13:17:33 +03:00
|
|
|
cd "$tempDir"
|
2010-02-24 13:57:08 +03:00
|
|
|
b43-fwcutter $file > /dev/null 2>&1
|
2010-01-19 13:17:33 +03:00
|
|
|
|
|
|
|
# Rename the pieces.
|
|
|
|
cd b43legacy
|
|
|
|
for i in $(ls -1); do
|
|
|
|
newFileName=$(echo $i | sed "s/\(.*\)\.fw$/bwi_v3_\1/g")
|
|
|
|
mv $i $newFileName
|
|
|
|
done
|
|
|
|
touch bwi_v3_ucode
|
|
|
|
|
|
|
|
# Install files.
|
2013-10-07 05:17:39 +04:00
|
|
|
mv * ${tempFirmwareDir}/${driver}/
|
2010-01-19 13:17:33 +03:00
|
|
|
|
2013-10-07 05:17:39 +04:00
|
|
|
rm "${tempFirmwareDir}/${driver}/$file"
|
2010-01-19 13:17:33 +03:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-10-07 05:17:39 +04:00
|
|
|
function makePackageInfo()
|
|
|
|
{
|
|
|
|
cat << EOF > .PackageInfo
|
|
|
|
name wifi_firmwares
|
|
|
|
version 2013_10_06-1
|
|
|
|
architecture any
|
|
|
|
summary "Firmwares for various wireless network cards"
|
|
|
|
description "Installs firmwares for the following wireless network cards:
|
|
|
|
Broadcom 43xx, Intel ipw2100, Intel ipw2200, and Marvell 88W8335.
|
|
|
|
Firmware for broadcom43xx is under the Copyright of Broadcom Corporation(R).
|
|
|
|
Firmware for marvell88w8335 is under the Copyright of Marvell Technology(R).
|
|
|
|
ipw2100,iprowifi2200 firmware is covered by the Intel(R) license located in
|
|
|
|
/boot/system/data/licenses/Intel (2xxx firmware). The user is not granted a
|
|
|
|
license to use the package unless these terms are agreed to."
|
|
|
|
|
|
|
|
packager "me"
|
|
|
|
vendor "myself"
|
|
|
|
copyrights {
|
|
|
|
"Copyright of Broadcom Corporation(R)"
|
|
|
|
"Copyright of Intel(R) Corporation"
|
|
|
|
"Copyright of Marvell Technology(R)"
|
|
|
|
}
|
|
|
|
licenses "Intel (2xxx firmware)"
|
|
|
|
flags {
|
|
|
|
"approve_license"
|
|
|
|
"system_package"
|
|
|
|
}
|
|
|
|
provides {
|
|
|
|
wifi_firmwares = 2013_10_06
|
|
|
|
}
|
|
|
|
requires {
|
|
|
|
haiku >= R1~alpha4
|
|
|
|
}
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function MakeHPKG()
|
|
|
|
{
|
2014-01-03 06:39:41 +04:00
|
|
|
cd "$tempFirmwareDir/../../.."
|
2013-10-07 05:17:39 +04:00
|
|
|
makePackageInfo
|
2014-05-12 11:45:35 +04:00
|
|
|
package create -C system -i .PackageInfo wifi_firmwares-1-any.hpkg
|
2013-10-07 05:17:39 +04:00
|
|
|
mv wifi_firmwares-1-any.hpkg `finddir B_SYSTEM_PACKAGES_DIRECTORY`
|
2013-10-07 05:33:14 +04:00
|
|
|
rm -rf "`finddir B_SYSTEM_TEMP_DIRECTORY`/package_me"
|
|
|
|
rm -rf "$tempDir"
|
2013-10-07 05:17:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-03-01 13:05:27 +03:00
|
|
|
mkdir -p "$tempDir"
|
2013-10-07 05:17:39 +04:00
|
|
|
mkdir -p "$tempFirmwareDir"
|
2010-01-19 13:17:33 +03:00
|
|
|
DisplayAlert
|