liblamb
Posts: 2
Joined: Sun Jul 22, 2012 3:01 am

Flashing an SD Card from an Android device

Sun Jul 22, 2012 3:07 am

The only SD Card reader/writer I have is an Android tablet. Can anyone give me tips on flashing the SD Card from Android? Thanks.

timothy3592
Posts: 64
Joined: Wed Jun 13, 2012 6:06 am

Re: Flashing an SD Card from an Android device

Sun Jul 22, 2012 4:36 am

Android devices are basically java running on a small linux system. So if your rooted (you can run su on your tablet) then your good to go.

You'll need:

1. A terminal emulator app, here's my favorite open source one https://github.com/jackpal/Android-Term ... /downloads
2. The su command
3. Some method of getting the decompressed image over to the android device.

How to:
First off, I'd recommend just shelling out for a usb card reader ($10 or less). If you still want to use the tablet because you either like to tinker or are very cheap then here's how.

1. Install the terminal emulator you downloaded.
2. run the app, you should have a terminal open with the android keyboard up
3. do some checks, attempt su, and dd, (failing dd, cat works its just cruder). busybox may also contain a dd applet, that works.
4. plug the tablet into your pc, and copy the uncompressed system image to the internal nand.
this is the easiest way unless you'd like to get insane with adb or some partitioning voodoo.
5. unmount your tablet from the pc.
6. insert target sdcard
7. terminal time.
8. ls /dev looking for mmcblk you might have an mmcblk0 and an mmcblk1 these are your sdcard and nand. Its likely that the higher numbered one is the one you inserted (0 was there first, you booted off it) but check around to make sure which is which.
a. which one has more partitions? say you have a /dev/mmcblk0p1 /dev/mmcblk0p2 etc... then mmcblk0 is probably the nand (android has a around 5 partitions splash, boot, recovery, userdata, system) and chances are the sdcard you inserted has 1 partition.
b. run the mount command in a terminal emulator. Can you pick out what is mounted on /system or /, don't trust what is mounted on /mnt/sdcard, its usually the internal nand.
c. unplug sdcard, run the ls /dev command again, plug in sdcard, run ls /dev, what new mmcblk device has appeared.
9. in a terminal emulator

Code: Select all

cd /mnt/sdcard #this is what comes up as internal when plugged into pc
#did you find dd
dd if=filenameof.img of=mmcblkX # where X is the number you found to be the sdcard's
#if you didn't find dd but had busybox put busybox before previous command
#lastly, if you found cat but not dd
cat filenameof.img > /dev/mmcblkX #again X is the sdcard
10. wait until flashing is finished (with some extra time thrown in for syncing) and remove the card perhaps asking the tablet to unmount it to be on the safe side.

All in all, I seriously wouldn't recommend using the tablet, I don't know if you might be able to plug it in and follow instructions as if the tablet were a card reader. I DO know that if you pick the wrong device in /dev you could at best write funny characters to your screen forcing you to reboot the tablet, or at worst (and its very likely) find the system partition in there and brick the tablet. Please just shell out for the card reader. :D

liblamb
Posts: 2
Joined: Sun Jul 22, 2012 3:01 am

Re: Flashing an SD Card from an Android device

Sun Jul 22, 2012 4:45 am

Yeah, that's what I suspected. Thanks for the reply.

ramas
Posts: 1
Joined: Tue Dec 15, 2015 11:13 am

Re: Flashing an SD Card from an Android device

Tue Dec 15, 2015 12:46 pm

I needed to install a copy of XBian on a micro-SD and I was able to do it on a card installed on an android phone.

First, root permission is needed on the android device.

Then it must be enough space on the nand flash to store the XBian (or anything else) image.

After connecting the device to the PC via USB cable, by ADB tools I got into the android device using command adb shell, and with standard linux shell commands (ls, cd, df, mount) I was able to identify the partiton on the nand memory where to store the image; it was on the /data partition.

With ADB tools I was able to copy the image (renamed here for brevity rpi2.img) in the nand memory, using the command adb push rpi2.img /data.

Then I had to restart the android device into recovery mode, to be able to access directly to the sd card; by exploring the partitions with adb shell commands I was able to know the block device related to the sd card, in my case was /dev/block/mmcblk1.

In order to flash the image, I issued the command dd if=/data/rpi2.img of=/dev/block/mmcblk1 in the adb shell session, then I put the micro-SD on the RPi2 and it started!

Hope it helps others :)

katiebell
Posts: 1
Joined: Sat Feb 20, 2016 6:40 pm

Re: Flashing an SD Card from an Android device

Sat Feb 20, 2016 6:44 pm

Ramas, thank you so much! This worked perfectly for me too, saved me from having to buy a card reader!

DragonAx
Posts: 1
Joined: Thu Apr 14, 2016 9:29 pm

Re: Flashing an SD Card from an Android device

Thu Apr 14, 2016 9:31 pm

Saved me from having to buy a computer...

Thanks!

Biggie69
Posts: 1
Joined: Wed Apr 20, 2016 8:06 am

Re: Flashing an SD Card from an Android device

Wed Jun 29, 2016 6:27 pm

I would just like to thank you gentlemen for your kind assistance..
Both @timothy3592 and @ramas (especially for /dev/block/mmcblck1 and ADB Shell ideas).. 8-)

I had to find a way to flash the *.img file to µSD without the reader, since the last working one in my house died yesterday. :shock:

Cheers gentlemen and keep up the good work..

YoungRpier
Posts: 1
Joined: Sat Apr 18, 2020 6:15 pm

Re: Flashing an SD Card from an Android device

Tue Apr 21, 2020 7:05 pm

Is there any simpler way of doing this? I am just a beginner and my only card reader broke. #stuckinquarentine

Return to “Beginners”