Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
W
White Rabbit Starting Kit
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
White Rabbit Starting Kit
Commits
233efb45
Commit
233efb45
authored
Jan 09, 2013
by
Benoit Rat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
scripts: update the script to ease the installation
parent
98e1e4d9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
195 additions
and
0 deletions
+195
-0
wr-ssk-get
scripts/wr-ssk-get
+195
-0
No files found.
scripts/wr-ssk-get
0 → 100755
View file @
233efb45
#!/bin/sh
## Script to ease the installation of gateware HDL when using
## the starting kit
##
## Authors:
## - Benoit Rat (Seven Solutions, www.sevensols.com)
##
## GNU Lesser General Public License Usage
## This file may be used under the terms of the GNU Lesser
## General Public License version 2.1 as published by the Free Software
## Foundation and appearing in the file LICENSE.LGPL included in the
## packaging of this file. Please review the following information to
## ensure the GNU Lesser General Public License version 2.1 requirements
## will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
#######################################################################################################
### Script to return text according to previous return
wr_echoret
()
{
if
[
$1
=
"0"
]
;
then
echo
"
$2
"
else
echo
"
$3
"
fi
}
### Fetching a file
fetchfile
()
{
url
=
$1
file
=
$(
basename
$url
)
output
=
${
DOWNLOADDIR
}
/
${
file
}
md5
=
$2
name
=
$3
if
[
!
-d
${
DOWNLOADDIR
}
]
;
then
mkdir
-p
${
DOWNLOADDIR
}
fi
## If output already exist check md5 or override it
if
[
-f
${
output
}
]
;
then
ourmd5
=
$(
cat
$output
|
md5sum
|
sed
's/ .*$//'
)
if
[
"
$ourmd5
"
=
"
$md5
"
]
;
then
echo
"File already exist with valid md5, Skiping download of
$file
"
return
0
else
echo
"File
$file
is corrupted, re-downloading"
rm
$output
fi
fi
## Download from upstream
wget
-nv
$url
-O
$output
echo
"wget -nv
$url
-O
$ouput
"
if
[
-s
$output
]
;
then
echo
"Retrieved
$filee
from upstream"
return
0
else
rm
-f
$output
echo
"Cannot download
$name
"
return
1
fi
}
linkedfiles
()
{
echo
"Linking HDL binaries"
# Loop on the fake download infor file....
echo
$fakedlinfo
|
while
read
url md5
;
do
lname
=
$(
echo
$url
|
sed
-E
's/.*\/(.*).bin-.*/\1.bin/'
)
if
[
-s
$hfile
]
;
then
ln
-fs
${
hname
}
${
lname
}
echo
"Linking
$hname
to
$lname
"
else
echo
"File
${
hname
}
was not found"
fi
done
echo
"DONE"
}
### Fetching the desired HDL binaries
fetch
()
{
url
=
$(
echo
${
PKGURL
}
|
cut
-d
" "
-f1
)
md5
=
$(
echo
${
PKGURL
}
|
cut
-d
" "
-f2
)
echo
"Fetching HDL binaries"
fetchfile
${
url
}
${
md5
}
echo
"Extracting ..."
cd
${
DOWNLOADDIR
}
;
tar
-xzvf
$(
basename
${
url
})
--wildcards
*
.bin
}
### Install firmware in /lib/firmware/fmc
insthdl
()
{
echo
"Installing firware in /lib/firmware/fmc"
installdir
=
/lib/firmware/fmc
if
[
!
-d
${
installdir
}
]
;
then
sudo mkdir
-p
${
installdir
}
fi
sudo cp
-v
${
DOWNLOADDIR
}
/spec-init.bin
${
DOWNLOADDIR
}
/wr_nic_dio.bin
${
installdir
}
wr_echoret
$?
"OK"
"ERROR"
checkdrv
;
}
checkdrv
()
{
echo
""
echo
"Checking the drivers"
for
mod
in
"fmc"
"spec"
"wr-nic"
;
do
if
[
-s
/lib/modules/
$(
uname
-r
)
/extra/
${
mod
}
.ko
]
;
then
echo
"
${
mod
}
.ko found!"
else
echo
"
${
mod
}
.ko was not found in /lib/modules/
$(
uname
-r
)
/extra/"
echo
"first checkout the spec-sw project and run: make && sudo make install"
return
1
fi
done
echo
"Creating dependancies... (This can take some time)"
echo
"sudo depmod -a"
sudo
depmod
-a
}
### Load module
loadmodule
()
{
echo
"loading modules & gatewares..."
echo
"sudo modprobe wr-nic"
sudo
modprobe wr-nic
}
### Insert module (should not be necesarry modprob should work)
insertmodule
()
{
echo
"inserting modules & gatewares..."
for
mod
in
"fmc"
"spec"
"wr-nic"
;
do
printf
"sudo insmod /lib/modules/
$(
uname
-r
)
/extra/
${
mod
}
.ko ...
\t
"
sudo
insmod /lib/modules/
$(
uname
-r
)
/extra/
${
mod
}
.ko
wr_echoret
$?
"OK"
"ERROR"
done
exit
0
}
### Show help of the function
help
()
{
cat
<<
EOF
Usage:
$(
basename
$0
)
[Options]
Options:
-h|--help) Show this little help
-a|--all) Fetch and install
-f|--fetch) Fetch files only
-i|--install) Install the gateware for the driver (require sudo)
-l|--load) Load modules in kernel (require sudo)
--insert) Insert modules in kernel (require sudo)
EOF
exit
0
}
#################################################
### Main execution
# setup script dir
scriptdir
=
$(
cd
$(
dirname
$0
)
;
pwd
)
DOWNLOADDIR
=
${
scriptdir
}
/../firmware
PKGURL
=
"http://www.ohwr.org/attachments/download/1815/wr-starting-kit-v1.0_gw.tar.gz 9a7a6d8e6815adebb6796a37d1621acd"
while
[
$#
-gt
0
]
;
do
# Until you run out of parameters . . .
case
"
$1
"
in
-h
|
--help
)
help
;;
-a
|
--all
)
fetch
;
insthdl instdrv
;
exit
;;
-f
|
--fetch
)
fetch
;
exit
;;
-i
|
--install
)
insthdl
;
exit
;;
-l
|
--load
)
loadmodule
;
exit
;;
--insert
)
insertmodule
;
exit
;;
*
)
help
;;
esac
shift
# Check next set of parameters.
done
help
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment