Author Topic: SD card blank after phone restart  (Read 1795 times)

Offline a01028a

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 11
  • Karma: 0
    • View Profile
SD card blank after phone restart
« on: April 03, 2015, 08:08:07 AM »
Hello,

My external SD card gets properly formated and mounted in GP. However, when the phone is restarted, the card format is not recognized any more, and it needs to be reformatted and therefore blanked. After that, it can be mounted but, obviously, the content has been erased.

Any idea? Thank you very much in advance

Offline christianlx-fra

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 19
  • Karma: 0
    • View Profile
Re: SD card blank after phone restart
« Reply #1 on: April 07, 2015, 01:04:31 PM »
Hi,

good luck with that...
I don't want to disappoint you but I have this problem since March 2014...
GP has already change my phone and I still have the problem with CM and with FOS. I install the OS from scrtach, the SD is recognized.... After a reboot, SD card disappeared. I've tested with 3 different SD card without succes and I'm still waiting an answer...

Christian.

Offline a01028a

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 11
  • Karma: 0
    • View Profile
Re: SD card blank after phone restart
« Reply #2 on: April 07, 2015, 01:22:28 PM »
 :(

Thank you for your answer. I have contacted GP, and they have asked me for more information about the problem. However, It seems that it is a known problem, and i don't think they are going to offer any solution. Anyway, if I find some solution or some working SD card brand i will make you know.

Best regards

Offline a01028a

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 11
  • Karma: 0
    • View Profile
Re: SD card blank after phone restart
« Reply #3 on: April 09, 2015, 01:47:47 PM »
 :)

Hello!

I come up with an interesting workaround. At least it works for me. When i restart the phone, the SD card format is not recognized any more and it needs to be reformatted. Then, I open a terminal app (or "adb shell" from PC). Being root, I run the following command:

ioctl /dev/block/mmcblk1 4703

Right away, the file system is detected and automatically mounted!.
My OS is Android 4.2.2 (the default one when i received the GP Revolution). However, i think this workaround can work with other linux-based operating systems.

Hope it helps!

PD: I provide a long explanation for those interested.

EXPLANATION

- For some reason (hardware problem?) the SD card cannot be read during boot. Perhaps it needs some time before the first read can take place.

- Once the phone is booted, the SD card is detected and it is working. In fact, it can be read in raw mode. For example, you can go to the terminal and run
   dd if=/dev/block/mmcblk1 of=/storage/emulated/0/test.img bs=512 count=4
to read the first 2K from the SD card

- The file /dev/block/mmcblk1p0 corresponds to the first partition in the SD card. However, this file is no present, because the SD card was not readable during boot. Therefore the partition cannot be mounted (if this file is not present, SD is seen as blank disk)

- In conclusion, it is necessary to make linux kernel to re-read the SD card, extract the partition table, and generate the /dev/block/mmcblk1p0 file

- There are several linux commands that perform this operation (partprobe, fdisk, hdparm). However, those commands are not available in my android (i'd like to install busybox, but this is another history)

- It turns that fdisk performs an ioctl system call with the BLKRRPART ioctl number, in order to make OS to rebuild the corresponding /dev files.

- There is an ioctl command in almost every Unix OS. The basic syntax is
    ioctl <device file> <number>

- By browsing "man ioctl_list" in a linux computer, it can be seen that the number corresponding to BLKRRPART is 0x0000125f=4703

- I end up with the command
    ioctl /dev/block/mmcblk1 4703