Using the SD card as extra storage on the Black

All,

Can someone point me in the right direction.

I’ve updated the Beagle Black via the SD card, now I want to be able to use an blank SD card for extra storage. If I just format a card and put it in the slot, the four LEDs light up and that’s it.

What do I need to do to use a blank card and mount it.

Many thanks,

Trefor

look into the uEnv.txt parameters. presumably even if you want to boot from eMMC the uEnv.txt file has to be present on the SD card, and with the correct parameters in it. If you google beaglebone black + uEnv.txt, you should land on the same wiki page i found a week or so ago. It seemed pretty informative.

Thanks, William.

I think to be honest, I’d rather boot off of the memory card and not mess about with using the eMMC but I just haven’t gotten around to looking at how to do that, yet.

Trefor

Trefor, what I’ve been able to figure out, there are few things preventing you from doing what you want right now. I could be wrong since I’ve just sort of muddled around as and when I’ve found the time. As you’ll see below, I eventually got something to work, but ymmv and there may be far more elegant ways to get there. Anyway, here is why this is a bit more painful that you might expect it to be:

(1) The kernel (including the most recent one) does not currently support the insertion and ejection of sdcard. As a result, the running kernel has no way to even see that you’ve inserted an sdcard, so nothing really works after that. The immediate implication is that once your BBB has booted and the kernel is up and running, the sdcard is essentially useless. If you insert an sdcard and do an “fdisk -l” it wont even list your card or the “/dev/mmcblk1” device.

(2) If I am right about (1) above, then your only option is to boot from sdcard after which both the on-board eMMC and the sdcard are visible to the kernel. However, there is a second complicating subtlety. The docs may lead you to conclude (as I initially did) that if the “USER/BOOT” button is NOT pressed at power on, then it boots from the eMMC and if it IS pressed, then it boots from the sdcard. From what I can see, this is sort of true. Here’s the catch: this is in fact the sequence that is used to determine where the u-boot boot loader is loaded from. However, once control is transferred to the bootloader, the boot loader always looks for a kernel on the sdcard if there is an sdcard inserted. This is why even if you dont press the USER/BOOT button and try and boot with a normal FAT32 formatted sdcard, it wont boot. That’s because the u-boot loader that loaded from eMMC is now up and running and trying to bootstrap from the inserted sdcard. The only way to get past this hurdle (without fixing u-boot) is to put an actual image there on that sdcard.

So now you see the dilemma: if the kernel is up and running, it cant see the sdcard. If the kernel is not running, then it’s up to u-boot, which can see the sdcard and so insists on trying to load the kernel image from the sdcard. The only way out of this situation therefore is to get a kernel image on the sdcard. In fact, ideally, we want to just put the kernel image (using dd) that’s already on the eMMC onto the sdcard and all would be great. Sadly, since you can’t even see the sdcard you can’t use the BBB to do this.

So, what you need to do is to partition the sdcard to be something that u-boot can boot from and then either copy a regular kernel image from the net or from your beaglebone eMMC into the sdcard. It’s not hard to do, and I did exactly that to get this all to work so I could use a 32G card, but it’s a bit of a pain since I had to do all of this on a mac. Let me know if you need to know how to do this, but this message is already long enough :slight_smile:

  • Vijay

I have a 32GB card and would like to use it for my root filesystem, would you happen to have a writeup of this process?

– Shae

It’s not too bad if you are on a Mac or on Linux. Here is it in a nutshell (on a Mac)

  1. On a mac you’ll need to have wget and 7za (or something to uncompress the .xz files).
  2. Grab a copy of the latest image (not the eMMC Flasher, just the latest image). I dont know why the 05.38 version isnt available yet but the 04.23 image is available here: http://downloads.angstrom-distribution.org/demo/beaglebone/

So just do something like this:

wget http://downloads.angstrom-distribution.org/demo/beaglebone/Angstrom-Cloud9-IDE-GNOME-eglibc-ipk-v2012.12-beaglebone-2013.04.13.img.xz

  1. Uncompress it to get the image:

7za x Angstrom-Cloud9-IDE-GNOME-eglibc-ipk-v2012.12-beaglebone-2013.04.13.img.xz

  1. Now insert your sdcard into your computer. It doesnt matter how big is, because this image is about 4G. The rest of the card will be unused. To get the image on to the sdcard, I used “dd” but you’ll have to make sure the device is not automatically mounted like the mac does. To see which is the sdcard I did:

