Android SD Configuration

Android-vold源码分析之格式化SD卡(10) 作者:gzshun. 原创作品,转载请标明出处! 来源:http://blog.csdn.net/gzshun 本文开始讨论sd卡的格式化功能,平时使用windows操作系统,也经常格式化磁盘。涉及到的 操作有这几步: 1.将分区信息写到硬盘的第一个设备节点的MBR结构中的分区表; 2.格式化分区到指定的文件系统类型。 MBR中存放分区表的位置在446-509,占用了64字节, 阅读详情

查看原文

FULL TEXT




Contents

  [hide]

[edit]SD Configuration and Setup

There are 2 approaches to format the SD card. You could either use the script available or follow the step by step instructions below.

Note: All these instructions are common across all OMAP platforms.

[edit]Preparation

Before you start, you need to know the device name for your SD-Card.

Getting the device name for your SD-Card:
If you have no idea which device name is correct run the following command.

$ sudo fdisk -ls

The device name you are looking for is the Disk which comes close the size of your SD-Card (e.g. for a 8 GB SD-Card one line might look like this: Disk /dev/sde: 8011 MByte, 8011120640 Byte. - so the device name for the SD-Card will be /dev/sde).

[edit]Script to partition/format SDCards

Attention: On 2010-07-29 the name of the second partition has been changed from "rootfs" to "Angstrom". So in order to use the script to create your SD-Card and us it with some prebuild binaries (like e.g. Pandroid) you have to change the name back to "rootfs" as it otherwise won't work.
http://git.openembedded.org/openembedded/tree/contrib/angstrom/omap3-mkcard.sh 

The usage of the script is:

$ sudo omap3-mkcard.sh /dev/sd<x>


You can also use this script which will refuse to use /dev/sda as the device (that tends to be your primary HDD!):

