diff options
Diffstat (limited to 'load_nandsim.sh')
-rwxr-xr-x | load_nandsim.sh | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/load_nandsim.sh b/load_nandsim.sh index 1df3813..4c3bb06 100755 --- a/load_nandsim.sh +++ b/load_nandsim.sh @@ -66,53 +66,53 @@ if [ "$#" -lt "1" ]; then exit 1 fi -SZ="$1" -EBSZ="$2" -PGSZ="$3" +size="$1" +eb_size="$2" +page_size="$3" if [ "$#" = "1" ]; then - EBSZ="16" - PGSZ="512" + eb_size="16" + page_size="512" elif [ "$#" = "2" ]; then - PGSZ="512" + page_size="512" fi -if [ "$PGSZ" -eq 512 ] && [ "$EBSZ" -ne "16" ]; then +if [ "$page_size" -eq 512 ] && [ "$eb_size" -ne "16" ]; then fatal "only 16KiB eraseblocks are possible in case of 512 bytes page" fi -if [ "$PGSZ" -eq "512" ]; then - case "$SZ" in +if [ "$page_size" -eq "512" ]; then + 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 ;; - *) fatal "flash size ${SZ}MiB is not supported, try 16, 32, 64 or 256" + *) fatal "flash size ${size}MiB is not supported, try 16, 32, 64 or 256" esac -elif [ "$PGSZ" -eq "2048" ]; then - case "$EBSZ" in - 64) FOURTH="0x05" ;; - 128) FOURTH="0x15" ;; - 256) FOURTH="0x25" ;; - 512) FOURTH="0x35" ;; - *) fatal "eraseblock ${EBSZ}KiB is not supported" +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" ;; + *) fatal "eraseblock ${eb_size}KiB is not supported" esac - case "$SZ" in - 64) modprobe nandsim first_id_byte=0x20 second_id_byte=0xa2 third_id_byte=0x00 fourth_id_byte="$FOURTH" ;; - 128) modprobe nandsim first_id_byte=0xec second_id_byte=0xa1 third_id_byte=0x00 fourth_id_byte="$FOURTH" ;; - 256) modprobe nandsim first_id_byte=0x20 second_id_byte=0xaa third_id_byte=0x00 fourth_id_byte="$FOURTH" ;; - 512) modprobe nandsim first_id_byte=0x20 second_id_byte=0xac third_id_byte=0x00 fourth_id_byte="$FOURTH" ;; - 1024) modprobe nandsim first_id_byte=0xec second_id_byte=0xd3 third_id_byte=0x51 fourth_id_byte="$FOURTH" ;; - *) fatal "unable to emulate ${SZ}MiB flash with ${EBSZ}KiB eraseblock" + 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" ;; + *) fatal "unable to emulate ${size}MiB flash with ${eb_size}KiB eraseblock" esac else - fatal "bad NAND page size ${PGSZ}KiB, it has to be either 512 or 2048" + fatal "bad NAND page size ${page_size}KiB, it has to be either 512 or 2048" fi if [ "$?" != "0" ]; then fatal "Error: cannot load nandsim" fi -echo "Loaded NAND simulator (${SZ}MiB, ${EBSZ}KiB eraseblock, $PGSZ bytes NAND page)" +echo "Loaded NAND simulator (${size}MiB, ${eb_size}KiB eraseblock, $page_size bytes NAND page)" exit 0 |