Skip to contentSkip to conversation

create-sdcard: Fix rootfs tarball search and selection

PATCH Superseded Priya N S 2 participants 6 messages Jun 7, 2021 – Jun 22, 2021

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Priya N S

author
#0 lore raw

cover create-sdcard: Fix rootfs tarball search and selection

From: Priya N S <[email protected]>

Hi All,
Below are the patches to fix the issues observed in the create-sdcard script.

Issue:
1. The create-sdcard script uses 'rootfs' as a regex keyword to find and list the filesystem tarballs which are available in the SDK package. As in the current SDK packages, the tarball names are in the following format,
tisdk-<IMAGE_TYPE>-image-<MACHINE>.tar.xz
Which doesn't have the rootfs keyword. This fails to list the tarballs available in the package and crashes the script execution.
2. The create-sdcard script detects a partitioned SD card as not partitioned because of the failure of the size check condition in the script.

Fix:
1. The 'image' is used as the regex keyword to match the tarball names in the SDK packages.
2. The usage of the cylinder size unit for partitioning the SD card is removed since the cylinder size is SD card manufacturer dependent. The parted command is replaced with fdisk since fdisk is an available installed utility.

Priya N S (3):
create-sdcard.sh: fix regex used for rootfs tarball
create-sdcard: Fix wrong rootfs tarball selection create-sdcard.sh: Stop using cylinder as unit for partition size

 create-sdcard.sh | 75 +++++++++++++++++++++++++++++++++++++-----------
 1 file changed, 58 insertions(+), 17 deletions(-)
Signature · 1 line
2.19.1.windows.1
author
#1 lore raw

PATCH 1/3 create-sdcard.sh: fix regex used for rootfs tarball

From: Priya N S <[email protected]>

From: Priya N S <[email protected]>

Filesystem tarballs present in SDK are in the format tisdk-<IMAGE_TYPE>-image-<MACHINE>.tar.xz. This is different from earlier format where 'rootfs' was present in all the filesystem tarball names. Update regex used for filesystem tarball search to use "image" as the keyword.

---
 create-sdcard.sh | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
create-sdcard.sh +4 -5
index 736cd42..264095a 100644
@@ -752,10 +752,9 @@ if [ $FILEPATHOPTION -eq 1 ] ; then
 	BOOTUENV=`ls $BOOTFILEPATH | grep uEnv.txt | awk {'print $1'}`
 	#rootfs
 	ROOTFILEPARTH="$PARSEPATH/filesystem"
-	#ROOTFSTAR=`ls  $ROOTFILEPARTH | grep tisdk.*rootfs | awk {'print $1'}`
 
 	#Make sure there is only 1 tar
-	CHECKNUMOFTAR=`ls $ROOTFILEPARTH | grep "tisdk.*rootfs" | grep 'tar.xz' | grep -n '' | grep '2:' | awk {'print $1'}`
+	CHECKNUMOFTAR=`ls $ROOTFILEPARTH | grep "tisdk.*image" | grep 'tar.xz' | grep -n '' | grep '2:' | awk {'print $1'}`
 	if [ -n "$CHECKNUMOFTAR" ]
 	then
 cat << EOM
@@ -767,15 +766,15 @@ cat << EOM
 ################################################################################
 
 EOM
-		ls --sort=size $ROOTFILEPARTH | grep "tisdk.*rootfs" | grep 'tar.xz' | grep -n '' | awk {'print "	" , $1'}
+		ls --sort=size $ROOTFILEPARTH | grep "tisdk.*image" | grep 'tar.xz' | grep -n '' | awk {'print "	" , $1'}
 		echo ""
 		read -p "Enter Number of rootfs Tarball: " TARNUMBER
 		echo " "
-		FOUNDTARFILENAME=`ls --sort=size $ROOTFILEPARTH | grep "rootfs" | grep 'tar.xz' | grep -n '' | grep "${TARNUMBER}:" | cut -c3- | awk {'print$1'}`
+		FOUNDTARFILENAME=`ls --sort=size $ROOTFILEPARTH | grep "image" | grep 'tar.xz' | grep -n '' | grep "${TARNUMBER}:" | cut -c3- | awk {'print$1'}`
 		ROOTFSTAR=$FOUNDTARFILENAME
 
 	else
