BEAGLEBONE BLACK: ACCESSING uSD AND USB STORAGE
ACCESSING THE uSD CARD
Once the operating system is flashed to the internal eMMC, the uSD card can be used as storage and it is a convenient means to store music tracks.
The command “fdisk -l” will list all the storage devices seen by the operating system:
Here is without any devices in the uSD slot. Listed is the internal eMMC storage device (listing only relevant parts):
After inserting a 32MB uSD card we see this additional device:
After inserting a 2 GB uSD card we see this device instead:
We realize that the any card inserted in the uSD slot is characterized by “/dev/mmcblk1p1″. “mmc” stands for “multimedia card” -both SD cards and eMMC devices conform to the “multimedia card” specification. “blk1″ I think represents “block device 1″ and “p1″ is “partition 1″
However, if the uSD card is already inserted during, we see the following:
The device is assigned /dev/mmcblk0p1. It appears the the order the device numbers are assigned at boot time is uSD card first, then internal eMMC.
Mounting the uSD card
In order to access the contents on the uSD card, the device must be first mounted. First create a “mount point” (a folder). Here I use the directory /media which is already present. Under /media create a directory to mount the uSD card. I created /media/card, /media/usb and /media/nas to represent the 3 different places where music tracks can be stored.
Use the command “mount”
The “-v” flag in “mount” is optional. Means “verbose”. Notice that after mounting the uSD card, I can see the “smallmusic” directory and 1 mp3 track.
Keep in mind that if the uSD card is already inserted at boot time, it is assigned “mmcblk0p1″ instead of “mmcblk1p1″
ACCESSING USB MEMORY STICK
If digital audio is transmitted through the I2S interface, then the USB host can also be used for a USB memory device.
The same procedure can be used to mount a usb memory stick:
- Insert a USB storage to the USB host connector
- Type “fdisk -l” to identify the device. Notice that it is /dev/sda1
- Type mount /dev/sda1 /”mount point” in my case, mount /dev/sda1 /media/usb
Inserting a USB storage device will show up as:
Since there is only one usb host port, a USB memory device will always appear as /dev/sda1 whether it is present during boot or not.
AUTOMATING THE MOUNT PROCESS
It becomes cumbersome to have to access the board through the command line in order to mount a storage device. For a music device, the ideal is to have these storage devices mounted automatically.
I tried different ways to auto-mount the devices when they are inserted:
- Autofs: looks like the most promising but did not work in my installation while following this excellent guide [link]
- usbmount: works well with uSD cards and USB storage at any time after boot, but when deleting the X11 package, it wound fail to mount uSD cards. usbmount was last updated in 2007 and is currently unmaintained.
- Add mount instructions in /etc/fstab which is invoked only during boot time.
For now the “best” option in my environment seems using /etc/fstab and ensuring the storage devices are present during boot. This seems a reasonable configuration for an audio player: Insert the storage devices and turn-on the device. Even if switching to another storage device requiring a reboot, the booting process is very short.
usbmount has better functionality because it works after boot. I didn’t like the fact that it stopped working for SD cards after I removed the X11 package (which I do not need). I’ll wait for more help on autofs and then I think I’ll switch to autofs.
For USB I added the following line to the /etc/fstab file.
Note the following:
- Add the “nofail” option. Without it the board will not be able to boot if no USB memory is present in the USB port.
- Ensure that the USB memory has a single partition since we are assuming it is always /dev/sda1. A newly formatted USB memory device will have a single partition
For the uSD Card and assuming that the card is inserted prior to boot, I added the following line:
Insert a uSD card and a USB memory device, boot the board and they will be mounted under /media/card and /media/usb (or whatever directory you had specified in /etc/fstab.