summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2012-08-03 10:33:35 +0300
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2012-08-03 10:33:35 +0300
commitf90ca3d493d78fc270ce6cd9142aeea9ce43bc54 (patch)
treeed8b7b5c339ff4c9867c628925e2f0cf80eb4b3e
parenta79e8d32b9c2ee20da1258688948ff409d6fb46b (diff)
load_nandsim.sh: simplify the code
First find out what the kernel module parameters should be, then load it once, instead of doing it in each 'case' section. Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
-rwxr-xr-xload_nandsim.sh42
1 files changed, 27 insertions, 15 deletions
diff --git a/load_nandsim.sh b/load_nandsim.sh
index 4c3bb06..1bb31e1 100755
--- a/load_nandsim.sh
+++ b/load_nandsim.sh
@@ -80,39 +80,51 @@ if [ "$page_size" -eq 512 ] && [ "$eb_size" -ne "16" ]; then
fatal "only 16KiB eraseblocks are possible in case of 512 bytes page"
fi
+first=
+second=
+third=
+fourth=
+
if [ "$page_size" -eq "512" ]; then
+ first="0x20"
case "$size" in
- 16) modprobe nandsim first_id_byte=0x20 second_id_byte=0x33 ;;
- 32) modprobe nandsim first_id_byte=0x20 second_id_byte=0x35 ;;
- 64) modprobe nandsim first_id_byte=0x20 second_id_byte=0x36 ;;
- 128) modprobe nandsim first_id_byte=0x20 second_id_byte=0x78 ;;
- 256) modprobe nandsim first_id_byte=0x20 second_id_byte=0x71 ;;
+ 16) second=0x33 ;;
+ 32) second=0x35 ;;
+ 64) second=0x36 ;;
+ 128) second=0x78 ;;
+ 256) second=0x71 ;;
*) fatal "flash size ${size}MiB is not supported, try 16, 32, 64 or 256"
esac
elif [ "$page_size" -eq "2048" ]; then
case "$eb_size" in
- 64) fourh_bite="0x05" ;;
- 128) fourh_bite="0x15" ;;
- 256) fourh_bite="0x25" ;;
- 512) fourh_bite="0x35" ;;
+ 64) fourth="0x05" ;;
+ 128) fourth="0x15" ;;
+ 256) fourth="0x25" ;;
+ 512) fourth="0x35" ;;
*) fatal "eraseblock ${eb_size}KiB is not supported"
esac
+
case "$size" in
- 64) modprobe nandsim first_id_byte=0x20 second_id_byte=0xa2 third_id_byte=0x00 fourth_id_byte="$fourh_bite" ;;
- 128) modprobe nandsim first_id_byte=0xec second_id_byte=0xa1 third_id_byte=0x00 fourth_id_byte="$fourh_bite" ;;
- 256) modprobe nandsim first_id_byte=0x20 second_id_byte=0xaa third_id_byte=0x00 fourth_id_byte="$fourh_bite" ;;
- 512) modprobe nandsim first_id_byte=0x20 second_id_byte=0xac third_id_byte=0x00 fourth_id_byte="$fourh_bite" ;;
- 1024) modprobe nandsim first_id_byte=0xec second_id_byte=0xd3 third_id_byte=0x51 fourth_id_byte="$fourh_bite" ;;
+ 64) first="0x20"; second="0xa2"; third="0x00 ";;
+ 128) first="0xec"; second="0xa1"; third="0x00 ";;
+ 256) first="0x20"; second="0xaa"; third="0x00 ";;
+ 512) first="0x20"; second="0xac"; third="0x00 ";;
+ 1024) first="0xec"; second="0xd3"; third="0x51 ";;
*) fatal "unable to emulate ${size}MiB flash with ${eb_size}KiB eraseblock"
esac
else
fatal "bad NAND page size ${page_size}KiB, it has to be either 512 or 2048"
fi
+first="first_id_byte=$first"
+second="second_id_byte=$second"
+[ -z "$third" ] || third="third_id_byte=$third"
+[ -z "$fourth" ] || fourth="fourth_id_byte=$fourth"
+
+modprobe nandsim "$first" "$second" $third $fourth
if [ "$?" != "0" ]; then
fatal "Error: cannot load nandsim"
fi
echo "Loaded NAND simulator (${size}MiB, ${eb_size}KiB eraseblock, $page_size bytes NAND page)"
-exit 0