Is msm_nand.c broken? - Wildfire Q&A, Help & Troubleshooting

I think msm_nand.c is broken because i got 56 bytes garbage from MEMREADOOB ioctl.
example code snippet:
memset(oobbuf, 0x55, 64);
oob.start = offs;
oob.length = 64;
oob.ptr = oobbuf;
if (ioctl(fd1, MEMREADOOB, &oob) != 0) {
perror("ioctl: ");
return -1;
}
page 0:
00000007E0: FF FF FF FF FF FF FF FF │ FF FF FF FF FF FF FF FF ˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙
00000007F0: FF FF FF FF FF FF FF FF │ FF FF FF FF FF FF FF FF ˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙
oob:
0000000800: 13 FD 23 69 75 23 8B 70 │ 52 8A A8 CF 56 CF FA 43 ‼ý#iu#<pRŠ¨ĎVĎúC
0000000810: 09 9F 79 FF A8 CF 56 CF │ FA 43 09 9F 79 FF 01 10 ○źy˙¨ĎVĎúC○źy˙☺►
0000000820: 00 00 01 00 00 30 00 00 │ 00 80 00 00 00 00 88 49 ☺ 0 _ _I
0000000830: 10 E2 F0 4E 39 B0 20 59 │ 55 55 55 55 55 55 55 55 ►âđN9° YUUUUUUUU
page 1:
0000000840: 03 00 00 00 01 00 00 00 │ FF FF 61 70 70 00 00 00 ♥ ☺ ˙˙app
Is it a driver bug? Anyone could fix it please?
htc wildfire buzz - Linux version 2.6.35.13-nFinity ([email protected]) (gcc version 4.4.3 (GCC)

Could it be caused by bad blocks on the nand? Can you provide a binary so I can test?

The blocks are good on this area. Thank you for testing.
You could download the source and binary at:
http://gnet.hu/memreadoob/memreadoob.c
http://gnet.hu/memreadoob/memreadoob

Other problem, I think we can't switch to MTD_MODE_RAW
i got this message in kernel log: msm_nand_read_oob: unsupported ops->len, 2112
but it doesn't contains MTD_OOB_RAW so we are not in raw mode.
cm-kernel/drivers/mtd/devices/msm_nand.c:
if (ops->datbuf != NULL &&
(ops->len % (mtd->writesize + mtd->oobsize)) != 0) {
pr_err("%s: unsupported ops->len,"
" %d for MTD_OOB_RAW\n", __func__, ops->len);
return -EINVAL;
}
}
if (ops->mode != MTD_OOB_RAW && ops->ooblen != 0 && ops->ooboffs != 0) {
pr_err("%s: unsupported ops->ooboffs, %d\n",
__func__, ops->ooboffs);
return -EINVAL;
}

phr3ak128 said:
Other problem, I think we can't switch to MTD_MODE_RAW
i got this message in kernel log: msm_nand_read_oob: unsupported ops->len, 2112
Click to expand...
Click to collapse
I have no such message in my kernel log.
I also ran memreadoob on my phone, and this is the output I got.
memreadoob
size: 262144000
erase size: 131072
write size: 2048
oob size: 64
2048 bytes readed
oob.start: 56
oob.length: 64
2048 bytes readed
oob.start: 56
oob.length: 64

Hi arco68,
Can we access the radio NAND after HBOOT has started AMSS (the radio OS?) I guess it is blocked by the radio? But I've read elsewhere that CWM 2.x can flash a radio.img, so it seems it does have access?

yes because in this test you read 2048 byte not 2112. it's other bug.
so if you see your /sdcard/test.img you will see the 56 bytes garbage on 0x800 instead of 64 bytes correct oob data.

xdbg said:
Hi arco68,
Can we access the radio NAND after HBOOT has started AMSS (the radio OS?) I guess it is blocked by the radio? But I've read elsewhere that CWM 2.x can flash a radio.img, so it seems it does have access?
Click to expand...
Click to collapse
CWM2 can flash radio yes, CWM3 can not. I don't think you want to mess with the radio part though.

phr3ak128 said:
yes because in this test you read 2048 byte not 2112. it's other bug.
so if you see your /sdcard/test.img you will see the 56 bytes garbage on 0x800 instead of 64 bytes correct oob data.
Click to expand...
Click to collapse
Well I have no idea what's correct or not to be honest. I'm sure if it was a major bug that it would have been fixed upstream a long time ago.
Have you tested with kernel 2.6.32, if it's the same?

Which kernel branch used from git for current nightly?

It's based on original HTC sources released on http://developer.htc.com/
My patched version, if you want to download and compile it yourself, is here:
https://github.com/arco/buzz-kernel-2.6.35

So, Are these bad for buzz? git://github.com/CyanogenMod/cm-kernel.git

What do you think who is the maintainer of msm_nand.c ?
When will be available 2.6.37 for buzz?

So, Are these bad for buzz? git://github.com/CyanogenMod/cm-kernel.git
Click to expand...
Click to collapse
Yes, it's for snapdragon devices.

phr3ak128 said:
What do you think who is the maintainer of msm_nand.c ?
When will be available 2.6.37 for buzz?
Click to expand...
Click to collapse
Google/Code Aurora, and probably some code done by HTC.
2.6.37 won't be available for the Tattoo. Anything higher than 2.6.35 I don't think will happen, unless some new phone with similar specs as the wildfire comes out with a newer kernel. And even then it could be impossible.

I see the msm-2.6.35 mtd driver is newer than yours. How possible this? I tried to complie that with msm_defconfig without success.

It's not compatible with our phone.

What is the problem with that, Is that not support MSM7225?

Think of it like this, you can't use the drivers for a Nvidia GeForce 9 card on an old GeForce 2 card, can you? If you understand what I mean?

phr3ak128 said:
What do you think who is the maintainer of msm_nand.c ?
When will be available 2.6.37 for buzz?
Click to expand...
Click to collapse
It's possible, but a huge amount of work. Porting all the hardware and making sure it works fine is really not trivial. It's time consuming, and the benefit right now of using 2.6.37 instead of 2.6.35 is unclear to me.

Related

Garmin-Asus M10 dual booting with android Garmin-Asus A10 ROM

