Discussion:
[Gumstix-users] Unable to format bootable SD card on modern system
gab_ngek
2017-03-05 23:48:48 UTC
Permalink
I last used Gumstix a couple years ago and just started a new project but
none of the existing procedures for creating the funky SD Card partitioning
work any more! I am using a Linux Mint 18.1 system.

The "mk2partsd" script bombs because "sfdisk" no longer supports the "-D"
option.
The "python-gumutils" will not install because it uses much older python
packages.

How can I create a bootable SD Card?



--
View this message in context: http://gumstix.8.x6.nabble.com/Unable-to-format-bootable-SD-card-on-modern-system-tp4971261.html
Sent from the Gumstix mailing list archive at Nabble.com.
Scott Ellis
2017-03-06 08:59:09 UTC
Permalink
I made this change to my own partitioning script about a year ago.

+# new versions of sfdisk don't use rotating disk params
+sfdisk_ver=`sfdisk --version | awk '{ print $4 }'`

-echo CYLINDERS – $CYLINDERS
+if [ $(ver $sfdisk_ver) -lt $(ver 2.26.2) ]; then
+ CYLINDERS=`echo $SIZE/255/63/512 | bc`
+ echo "CYLINDERS – $CYLINDERS"
+ SFDISK_CMD="sfdisk --force -D -uS -H255 -S63 -C ${CYLINDERS}"
+else
+ SFDISK_CMD="sfdisk"
+fi

echo -e "\nOkay, here we go ...\n"

@@ -57,7 +68,7 @@ echo -e "\n=== Creating 2 partitions ===\n"
{
echo 128,130944,0x0C,*
echo 131072,,,-
-} | sfdisk --force -D -uS -H 255 -S 63 -C $CYLINDERS $DRIVE
+} | $SFDISK_CMD $DRIVE


Basically get rid of the spinning disk params to sfdisk.

You can probably do something similar to the Gumstix script.


Curious, why do you think the card partitioning is 'funky'?

There is a FAT bootloader partition and a EXT rootfs partition.

Most embedded boards use this same type of partitioning.

The only alternative I've seen is skipping the FAT partition and
putting the bootloader at some magic offset in the the unpartitioned
start of the flash/eMMC/card.

The FAT partition scheme is usually easier to work with.

No idea about the python gumutils stuff.

Regards,
Scott
Post by gab_ngek
I last used Gumstix a couple years ago and just started a new project but
none of the existing procedures for creating the funky SD Card partitioning
work any more! I am using a Linux Mint 18.1 system.
The "mk2partsd" script bombs because "sfdisk" no longer supports the "-D"
option.
The "python-gumutils" will not install because it uses much older python
packages.
How can I create a bootable SD Card?
--
http://gumstix.8.x6.nabble.com/Unable-to-format-bootable-SD-card-on-modern-system-tp4971261.html
Sent from the Gumstix mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
gumstix-users mailing list
https://lists.sourceforge.net/lists/listinfo/gumstix-users
gab_ngek
2017-03-07 17:04:19 UTC
Permalink
I made those changes to the meta-gumstix-extras/scripts/mk2partsd script and
it executes. I will check that it works shortly.

The reason I called it a "funky" format is that it requires such a crazy set
of steps instead of just a simple gparted standard partitioning approach.
If it was as simple as declaring a FAT partition and an EXT partition,
that's pretty straightforward.

New mk2partsd:
/
#! /bin/sh
#
# (c) Copyright 2014 Gumstix, Inc.
# Licensed under terms of GPLv2
#
# Based on mk2PartSDCard.sh from Texas Instrument
# http://processors.wiki.ti.com/index.php/How_to_Make_3_Partition_SD_Card
#
# example usage: $ sudo mk2partsd /dev/sdb


DRIVE=$1

dd if=/dev/zero of=$DRIVE bs=1024 count=1024

SIZE=`fdisk -l $DRIVE | grep Disk | awk '{print $5}'`

echo DISK SIZE - $SIZE bytes

# new versions of sfdisk don't use rotating disk params
sfdisk_ver=`sfdisk --version | awk '{ print $4 }'`

