Unable to format bootable SD card on modern system

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Unable to format bootable SD card on modern system

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?
Reply | Threaded
Open this post in threaded view
|

Re: Unable to format bootable SD card on modern system

Scott Ellis
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

"gab_ngek" <[hidden email]> said:

> 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.
>
> ------------------------------------------------------------------------------
> 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
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gumstix-users
>



------------------------------------------------------------------------------
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gumstix-users
Reply | Threaded
Open this post in threaded view
|

Re: Unable to format bootable SD card on modern system

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.

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
Reply | Threaded
Open this post in threaded view
|

Re: Unable to format bootable SD card on modern system

Scott Ellis
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.

"gab_ngek" <[hidden email]> said:

> 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.
>
> ------------------------------------------------------------------------------
> 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
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gumstix-users
>



------------------------------------------------------------------------------
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gumstix-users
Reply | Threaded
Open this post in threaded view
|

Re: Unable to format bootable SD card on modern system

gab_ngek
I was able to format the SD card with gparted and have the IronSTORM-P COM boot properly but the older FireSTORM was not able to read that card.  Do the older COMs require a different configuration or do I need to load newer firmware onto the FireSTORM COM?
Reply | Threaded
Open this post in threaded view
|

Re: Unable to format bootable SD card on modern system

Keith Lee
FWIW, I use the following version of the script when partitioning my SD cards:

https://github.com/GumstixExperimental/GuruTools/blob/master/new_mk2partsd/mk2partsd

It's short and sweet and does the job.  I modified the original when I upgraded to Ubuntu 16.4 and it stopped working.

Assuming you format your SD card as per the instructions or using my script, and upload a working disk image, the FireSTORM should have no problem.  You may have to clear the flash memory from U-Boot as in gstix.org's instructions:

# nand erase 240000 20000
# reset