Hello!
I tried to use create-sdcard script to configure sdcard and faced with one problem. Script can't create partitions because it cannot correctly recognize sdcard size.
When next rows in script are executed, SIZE can't be calculate.
EOM
dd if=/dev/zero of=$DRIVE bs=1024 count=1024
SIZE=`fdisk -l $DRIVE | grep Disk | awk '{print $5}'`
echo DISK SIZE - $SIZE bytes
CYLINDERS=`echo $SIZE/255/63/512 | bc`
sfdisk -D -H 255 -S 63 -C $CYLINDERS $DRIVE << EOF
,9,0x0C,*
10,90,,-
100,,,-
EOF
sudo fdisk -l /dev/sdv | grep Disk | awk '{print $5}' befor calling script returens 2001731584 (size of SD card - as expected)
BUT WHEN I RUN SCRIPT AND AFTER IT sudo fdisk -l /dev/sdv | grep Disk | awk '{print $5}' returns:
Disk /dev/sdb doesn't contain a valid partition table
2001731584
And it cause that SIZE can't be calculated.
When I set SIZE in script manually all work well:
SIZE=2001731584 #`fdisk -l $DRIVE | grep Disk | awk '{print $5}'`
Can anyone explain to me why this is happening?
Thanks!
Log before changing (bad): sudo ./create-sdcard.sh
################################################################################
This script will create a bootable SD card from custom or pre-built binaries.
The script must be run with root permissions and from the bin directory of
the SDK
Example:
$ sudo ./create-sdcard.sh
Formatting can be skipped if the SD card is already formatted and
partitioned properly.
################################################################################
Availible Drives to write images to:
# major minor size name
1: 8 16 1954816 sdb
Enter Device Number: 1
sdb was selected
Checking the device is unmounted
sdb1 sdb2 sdb3
SD Card is not correctly partitioned
################################################################################
Select 2 partitions if only need boot and rootfs (most users)
Select 3 partitions if need SDK & CCS on SD card. This is usually used
by device manufacturers with access to partition tarballs.
****WARNING**** continuing will erase all data on sdb
################################################################################
Number of partitions needed [2/3] : 2
Now partitioning sdb with 2 partitions...
################################################################################
Now making 2 partitions
################################################################################
1024+0 records in
1024+0 records out
1048576 bytes (1.0 MB) copied, 1.0792 s, 972 kB/s
Disk /dev/sdb doesn't contain a valid partition table
./create-sdcard.sh: line 515: 2001731584: command not found
DISK SIZE - bytes
(standard_in) 1: syntax error
Usage:
sfdisk [options] <device> [...]
Options:
-s, --show-size list size of a partition
-c, --id change or print partition Id
--change-id change Id
--print-id print Id
-l, --list list partitions of each device
-d, --dump idem, but in a format suitable for later input
-i, --increment number cylinders etc. from 1 instead of from 0
-u, --unit <letter> units to be used; <letter> can be one of
S (sectors), C (cylinders), B (blocks), or M (MB)
-1, --one-only reserved option that does nothing currently
-T, --list-types list the known partition types
-D, --DOS for DOS-compatibility: waste a little space
-E, --DOS-extended DOS extended partition compatibility
-R, --re-read make the kernel reread the partition table
-N <number> change only the partition with this <number>
-n do not actually write to disk
-O <file> save the sectors that will be overwritten to <file>
-I <file> restore sectors from <file>
-V, --verify check that the listed partitions are reasonable
-v, --version display version information and exit
-h, --help display this help text and exit
Dangerous options:
-f, --force disable all consistency checking
--no-reread do not check whether the partition is in use
-q, --quiet suppress warning messages
-L, --Linux do not complain about things irrelevant for Linux
-g, --show-geometry print the kernel's idea of the geometry
-G, --show-pt-geometry print geometry guessed from the partition table
-A, --activate[=<device>] activate bootable flag
-U, --unhide[=<dev>] set partition unhidden
-x, --show-extended also list extended partitions in the output,
or expect descriptors for them in the input
--leave-last do not allocate the last cylinder
--IBM same as --leave-last
--in-order partitions are in order
--not-in-order partitions are not in order
--inside-outer all logicals inside outermost extended
--not-inside-outer not all logicals inside outermost extended
--nested every partition is disjoint from all others
--chained like nested, but extended partitions may lie outside
--onesector partitions are mutually disjoint
Override the detected geometry using:
-C, --cylinders <number> set the number of cylinders to use
-H, --heads <number> set the number of heads to use
-S, --sectors <number> set the number of sectors to use
################################################################################
Partitioning Boot
################################################################################
mkfs.vfat 3.0.13 (30 Jun 2012)
/dev/sdb1: No such file or directory
################################################################################
Partitioning rootfs
################################################################################
mke2fs 1.42.5 (29-Jul-2012)
Could not stat /dev/sdb2 --- No such file or directory
The device apparently does not exist; did you specify it correctly?
################################################################################
Partitioning is now done
Continue to install filesystem or select 'n' to safe exit
**Warning** Continuing will erase files any files in the partitions
################################################################################
Would you like to continue? [y/n] : y
Mount the partitions
mount: special device /dev/sdb1 does not exist
mount: special device /dev/sdb2 does not exist
Emptying partitions
Syncing....
################################################################################
Choose file path to install from
1 ) Install pre-built images from SDK
2 ) Enter in custom boot and rootfs file paths
################################################################################
Choose now [1/2] : 1
Will now install from SDK pre-built images
now installing: ti-sdk-am335x-evm-05.07.00.00
################################################################################
Copying files now... will take minutes
################################################################################
Copying boot partition
MLO copied
u-boot.bin copied
u-boot.img copied
uImage copied
Copying rootfs System partition
Written 100%
Syncing...
Un-mount the partitions
umount2: Invalid argument
umount: boot: not mounted
umount2: Invalid argument
umount: rootfs: not mounted
Remove created temp directories
Operation Finished
Log after changing (good): sudo ./create-sdcard.sh
################################################################################
This script will create a bootable SD card from custom or pre-built binaries.
The script must be run with root permissions and from the bin directory of
the SDK
Example:
$ sudo ./create-sdcard.sh
Formatting can be skipped if the SD card is already formatted and
partitioned properly.
################################################################################
Availible Drives to write images to:
# major minor size name
1: 8 16 1954816 sdb
Enter Device Number: 1
sdb was selected
Checking the device is unmounted
sdb1 sdb2 sdb3
72261 1871572
################################################################################
Detected device has 2 partitions already
Re-partitioning will allow the choice of 2 or 3 partitions
################################################################################
Would you like to re-partition the drive anyways [y/n] : n
Skipping partitioning
################################################################################
Partitioning is now done
Continue to install filesystem or select 'n' to safe exit
**Warning** Continuing will erase files any files in the partitions
################################################################################
Would you like to continue? [y/n] : y
Mount the partitions
Emptying partitions
Syncing....
################################################################################
Choose file path to install from
1 ) Install pre-built images from SDK
2 ) Enter in custom boot and rootfs file paths
################################################################################
Choose now [1/2] : 1
Will now install from SDK pre-built images
now installing: ti-sdk-am335x-evm-05.07.00.00
################################################################################
Copying files now... will take minutes
################################################################################
Copying boot partition
MLO copied
u-boot.bin copied
u-boot.img copied
uImage copied
Copying rootfs System partition
Written 100%
Syncing...
Un-mount the partitions
Remove created temp directories
Operation Finished