#!/bin/bash
if [ ! "$1" = "/dev/sda" ] ; then
	unset LANG
	DRIVE=$1
	if [ -b "$DRIVE" ] ; then
		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`
		echo CYLINDERS - $CYLINDERS
		{
		echo ,9,0x0C,*
		echo ,,,-
		} | sfdisk -D -H 255 -S 63 -C $CYLINDERS $DRIVE
		mkfs.vfat -F 32 -n "boot" ${DRIVE}1
		mke2fs -j -L "rootfs" ${DRIVE}2
	fi 
fi


After running the script mount the SD card partitions on host:

mkdir /tmp/mmc1
mkdir /tmp/mmc2
sudo mount /dev/sdx1 /tmp/mmc1
sudo mount /dev/sdx2 /tmp/mmc2

Verified to work on Ubuntu to boot boards such as beagle, omapzoom2 etc. A big thanks to XorA!

[edit]Alternative Script to format SD Cards for 3 partitions

Some times you may want 3 partitions. You may also want to format only the boot and rootfs partitions, and leave the media files in a separate partition for reuse with the new images.

When we format the boot partition we also need to change Android BOOT binaries in order to work around some known limitations. But every time we format the boot partition, we have to copy all the media files once again (which is very annoying). So, it is more convenient to place the video clips, jpegs and any other media content in a separate FAT partition which need not be touched while changing the boot binaries.

Here is a script which lets you either created 2 or 3 partitions (the optional 'media drive' if you want to). It is more generalized than the above script -- because it extends its functionality. With this script you can also just format the first two drives without touching the media drive (the third one):

  • FAT/boot partition
  • EXT3 partition
  • FAT partition for media files

Copy the below text into a file (say, mkcard.sh). Make the file an executable file (chmod +x mkcard.sh). Then you can run it with administrative privileges like $sudo ./mkcard.sh /dev/sdx.) sdx is the name of your device on which the SD card is mounted. (Warning: This is, of course, a dangerous process if wrong arguments are given.)

#! /bin/bash
# mkcard.sh v0.5
# (c) Copyright 2009 Graeme Gregory <dp@xora.org.uk>
# Licensed under terms of GPLv2
#
# Parts of the procudure base on the work of Denys Dmytriyenko
# http://wiki.omap.com/index.php/MMC_Boot_Format
#
# Extended for 3 partitions by Prasad Golla <golla@ti.com> in April 2011.
# The 'media' partition can be used for storing media clips which can 
# be preserved even if the binaries in the other partitions are erased.

export LC_ALL=C

if [ $# -ne 1 ]; then
        echo "Usage: $0 <drive>"
        exit 1;
fi

DRIVE=$1

SKIPMEDIA=0

function format_boot_drive (){
echo "Formatting boot drive"
if [ -b ${DRIVE}1 ]; then
        umount ${DRIVE}1
        mkfs.vfat -F 32 -n "boot" ${DRIVE}1
else
        if [ -b ${DRIVE}p1 ]; then
                umount ${DRIVE}p1
                mkfs.vfat -F 32 -n "boot" ${DRIVE}p1
        else
                echo "Can't find boot partition in /dev"
        fi
fi
}

function format_rootfs_drive (){
echo "Formatting rootfs drive"
if [ -b ${DRIVE}2 ]; then
        umount ${DRIVE}2
        mke2fs -j -L "rootfs" ${DRIVE}2
else
        if [ -b ${DRIVE}p2 ]; then
                umount ${DRIVE}p2
                mke2fs -j -L "rootfs" ${DRIVE}p2
        else
                echo "Can't find rootfs partition in /dev"
        fi
fi
}

function format_media_drive (){
echo "Formatting media mediadrive"
if [ -b ${DRIVE}3 ]; then
        umount ${DRIVE}3
        mkfs.vfat -F 32 -n "media" ${DRIVE}3
else
        if [ -b ${DRIVE}p3 ]; then
                umount ${DRIVE}p3
                mkfs.vfat -F 32 -n "media" ${DRIVE}p3
        else
                echo "Can't find media partition in /dev"
        fi
fi
}

function get_media_drive_size(){

echo "How big of a media drive do you want?"
echo "Enter 0 to NOT create the media drive."
echo "Enter 1 for 1GB."
echo "Enter 64 for 64MB."
echo "Enter 128 for 128MB."
echo "Enter 512 for 512MB."
echo "Enter 256 for 256MB."
echo -n "Enter size of media drive you want: "

read disksize

case "$disksize" in
0)   SKIPMEDIA=1; return ;;
1)   MEDIASIZEREQ=`echo "1024 * 1024 * 1024" | bc` ;;
512) MEDIASIZEREQ=`echo "1024 * 1024 * 1024 / 2" | bc` ;;
256) MEDIASIZEREQ=`echo "1024 * 1024 * 1024 / 4" | bc` ;;
128) MEDIASIZEREQ=`echo "1024 * 1024 * 1024 / 8" | bc` ;;
64)  MEDIASIZEREQ=`echo "1024 * 1024 * 1024 / 16" | bc` ;;
*)   echo "Not a valid option. Try again."; get_media_drive_size;;
esac

echo Media size in bytes - $MEDIASIZEREQ
MEDIACYLINDERS=`echo $MEDIASIZEREQ/255/63/512 | bc`
echo Media CYLINDERS - $MEDIACYLINDERS

}

function create_drives(){
dd if=/dev/zero of=$DRIVE bs=1024 count=1024

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

echo DISK SIZE - $SIZE bytes

CYLINDERS=`echo $SIZE/255/63/512 | bc`
echo CYLINDERS - $CYLINDERS

get_media_drive_size;

if [ $SKIPMEDIA == 1 ] ; then
{
echo ,9,0x0C,*
echo ,,,-
} | sfdisk -D -H 255 -S 63 -C $CYLINDERS $DRIVE
sleep 1
return;
fi

LASTCYLINDERLINUX=`echo $CYLINDERS - 9 - $MEDIACYLINDERS | bc`

{
echo ,9,0x0C,*
echo ,$LASTCYLINDERLINUX,,-
echo ,,0x0C,-
} | sfdisk -D -H 255 -S 63 -C $CYLINDERS $DRIVE

sleep 1
}

echo "To format the boot and rootfs only, enter 'f'."
echo "To create the boot, media and rootfs and format them, enter 'c'."
echo -n "Enter c or f:"

read answer

case "$answer" in
f) format_boot_drive; format_rootfs_drive; exit ;;
c) create_drives; format_boot_drive; format_rootfs_drive; format_media_drive; exit;;
*) echo "Not a valid option. Exiting"; exit ;;
esac


[edit]Step by Step Instructions to format SD card

Since putting a Linux file system on a FAT32 partition is problematic, it is recommended to also create a 2nd partition.

  • Insert your SD card into your Linux box
  • Do not mount it

The card shows up as /dev/sd*. To identify the card, you can either do:

  • dmesg | grep sd[a-z]. You will see something like [172407.246308] sdb: sdb1 sdb2 so drive is /dev/sdb
  • ls /dev/sd* before and after plugging SD card and find created devices


For this example

  • we will assume the card shows up as /dev/sdc - substitute this for the real device on your specific machine. Fdisk the drive and print the partition information
sudo fdisk /dev/sdc
Command (m for help): p
Disk /dev/sdc: 1018 MB, 993001472 bytes
...<more>...

Look for the size in bytes of the device and calculate the number of cylinders, dropping fractions, if we have 255 heads and 63 sectors (and 512 bytes per sector so 1 cylinder is 255 * 63 * 512 = 8225280 bytes).


new_cylinders = Size / 8225280 (for this example we will have 993001472 / 8225280 which equals 120.725 or 120 cylinders)


[edit]Delete existing Partitions

Since we are changing the underlying geometry of the disk, we must clear the partition table before doing it. So delete all partitions using the fdisk 'd' command - yes, you will lose all data on the card. Once that is done, we can set the new geometry in expert mode. We will set the number of heads to 255, number of sectors to 63, and number of cylinders to new_cylinders.

Command (m for help):  d
Partition number (1-4): 1
Command (m for help):  d
Partition number (1-4): 2

[edit]Configure SD Card

Command (m for help): x
Expert command (m for help): h
Number of heads (1-256, default 30): 255
Expert command (m for help): s
Number of sectors (1-63, default 29): 63
Warning: setting sector offset for DOS compatiblity
Expert command (m for help): c
Number of cylinders (1-1048576, default 2286): <new_cylinders calculated from above> 


[edit]Configure SD Partitions

Now we return to the main menu and create 2 partitions as needed - 1 boot partition of 64Meg and the rest a linux partition.

  • Note: +64M is used to set the boot partition to 64MB. If media content is stored on the SD this parition size should be increased to make room for media content (mp3, mp4, aac, etc...). Assuming a 2GB SD card is used a partition size of +1024MB should be enough to handle 1GB of media content.
Expert command (m for help): r
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-123, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-123, default 123): +64M (see note above)
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (10-123, default 10):
Using default value 10
Last cylinder or +size or +sizeM or +sizeK (10-123, default 123):
Using default value 123


[edit]Fat32 Partition

Command (m for help): t
Partition number (1-4): 1
Hex code (type L to list codes): c
Changed system type of partition 1 to c (W95 FAT32 (LBA))
* You have to format 1st partitions with vfat32 filesystem.
Command (m for help): a
Partition number (1-4): 1


[edit]Check Partition Table

The partition table should look something like the following. Notice the heads, sectors, and cylinders. Make sure partition 1 is active and FAT32. If it looks good - write the new partition information out.

Command (m for help): p
Disk /dev/sdc: 993 MB, 993001472 bytes
255 heads, 63 sectors/track, 120 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000

Device Boot Start End Blocks Id System
/dev/sdc1 * 1 9 72261 c W95 FAT32 (LBA)
/dev/sdc2 10 120 891607+ 83 Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: If you have created or modified any DOS 6.x
partitions, please see the fdisk manual page for additional
information.
Syncing disks.


[edit]Formatting Partitions

Format the filesystems on the partitions:

# sudo mkfs.vfat -F 32 -n boot /dev/sdc1
# sudo mkfs.ext3 -L rootfs /dev/sdc2

[edit]Creating a mount point

mkdir /tmp/mmc1
mkdir /tmp/mmc2
sudo mount /dev/sdc1 /tmp/mmc1
sudo mount /dev/sdc2 /tmp/mmc2

[edit]Problem seen with FDISK not erasing the first sector

The fdisk utility does not seem to erase the first few bytes of the first sector in the card when the partition table is saved.

Use dd to erase the first sector.

sudo dd if=/dev/zero of=/dev/<sdb> bs=1024 count=1

Then use the procedure listed in section above to create new partitions and format them accordingly

[edit]Video walkthrough

A video walkthrough of the above process can be found below:


Contents

  [hide]

[edit]SD Configuration and Setup

There are 2 approaches to format the SD card. You could either use the script available or follow the step by step instructions below.

Note: All these instructions are common across all OMAP platforms.

[edit]Preparation

Before you start, you need to know the device name for your SD-Card.

Getting the device name for your SD-Card:
If you have no idea which device name is correct run the following command.

$ sudo fdisk -ls

The device name you are looking for is the Disk which comes close the size of your SD-Card (e.g. for a 8 GB SD-Card one line might look like this: Disk /dev/sde: 8011 MByte, 8011120640 Byte. - so the device name for the SD-Card will be /dev/sde).

[edit]Script to partition/format SDCards

Attention: On 2010-07-29 the name of the second partition has been changed from "rootfs" to "Angstrom". So in order to use the script to create your SD-Card and us it with some prebuild binaries (like e.g. Pandroid) you have to change the name back to "rootfs" as it otherwise won't work.
http://git.openembedded.org/openembedded/tree/contrib/angstrom/omap3-mkcard.sh 

The usage of the script is:

$ sudo omap3-mkcard.sh /dev/sd<x>


You can also use this script which will refuse to use /dev/sda as the device (that tends to be your primary HDD!):

#!/bin/bash
if [ ! "$1" = "/dev/sda" ] ; then
	unset LANG
	DRIVE=$1
	if [ -b "$DRIVE" ] ; then
		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`
		echo CYLINDERS - $CYLINDERS
		{
		echo ,9,0x0C,*
		echo ,,,-
		} | sfdisk -D -H 255 -S 63 -C $CYLINDERS $DRIVE
		mkfs.vfat -F 32 -n "boot" ${DRIVE}1
		mke2fs -j -L "rootfs" ${DRIVE}2
	fi 