-		ROOTFSTAR=`ls  $ROOTFILEPARTH | grep "tisdk.*rootfs" | grep 'tar.xz' | awk {'print $1'}`
+		ROOTFSTAR=`ls  $ROOTFILEPARTH | grep "tisdk.*image" | grep 'tar.xz' | awk {'print $1'}`
 	fi
 
 	ROOTFSUSERFILEPATH=$ROOTFILEPARTH/$ROOTFSTAR
Signature · 1 line
2.19.1.windows.1
author
#2 lore raw

PATCH 2/3 create-sdcard: Fix wrong rootfs tarball selection

In reply to Priya N S

From: Priya N S <[email protected]>

From: Priya N S <[email protected]>

* Validate user input of rootfs tarball selection.
* This will not allow the user to proceed with wrong rootfs tarball selection.

---
 create-sdcard.sh | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)
create-sdcard.sh +13 -3
index 264095a..8f99687 100644
@@ -767,9 +767,19 @@ cat << EOM
 
 EOM
 		ls --sort=size $ROOTFILEPARTH | grep "tisdk.*image" | grep 'tar.xz' | grep -n '' | awk {'print "	" , $1'}
-		echo ""
-		read -p "Enter Number of rootfs Tarball: " TARNUMBER
-		echo " "
+		COUNT=`ls $ROOTFILEPARTH | grep "tisdk.*image" | grep 'tar.xz' | grep -n '' | awk {'print $1'} | wc -l`
+		ENTERCORRECTLY="0"
+		while [ $ENTERCORRECTLY -ne 1 ]
+		do
+			read -p "Enter Number of rootfs Tarball: " TARNUMBER
+			echo " "
+			if [ -z "${TARNUMBER//[0-$COUNT]}" ] && [ -n "$TARNUMBER" ] ; then
+				ENTERCORRECTLY=1
+			else
+				echo "Invalid selection!"
+			fi
+			echo ""
+		done
 		FOUNDTARFILENAME=`ls --sort=size $ROOTFILEPARTH | grep "image" | grep 'tar.xz' | grep -n '' | grep "${TARNUMBER}:" | cut -c3- | awk {'print$1'}`
 		ROOTFSTAR=$FOUNDTARFILENAME
 
Signature · 1 line
2.19.1.windows.1
author
#3 lore raw

PATCH 3/3 create-sdcard.sh: Stop using cylinder as unit for partition size

In reply to Priya N S

From: Priya N S <[email protected]>

From: Priya N S <[email protected]>

* Cylinder size of sdcard is manufacturer dependent. To standardize sdcard partitioning remove the use of cylinder (cyl) unit.
* While at it shift to using fdisk for the partitioning the sdcard. fdisk is already used in the script and this reduces the dependencies of this script on available installed applications.
* This fixes cases where already partitioned cards were being detected as not partitioned because of size check elsewhere in the script failing.

---
 create-sdcard.sh | 50 +++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 41 insertions(+), 9 deletions(-)
create-sdcard.sh +41 -9
index 8f99687..1114f70 100644
@@ -501,11 +501,29 @@ SIZE=`fdisk -l $DRIVE | grep Disk | awk '{print $5}'`
 
 echo DISK SIZE - $SIZE bytes
 
-parted -s $DRIVE mklabel msdos
-parted -s $DRIVE unit cyl mkpart primary fat32 -- 0 9
-parted -s $DRIVE set 1 boot on
-parted -s $DRIVE unit cyl mkpart primary ext2 -- 9 310
-parted -s $DRIVE unit cyl mkpart primary ext2 -- 310 -2
+cat << END | fdisk $DRIVE
+n
+p
+1
+
++75M
+n
+p
+2
+
++2.4G
+n
+p
+3
+
+
+t
+1
+c
+a
+1
+w
+END
 
 
 cat << EOM
@@ -559,10 +577,24 @@ SIZE=`fdisk -l $DRIVE | grep Disk | awk '{print $5}'`
 
 echo DISK SIZE - $SIZE bytes
 