diskutil list

and it’ll list all your disks. Identify the one corresponding to the sdcard. YOU DONT WANT TO GET THIS STEP WRONG since you are now going to write all over this disk and it is almost guaranteed to scramble your drive irrretrievably if you mess this up :slight_smile:

I’ll use diskX to denote the disk that is your sdcard. In my case it was /dev/disk1 … make absolutely you identify the right disk and then unmount (do NOT eject it) like this:

diskutil unmountDisk /dev/diskX

  1. Now you can overwrite the sdcard with the image you just grabbed using the “raw” disk. If you used /dev/diskX in the previous step, you now use “/dev/rdiskX” … note the “r” in “rdiskX” and once you are sure that this is the right device, do this:

dd if=Angstrom-Cloud9-IDE-GNOME-eglibc-ipk-v2012.12-beaglebone-2013.04.13.img of=/dev/rdiskX bs=10M

This step will likely take a while.

  1. That should be about it. When it finishes, eject the disk:

diskutil eject /dev/diskX

This sdcard should be bootable. It’ll have about 4G used up, but you can use fdisk+mkfs to format the unused space into extra space.

I think that was pretty much it. I did a few days ago and I’m repeating this from memory so I dont know if I missed anything. I’ll try and write it up and put it on a webpage if I get a chance to do that.

In case I didnt yell loud enough, don’t underestimate the importance of making sure you identify the right device in step 5 :slight_smile:

  • Vijay

Shae … I’m suddenly feeling very foolish. I just realized that although the BBB doesn’t recognize when a card is inserted into the on-board sdcard reader, it does have a USB port. So here is a very much simpler way to do what you want. I just tried it and it worked fine.

  1. Boot your BBB as normal
  2. Attach a USB microsdcard reader to the USB (using the normal USB Host connector, not the micro-usb you use to hook up to the computer). These are cheap and easily available … I see them at my local Frys for less than ten bucks from time to time.
  3. Insert your microsd card into the USB reader. It should be recognized on the BBB, usually as /dev/sda
  4. Make sure it is /dev/sda by doing: “fdisk -l” … I’ll assume its /dev/sda here, but you should use whatever you see on your system to make sure you arent overwriting the wrong thing :slight_smile:
  5. Copy the eMMC contents over to the sdcard like so:
    dd if=/dev/mmcblk0 of=/dev/sda bs=10M
  6. You’re done. This will be a bootable card, and the rest of the space is unused. You can use fdisk+mkfs to get it to look like you want.
  7. Unplug the sdcard from the reeader and plug it into the other end (sd reader built in to the BBB) and it should boot just fine.

I’m feeling a lot better about this now … I wish I had thought about the sdcard reader+usb sometime ago instead of messing with all those Mac commands!

  • VV

For now, that is the way to go.

Gerald