fi


After running the script mount the SD card partitions on host:

mkdir /tmp/mmc1
mkdir /tmp/mmc2
sudo mount /dev/sdx1 /tmp/mmc1
sudo mount /dev/sdx2 /tmp/mmc2

Verified to work on Ubuntu to boot boards such as beagle, omapzoom2 etc. A big thanks to XorA!

[edit]Alternative Script to format SD Cards for 3 partitions

Some times you may want 3 partitions. You may also want to format only the boot and rootfs partitions, and leave the media files in a separate partition for reuse with the new images.

When we format the boot partition we also need to change Android BOOT binaries in order to work around some known limitations. But every time we format the boot partition, we have to copy all the media files once again (which is very annoying). So, it is more convenient to place the video clips, jpegs and any other media content in a separate FAT partition which need not be touched while changing the boot binaries.

Here is a script which lets you either created 2 or 3 partitions (the optional 'media drive' if you want to). It is more generalized than the above script -- because it extends its functionality. With this script you can also just format the first two drives without touching the media drive (the third one):

  • FAT/boot partition
  • EXT3 partition
  • FAT partition for media files

Copy the below text into a file (say, mkcard.sh). Make the file an executable file (chmod +x mkcard.sh). Then you can run it with administrative privileges like $sudo ./mkcard.sh /dev/sdx.) sdx is the name of your device on which the SD card is mounted. (Warning: This is, of course, a dangerous process if wrong arguments are given.)