-parted -s $DRIVE mklabel msdos
-parted -s $DRIVE unit cyl mkpart primary fat32 -- 0 9
-parted -s $DRIVE set 1 boot on
-parted -s $DRIVE unit cyl mkpart primary ext2 -- 9 -2
+cat << END | fdisk $DRIVE
+n
+p
+1
+
++75M
+n
+p
+2
+
+
+t
+1
+c
+a
+1
+w
+END
 
 cat << EOM
 
Signature · 1 line
2.19.1.windows.1
#4 lore raw
In reply to Priya N S
Quoted 5 lines · Priya N S

From: Priya N S <[email protected]>

Hi All,
Below are the patches to fix the issues observed in the create-sdcard script.

a) Do these apply to meta-arago?
b) why not use the wic and bmap files instead?

Quoted 36 lines

Issue:
1. The create-sdcard script uses 'rootfs' as a regex keyword to find and list the filesystem tarballs which are available in the SDK package. As in the current SDK packages, the tarball names are in the following format,
tisdk-<IMAGE_TYPE>-image-<MACHINE>.tar.xz
Which doesn't have the rootfs keyword. This fails to list the tarballs available in the package and crashes the script execution.
2. The create-sdcard script detects a partitioned SD card as not partitioned because of the failure of the size check condition in the script.

Fix:
1. The 'image' is used as the regex keyword to match the tarball names in the SDK packages.
2. The usage of the cylinder size unit for partitioning the SD card is removed since the cylinder size is SD card manufacturer dependent. The parted command is replaced with fdisk since fdisk is an available installed utility.

Priya N S (3):
create-sdcard.sh: fix regex used for rootfs tarball
create-sdcard: Fix wrong rootfs tarball selection create-sdcard.sh: Stop using cylinder as unit for partition size

 create-sdcard.sh | 75 +++++++++++++++++++++++++++++++++++++-----------
 1 file changed, 58 insertions(+), 17 deletions(-)
Signature · 6 lines
2.19.1.windows.1

_______________________________________________
meta-arago mailing list
[email protected]
http://arago-project.org/cgi-bin/mailman/listinfo/meta-arago
Signature · 3 lines
Regards,
Nishanth Menon
Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3  1A34 DDB5 849D 1736 249D
#5 lore raw
Quoted 9 lines · Nishanth Menon
Quoted 5 lines · Priya N S

From: Priya N S <[email protected]>

Hi All,
Below are the patches to fix the issues observed in the create-sdcard script.

a) Do these apply to meta-arago?

These patches need to be applied to the tisdk-setup-scripts repo. I will update the subject line of the patches with the repo name in V2.

Quoted 1 line

b) why not use the wic and bmap files instead?

SD create scripts are supported in the SDK 7.03 release. Need to align if we need to remove the support for SD create scripts and migrate to wic files completely in the future release.

Quoted 42 lines
Quoted 30 lines

Issue:
1. The create-sdcard script uses 'rootfs' as a regex keyword to find and list the filesystem tarballs which are available in the SDK package. As in the current SDK packages, the tarball names are in the following format,
tisdk-<IMAGE_TYPE>-image-<MACHINE>.tar.xz
Which doesn't have the rootfs keyword. This fails to list the tarballs available in the package and crashes the script execution.
2. The create-sdcard script detects a partitioned SD card as not partitioned because of the failure of the size check condition in the script.

Fix:
1. The 'image' is used as the regex keyword to match the tarball names in the SDK packages.
2. The usage of the cylinder size unit for partitioning the SD card is removed since the cylinder size is SD card manufacturer dependent. The parted command is replaced with fdisk since fdisk is an available installed utility.

Priya N S (3):
create-sdcard.sh: fix regex used for rootfs tarball
create-sdcard: Fix wrong rootfs tarball selection create-sdcard.sh: Stop using cylinder as unit for partition size

 create-sdcard.sh | 75 +++++++++++++++++++++++++++++++++++++-----------
 1 file changed, 58 insertions(+), 17 deletions(-)
Quoted 7 lines

--
2.19.1.windows.1

_______________________________________________
meta-arago mailing list
[email protected]
http://arago-project.org/cgi-bin/mailman/listinfo/meta-arago

--
Regards,
Nishanth Menon
Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3 1A34 DDB5 849D 1736 249D