Trash Fr:MultiMediaCard

From ArmadeusWiki
Jump to: navigation, search

Instructions pour utiliser la MultiMediaCard (MMC/SD) sur votre carte Armadeus

Introduction

You can use standard MMC/SD cards with your Armadeus board, if you have the corresponding connector attached to your devt board. See MMC/SD page to know how to connect the hardware part.

Installation

when you build your kernel image, then modify your configuration:

[user@toto]$ make xconfig

in Device Drivers->MMC/SD Card support->iMX Support In FileSystems, don't forgt to add support for the filesystem on the MMC and if you activate FAT/VFAT, don't forget to activate Native Language Support (NLS) otherwise you'll get errors like:

Unable to load NLS charset cp437
FAT: codepage cp437 not found

Save your configuration and then rebuild your kernel image:

[user@toto]$ make

now you should have following drivers in your kernel source tree:

drivers/mmc/

Copy mmc_core.ko, imxmmc.ko & mmc_block.ko to your target root filessytem in /lib/modules/ or reflash the generated rootfs.

If not already existing then create MMC block devices:

# mknod /dev/mmcblk0 b 254 0
# mknod /dev/mmcblk0p1 b 254 1

If not already existing then create the mount point (/mnt/mmc):

# mkdir -p /mnt/mmc

Préparation de la SD/MMC

La plupart des SD/MMC commercialisées ne sont pas formatées correctement ou ne dispose pas de table de partition standard. Nous allons donc voir comment préparer notre SD/MMC toute neuve afin que celle-ci soit reconnue par notre console. Introduisez votre SD/MMC dans le lecteur de carte sur votre PC Linux. Il faut ensuite récupérer le nom du device assigné à la MMC (généralement /dev/sda1). Si votre distribution monte automatiquement les périphériques de stockage USB, annulez ce montage. Pour récupérer le device de la MMC je regarde généralement dans /var/log/messages et je recherche le dernier message du type:

usb 5-7: new high speed USB device using ehci_hcd and address 5
Initializing USB Mass Storage driver...
scsi7 : SCSI emulation for USB Mass Storage devices
usbcore: registered new driver usb-storage
 USB Mass Storage support registered.
sd 7:0:0:1: Attached scsi generic sg2 type 0
  Vendor: Hama      Model: CardReaderMMC/SD  Rev: 1.9C
  Type:   Direct-Access                      ANSI SCSI revision: 00
SCSI device sdd: 501760 512-byte hdwr sectors (257 MB)
sdd: Write Protect is off
 SCSI device sdd: 501760 512-byte hdwr sectors (257 MB)
sdd: Write Protect is off
 sdd: sdd1
sd 7:0:0:2: Attached scsi removable disk sdd
sd 7:0:0:2: Attached scsi generic sg3 type 0

Ici ma MMC de 256 Mo s'est vue assignée /dev/sdd1.
Maintenant avec fdisk, étudions un peu le contenu de notre carte:

# /sbin/fdisk /dev/sdd1

Command (m for help): p 

Disk /dev/sdd1: 256 MB, 256884736 bytes
16 heads, 32 sectors/track, 979 cylinders
Units = cylinders of 512 * 512 = 262144 bytes

This doesn't look like a partition table
Probably you selected the wrong device.

    Device Boot      Start         End      Blocks   Id  System
/dev/sdd1p1   ?     1519797     3749308   570754815+  72  Unknown
Partition 1 has different physical/logical beginnings (non-Linux?):
    phys=(357, 116, 40) logical=(1519796, 11, 5)
Partition 1 has different physical/logical endings:
    phys=(357, 32, 45) logical=(3749307, 11, 3)
Partition 1 does not end on cylinder boundary.
/dev/sdd1p2   ?      329472     4110777   968014120   65  Novell Netware 386
Partition 2 has different physical/logical beginnings (non-Linux?):
    phys=(288, 115, 43) logical=(329471, 11, 19)
Partition 2 has different physical/logical endings:
    phys=(367, 114, 50) logical=(4110776, 14, 2)
Partition 2 does not end on cylinder boundary.
/dev/sdd1p3   ?     3652113     7433418   968014096   79  Unknown
Partition 3 has different physical/logical beginnings (non-Linux?):
    phys=(366, 32, 33) logical=(3652112, 3, 26)
Partition 3 has different physical/logical endings:
    phys=(357, 32, 43) logical=(7433417, 4, 25)
Partition 3 does not end on cylinder boundary.
/dev/sdd1p4   ?           1     7103958  1818613248    d  Unknown
Partition 4 has different physical/logical beginnings (non-Linux?):
    phys=(372, 97, 50) logical=(0, 0, 1)
Partition 4 has different physical/logical endings:
    phys=(0, 10, 0) logical=(7103957, 15, 32)
Partition 4 does not end on cylinder boundary.

Partition table entries are not in disk order

Comme vous pouvez le constater, c'est un peu le fouillis sur cette carte. Effaçons toute les partitions:

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

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

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

Command (m for help): d
Selected partition 4

Command (m for help): p

Disk /dev/sdd1: 256 MB, 256884736 bytes
16 heads, 32 sectors/track, 979 cylinders
Units = cylinders of 512 * 512 = 262144 bytes

    Device Boot      Start         End      Blocks   Id  System

Puis créons une partition Linux. Afin de ne pas payer de royalties inutilement ;-) nous choisissons bien sûr de ne pas utiliser de type de fichier FAT.

Command (m for help): n
Command action
  e   extended
  p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-979, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-979, default 979):
Using default value 979

Finalement, sauvons nos modifications et quittons fdisk:

Command (m for help): p

Disk /dev/sdd1: 256 MB, 256884736 bytes
16 heads, 32 sectors/track, 979 cylinders
Units = cylinders of 512 * 512 = 262144 bytes

    Device Boot      Start         End      Blocks   Id  System
/dev/sdd1p1               1         979      250608   83  Linux
Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 22: Invalid argument.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.

Il ne nous reste plus désormais qu'à formatter la MMC:

 # /sbin/mkfs.ext2 /dev/sdd1
mke2fs 1.38 (30-Jun-2005)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
62744 inodes, 250864 blocks
12543 blocks (5.00%) reserved for the super user
First data block=1
31 block groups
8192 blocks per group, 8192 fragments per group
2024 inodes per group
Superblock backups stored on blocks:
       8193, 24577, 40961, 57345, 73729, 204801, 221185

Writing inode tables: done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 20 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

Voilà la carte est prête à être utilisée (à supposer qu'il existe un point de montage /mnt/mmc):

# mount /dev/sdd1 /mnt/mmc/
# ls -al /mnt/mmc/
total 17
drwxr-xr-x 3 root root  1024 2007-01-15 12:56 .
drwxr-xr-x 4 root root  4096 2007-01-15 12:58 ..
drwx------ 2 root root 12288 2007-01-15 12:56 lost+found

Copiez maintenant vos données sur la MMC:

$ cp /mnt/mmc/

Voilà il ne reste plus qu'à démonter la MMC (en tant que root) et la mettre sur l'APF9328

# umount /mnt/mmc

Utilisation

Le driver MMC étant désormais statique au noyau, pas besoin de charger de module. Insérez votre MMC et vérifiez qu'elle est bien détectée:

imx-mmc imx-mmc.0: card inserted
mmcblk0: mmc0:0001 MMC    250880KiB
 mmcblk0: p1

Montons la MMC dans /media/mmc:

# mkdir -p /media/mmc
# mount /dev/mmcblk0p1 /media/mmc/

TBDL

Links

Other languages:

English Flag.svg English  •  French Flag.svg Français