#! /bin/bash
# mkcard.sh v0.5
# (c) Copyright 2009 Graeme Gregory <dp@xora.org.uk>
# Licensed under terms of GPLv2
#
# Parts of the procudure base on the work of Denys Dmytriyenko
# http://wiki.omap.com/index.php/MMC_Boot_Format
#
# Extended for 3 partitions by Prasad Golla <golla@ti.com> in April 2011.
# The 'media' partition can be used for storing media clips which can 
# be preserved even if the binaries in the other partitions are erased.

export LC_ALL=C

if [ $# -ne 1 ]; then
        echo "Usage: $0 <drive>"
        exit 1;
fi

DRIVE=$1

SKIPMEDIA=0

function format_boot_drive (){
echo "Formatting boot drive"
if [ -b ${DRIVE}1 ]; then
        umount ${DRIVE}1
        mkfs.vfat -F 32 -n "boot" ${DRIVE}1
else
        if [ -b ${DRIVE}p1 ]; then
                umount ${DRIVE}p1
                mkfs.vfat -F 32 -n "boot" ${DRIVE}p1
        else
                echo "Can't find boot partition in /dev"
        fi
fi
}

function format_rootfs_drive (){
echo "Formatting rootfs drive"
if [ -b ${DRIVE}2 ]; then
        umount ${DRIVE}2
        mke2fs -j -L "rootfs" ${DRIVE}2
else
        if [ -b ${DRIVE}p2 ]; then
                umount ${DRIVE}p2
                mke2fs -j -L "rootfs" ${DRIVE}p2
        else
                echo "Can't find rootfs partition in /dev"
        fi
fi
}

function format_media_drive (){
echo "Formatting media mediadrive"
if [ -b ${DRIVE}3 ]; then
        umount ${DRIVE}3
        mkfs.vfat -F 32 -n "media" ${DRIVE}3
else
        if [ -b ${DRIVE}p3 ]; then
                umount ${DRIVE}p3
                mkfs.vfat -F 32 -n "media" ${DRIVE}p3
        else
                echo "Can't find media partition in /dev"
        fi
fi
}

function get_media_drive_size(){

echo "How big of a media drive do you want?"
echo "Enter 0 to NOT create the media drive."
echo "Enter 1 for 1GB."
echo "Enter 64 for 64MB."
echo "Enter 128 for 128MB."
echo "Enter 512 for 512MB."
echo "Enter 256 for 256MB."
echo -n "Enter size of media drive you want: "

read disksize

case "$disksize" in
0)   SKIPMEDIA=1; return ;;
1)   MEDIASIZEREQ=`echo "1024 * 1024 * 1024" | bc` ;;
512) MEDIASIZEREQ=`echo "1024 * 1024 * 1024 / 2" | bc` ;;
256) MEDIASIZEREQ=`echo "1024 * 1024 * 1024 / 4" | bc` ;;
128) MEDIASIZEREQ=`echo "1024 * 1024 * 1024 / 8" | bc` ;;
64)  MEDIASIZEREQ=`echo "1024 * 1024 * 1024 / 16" | bc` ;;
*)   echo "Not a valid option. Try again."; get_media_drive_size;;
esac

echo Media size in bytes - $MEDIASIZEREQ
MEDIACYLINDERS=`echo $MEDIASIZEREQ/255/63/512 | bc`
echo Media CYLINDERS - $MEDIACYLINDERS

}