M10 and A10 have such similar hardware, hopefully, the A10's ROM would be an ideal candidate for dual booting android in M10.
Anyone who has the same thoughts?
If someone could get the A10 ROM, I can try creating a kitchen and an android ROM for M10. I am no expert, but I think my linux knowledge should help.
can this help?
kindly google for software update of A10. i was not allowed to post the link.
i am new to windows mobile but i will certainly like too see android on m10.
these are my 2 cents
hope this helps.
http://www.garminasus.com/zh_TW/support/a10-updates.html
Thanks guys. The update link gave me a ext2fs file system image. Which after unpacking has 4 files:
1. 512_A10_PACKAGE.raw (probably the most iteresting part, 284MB)
2. system_version.sig
3. 512_A10_PACKAGE.raw.sig
4. system_version
I am still trying to dig and figure out what the raw file is. All comments and tips are welcome.
I hope you succeed
http://forum.xda-developers.com/showthread.php?t=455648
Really looking forward to run android on my M10, it will be super cool!
Here is a hex dump of the first few kbs of the raw file:
00000000 50 61 63 6b 61 67 65 20 6f 66 20 53 44 20 44 6f |Package of SD Do|
00000010 77 6e 6c 6f 61 64 00 ff ff ff ff ff ff ff ff ff |wnload..........|
00000020 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
*
00000040 4d 6f 6e 20 4f 63 74 20 31 38 20 31 34 3a 31 39 |Mon Oct 18 14:19|
00000050 3a 30 37 20 32 30 31 30 0a 00 ff ff ff ff ff ff |:07 2010........|
00000060 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
*
00000080 0a 00 00 00 b0 ed 5b 1c ff ff ff ff ff ff ff ff |......[.........|
00000090 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
*
000001f0 70 61 72 74 69 74 69 6f 6e 2e 6d 62 6e 00 ff ff |partition.mbn...|
00000200 ff ff ff ff ff ff ff ff 00 04 00 00 d0 01 00 00 |................|
00000210 71 63 73 62 6c 68 64 5f 63 66 67 64 61 74 61 2e |qcsblhd_cfgdata.|
00000220 6d 62 6e 00 ff ff ff ff d0 07 00 00 84 2c 00 00 |mbn..........,..|
00000230 71 63 73 62 6c 2e 6d 62 6e 00 ff ff ff ff ff ff |qcsbl.mbn.......|
00000240 ff ff ff ff ff ff ff ff 54 36 00 00 f0 df 00 00 |........T6......|
00000250 6f 65 6d 73 62 6c 2e 6d 62 6e 00 ff ff ff ff ff |oemsbl.mbn......|
00000260 ff ff ff ff ff ff ff ff 44 18 01 00 e8 b8 0e 00 |........D.......|
00000270 61 6d 73 73 2e 6d 62 6e 00 ff ff ff ff ff ff ff |amss.mbn........|
00000280 ff ff ff ff ff ff ff ff 2c d3 0f 00 28 e0 2d 01 |........,...(.-.|
00000290 61 70 70 73 62 6f 6f 74 2e 6d 62 6e 00 ff ff ff |appsboot.mbn....|
000002a0 ff ff ff ff ff ff ff ff 54 b5 3d 01 5c d9 00 00 |........T.=.\...|
000002b0 61 70 70 73 2e 6d 62 6e 00 ff ff ff ff ff ff ff |apps.mbn........|
000002c0 ff ff ff ff ff ff ff ff b0 90 3e 01 28 98 36 00 |..........>.(.6.|
000002d0 72 65 63 6f 76 65 72 79 2e 69 6d 67 00 ff ff ff |recovery.img....|
000002e0 ff ff ff ff ff ff ff ff d8 2a 75 01 00 00 42 00 |.........*u...B.|
000002f0 75 73 65 72 64 61 74 61 2e 6e 61 6e 64 69 6d 67 |userdata.nandimg|
00000300 00 ff ff ff ff ff ff ff d8 2c b7 01 80 10 00 00 |.........,......|
00000310 73 79 73 74 65 6d 5f 65 78 74 33 2e 69 6d 67 00 |system_ext3.img.|
00000320 ff ff ff ff ff ff ff ff 58 3f b7 01 00 00 00 10 |........X?......|
00000330 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
*
000003f0 53 69 6e 67 68 6f 6d 65 5f 4c 65 65 00 ff ff ff |Singhome_Lee....|
00000400 53 52 31 00 ff ff ff ff ff ff ff ff ff ff ff ff |SR1.............|
00000410 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
....
I see two headers. Followed by a section which may be some signature? And then a file list. The rest of the contents is possibly files. I am not sure what the number at the end of each file name means. The file name "recovery.img" got my hopes high.
Linux does not directly recognize this format. It may be custom. Will try extracting recovery.img assuming the rest of the file is somehow delimited. If someone can recognize the format, that would be great. As usual, all comments are welcome.
i think same with you
m10 may be use android
you are cool
Howabout using A50 updated Rom since M10 and A50 share the same screen size.
Link: http://www.garminasus.com/en_AU/support/nuvifone-a50-software-updates.html
hey akku good work. keep going. yaar i dont know any thing but i think u should ask guy who ported android on p 535 asus pda.
hope this helps.
dude plzzzz port android to m10. m dying for it.
Hello! The following links are useful?
http://www.godevice.com/2010/08/19/convert-your-windows-mobile-into-android-device/
Thanks for all the tips guys. Just managed to extract the following files from the update package:
system_ext3 file system image:
http://hotfile.com/dl/83156994/76dbe38/system_ext3.img.zip.html
recovery.img and the extracted components:
http://hotfile.com/dl/83167576/975a3e1/recovery.img.d.zip.html
the recovery.img package contains the extracted contents as well, thanks to split_booting.pl posted on the other forum.
Did not bother extracting the other files in the update package. Not sure if they are important.
Disclaimer: There was no licence when I downloaded the original file. I own an M10 and so I hope I have the right to do whatever I am doing. You are responsible to check your own license rights.
Trying to put these together with haret next.
Great man,
Please, continue working on this. I think a lot of people will be very grateful if you succeed.
If you need any support or donation to continue, just say.
Cool~~
Could you find the following files in recovery.img??
another doc says..if you can find zImage, at least you can boot into linux command line mode.
-rootfs.img
-system.ext2 (system_ext3??)
-zImage
multi888 said:
Howabout using A50 updated Rom since M10 and A50 share the same screen size.
Click to expand...
Click to collapse
Its bed idea. M10s screen has size 800x480 but screen on A50 has size 480x320 and A50s screen supports multitouch. So, I don't think that A50 image is sutable for M10.
aaaku
Keep going!
Have you tried to boot image on M10? And could you please share with us your progress. I mean, what have you done and what is to be done.
Guys, my current attempts are to
1. pick up one of the htc dual boot android roms
2. Replace the fs, kernel and initrd
3. try to boot.
Haret always crashes with some unknown exception. If I know linux, screen size shouldn't be a big issue. There should be params to change this. The reason for picking up A10 rom is the processor match and the rest of device driver compatibility. Please let me know if anyone thinks otherwise.
Feel free to cook things yourself too. As I said, I am no android or mobile expert. I just know some linux. If you want me to extract something from a different update file, I can do that.
Does anyone know how to extract anything from an update exe. Is it some kind of self extracting zip ?
Dear aaaku,
What tools do you use to extract files from 512_A10_PACKAGE.raw? Could you explain this part?? Thanks~
After reserched some documents, i think the problem is haret itself. Haret don't seem to support MSN7227 cpu, so it misrecognize msm7227 as an ARMv6 cpu.
Here are some relative posts..
http://forum.xda-developers.com/showthread.php?p=7834782
http://lists.linuxtogo.org/pipermail/haret-devel/2010-February/000006.html
Was there any luck in porting android to M10? I am interested in it.
sad to know that ... even htc hd mini has no android 4 it.... m10 n htc mini share same processor... too bad to hear that....
i suggest lets put up a bounty to develop a haret for both phones... any one in?

Key To Unlocking Bootloader Found!

This is excellent news!
Read here: Sholes Keyleak Explained
and here: Twitter Feed
It won't be long now!
Great news I hope Cyanogen is ported soon. And hello to Gingerbread.
Very nice!!!!!!:d
It's a shame Eugene_373's Defy bit the dust.
We could really use a Dev of his skills now.
How can I get the variable s and data?
k = s - sha1sum(data)
P.S.: His explanation: the vulnerability is that p is 0, which makes r=1, which makes s = sha1sum(data) - k
Did you get the keys posted on Twitter?
psicodelico said:
How can I get the variable s and data?
k = s - sha1sum(data)
P.S.: His explanation: the vulnerability is that p is 0, which makes r=1, which makes s = sha1sum(data) - k
Click to expand...
Click to collapse
Beach_Head said:
Did you get the keys posted on Twitter?
Click to expand...
Click to collapse
that is for milestone, we need the values from Defy to found the Key.
Have you tried?
There's no mention that the key is different for all phones using the Sholes platform...
psicodelico said:
that is for milestone, we need the values from Defy to found the Key.
Click to expand...
Click to collapse
No, I didn't try yet. I'm just waiting... . Let the things happen.
I'll be testing it when I get home.
I hope I don't brick my device in the process...
psicodelico said:
No, I didn't try yet. I'm just waiting... . Let the things happen.
Click to expand...
Click to collapse
Great news. Hope other devs jump into this right away. Will be looking forward.
Maybe is easier to post the keys here:
7e 21 a8 37 64 12 75 a3 47 13 54 42 12 48 58 12 71 a4 5e 41 a7 64 72 34 2a 6f e2 0a 97 8f <== sholes private key
97 6a 21 7a 67 41 37 9f 26 53 4a 61 7f 2a 86 ae ff 71 21 78 2e 61 4f 71 90 3e 00 27 fe 9b <== initialization vector
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <== nonce (e)
Click to expand...
Click to collapse
Taken from William Pitcock twitter: http://twitter.com/nenolod
Hi, but what does it meen?
What can we do now?
And how?
Can we crack the bootloader?
Custom ROms?Kernel?Cyanogenmod 7 for defy??
Sweet maybe in the future there'll be a cool rom for my Droid 2 global
Sent from my DROID2 GLOBAL using XDA App
But what we have to do now?
What can we do with this information an keys?
So we gettin custom kernels soon?
Sent from my thumbs
Your recovery must update the signatures on the Codegroup Descriptor Table (CDT). If it does not, your recovery will brick the phone if you attempt to flash a custom ROM.
I understand nothing ))
Who can do this?
Where are the defy gurus!!!!
I can't belive it! It must to be an april fool! *_*
totally awesome *.*
can't wait to see the first custom kernels

adb is the only thing not working, bricked??

My problem ; no adb connection in booted OS nor in recovery .
everything else works fine; sdcard, bluetooth , mounting sd on PC all ok.
my handset : pvt4, oxygen Hboot, S-off
I allready tried "fastboot oem eraseconfig"
but stil no adb connection possible..
before I do anything stupid I want to make sure if I have the usb-brick
cause it seems I haven't apart from the not working adb.
I can adb with my other pvt3 desire so my pc setup is ok.
Is it possible to have usb brick whilst everything else apart from adb is working fine?
Is there something that can be checked? I have uploaded my misc.img
for the specialists amongst us to see if its ok or not
Hope anyone can shed some light on this.
ps similar post of me in usb brick thread in developer section but I thought
I had more chance on an answer here.
grtz lanbase
well you dont have USB brick
what happens when you do adb devices ?
also make sure your ADB is installed properly (try reinstalling?) and maybe try with diffrent ROM ?
hi,
just edit your misc img =>
00000000:48 54 43 5f 5f 33 30 34 00 ff ff ff ff ff ff ff HTC__304.ÿÿÿÿÿÿÿ
00000010:00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000020:44 65 76 69 63 65 57 61 72 6d 42 6f 6f 74 00 ff DeviceWarmBoot.ÿ
00000030:ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00000040:ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
00000050:43 45 20 53 65 72 69 61 6c 20 49 6e 55 73 65 00 CE Serial InUse.
00000060:44 65 62 75 67 20 43 61 62 6c 65 20 45 6e 61 00 Debug Cable Ena.
00000070:43 45 20 20 20 55 53 42 20 20 49 6e 55 73 65 00 CE USB InUse.
00000080:00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000090:43 6c 65 61 72 41 75 74 6f 49 6d 61 67 65 20 00 ClearAutoImage .
000000a0:32 2e 32 39 2e 34 30 35 2e 32 00 00 00 00 00 2.29.405.2.....
so to my point of veiw your file is right (see first line)
compare to mine it s all right (mine is HTC_204)
i won't say it s usb brick, when plug did you look at device manager??
know that your comp is fine but maybe the also right just sof issue.
just to be sure
hoe tis help
dzumagos said:
what happens when you do adb devices?
Click to expand...
Click to collapse
You should a serial number followed by "device" - this confirms your PC is recognizing your device.
thanx dzumagos for confirming my misc.img is ok, that's what I thought; no usb brick, then why the hell is adb not working on this device and working fine on my other one???
adb devices command doesn't
give me anything.
I have 2 desires, one of them is ok and gives me the serial as it should.
the one with non working adb just returns with command promt.
Sent from my HTC Desire using Tapatalk
hi,
i won't say it s usb brick, when plug did you look at device manager??
know that your comp is fine but maybe the also right just sof issue.
just to be sure
Click to expand...
Click to collapse
Thanx mate, for making me look at device manager when I plug in the phone. I noticed "adb with an exclamation mark" when plugging in my pvt4 and "android adb interface" when plugging in my pvt3
in device manager.
I reinstalled the adb driver with the pvt4 plugged in and now both devices have working adb!!! who would have thought that adb driver was corrupted somehow and able to recognize one phone and not the other....
Anyhow problem solved! thanx guys!
Sent from my HTC Desire using Tapatalk

[ASK] Link2SD for galaxy W

I wanna ask,
is galaxy w need link2sd installed?
what setting that would be good if installing link2sd?
Actually it depends on how much applications you want being installed on your phone but yes it worths installing it for at least 5 reasons:
Being able to mount to your computer your SD cards using the debug mode without stopping the applications that you should have moved to the SD card using the native App2SD.
Not being limited by the size of the /data partition because of the *.dex files generated for the dalvik cache.
You can move any kind of applications even those that are not movable to SD!
Link2SD includes free utilities like conversion of system application to user application (and vice versa) that you'll have to pay for with other solutions like Titanium Backup.
Avoiding slow downs because of the loop mounts created (Just run the "mount" command from an adb shell or terminal and you'll see).
Indeed I noticed a global slow down of my phone after I've started getting more and more applications being installed and beside I'm using some other tool to avoid push services and other unwanted background processes to be started by some applications, I've come to the conclusion that too many loop mounts because of the native App2SD is not good either (I suspect it takes over the RAM).
Actually the Link2SD FAQ will give you all the good reasons why to use it:
http://www.link2sd.info/faq
Recommendations:
I'd like to also share share my experience (I may move the following to another thread):
Recommend microSD cards:
Regarding the microSD card you can use even a 32 GB class 10.
The ones I recommend (32 GB class 10) are Samsung, SanDisk, Transcend (Those Transcend ones made in Korea are logically made by Samsung, the ones made in China are made by SanDisk).
Partitionning and formatting:
The tough part is the partitioning and formatting.
Out of the box, all the microSD cards are partitioned and formatted so that they are aligned with their erase block size (it can be 8 MiB, 12 MiB...)
Thus you'll have to consult so you'll know the erase block size:
the Linaro flash card survey:
https://wiki.linaro.org/WorkingGroups/Kernel/Projects/FlashCardSurvey
the corresponding flashbench mailing list
http://lists.linaro.org/mailman/listinfo/flashbench-results
You can also use the flashbench tool to figure it out.
The problem is that you cannot create or resize the FAT32 partition using Windows (even with minitool partition or paragon partition manager), nor with Linux by using gparted or other because you won't get your partitions aligned with the erase blocks and thus you'll get bad performances and faster wearing of your card.
Backup:
Before formatting do a raw backup of the first 16 MiB (for the partitions table and the FAT32 description) using busybox dd on the phone itself or dd on Linux.
For example on the phone:
dd if=/dev/block/mmcblk1 of=/sdcard/mmcblk1-orig-1st-16MiB.img bs=4M count=4
Also you must keep using the default cluster size of 32 kiB because of optimization done at the level of Android and because smaller cluster size will mean more memory taken from the RAM - Actually the FAT is loaded in the RAM, so you must keep it not too big.
Formulas:
Then decide how much you need for the Link2SD partition - You can start with 1 GiB or so, personally I use about 2 GiB. You can check how much space is taken by the asec images to decide...
Now here comes some math (The formulas are to be used in LibreOffice Calc):
Partitioning:
We need to define the new size for the FAT32 partition at the beginning so it is aligned with the erase block size and so that the File Allocation Tables are located between the special offsets (especially true with SanDisk - for example the FAT must be located between the offsets at 4 MiB and 12 MiB, that's why most SD card have 4 MiB unpartitioned free space at the beginning).
Code:
new_fat32_partition_size = MROUND(whole_microsd_size - wanted_link2sd_partition_size + fat32_start_offset ; erase_block_size) - fat32_start_offset
With:
whole_microsd_size: The actual total size of the card - You can get it using fdisk.
wanted_link2sd_partition_size: The size you'd like for the Link2SD partition.
fat32_start_offset: The offset where the 1st FAT32 partition starts.
erase_block_size: The erase block size.
So for example for a SanDisk microSDHC 32 GB Class 10, we have an erase block size of 12 MiB (actually 3 times 4 MiB) and a FAT description that has to start at the offset at 4 MiB and then next erase block that starts at the offset at 12 MiB.
Therefore you'll have:
Code:
new_fat32_partition_size = MROUND(30,101,504 kiB - 1,061,376 kiB + 4,194,304 kiB ; erase_block_size) - 12 582 912 kiB = 30,101,504 kiB
Therefore using fdisk you should get something like the following when printing the partitions (p) - Don't forget to disable the DOS compatibility flag and use the sector as the unit:
Code:
Disk /dev/mmcblk0: 31.9 GB, 31914983424 bytes
4 heads, 16 sectors/track, 973968 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: 0x9a064f9d
Device Boot Start End Blocks Id System
/dev/mmcblk0p1 8192 60211199 30101504 c W95 FAT32 (LBA)
/dev/mmcblk0p2 60211200 62333951 1061376 83 Linux
FAT32 formatting:
In order to use mkdosfs 3.0.9 or later with the right amount of reserved sectors so the root directory and data will start exactly at the next erase block offset.
The idea is to make so that the FATs ends exactly before that offset, but for that we need to know the size of one FAT.
Here is the formula based on mkdosfs source code, to calculate that needed number of reserved sectors:
Code:
total_number_of_sectors = total_number_of_blocks * block_size / sector_size
number_of_sectors_for_fats_and_data = total_number_of_sectors - MROUND(default_number_of_reserved_sectors ; cluster_size)
number_of_clusters = (number_of_sectors_for_fats_and_data * sector_size + number_of_fats * 8) / (cluster_size * sector_size + number_of_fats * 4)
fat_size = MROUND(CEILING((number_of_clusters + 2) * 4 / sector_size ; 1) ; cluster_size)
root_directory_offset = default_number_of_reserved_sectors + number_of_fats * fat_size
aligned_root_directory_offset = MROUND(root_directory_offset ; erase_block_size * 1024^2 / sector_size)
number_of_reserved_sectors = aligned_root_directory_offset - root_directory_offset + default_number_of_reserved_sectors
With:
sector_size: 512 bytes (Standard value)
block_size: 1,024 bytes (Standard value)
total_number_of_blocks: new_fat32_partition_size in kiB
default_number_of_reserved_sectors: 64 (can be 32)
cluster_size: 64 sectors (i.e. 32 kiB)
number_of_fats: 2 (Standard value)
So for example for that same card you'll get:
Code:
total_number_of_sectors = 60,203,008
number_of_reserved_sectors = 1,664
Therefore here is the command to format the FAT32 partition:
Code:
$> sudo mkdosfs -F 32 -s 64 -R 1664 -n EXTERNAL_SD -v /dev/mmcblk0p1
mkdosfs 3.0.9 (31 Jan 2010)
/dev/mmcblk0p1 has 4 heads and 16 sectors per track,
logical sector size is 512,
using 0xf8 media descriptor, with 60203008 sectors;
file system has 2 32-bit FATs and 64 sectors per cluster.
FAT size is 7360 sectors, and provides 940416 clusters.
There are 1664 reserved sectors.
Volume ID is 8aa89e36, volume label EXTERNAL_SD.
You can see that each FAT takes less than 3.6 MiB, so with 2 FATs and the reserved sector the FAT description takes less than 8 MiB.
You can then check using hexdump if indeed the root directory starts at the the 12 MiB offset (knowing that the partition begin at the 4 MiB offset - indeed 12 = 4 + 8).
For that let's read the first 13 MiB of the card:
Code:
$> sudo hd -n $[13*1024*1024] /dev/mmcblk0
00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
000001b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 80 82 |................|
000001c0 03 00 0c f8 95 a3 00 20 00 00 00 a0 96 03 00 f8 |....... ........|
000001d0 96 a3 83 1b f3 28 00 c0 96 03 00 64 20 00 00 00 |.....(.....d ...|
000001e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
000001f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa |..............U.|
00000200 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
00400000 eb 58 90 6d 6b 64 6f 73 66 73 00 00 02 40 80 06 |[email protected]|
00400010 02 00 00 00 00 f8 00 00 10 00 04 00 00 00 00 00 |................|
00400020 00 a0 96 03 c0 1c 00 00 00 00 00 00 02 00 00 00 |................|
00400030 01 00 06 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00400040 00 00 29 e5 a5 dc 46 45 58 54 45 52 4e 41 4c 5f |..)...FEXTERNAL_|
00400050 53 44 46 41 54 33 32 20 20 20 0e 1f be 77 7c ac |SDFAT32 ...w|.|
00400060 22 c0 74 0b 56 b4 0e bb 07 00 cd 10 5e eb f0 32 |".t.V.......^..2|
00400070 e4 cd 16 cd 19 eb fe 54 68 69 73 20 69 73 20 6e |.......This is n|
00400080 6f 74 20 61 20 62 6f 6f 74 61 62 6c 65 20 64 69 |ot a bootable di|
00400090 73 6b 2e 20 20 50 6c 65 61 73 65 20 69 6e 73 65 |sk. Please inse|
004000a0 72 74 20 61 20 62 6f 6f 74 61 62 6c 65 20 66 6c |rt a bootable fl|
004000b0 6f 70 70 79 20 61 6e 64 0d 0a 70 72 65 73 73 20 |oppy and..press |
004000c0 61 6e 79 20 6b 65 79 20 74 6f 20 74 72 79 20 61 |any key to try a|
004000d0 67 61 69 6e 20 2e 2e 2e 20 0d 0a 00 00 00 00 00 |gain ... .......|
004000e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
004001f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa |..............U.|
00400200 52 52 61 41 00 00 00 00 00 00 00 00 00 00 00 00 |RRaA............|
00400210 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
004003e0 00 00 00 00 72 72 41 61 7e 59 0e 00 03 00 00 00 |....rrAa~Y......|
004003f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa |..............U.|
00400400 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
00400c00 eb 58 90 6d 6b 64 6f 73 66 73 00 00 02 40 80 06 |[email protected]|
00400c10 02 00 00 00 00 f8 00 00 10 00 04 00 00 00 00 00 |................|
00400c20 00 a0 96 03 c0 1c 00 00 00 00 00 00 02 00 00 00 |................|
00400c30 01 00 06 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00400c40 00 00 29 e5 a5 dc 46 45 58 54 45 52 4e 41 4c 5f |..)...FEXTERNAL_|
00400c50 53 44 46 41 54 33 32 20 20 20 0e 1f be 77 7c ac |SDFAT32 ...w|.|
00400c60 22 c0 74 0b 56 b4 0e bb 07 00 cd 10 5e eb f0 32 |".t.V.......^..2|
00400c70 e4 cd 16 cd 19 eb fe 54 68 69 73 20 69 73 20 6e |.......This is n|
00400c80 6f 74 20 61 20 62 6f 6f 74 61 62 6c 65 20 64 69 |ot a bootable di|
00400c90 73 6b 2e 20 20 50 6c 65 61 73 65 20 69 6e 73 65 |sk. Please inse|
00400ca0 72 74 20 61 20 62 6f 6f 74 61 62 6c 65 20 66 6c |rt a bootable fl|
00400cb0 6f 70 70 79 20 61 6e 64 0d 0a 70 72 65 73 73 20 |oppy and..press |
00400cc0 61 6e 79 20 6b 65 79 20 74 6f 20 74 72 79 20 61 |any key to try a|
00400cd0 67 61 69 6e 20 2e 2e 2e 20 0d 0a 00 00 00 00 00 |gain ... .......|
00400ce0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
00400df0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa |..............U.|
00400e00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
004d0000 f8 ff ff 0f ff ff ff 0f f8 ff ff 0f ff ff ff 0f |................|
004d0010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
00868000 f8 ff ff 0f ff ff ff 0f f8 ff ff 0f ff ff ff 0f |................|
00868010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
00c00000 45 58 54 45 52 4e 41 4c 5f 53 44 08 00 00 52 b3 |EXTERNAL_SD...R.|
We can see that indeed the root partition starts at the offset 0x00c00000 which is 12 MiB!
Also note that 0x00400000 is the 4 MiB offset, the beginning of the FAT32 partition...
You can try the hexdump against the backup you did and you'll see that the factory formatting is also with a number of reserved sector so that the root directory is aligned. For example I've found the root directory at the 12 MiB offset (of course) and for that they use 1,170 reserved sector (I've decoded the hexdump to get that value) which matches the formula. They also set 8,192 hidden sectors - that's more for compatibility with some cameras, we don't care here...
Link2SD formatting:
I use ext4 for that partition, I've got inspiration from http://blogofterje.wordpress.com/2012/01/14/optimizing-fs-on-sd-card/, however I'm not sure if indeed using the stride and the stripe-width options is really needed:
Code:
[FONT=Courier New]$ sudo mkfs.ext4 -O ^has_journal -E stride=4,stripe-width=512 -b 4096 -L Link2SD /dev/mmcblk0p2
mke2fs 1.41.14 (22-Dec-2010)
Filesystem label=Link2SD
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=4 blocks, Stripe width=512 blocks
66384 inodes, 265344 blocks
13267 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=272629760
9 block groups
32768 blocks per group, 32768 fragments per group
7376 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376
Writing inode tables: done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 30 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.[/FONT]
Anyway I consider the Link2SD partition is going to be used much more for read than write and we need the same file system that is used on the other partitions of the phone (i.e. ext4).
I hope it's not too complicated and that will help
Some other references:
http://android.bytearrays.com/android/align-your-sdcard-fat-and-ext-partition/
http://www.bradfordembedded.com/2011/12/format-an-sd-card-with-8-mib-aligned-partitions/
http://www.olpcnews.com/forum/index.php?topic=4993.0
http://www.patriotmemory.com/forums...ite-speed-by-aligning-FAT32&p=41521#post41521
http://forum.xda-developers.com/showthread.php?t=1224408
What a long and completed answer
I'll read and try to understand the way one-by-one. Thanks for sharing your knowledge!
Sent from my GT-I8150 using Tapatalk 2
v0rt3x said:
Actually it depends on how much applications you want being installed on your phone but yes it worths installing it for at least 5 reasons:
Being able to mount to your computer your SD cards using the debug mode without stopping the applications that you should have moved to the SD card using the native App2SD.
Not being limited by the size of the /data partition because of the *.dex files generated for the dalvik cache.
You can move any kind of applications even those that are not movable to SD!
Link2SD includes free utilities like conversion of system application to user application (and vice versa) that you'll have to pay for with other solutions like Titanium Backup.
Avoiding slow downs because of the loop mounts created (Just run the "mount" command from an adb shell or terminal and you'll see).
Indeed I noticed a global slow down of my phone after I've started getting more and more applications being installed and beside I'm using some other tool to avoid push services and other unwanted background processes to be started by some applications, I've come to the conclusion that too many loop mounts because of the native App2SD is not good either (I suspect it takes over the RAM).
Actually the Link2SD FAQ will give you all the good reasons why to use it:
http://www.link2sd.info/faq
Recommendations:
I'd like to also share share my experience (I may move the following to another thread):
Recommend microSD cards:
Regarding the microSD card you can use even a 32 GB class 10.
The ones I recommend (32 GB class 10) are Samsung, SanDisk, Transcend (Those Transcend ones made in Korea are logically made by Samsung, the ones made in China are made by SanDisk).
Partitionning and formatting:
The tough part is the partitioning and formatting.
Out of the box, all the microSD cards are partitioned and formatted so that they are aligned with their erase block size (it can be 8 MiB, 12 MiB...)
Thus you'll have to consult so you'll know the erase block size:
the Linaro flash card survey:
https://wiki.linaro.org/WorkingGroups/Kernel/Projects/FlashCardSurvey
the corresponding flashbench mailing list
http://lists.linaro.org/mailman/listinfo/flashbench-results
You can also use the flashbench tool to figure it out.
The problem is that you cannot create or resize the FAT32 partition using Windows (even with minitool partition or paragon partition manager), nor with Linux by using gparted or other because you won't get your partitions aligned with the erase blocks and thus you'll get bad performances and faster wearing of your card.
Backup:
Before formatting do a raw backup of the first 16 MiB (for the partitions table and the FAT32 description) using busybox dd on the phone itself or dd on Linux.
For example on the phone:
dd if=/dev/block/mmcblk1 of=/sdcard/mmcblk1-orig-1st-16MiB.img bs=4M count=4
Also you must keep using the default cluster size of 32 kiB because of optimization done at the level of Android and because smaller cluster size will mean more memory taken from the RAM - Actually the FAT is loaded in the RAM, so you must keep it not too big.
Formulas:
Then decide how much you need for the Link2SD partition - You can start with 1 GiB or so, personally I use about 2 GiB. You can check how much space is taken by the asec images to decide...
Now here comes some math (The formulas are to be used in LibreOffice Calc):
Partitioning:
We need to define the new size for the FAT32 partition at the beginning so it is aligned with the erase block size and so that the File Allocation Tables are located between the special offsets (especially true with SanDisk - for example the FAT must be located between the offsets at 4 MiB and 12 MiB, that's why most SD card have 4 MiB unpartitioned free space at the beginning).
Code:
new_fat32_partition_size = MROUND(whole_microsd_size - wanted_link2sd_partition_size + fat32_start_offset ; erase_block_size) - fat32_start_offset
With:
whole_microsd_size: The actual total size of the card - You can get it using fdisk.
wanted_link2sd_partition_size: The size you'd like for the Link2SD partition.
fat32_start_offset: The offset where the 1st FAT32 partition starts.
erase_block_size: The erase block size.
So for example for a SanDisk microSDHC 32 GB Class 10, we have an erase block size of 12 MiB (actually 3 times 4 MiB) and a FAT description that has to start at the offset at 4 MiB and then next erase block that starts at the offset at 12 MiB.
Therefore you'll have:
Code:
new_fat32_partition_size = MROUND(30,101,504 kiB - 1,061,376 kiB + 4,194,304 kiB ; erase_block_size) - 12 582 912 kiB = 30,101,504 kiB
Therefore using fdisk you should get something like the following when printing the partitions (p) - Don't forget to disable the DOS compatibility flag and use the sector as the unit:
Code:
Disk /dev/mmcblk0: 31.9 GB, 31914983424 bytes
4 heads, 16 sectors/track, 973968 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: 0x9a064f9d
Device Boot Start End Blocks Id System
/dev/mmcblk0p1 8192 60211199 30101504 c W95 FAT32 (LBA)
/dev/mmcblk0p2 60211200 62333951 1061376 83 Linux
FAT32 formatting:
In order to use mkdosfs 3.0.9 or later with the right amount of reserved sectors so the root directory and data will start exactly at the next erase block offset.
The idea is to make so that the FATs ends exactly before that offset, but for that we need to know the size of one FAT.
Here is the formula based on mkdosfs source code, to calculate that needed number of reserved sectors:
Code:
total_number_of_sectors = total_number_of_blocks * block_size / sector_size
number_of_sectors_for_fats_and_data = total_number_of_sectors - MROUND(default_number_of_reserved_sectors ; cluster_size)
number_of_clusters = (number_of_sectors_for_fats_and_data * sector_size + number_of_fats * 8) / (cluster_size * sector_size + number_of_fats * 4)
fat_size = MROUND(CEILING((number_of_clusters + 2) * 4 / sector_size ; 1) ; cluster_size)
root_directory_offset = default_number_of_reserved_sectors + number_of_fats * fat_size
aligned_root_directory_offset = MROUND(root_directory_offset ; erase_block_size * 1024^2 / sector_size)
number_of_reserved_sectors = aligned_root_directory_offset - root_directory_offset + default_number_of_reserved_sectors
With:
sector_size: 512 bytes (Standard value)
block_size: 1,024 bytes (Standard value)
total_number_of_blocks: new_fat32_partition_size in kiB
default_number_of_reserved_sectors: 64 (can be 32)
cluster_size: 64 sectors (i.e. 32 kiB)
number_of_fats: 2 (Standard value)
So for example for that same card you'll get:
Code:
total_number_of_sectors = 60,203,008
number_of_reserved_sectors = 1,664
Therefore here is the command to format the FAT32 partition:
Code:
$> sudo mkdosfs -F 32 -s 64 -R 1664 -n EXTERNAL_SD -v /dev/mmcblk0p1
mkdosfs 3.0.9 (31 Jan 2010)
/dev/mmcblk0p1 has 4 heads and 16 sectors per track,
logical sector size is 512,
using 0xf8 media descriptor, with 60203008 sectors;
file system has 2 32-bit FATs and 64 sectors per cluster.
FAT size is 7360 sectors, and provides 940416 clusters.
There are 1664 reserved sectors.
Volume ID is 8aa89e36, volume label EXTERNAL_SD.
You can see that each FAT takes less than 3.6 MiB, so with 2 FATs and the reserved sector the FAT description takes less than 8 MiB.
You can then check using hexdump if indeed the root directory starts at the the 12 MiB offset (knowing that the partition begin at the 4 MiB offset - indeed 12 = 4 + 8).
For that let's read the first 13 MiB of the card:
Code:
$> sudo hd -n $[13*1024*1024] /dev/mmcblk0
00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
000001b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 80 82 |................|
000001c0 03 00 0c f8 95 a3 00 20 00 00 00 a0 96 03 00 f8 |....... ........|
000001d0 96 a3 83 1b f3 28 00 c0 96 03 00 64 20 00 00 00 |.....(.....d ...|
000001e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
000001f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa |..............U.|
00000200 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
00400000 eb 58 90 6d 6b 64 6f 73 66 73 00 00 02 40 80 06 |[email protected]|
00400010 02 00 00 00 00 f8 00 00 10 00 04 00 00 00 00 00 |................|
00400020 00 a0 96 03 c0 1c 00 00 00 00 00 00 02 00 00 00 |................|
00400030 01 00 06 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00400040 00 00 29 e5 a5 dc 46 45 58 54 45 52 4e 41 4c 5f |..)...FEXTERNAL_|
00400050 53 44 46 41 54 33 32 20 20 20 0e 1f be 77 7c ac |SDFAT32 ...w|.|
00400060 22 c0 74 0b 56 b4 0e bb 07 00 cd 10 5e eb f0 32 |".t.V.......^..2|
00400070 e4 cd 16 cd 19 eb fe 54 68 69 73 20 69 73 20 6e |.......This is n|
00400080 6f 74 20 61 20 62 6f 6f 74 61 62 6c 65 20 64 69 |ot a bootable di|
00400090 73 6b 2e 20 20 50 6c 65 61 73 65 20 69 6e 73 65 |sk. Please inse|
004000a0 72 74 20 61 20 62 6f 6f 74 61 62 6c 65 20 66 6c |rt a bootable fl|
004000b0 6f 70 70 79 20 61 6e 64 0d 0a 70 72 65 73 73 20 |oppy and..press |
004000c0 61 6e 79 20 6b 65 79 20 74 6f 20 74 72 79 20 61 |any key to try a|
004000d0 67 61 69 6e 20 2e 2e 2e 20 0d 0a 00 00 00 00 00 |gain ... .......|
004000e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
004001f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa |..............U.|
00400200 52 52 61 41 00 00 00 00 00 00 00 00 00 00 00 00 |RRaA............|
00400210 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
004003e0 00 00 00 00 72 72 41 61 7e 59 0e 00 03 00 00 00 |....rrAa~Y......|
004003f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa |..............U.|
00400400 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
00400c00 eb 58 90 6d 6b 64 6f 73 66 73 00 00 02 40 80 06 |[email protected]|
00400c10 02 00 00 00 00 f8 00 00 10 00 04 00 00 00 00 00 |................|
00400c20 00 a0 96 03 c0 1c 00 00 00 00 00 00 02 00 00 00 |................|
00400c30 01 00 06 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00400c40 00 00 29 e5 a5 dc 46 45 58 54 45 52 4e 41 4c 5f |..)...FEXTERNAL_|
00400c50 53 44 46 41 54 33 32 20 20 20 0e 1f be 77 7c ac |SDFAT32 ...w|.|
00400c60 22 c0 74 0b 56 b4 0e bb 07 00 cd 10 5e eb f0 32 |".t.V.......^..2|
00400c70 e4 cd 16 cd 19 eb fe 54 68 69 73 20 69 73 20 6e |.......This is n|
00400c80 6f 74 20 61 20 62 6f 6f 74 61 62 6c 65 20 64 69 |ot a bootable di|
00400c90 73 6b 2e 20 20 50 6c 65 61 73 65 20 69 6e 73 65 |sk. Please inse|
00400ca0 72 74 20 61 20 62 6f 6f 74 61 62 6c 65 20 66 6c |rt a bootable fl|
00400cb0 6f 70 70 79 20 61 6e 64 0d 0a 70 72 65 73 73 20 |oppy and..press |
00400cc0 61 6e 79 20 6b 65 79 20 74 6f 20 74 72 79 20 61 |any key to try a|
00400cd0 67 61 69 6e 20 2e 2e 2e 20 0d 0a 00 00 00 00 00 |gain ... .......|
00400ce0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
00400df0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa |..............U.|
00400e00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
004d0000 f8 ff ff 0f ff ff ff 0f f8 ff ff 0f ff ff ff 0f |................|
004d0010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
00868000 f8 ff ff 0f ff ff ff 0f f8 ff ff 0f ff ff ff 0f |................|
00868010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
00c00000 45 58 54 45 52 4e 41 4c 5f 53 44 08 00 00 52 b3 |EXTERNAL_SD...R.|
We can see that indeed the root partition starts at the offset 0x00c00000 which is 12 MiB!
Also note that 0x00400000 is the 4 MiB offset, the beginning of the FAT32 partition...
You can try the hexdump against the backup you did and you'll see that the factory formatting is also with a number of reserved sector so that the root directory is aligned. For example I've found the root directory at the 12 MiB offset (of course) and for that they use 1,170 reserved sector (I've decoded the hexdump to get that value) which matches the formula. They also set 8,192 hidden sectors - that's more for compatibility with some cameras, we don't care here...
Link2SD formatting:
I use ext4 for that partition, I've got inspiration from http://blogofterje.wordpress.com/2012/01/14/optimizing-fs-on-sd-card/, however I'm not sure if indeed using the stride and the stripe-width options is really needed:
Code:
[FONT=Courier New]$ sudo mkfs.ext4 -O ^has_journal -E stride=4,stripe-width=512 -b 4096 -L Link2SD /dev/mmcblk0p2
mke2fs 1.41.14 (22-Dec-2010)
Filesystem label=Link2SD
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=4 blocks, Stripe width=512 blocks
66384 inodes, 265344 blocks
13267 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=272629760
9 block groups
32768 blocks per group, 32768 fragments per group
7376 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376
Writing inode tables: done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 30 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.[/FONT]
Anyway I consider the Link2SD partition is going to be used much more for read than write and we need the same file system that is used on the other partitions of the phone (i.e. ext4).
I hope it's not too complicated and that will help
Some other references:
http://android.bytearrays.com/android/align-your-sdcard-fat-and-ext-partition/
http://www.bradfordembedded.com/2011/12/format-an-sd-card-with-8-mib-aligned-partitions/
http://www.olpcnews.com/forum/index.php?topic=4993.0
http://www.patriotmemory.com/forums...ite-speed-by-aligning-FAT32&p=41521#post41521
http://forum.xda-developers.com/showthread.php?t=1224408
Click to expand...
Click to collapse
what a nice answer... It's too complicated, but I think I can understand overall of that.. thanks mate
USB storage
Galaxy W has an internal USB Storage. Link2sd failed to move apps that have big database or library (like sygic) to the external memory but instead it was moved to the internal USB storage. How do I make Link2sd to move all the large apps to the external memory? Thanks in advance
Scootster said:
Galaxy W has an internal USB Storage. Link2sd failed to move apps that have big database or library (like sygic) to the external memory but instead it was moved to the internal USB storage. How do I make Link2sd to move all the large apps to the external memory? Thanks in advance
Click to expand...
Click to collapse
Swap the storage so that your external_sd will change place with the internal storage
Pressing "Thanks" button will be much appreciated if user's posts useful for you
swapped memory
reddvilzz said:
Swap the storage so that your external_sd will change place with the internal storage
Pressing "Thanks" button will be much appreciated if user's posts useful for you
Click to expand...
Click to collapse
I swapped memory before this but the phone perform not very good. It lagged very much in switching from one task to another.
If memory was to swapped, then there is no use for Link2sd isn't it? because all apps were installed directly to. external memory. Does memory card needs to be in 2 partition?
No, swapped ish juz useless trick and could break ur sd card.
Dwama said:
No, swapped ish juz useless trick and could break ur sd card.
Click to expand...
Click to collapse
What are you talking about?
There are 2 meanings of the word 'swap' for the W:
The 1st meaning is creating a swapfile and/or swap partition.
The 2nd meaning is to change the mount points of the internal SD and the external SD so that Android thought the external SD is the internal one (mounted at /sdcard) and the internal SD gets mounted to the external point ( /sdcard/external_sd)
The 1st meaning is the dangerous one. The 2nd meaning is instead very useful.
-- xda app / CM9b3 / DXKL1 / Galaxy W --

Mifare card emulation

Based on this article "nelenkov.blogspot.fr/2012/10/emulating-pki-smart-card-with-cm91.html", i'm trying to emulate mifare card managing APDU on android (cyanogen9, on nexus S).
According to the APDU received, my application should answer the right APDU, thus simulating the mifare behaviour.
However receiving a specific APDU give me weird behavior.
For example with rfidiot reading a mifare card (just block 1 after auth) give me:
Code:
#rfidiot-cli.py -d -r1 select mf key a FFFFFFFFFFFF mf auth a 0 mf dump 1 1
> FF CA 00 00 00
< CD EA 7D 2B 90 0
Tag ID: CDEA7D2B
ATR: 3B8F8001804F0CA000000306030001000000006A
Setting Mifare Key A: FFFFFFFFFFFF
Authenticating to sector 00 with Mifare Key A (FFFFFFFFFFFF)
> FF 82 20 00 06 FF FF FF FF FF FF
< [] 90 0
> FF 88 00 00 60 00
< [] 90 0
OK
Dumping data blocks 01 to 01:
> FF 88 00 01 60 00
< [] 90 0
> FF B0 00 01 01
< [] 6C 10
> FF B0 00 01 10
< 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 90 0
01: 00000000000000000000000000000000 ................
Then reading my app emulating the mifare, i got a wrong comportment:
Code:
#rfidiot-cli.py -d -r1 select mf key a FFFFFFFFFFFF mf auth a 0 mf dump 1 1
> FF CA 00 00 00
< 08 F0 82 65 90 0
Tag ID: 08F08265
ATR: 3B80800101
Setting Mifare Key A: FFFFFFFFFFFF
Authenticating to sector 00 with Mifare Key A (FFFFFFFFFFFF)
> FF 82 20 00 06 FF FF FF FF FF FF
< [] 90 0
> FF 88 00 00 60 00
< [] 90 0
OK
Dumping data blocks 01 to 01:
> FF 88 00 01 60 00
< [] 90 0
> FF B0 00 01 01
< [] 69 81
Failed: Command incompatible with file structure
An error appear on FF B0 00 01 01 APDU command. And i don't know where the 6981 APDU command comes from..
In the logcat, i have an error on the transeive, just when it try to catch the FF B0 00 01 01 APDU command...
Does someone can help me on this "bug" ?
Hi,
Mifare Classic cards do not use ISO 7816-4 APDUs. Thus, you cannot emulate such a card using your Nexus S.
The APDUs you use to access the Mifare Classic card in your example (those starting with FF...) are commands that you send to the Mifare reader chip. The Mifare reader then translates them to Mifare Classic commands (some weired non-standard-compliant partly encrypted protocol). Also the error code you see is generated by the reader that was unable to communicate with your phone using the Mifare Classic protocol.
br
Michael
Hi guys,
Can we edit data on mifire cards with our phones? And if so, how? I just by accident put my student id card under my phone and when phone beeped i freaked out ;d now im having fun, so im wondering if i can edit my card? Just to mess a little..
xhenga said:
Hi guys,
Can we edit data on mifire cards with our phones? And if so, how? I just by accident put my student id card under my phone and when phone beeped i freaked out ;d now im having fun, so im wondering if i can edit my card? Just to mess a little..
Click to expand...
Click to collapse
Yep, you can write Mifare clasic tags, if you have an device with an NXP nfc chip, and the tag is not write-protected or encrypted....devices with a broadcom nfc chip can write nfc forum 1-4 compatible tags (also not write-protected and not encrypted ). ....
However you can use apps like NFC ReTag to start some activities even if your tag is write-protected or encrypted

Categories

Resources