Don't do it. Unless its an industrial SD card (and I don't think
there are many 32G industrial SD) it has an excellent chance of
failing and causing you a lot of pain.
Most SD cards (including a number of ones that shipped with the BBW
are amazingly
unreliable POS without wear leveling/power cycle tolerance or any of
the other sane measure you're probably expecting.

Britton

Great description of an SD card.

Gerald

While on this subject, what about USB flash drives ? No real reason to ask other than perhaps we may eventually want to use some sort of external storage method for data logging.

We have a work around described above and that is good. Would not a proper solution, however, be to patch the kernel such that card insert/eject events were recognized? what would need done to accomplish such detection? Also might some work be done with the rom code that loads u-boot such that it simply makes it’s first choice of boot media based upon the boot button and upon not finding it goes on to alternate choices, then with u-boot such that u-boot makes note of other devices but uses the device it loaded from as /boot & / .

Eric

I am not sure if this is what you’re after but Im running debian from an SD card, Angstrom when booting fro mthe eMMC.

root@arm:~# ls -l /dev/mmc*
brw-rw—T 1 root floppy 179, 0 Dec 31 17:00 /dev/mmcblk0
brw-rw—T 1 root floppy 179, 1 Dec 31 17:00 /dev/mmcblk0p1
brw-rw—T 1 root floppy 179, 2 Dec 31 17:00 /dev/mmcblk0p2
brw-rw—T 1 root floppy 179, 8 Dec 31 17:00 /dev/mmcblk1
brw-rw—T 1 root floppy 179, 16 Dec 31 17:00 /dev/mmcblk1boot0
brw-rw—T 1 root floppy 179, 24 Dec 31 17:00 /dev/mmcblk1boot1
brw-rw—T 1 root floppy 179, 9 Dec 31 17:00 /dev/mmcblk1p1
brw-rw—T 1 root floppy 179, 10 Dec 31 17:00 /dev/mmcblk1p2

Thanks. It didn’t work to just mknod the device files. Maybe the way to go is to replace the eMMC bootloader with something that will boot even when blank or non-bootable sdcard is inserted in the BBB…

I spent a huge amount of time working with the original BeagleBoard a few years ago, but have not been working with it recently, and not had a BBB until this past week.

I’m trying to use a microsd card as extra storage while running on my beaglebone black. I thought I’d followed the correct directions to get the memory card formatted and configured correctly, but when I power on the BBB with the sd card inserted, all I get is solid LEDS.

Now I’ve got the SDCard in a usb adapter and mounted. I can see that the built in flash is /dev/mmcblk0. I’ve added lines to my uEnv.txt file according to http://dev.gentoo.org/~armin76/arm/beagleboneblack/install_emmc.xml#expand in hopes of getting the device to boot but am not having any luck. I think I’m confused as to the specific parameters, and the processor doing somethign slightly different depending on if it sees the removable card.

What I really want is for the board to boot from its internal storage, and mount the second partition from the microsd card over /home/ so that I can use all of that space for user storage.

I copied the entire contents of /dev/mmcblk0p1 to the FAT boot partition on the memory card, and then modified the uEnv.txt file on the memory card. Should that work?

Since it didn’t work, can someone tell me if I was close, and should have been able to fix it simply by using the correct options in the uEnv.txt file?

root@beaglebone:/media/BEAGLEBONE_# fdisk -l

Disk /dev/mmcblk0: 1920 MB, 1920991232 bytes
255 heads, 63 sectors/track, 233 cylinders, total 3751936 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Device Boot Start End Blocks Id System
/dev/mmcblk0p1 * 63 144584 72261 c W95 FAT32 (LBA)
/dev/mmcblk0p2 144585 3743144 1799280 83 Linux

Disk /dev/mmcblk0boot1: 1 MB, 1048576 bytes
4 heads, 16 sectors/track, 32 cylinders, total 2048 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk /dev/mmcblk0boot0: 1 MB, 1048576 bytes
4 heads, 16 sectors/track, 32 cylinders, total 2048 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk /dev/sda: 31.9 GB, 31914983424 bytes
64 heads, 32 sectors/track, 30436 cylinders, total 62333952 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Device Boot Start End Blocks Id System
/dev/sda1 * 63 144584 72261 c W95 FAT32 (LBA)
/dev/sda2 144585 62333951 31094683+ 83 Linux
root@beaglebone:/media/BEAGLEBONE_# cat /media/BEAGLEBONE_/uEnv.txt

bootpart=1:2
mmcroot=/dev/mmcblk1p2
optargs=quiet

What is the contents of your current uEnv.txt file ?

Anyhow to boot from the emmc you need a uEnv

.txt file that looks something like this.

mmcdev=1
bootpart=1:2
mmcroot=/dev/mmcblk1p2 ro

Grr, sorry for the multiposts kind of mufti tasking here. Sorry guys / Gals.

mmcdev=1
bootpart=1:2
mmcroot=/dev/mmcblk1p2 ro

That needs to be in a uEnv.txt file on the SD card.

I didn’t have the mmcdev=1 line. I’ll try that in the morning when I get around to rebooting the unit. The existing contents of my uEnv.txt file were:

bootpart=1:2
mmcroot=/dev/mmcblk1p2
optargs=quiet

Sabi ni William noong Thursday, June 27, 2013 10:35:07 AM UTC+8:

Grr, sorry for the multiposts kind of mufti tasking here. Sorry guys / Gals.

mmcdev=1
bootpart=1:2
mmcroot=/dev/mmcblk1p2 ro

That needs to be in a uEnv.txt file on the SD card.

Thanks. That worked, so I know my SD card and the SD slot are both working. I’ve been having trouble booting off any SD, and was afraid my 'bone’s slot wasn’t reading cards properly. Looking at other possibilities