function create_drives(){
dd if=/dev/zero of=$DRIVE bs=1024 count=1024

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

echo DISK SIZE - $SIZE bytes

CYLINDERS=`echo $SIZE/255/63/512 | bc`
echo CYLINDERS - $CYLINDERS

get_media_drive_size;

if [ $SKIPMEDIA == 1 ] ; then
{
echo ,9,0x0C,*
echo ,,,-
} | sfdisk -D -H 255 -S 63 -C $CYLINDERS $DRIVE
sleep 1
return;
fi

LASTCYLINDERLINUX=`echo $CYLINDERS - 9 - $MEDIACYLINDERS | bc`

{
echo ,9,0x0C,*
echo ,$LASTCYLINDERLINUX,,-
echo ,,0x0C,-
} | sfdisk -D -H 255 -S 63 -C $CYLINDERS $DRIVE

sleep 1
}

echo "To format the boot and rootfs only, enter 'f'."
echo "To create the boot, media and rootfs and format them, enter 'c'."
echo -n "Enter c or f:"

read answer

case "$answer" in
f) format_boot_drive; format_rootfs_drive; exit ;;
c) create_drives; format_boot_drive; format_rootfs_drive; format_media_drive; exit;;
*) echo "Not a valid option. Exiting"; exit ;;
esac


[edit]Step by Step Instructions to format SD card

Since putting a Linux file system on a FAT32 partition is problematic, it is recommended to also create a 2nd partition.

  • Insert your SD card into your Linux box
  • Do not mount it

The card shows up as /dev/sd*. To identify the card, you can either do:

  • dmesg | grep sd[a-z]. You will see something like [172407.246308] sdb: sdb1 sdb2 so drive is /dev/sdb
  • ls /dev/sd* before and after plugging SD card and find created devices


For this example

  • we will assume the card shows up as /dev/sdc - substitute this for the real device on your specific machine. Fdisk the drive and print the partition information
sudo fdisk /dev/sdc
Command (m for help): p
Disk /dev/sdc: 1018 MB, 993001472 bytes
...<more>...

Look for the size in bytes of the device and calculate the number of cylinders, dropping fractions, if we have 255 heads and 63 sectors (and 512 bytes per sector so 1 cylinder is 255 * 63 * 512 = 8225280 bytes).


new_cylinders = Size / 8225280 (for this example we will have 993001472 / 8225280 which equals 120.725 or 120 cylinders)


[edit]Delete existing Partitions

Since we are changing the underlying geometry of the disk, we must clear the partition table before doing it. So delete all partitions using the fdisk 'd' command - yes, you will lose all data on the card. Once that is done, we can set the new geometry in expert mode. We will set the number of heads to 255, number of sectors to 63, and number of cylinders to new_cylinders.

Command (m for help):  d
Partition number (1-4): 1
Command (m for help):  d
Partition number (1-4): 2

[edit]Configure SD Card

Command (m for help): x
Expert command (m for help): h
Number of heads (1-256, default 30): 255
Expert command (m for help): s
Number of sectors (1-63, default 29): 63
Warning: setting sector offset for DOS compatiblity
Expert command (m for help): c
Number of cylinders (1-1048576, default 2286): <new_cylinders calculated from above> 


[edit]Configure SD Partitions

Now we return to the main menu and create 2 partitions as needed - 1 boot partition of 64Meg and the rest a linux partition.

  • Note: +64M is used to set the boot partition to 64MB. If media content is stored on the SD this parition size should be increased to make room for media content (mp3, mp4, aac, etc...). Assuming a 2GB SD card is used a partition size of +1024MB should be enough to handle 1GB of media content.
Expert command (m for help): r
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-123, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-123, default 123): +64M (see note above)
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (10-123, default 10):
Using default value 10
Last cylinder or +size or +sizeM or +sizeK (10-123, default 123):
Using default value 123


[edit]Fat32 Partition

Command (m for help): t
Partition number (1-4): 1
Hex code (type L to list codes): c
Changed system type of partition 1 to c (W95 FAT32 (LBA))
* You have to format 1st partitions with vfat32 filesystem.
Command (m for help): a
Partition number (1-4): 1


[edit]Check Partition Table

The partition table should look something like the following. Notice the heads, sectors, and cylinders. Make sure partition 1 is active and FAT32. If it looks good - write the new partition information out.

Command (m for help): p
Disk /dev/sdc: 993 MB, 993001472 bytes
255 heads, 63 sectors/track, 120 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000

Device Boot Start End Blocks Id System
/dev/sdc1 * 1 9 72261 c W95 FAT32 (LBA)
/dev/sdc2 10 120 891607+ 83 Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: If you have created or modified any DOS 6.x
partitions, please see the fdisk manual page for additional
information.
Syncing disks.


