ddsect.sh: small cleanups
[ddsect.git] / ddsect.sh
index b1c5122..a11a1ec 100755 (executable)
--- a/ddsect.sh
+++ b/ddsect.sh
@@ -34,11 +34,11 @@ parse_map_file()
   do
     RANGE=$(echo $line | cut -d ':' -f 1)
     START_ADDRESS=$(( $(echo $RANGE | cut -d '-' -f 1) ))
-    END_ADDRESS=$(( $(echo $RANGE | cut -d '-' -f 2) ))
+    END_ADDRESS=$(( $(echo $RANGE | cut -d '-' -f 2) - 1))
 
     NAME=$(echo $line | cut -d ':' -f 2 | sed -e 's/^"//'  -e 's/"$//')
 
-    SIZE=$(($END_ADDRESS - $START_ADDRESS))
+    SIZE=$(($END_ADDRESS - $START_ADDRESS + 1))
 
     SIZE_KiB=$(($SIZE / 1024))
 
@@ -52,7 +52,7 @@ print_map_info()
 
   (
   echo "NAME START_ADDRESS END_ADDRESS SIZE SIZE_KiB"
-  parse_map_file $1
+  parse_map_file $MAP_FILE
   ) | column -s " ," -t
 }
 
@@ -67,7 +67,6 @@ split_image()
   do
     echo_exec dd ibs=1 skip=$START_ADDRESS count=$SIZE if="$IMAGE_FILE" of="${NAME}.bin"
   done
-
 }
 
 join_image()