if [ $sfdisk_ver -lt '2.26.2' ]; then
CYLINDERS=`echo $SIZE/255/63/512 | bc`
echo "CYLINDERS – $CYLINDERS"
SFDISK_CMD="sfdisk --force -D -uS -H255 -S63 -C ${CYLINDERS}"
else
SFDISK_CMD="sfdisk"
fi

#sfdisk --force -D -uS -H 255 -S 63 -C $CYLINDERS $DRIVE << EOF
#128,130944,0x0C,*
#131072,,,-
#EOF

echo -e "\n=== Creating 2 partitions ===\n"
{
echo 128,130944,0x0C,*
echo 131072,,,-
} | $SFDISK_CMD $DRIVE

if [ -b ${1}1 ]; then
mkfs.vfat -F 32 -n "boot" ${DRIVE}1
else
mkfs.vfat -F 32 -n "boot" ${DRIVE}p1
fi

if [ -b ${1}2 ]; then
mkfs.ext4 -L "rootfs" ${DRIVE}2
else
mkfs.ext4 -L "rootfs" ${DRIVE}p2
fi
/



--
View this message in context: http://gumstix.8.x6.nabble.com/Unable-to-format-bootable-SD-card-on-modern-system-tp4971261p4971269.html
Sent from the Gumstix mailing list archive at Nabble.com.
Scott Ellis
2017-03-07 18:11:30 UTC
Permalink
You can use whatever partitioning tool you want.

It really is that simple. A bootable FAT partition big enough for the
bootloader files and the rest of the card partitioned as EXT.

The Gumstix SOC doesn't care what tool you use.
Post by gab_ngek
I made those changes to the meta-gumstix-extras/scripts/mk2partsd script and
it executes. I will check that it works shortly.
The reason I called it a "funky" format is that it requires such a crazy set
of steps instead of just a simple gparted standard partitioning approach.
If it was as simple as declaring a FAT partition and an EXT partition,
that's pretty straightforward.
/
#! /bin/sh
#
# (c) Copyright 2014 Gumstix, Inc.
# Licensed under terms of GPLv2
#
# Based on mk2PartSDCard.sh from Texas Instrument
# http://processors.wiki.ti.com/index.php/How_to_Make_3_Partition_SD_Card
#
# example usage: $ sudo mk2partsd /dev/sdb
DRIVE=$1
dd if=/dev/zero of=$DRIVE bs=1024 count=1024
SIZE=`fdisk -l $DRIVE | grep Disk | awk '{print $5}'`
echo DISK SIZE - $SIZE bytes
# new versions of sfdisk don't use rotating disk params
sfdisk_ver=`sfdisk --version | awk '{ print $4 }'`
if [ $sfdisk_ver -lt '2.26.2' ]; then
CYLINDERS=`echo $SIZE/255/63/512 | bc`
echo "CYLINDERS – $CYLINDERS"
SFDISK_CMD="sfdisk --force -D -uS -H255 -S63 -C ${CYLINDERS}"
else
SFDISK_CMD="sfdisk"
fi
#sfdisk --force -D -uS -H 255 -S 63 -C $CYLINDERS $DRIVE << EOF
#128,130944,0x0C,*
#131072,,,-
#EOF
echo -e "\n=== Creating 2 partitions ===\n"
{
echo 128,130944,0x0C,*
echo 131072,,,-
} | $SFDISK_CMD $DRIVE
if [ -b ${1}1 ]; then
mkfs.vfat -F 32 -n "boot" ${DRIVE}1
else
mkfs.vfat -F 32 -n "boot" ${DRIVE}p1
fi
if [ -b ${1}2 ]; then
mkfs.ext4 -L "rootfs" ${DRIVE}2
else
mkfs.ext4 -L "rootfs" ${DRIVE}p2
fi
/
--
http://gumstix.8.x6.nabble.com/Unable-to-format-bootable-SD-card-on-modern-system-tp4971261p4971269.html
Sent from the Gumstix mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Announcing the Oxford Dictionaries API! The API offers world-renowned
dictionary content that is easy and intuitive to access. Sign up for an
account today to start using our lexical data to power your apps and
projects. Get started today and enter our developer competition.
http://sdm.link/oxford
_______________________________________________
gumstix-users mailing list
https://lists.sourceforge.net/lists/listinfo/gumstix-users
Loading...