[edit]Formatting Partitions

Format the filesystems on the partitions:

# sudo mkfs.vfat -F 32 -n boot /dev/sdc1
# sudo mkfs.ext3 -L rootfs /dev/sdc2

[edit]Creating a mount point

mkdir /tmp/mmc1
mkdir /tmp/mmc2
sudo mount /dev/sdc1 /tmp/mmc1
sudo mount /dev/sdc2 /tmp/mmc2

[edit]Problem seen with FDISK not erasing the first sector

The fdisk utility does not seem to erase the first few bytes of the first sector in the card when the partition table is saved.

Use dd to erase the first sector.

sudo dd if=/dev/zero of=/dev/<sdb> bs=1024 count=1

Then use the procedure listed in section above to create new partitions and format them accordingly

[edit]Video walkthrough

A video walkthrough of the above process can be found below:

别浪费你的SD卡!树莓派4刷入Android 14后,手把手教你用GParted无损扩容全流程 本文详细介绍了如何在树莓派4上刷入Android 14后,使用GParted工具无损扩容SD卡的全流程。从分区调整到性能优化,提供了一系列实用技巧,帮助用户充分利用存储空间并提升系统运行效率。 阅读详情

相关推荐

避坑指南:树莓派4安装Android 14后,SD卡扩容和GPIO按键配置这些细节别忽略

本文详细介绍了在树莓派4上安装Android 14后的进阶配置技巧,重点解决SD卡存储扩容和GPIO物理按键配置两大关键问题。通过GParted工具实现SD卡空间完全释放,并深入讲解GPIO按键的硬件连接与软件配置方法,帮助用户充分发挥树莓派4的性能潜力。

529

【无标题】

