blob: e9eb9e6167d142f432973ed94ca64bec9ce24665 [file] [log] [blame]
Gunnar Millse8221902017-02-03 15:59:06 -06001#!/bin/sh
2
3help=$'Generate SquashFS image Script
4
5Generates a SquashFS image from the PNOR image
6
7usage: generate-squashfs [OPTION]
8
9Options:
Gunnar Mills37751f92017-02-07 21:05:01 -060010 -f, --file <file> Specify destination file. Defaults to
11 `pwd`/pnor.xz.squashfs if unspecified.
Gunnar Millse8221902017-02-03 15:59:06 -060012 -h, --help Display this help text and exit.
13'
14
Gunnar Mills18f7cdb2017-02-07 16:44:19 -060015declare -a partitions=(
16"HBB"
17"HBEL"
18"GUARD"
19"HBD"
20"DJVPD"
21"MVPD"
22"CVPD"
23"HBI"
24"SBE"
25"HCODE"
26"HBRT"
27"PAYLOAD"
28"TEST"
29"TESTRO"
30"HBBL"
31"GLOBAL"
32"RINGOVD"
33"SBKT"
34"OCC"
35)
36
Gunnar Mills37751f92017-02-07 21:05:01 -060037outfile=`pwd`"/pnor.xz.squashfs"
38
Gunnar Millse8221902017-02-03 15:59:06 -060039while [[ $# -gt 0 ]]; do
40 key="$1"
41 case $key in
Gunnar Mills37751f92017-02-07 21:05:01 -060042 -f|--file)
43 outfile="$2"
44 shift 2
45 ;;
Gunnar Millse8221902017-02-03 15:59:06 -060046 -h|--help)
47 echo "$help"
48 exit
49 ;;
50 *)
51 echo "Unknown option $1. Display available options with -h or --help"
52 exit
53 ;;
54 esac
55done
Gunnar Mills18f7cdb2017-02-07 16:44:19 -060056
Gunnar Mills37751f92017-02-07 21:05:01 -060057scratch_dir=`mktemp -d` || exit 1
58
Gunnar Mills18f7cdb2017-02-07 16:44:19 -060059for partition in "${partitions[@]}"; do
60 echo "Reading ${partition}..."
Gunnar Mills37751f92017-02-07 21:05:01 -060061 pflash_cmd="pflash --partition=${partition} --read=${scratch_dir}/${partition}"
Gunnar Mills18f7cdb2017-02-07 16:44:19 -060062 ${pflash_cmd} || exit 1
63done
Gunnar Mills37751f92017-02-07 21:05:01 -060064
65echo "Creating SquashFS image..."
66
67cd "${scratch_dir}"
68squashfs_cmd="mksquashfs ${partitions[*]} ${outfile}"
69${squashfs_cmd} || exit 1
70
71echo "SquashFS Image at ${outfile}"
72rm -r "${scratch_dir}"