marc
marc

Reputation: 827

how do you find out which partition maps to which memory device type on embedded linux?

fdisk command does not provide ample details on this matter. I would like to know which hardware memory device maps to which partition node under /dev/ on embedded linux.

I am running 3.10 embedded linux (yocto project) on i.mx processor 6quad SABRESD for smart devices board.

Upvotes: 3

Views: 3742

Answers (1)

Craig McQueen
Craig McQueen

Reputation: 43446

You could get some information from udev, if you're using udev in your embedded system (since you're using Yocto, there's a good chance you're using udev unless you're really cutting it down to a minimal system).

For example, I'm running Yocto on a BeagleBone Black type system, which has an SD card and an on-board eMMC. The devices show up as /dev/mmcblk0 and /dev/mmcblk1, and which way around it is depends on which memory it booted from (boot device is always /dev/mmcblk0).

You can use udevadm info -a -n <dev-name> to get information about a device:

# udevadm info -a -n /dev/mmcblk0

Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.

  looking at device '/devices/ocp/48060000.mmc/mmc_host/mmc0/mmc0:b368/block/mmcblk0':
    KERNEL=="mmcblk0"
    SUBSYSTEM=="block"
    DRIVER==""
    ATTR{ro}=="0"
    ATTR{size}=="1953792"
    ATTR{stat}=="     585      388    38332     3420       78       64     1136     1370        0     2960     4790"
    ATTR{range}=="8"
    ATTR{discard_alignment}=="0"
    ATTR{force_ro}=="0"
    ATTR{ext_range}=="8"
    ATTR{alignment_offset}=="0"
    ATTR{inflight}=="       0        0"
    ATTR{removable}=="0"
    ATTR{capability}=="10"

  looking at parent device '/devices/ocp/48060000.mmc/mmc_host/mmc0/mmc0:b368':
    KERNELS=="mmc0:b368"
    SUBSYSTEMS=="mmc"
    DRIVERS=="mmcblk"
    ATTRS{cid}=="1b534d30303030301002b2ffa200b27f"
    ATTRS{csd}=="002f00325b5983b9edb7ff9f16400005"
    ATTRS{scr}=="0225000000000000"
    ATTRS{date}=="02/2011"
    ATTRS{name}=="00000"
    ATTRS{type}=="SD"
    ATTRS{preferred_erase_size}=="4194304"
    ATTRS{fwrev}=="0x0"
    ATTRS{hwrev}=="0x1"
    ATTRS{oemid}=="0x534d"
    ATTRS{manfid}=="0x00001b"
    ATTRS{serial}=="0x02b2ffa2"
    ATTRS{erase_size}=="512"

  looking at parent device '/devices/ocp/48060000.mmc/mmc_host/mmc0':
    KERNELS=="mmc0"
    SUBSYSTEMS=="mmc_host"
    DRIVERS==""

  looking at parent device '/devices/ocp/48060000.mmc':
    KERNELS=="48060000.mmc"
    SUBSYSTEMS=="platform"
    DRIVERS=="omap_hsmmc"

  looking at parent device '/devices/ocp':
    KERNELS=="ocp"
    SUBSYSTEMS=="platform"
    DRIVERS==""

Then you could make a udev rule to make a symbolic link to the device/partition you're interested in. E.g.:

SUBSYSTEM=="block", ATTRS{type}=="MMC", ATTR{partition}=="2", SYMLINK+="mmcblk-emmc-data"
SUBSYSTEM=="block", ATTRS{type}=="SD", ATTR{partition}=="2", SYMLINK+="mmcblk-sd-data"

Which should make a symlink or two:

# ls -al /dev/mmcblk-*
lrwxrwxrwx    1 root     root             9 Jul  1 17:34 /dev/mmcblk-emmc-data -> mmcblk1p2
lrwxrwxrwx    1 root     root             9 Jul  1 17:34 /dev/mmcblk-sd-data -> mmcblk0p2

Upvotes: 2

Related Questions