想一下平时使用的持久化方案:这些文件都是默认放在内部存储里。如果包名为:com.yc.helper,则对应的内部存储目录为:/data/data/com.yc.helper/机身内部存储一般存储那些文件呢?大概有以下这些那么怎么通过代码访问到这些路径的文件呢?代码如下所示``` context.getCacheDir().getAbsolutePath() context.getCodeCacheDir().getAbsolutePath() //databases 直接通过getDatabasePath(

xiaokangss的博客 359

DNESP32P4 USB Slave实现Modbus从站读SD卡

USB Device(USB从设备)是嵌入式系统与主机通信的基础协议角色,其核心在于精准实现USB描述符、端点管理与协议栈响应;Modbus Slave则是工业自动化中标准的应用层从站角色,负责解析请求并返回寄存器数据。二者结合需跨越物理层(USB)、数据链路层(Bulk传输)与应用层(Modbus ADU解析)的协议叠层设计。DNESP32P4凭借原生USB OTG外设、可配置Endpoint缓冲区及双DMA通道能力,成为实现USB Vendor Class类Modbus从设备的理想平台,适用于PLC日志

weixin_33871366的博客 392

三星手机出现红字your phone couldn’t start normally. some configuration data may be corrupt.

早上重启了一下三星S10手机出现如下情况 [caption id="attachment_321" align="alignnone" width="600"] 三星[/caption] 然后就再也开不了机了,选啥都没用. 选了第二个又出现这个 [caption id="attachment_322" align="alignnone" width="450"] 三星[/caption] 弄了一个多小时,最后终于弄好了 在上图中选第三个在下一个界面选第一个,正常后改动时间,把时间改到一个月之前,

reg183的专栏 4587

把树莓派4变成安卓开发板:Android 14上的ADB、VNC远程调试与GPIO按键映射全攻略

本文详细介绍了如何将树莓派4打造成强大的安卓开发板,运行Android 14系统并实现高级调试与硬件控制。内容包括无线ADB调试、VNC远程桌面配置、GPIO按键映射等实用技巧,帮助开发者充分利用树莓派4的硬件潜力,提升物联网和智能设备开发效率。

519

mpu6050原理图_STM32控制 MPU6050 六轴陀螺仪资料汇总

一般使用MPU6050的步骤是先驱动I2C总线,然后初始化MPU6050,从MPU6050读取数据,最后是数据的处理。本文档详细介绍有关MPU6050 三维角度传感器电子陀螺仪使用说明。附件内容提供该 MPU6050模块原理图,配套STM32代码,相关数据手册及参考文档。实物连接图:MPU6050 六轴陀螺仪特点:使用芯片:MPU-6050供电电源:3-5v(内部低压差稳压)通信方式:标...

weixin_39911056的博客 4758

Android Build SD Configuration

转载地址: http://omappedia.org/wiki/Android_Build_SD_Configuration Step 5 Contents [hide] 1SD Configuration and Setup2Preparation3Script to partition/format SDCards4Alternative Script

meilinbaobei的专栏 516

POWER(十一)charge pump原理

电荷泵是一种基于电容充放电原理的DC-DC转换电路,通过开关控制实现电压转换,包括升压、降压和负压输出。其核心是利用电荷守恒原理,通过电容存储和转移电荷来改变输出电压。典型拓扑结构包括倍压电路和多阶升压电路,具有结构简单、体积小等优势。关键参数包括转换效率、输出电流能力和开关频率,适用于芯片供电、显示屏驱动等低功耗场景。LVDS部分补充说明了自举电路在驱动电路中的应用及其自同步特性。

zhlwsh的博客 2808

android eclipse 控件树,在 Eclipse 文件资源管理器中,是否有人知道如何创建文件夹树?_android_开发99编程知识库...

正在創建SD卡Access to your Android SDK Tools folder and use command"mksdcard" in order to create one.By default installation on Windows, the Tools folder should be here:C:Program FilesAndroidandroid-sdktoo...

weixin_42100188的博客 104

数据集分享 | IWR1642呼吸心跳数据集

雷达开源数据库 数据集

【调皮连续波】雷达技术领域知识博主 3205

国产SR8201F以太网PHY芯片调试避坑指南:从机贴失败到杜邦线救场的实战记录

本文详细介绍了国产SR8201F以太网PHY芯片的调试避坑指南,涵盖硬件设计、PCB布局、SMT贴片及软件驱动等关键环节。通过实战案例解析,帮助工程师解决MII/RMII接口配置、电源设计、信号完整性等典型问题,提升以太网通信稳定性与EMC性能。

c6d7e8f9g的博客 1215

DNESP32P4实现USB MSC从机读卡器实战指南

USB大容量存储(MSC)是嵌入式设备实现即插即用数据交换的核心协议,其底层基于USB Device角色与BOT传输机制,通过标准SCSI命令(如READ_10、INQUIRY)完成扇区级读写。该方案规避了Host模式下外置读卡器兼容性差、驱动复杂等痛点,依托芯片原生USB OTG控制器,将MCU直接暴露为标准化存储节点,具备高兼容性、零上位机依赖和批量数据吞吐优势。在工业采集终端、智能仪表及Android 11现场设备中,MSC Slave架构可无缝对接PC或移动系统自带驱动,显著降低部署门槛。本文聚焦D

weixin_33937778的博客 896

Ubuntu 22.04下Colmap带CUDA支持的编译安装全攻略(附显卡架构查询指南)

本文详细指导在Ubuntu 22.04系统上从源码编译安装支持CUDA加速的Colmap,解决了官方版本无GPU支持导致处理速度慢的问题。重点包括环境依赖准备、CUDA工具链配置、显卡计算能力查询以及完整的编译安装步骤,旨在帮助研究者和开发者高效部署高性能三维重建工具。

gold8的专栏 344

Android p2p service,android – WifiP2pDnsSdServiceInfo.newInstance中的可用服务类型

我正在编写一个使用Wifi Direct的Android应用程序.我正在尝试启动我的服务,我正在调用WifiP2pDnsSdServiceInfo.newInstance.但是,我一直在寻找可以使用的不同服务类型,到目前为止我只找到了“_presence._tcp”.我知道我应该以某种方式找到一个“有意义”的服务类型,我的应用程序试图完成.我可以“发明”它吗?有没有可用的协议列表?非常感谢!解决方...

weixin_42363510的博客 306

零基础学习simulink-- 基于自适应模糊PID控制的直流电机速度控制系统

通过上述代码实现,您可以逐步创建和搭建一个基于自适应模糊PID控制的直流电机速度控制系统。该系统能够根据电机的状态和误差实时调整PID参数,确保电机速度稳定在设定范围内。自适应模糊PID控制具有较强的鲁棒性和适应性,能够在存在不确定性和扰动的情况下提供快速且精确的控制性能。Simulink提供了强大的建模和仿真工具,使得控制系统工程师能够快速构建复杂的控制算法,并将其应用于实际工程中。直流电机建模:建立直流电机的动态模型,包括电枢电压、电流、转速和负载扭矩。自适应模糊PID控制器设计。

amy_mhd的博客 413

Qt Creator 下载和安装

在线安装程序是一个小型的安装程序,它将在您的计算机上下载和安装 Qt Creator。离线安装程序是一个较大的安装包,您可以将其保存在本地,并在没有网络连接的情况下安装 Qt Creator。在 Qt 官方网站上,您可以找到 Qt Creator 的下载页面。Qt Creator 是一款跨平台的集成开发环境(IDE),用于开发基于 Qt 框架的应用程序。在这一步中,您可以选择是否安装 Qt Creator 的附加组件。一旦您完成了组件的选择,安装程序将开始将 Qt Creator 安装到您的计算机上。

HackLogic的博客 6817

ADROID 2.1 架构解析 9 SD/USB

9 SD/USB 9.1 主流程 文件:system/core/vold/Vold.c int main(int argc, char **argv) {        ... mkdir("/dev/block/vold", 0755);        ...         /*      * Bootstrap      */       bootstrap =

jifengwei_21的专栏 643

WinCC7.5 SP2 安装与授权(文末附授权软件)

安装部分参考了wincc7.5官网下载及安装配置(适配window10超详细教程) 主要介绍授权部分(仅供学习,商用请下载正版授权): 通过官网下载安装了WinCC7.5(需要在西门子官网注册账户,10积分下载)。 安装成功以后,还没授权,先别立即打开。 下载Sim_EBK_Install 复制链接到百度网盘中离线下载: 都是一样的软件,版本不同。有部分解压时需要输入密码,可选择方框里的不需要解压密码: 解压以后,打开: 最后检查秘钥授权是否成功 打开桌面(这是安装WinCC以后就有的): 左

skr? 7万+

Android eclipse 运行项目设置程序默认安装到SD卡

Android eclipse 运行项目设置程序默认安装到SD卡 1、在Android手机启用USB调试功能 2、在Windows系统中打开命令提示符(开始菜单,选择运行,输入cmd回车即可),使用CD命令切换到Android-SDK\tools目录下(即adb.exe文件目录下),Android-SDK为你前面安装Android SDK指定的目录。 3、在命令提示符进入Android-SDK\...

weixin_30471065的博客 81

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

Android的Configuration系统设置

Android中Configuration类专门用于描述手机设备上的配置信息,这些配置信息既包括用户特定的配置项,也包括系统的动态设备配 置。 通过Configuration对象提供的基本属性来获取系统的配置信息,例如: public int densityDpi; //得到设备的密度 public float fontScale; //获取当前用户设置的字体的缩放因子 public int KeyboardHidden; //该属性会返回一个boolean

mike_jun的博客 3149

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

安卓动作汇总

String FRAMEWORK_INSTRUMENTATION_TEST_CATEGORY 类别:To be used as code under test for framework instrumentation tests. "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST"16 0x00000010。

m0_72431373的博客 358

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

android配置信息类-Configuration

android提供了一个Configuration类,主要用来描述与能让应用程序获取的资源相关的所有硬件配置信息。包含用户指定的信息项(本地和缩放比例)和动态硬件配置(一系列的输入设备)。 Configuration 类中包含了很多种信息,例如系统字体大小,orientation,输入设备类型等等. fontScale -- 来源于system.prop中 sys.font.scale配置项 ...

lishunjin987的博客 364

MASTG Android 拦截代理配置实战:从模拟器/真机代理设置到绕过 Network Security Configuration

本文基于 OWASP Mobile Application Security Testing Guide(MASTG)的 [MASTG-TECH-0011](https://link.gitcode.com/i/acc7b083200dfec2f9b2c0fba89dbe07) 技术条目,系统讲解如何在 Android 测试环境中搭建 HTTP(S) 拦截代理,覆盖模拟器与真机两类场景的代理配置、

gitblog_00088的博客 181

Android模拟器SD Card映像文件使用方法

1.mksdcard命令用cmd进入SDK的Tools目录,执行mksdcard命令。会出现如下帮助信息我们可以看到sdcardimage支持FAT32格式,其中usage:mksdcard[-llabel]<size><file>是主要的参数。-l后面跟的是磁盘卷标,如g就代表g盘;size为制定容量大小,单位有KB和MB;file代表生成的...

dashi6629的博客 270

Vita3K-Android:在安卓设备上畅玩PS Vita游戏的终极指南

Vita3K-Android是一款革命性的开源PS Vita模拟器,专为安卓平台优化,让玩家能够在移动设备上重温索尼掌机的经典游戏。作为Vita3K模拟器的安卓版本,该项目不仅继承了桌面版的强大功能,还针对移动设备进行了深度优化,为安卓用户带来了前所未有的PS Vita游戏体验。 ## 🎮 为什么选择Vita3K-Android? 随着移动设备性能的飞速提升,在安卓手机上运行PS Vita游

gitblog_00607的博客 391

Android studio无法获取Asserts文件,通过内置sd卡来获取路径

项目中,需要读取一个配置文件,来加载对应的后台服务,但文件放在asserts文件夹下,百度了一下,是无法获取到绝对路径的,这样就势必要修改整个的服务结构和方法,所以采用了一个折中的方式,先将文件放在工程的asserts文件夹内,然后代码中先复制到手机内置的sd卡中,这样就能知道一个绝对路径.代码如下:     注:asserts中的文件路径无法获取到绝对路径,是因为这个文件并没有打包到apk中,

你好邱林和的专栏 2492
上一篇: 新官上任应该做些什么
下一篇: SpringAnnotations By Craig Walls
AutoAsm
博客等级 码龄27年 27粉丝 20原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值