Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(161)

Side by Side Diff: util/wp-range.sh

Issue 5136001: Add new testing framework along with a few micro-tests. (Closed) Base URL: svn://coreboot.org/flashrom/trunk/util
Patch Set: General updates, add rough EC unit testing Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 #!/bin/sh
2 #
3 # Copyright (C) 2010 Google Inc.
4 # Written by David Hendricks for Google Inc.
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19
20 # Assume we can set a write protect range for 0-64KB
21 # This assumes the output from wp-status is:
22 # "some text ... start=0x00000000, len=0x00010000"
23 # where the start and length are key=value pairs
24
25 # FIXME: Should we intentionally disable write protection for this? The
26 # status register will not be changeable if hardware WP is in effect.
27 # Then again, if hardware WP is on, then we won't be able to disable WP
28 # either...
29
30 LOGFILE="${0}.log"
31 NEW_WP_RANGE_START=0x000000
32 NEW_WP_RANGE_LEN=0x010000
33
34 # Back-up old settings
35 tmp=$(./flashrom ${FLASHROM_PARAM} --wp-status 2>/dev/null)
36 old_start=${tmp##*start=}
37 old_start=`printf "%s" "${old_start%%,*}"`
38
39 old_len=${tmp##*len=}
40 old_len=`printf "%s" "${old_len%%,*}"`
41 echo "old start: ${old_start}, old length: ${old_len}" >> ${LOGFILE}
42
43 # If the old write protection settings are the same as the new ones, we need
44 # to choose new values. If this is the case, we'll extend the range to the
45 # next 64K block.
hailfinger 2010/11/23 20:05:34 That won't work for most flash chips because each
Stefan Reinauer 2010/11/23 21:14:14 Oh.. would we want some flashrom function to dump
dhendrix 2010/11/24 02:48:14 Correct -- This is sort of a crappy method that wi
46 if [ $((${old_start} == ${NEW_WP_RANGE_START})) -ne 1 ] && [ $((${old_len} == ${ NEW_WP_RANGE_LEN})) -ne 1 ] ; then
47 NEW_WP_RANGE_LEN=$((${NEW_WP_RANGE_LEN} + 0x10000}))
48 fi
49
50 # Try to set new range values
51 echo "attempting to set write protect range: start=${NEW_WP_RANGE_START} ${NEW_W P_RANGE_LEN}" >> ${LOGFILE}
52 ./flashrom ${FLASHROM_PARAM} --wp-range ${NEW_WP_RANGE_START} ${NEW_WP_RANGE_LEN } 2>/dev/null
53 if [ ${?} -ne ${EXIT_SUCCESS} ]; then
54 echo -n "failed to set write protect range" >> ${LOGFILE}
55 return ${EXIT_FAILURE}
56 fi
57
58 tmp=$(./flashrom ${FLASHROM_PARAM} --wp-status 2>/dev/null)
hailfinger 2010/11/23 20:05:34 You only check that the printed range and the requ
dhendrix 2010/11/24 02:48:14 Yeah :-/ For all this test is concerned, one could
59 new_start=${tmp##*start=}
60 new_start=`printf "%s" "${new_start%%,*}"`
61
62 new_len=${tmp##*len=}
63 new_len=`printf "%s" "${new_len%%,*}"`
64
65 if [ $((${new_start} == ${NEW_WP_RANGE_START})) -ne 1 ]; then return ${EXIT_FAIL URE} ; fi
66 if [ $((${new_len} == ${NEW_WP_RANGE_LEN})) -ne 1 ]; then return ${EXIT_FAILURE} ; fi
67
68 # restore the old settings
69 ./flashrom ${FLASHROM_PARAM} --wp-range ${old_start} ${old_len} 2>/dev/null
70 if [ ${?} -ne ${EXIT_SUCCESS} ]; then
71 echo "failed to restore old settings" >> ${LOGFILE}
72 return ${EXIT_FAILURE}
73 fi
74
75 echo "$0: passed" >> ${LOGFILE}
76 return ${EXIT_SUCCESS}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698