Change tool "fmap_decode" to "mosys"

The fmap_decode tool from flashmap project is deprecated.
mosys provides more functionality and fit better into the
host environment.

BUG=chromium-os:6264
TEST=manually

Change-Id: I513d36c8a8f657fdb4cb10d08a867876c32d36b6

Review URL: http://codereview.chromium.org/3388002
diff --git a/scripts/image_signing/resign_firmwarefd.sh b/scripts/image_signing/resign_firmwarefd.sh
index d3f306b..ad2d4d9 100755
--- a/scripts/image_signing/resign_firmwarefd.sh
+++ b/scripts/image_signing/resign_firmwarefd.sh
@@ -14,10 +14,10 @@
 # firmware_datakey: Key used to sign firmware data (in .vbprivk format)
 # firmware_keyblock: Key block for firmware data key (in .keyblock format)
 #
-# Both the fmap_decode tool and vbutil_firmware should be in the system path.
+# Both the mosys tool and vbutil_firmware should be in the system path.
 #
-# This script parses the output of fmap_decode tool from the Flashmap project
-# http://code.google.com/p/flashmap
+# This script parses the output of mosys tool from
+# http://code.google.com/p/mosys
 #
 # to determine the regions in the image containing "Firmware [A|B] Data" and
 # "Firmware [A|B] Key", which contain firmware data and firmware vblocks
@@ -25,7 +25,7 @@
 # passed as arguments and output a new firmware image, with this new firmware
 # vblocks the old ones.
 #
-# Here is an example output of fmap_decode:
+# Here is an example output of mosys:
 #
 # area_offset="0x001c0000" area_size="0x00040000" area_name="Boot Stub" \
 #   area_flags_raw="0x01" area_flags="static"
@@ -61,7 +61,7 @@
 fi
 
 # Make sure the tools we need are available.
-for prog in fmap_decode vbutil_firmware; do
+for prog in mosys vbutil_firmware; do
   type -P "${prog}" &>/dev/null || \
     { echo "${prog} tool not found."; exit 1; }
 done
@@ -80,7 +80,7 @@
 for i in "A" "B"
 do
   match_str="$i Key"
-  line=$(fmap_decode $1 | grep "$match_str")
+  line=$(mosys -f -k eeprom map $1 | grep "$match_str")
   offset="$(echo $line | sed -e 's/.*area_offset=\"\([a-f0-9x]*\)\".*/\1/')"
   eval let \
     fw${i}_vblock_offset="$offset"
@@ -89,7 +89,7 @@
     fw${i}_vblock_size="$size"
 
   match_str="$i Data"
-  line=$(fmap_decode $1 | grep "$match_str")
+  line=$(mosys -f -k eeprom map $1 | grep "$match_str")
   offset="$(echo $line | sed -e 's/.*area_offset=\"\([a-f0-9x]*\)\".*/\1/')"
   eval let \
     fw${i}_offset="$offset"
diff --git a/scripts/image_signing/unpack_firmwarefd.sh b/scripts/image_signing/unpack_firmwarefd.sh
index f16f6b4..bf8df6a 100755
--- a/scripts/image_signing/unpack_firmwarefd.sh
+++ b/scripts/image_signing/unpack_firmwarefd.sh
@@ -7,7 +7,7 @@
 # Script that unpacks a firmware image (in .fd format) into its component
 # pieces. Only outputs firmware A and B data, vblocks and the GBB.
 
-# The fmap_decode tool must be in the system path.
+# The mosys tool must be in the system path.
 
 # Abort on error
 set -e
@@ -20,14 +20,14 @@
 fi
 
 # Make sure the tools we need are available.
-type -P fmap_decode &>/dev/null || \
-  { echo "fmap_decode tool not found."; exit 1; }
+type -P mosys &>/dev/null || \
+  { echo "mosys tool not found."; exit 1; }
 
 src_fd=$1
 
 # Grab GBB Area offset and size
 match_str="GBB Area"
-line=$(fmap_decode $1 | grep "$match_str")
+line=$(mosys -f -k eeprom map $1 | grep "$match_str")
 offset="$(echo $line | sed -e 's/.*area_offset=\"\([a-f0-9x]*\)\".*/\1/')"
 let gbb_offset="$offset"
 size="$(echo $line | sed -e 's/.*area_size=\"\([a-f0-9x]*\)\".*/\1/')"
@@ -37,7 +37,7 @@
 for i in "A" "B"
 do
   match_str="$i Key"
-  line=$(fmap_decode $1 | grep "$match_str")
+  line=$(mosys -f -k eeprom map $1 | grep "$match_str")
   offset="$(echo $line | sed -e 's/.*area_offset=\"\([a-f0-9x]*\)\".*/\1/')"
   eval let \
     fw${i}_vblock_offset="$offset"
@@ -46,7 +46,7 @@
     fw${i}_vblock_size="$size"
 
   match_str="$i Data"
-  line=$(fmap_decode $1 | grep "$match_str")
+  line=$(mosys -f -k eeprom map $1 | grep "$match_str")
   offset="$(echo $line | sed -e 's/.*area_offset=\"\([a-f0-9x]*\)\".*/\1/')"
   eval let \
     fw${i}_offset="$offset"