SD-Card (i.MX31): Unterschied zwischen den Versionen

Aus BECOM Systems Support
Zur Navigation springen Zur Suche springen
en>Peter
K (1 Version importiert)
 
K (1 Version importiert)
 
(kein Unterschied)

Aktuelle Version vom 31. Oktober 2023, 09:03 Uhr

Kernel configuration

You can find all MMC/SD card related options in the kernel configuration at Device Drivers -> MMC/SD Card Support. The following options need to be checked:

  * MMC/SD Card Support
  * MMC Block device driver
     * Use bounce buffer for simple hosts
  * Freescale MXC Multimedia Card Interface support


Using the card

After the device finishes booting, insert an SD Card into the appropriate slot located at the bottom side of the dev board. You should immediately see messages telling you information about the card:

mmcblk0: mmc1:b368 SDC   975360KiB
 mmcblk0: p1

Check if the devnode /dev/mmcblk0 exists:

ls /dev/mmcblk0

We will now partition and format the card. Make sure no important data is stored on the card, since it will be deleted. Run the following commands:

dd if=/dev/zero of=/dev/mmcblk0 bs=1024 count=512     // clear the first 512 kb

fdisk /dev/mmcblk0                                    // run fdisk
   // use "o" to delete existing partitions
   // use "n" to create a new partition
   // use "w" to write the partition table and exit
mkfs.ext2 /dev/mmcblk0p1                              // create an ext2 filesystem

mkdir /mnt/mmc1                                       // create a mountpoint
mount -t ext2 /dev/mmcblk0p1 /mnt/mmc1                // Mount the partition
ls /mnt/mmc1                                          // view the contents (empty except for lost+found)
umount /mnt/mmc1                                      // Unmount mmc before ejecting it


Automount using udev

(Make sure that AutoFS is being compiled as a module (Kernel Configuration -> File Systems -> Kernel Automounter Version 4 Support).)

Create the directory /mnt/mmc1.

mkdir /mnt/mmc1

Create a file named 09-mmc.rules in /etc/udev/rules.d. Paste the following line(s).

KERNEL=="mmcblk0p1", ACTION=="add", RUN+="/etc/udev/scripts/mmc_mount.sh"
KERNEL=="mmcblk0p1", ACTION=="remove", RUN+="/etc/udev/scripts/mmc_umount.sh"

Create a new file named mmc_mount.sh in /etc/udev/scripts and paste the following lines. Make sure it is executable (chmod) by the user who will run it.

#!/bin/sh
mount -t ext2 /dev/mmcblk0p1 /mnt/mmc1

Create a new file named mmc_umount.sh in /etc/udev/scripts and paste the following lines. Make sure it is executable (chmod) by the user who will run it.

#!/bin/sh
umount /mnt/mmc1

Done. Boot your device without the card inserted and on the first insert, it will mount the device automatically. A umount is not really useful, since it will only be run when the card has already been ejected which renders it useless.