]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - keystone-demos/matrix-apps.git/blob - utility_flash/cgi-bin/flashread.cgi
b6c2a99dbd9ad9cefb6e08ced90f753c49dccf42
[keystone-demos/matrix-apps.git] / utility_flash / cgi-bin / flashread.cgi
1 #!/bin/sh
2 echo Content-type: text/html
3 echo 
4 echo 
6 cat << EOM
7 <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'> <html xmlns='http://www.w3.org/1999/xhtml'>
8 <head><meta http-equiv='Pragma' CONTENT='no-cache' /> <meta http-equiv='content-type' content='text/html; charset=utf-8' /> <title>C6x Linux Web Control Panel</title><link rel='stylesheet' href='/default.css' type='text/css' />
9 </head>
10 <body>
11 <div id='wrapper'><div id='logo'><h1>Flash Read</h1>
12 </div><div id='header'><div id='menu'><ul><li><a href='/flash.html'>Back</a></li>
13 </ul></div></div></div>
14 <div id='page'>
15 EOM
17 display_footer()
18 {
19 cat << EOM2
20 <hr>
21 <div style='clear: both;'>&nbsp;</div>
22 </div>
23 <div id='footer'><p id='legal'>( c ) 2013 Texas Instruments Incorporated&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p></div>
24 </body>
25 </html>
26 EOM2
27 }
29 TMPFILE=`mktemp`
30 cat > $TMPFILE
32 get_params()
33 {
34 partition=$(cat $TMPFILE | sed -n '4p'| sed 's/.$//')
35 mtddevname=$(cat /proc/mtd | awk -v pat="$partition" '$0 ~ pat {printf $1}' | sed 's/://')
36 mtddev="/dev/"$mtddevname
37 TMPFILE_DATA="../"$partition".bin"
38 }
40 check_params()
41 {
43 #check for the NAND partition
44 if [ "$mtddevname" = "" ] ; then
45 cat << EOM1
46 <div id='content'>
47 <p>Could not find Nand partition for <i>$partition</i> ...</p>
48 <br>
49 </div>
50 EOM1
51 display_footer
52 rm -f $TMPFILE
53 exit
54 fi
56 mtdsz="0x"$(cat /proc/mtd | awk -v pat="$partition" '$0 ~ pat {printf $2}')
57 mtdsz=$(($mtdsz))
58 }
60 read_flash()
61 {
62 cat << EOM1
63 <div id='content'>
64 <p>Reading <i>$mtdsz</i> bytes from <i>$mtddev</i> ...</p>
65 </div>
66 EOM1
67 nanddump -o -q -f $TMPFILE_DATA -l $mtdsz $mtddev
68 sync
69 }
71 #Allow User to download the file
72 file_download()
73 {
74 cat << EOM1
75 <div id='content'>
76 <input type="button" name="Button" value="Save NAND data" onClick="window.open('$TMPFILE_DATA', 'download'); return false;">
77 </div>
78 EOM1
79 }
81 get_params
82 check_params
83 read_flash
84 file_download
86 #cleanup
87 rm -f $TMPFILE
89 display_footer