Bug 621 - (int-34059) Unable to use 2GB MMC cards
: Unable to use 2GB MMC cards
Product: Core
: 2.0
: All All
: Medium critical with 19 votes (vote)
: 2.1
Assigned To: Maemo QA (deprecated)
: linux-kernel-bugs
  Show dependency tree
Reported: 2006-06-21 21:35 UTC by Brad Burleson
Modified: 2008-12-06 16:13 UTC (History)
3 users (show)

See Also:

Set the partition table sector size to 512 bytes for N770 MMC device (932 bytes, patch)
2006-10-22 14:53 UTC, Paul Sjoberg
Make g_file_storage.ko able to use block sizes greater than 512 bytes (13.57 KB, patch)
2006-10-29 13:18 UTC, Paul Sjoberg


You need to log in before you can comment on or make changes to this bug.

Description Brad Burleson (reporter) 2006-06-21 21:35:21 UTC
Inserting a 2GB MMC card in the 770 (formatted to contain two partitions:  
128MB FAT, and the rest as ext2) causes the following messages to be reported 
(via 'dmesg'):

[    3.218383] mmcblk0p0 mmc0:0001 MMCm 2039296KiB
[    3.219024]  mmcblk0: p1 p2
[  12.700378] FAT: bogus number of reserved sectors
[  12.700531] VFS: Can't find a valid FAT filesystem on dev mmcblk0p2
[  12.710937] FAT: bogus number of reserved sectors
[  12.711090] VFS: Can't find a valid FAT filesystem on dev mmcblk0p2
[  12.721435] VFS: Can't find an ext2 filesystem on dev mmcblk0p2
The card has been formatted to contain 2 partitions:  128MB FAT and the rest 
ext2.  Attempting to mount the ext2 filesystem after boot gives:
# mount /dev/mmcblk0p2 /mnt
mount: Mounting /dev/mmcblk0p2 on /mnt failed: invalid argument
followed by the above FAT/VFS error messages (note that I have modified the 
init scripts to insmod the ext2 kernel module).  

Initially, I tried using the card as a single 2GB FAT partition (as shipped 
from the manufacturer) but again no valid FAT filesystem was discovered.  In 
case it mattered, I tried various disk geometries such as 255H/63S/253C and 

I was pointed to the following discussion thread that seems to indicate there 
is a problem with drivers/mmc/mmc_block.c (a patch is included in the following 
thread): http://lkml.org/lkml/2006/6/8/234

It would be a nice selling point to support 2GB cards (given how user's 
resource needs seem to grow over time) if it's a simple software problem.
Comment 1 Mickael Marchand 2006-06-22 00:04:21 UTC
I tried that patch with my (just received) 2Go RAPID MMC card on the beta,
it works just nicely, so please include it.

a precompiled kernel (for beta 2006) is here : 
http://www.freenux.org/~mm/zImage-su-18-200625 for those who needs it 
(no warranty :) 
if you dare, flash it to your nokia with :
flasher -f -k zImage-su-18-200625

Comment 2 Neil MacLeod maemo.org 2006-06-23 14:44:43 UTC
It would be a crime to release OS 2006 without this patch!

1GB isn't enough these days, and I will be looking to purchase 2GB+ RS-MMC when
they become available. Ideally 4GB would be my ideal size, and one day may
become available, so hopefully OS 2006 can support these larger sized RS MMC
cards using the available patch.
Comment 3 narong 2006-06-24 04:29:07 UTC
I vote to include in the final 2006 also.  I got a 2 gig card on the way myself
since I heard of this patch.
Comment 4 narong 2006-07-01 17:56:55 UTC
Can someone PULLEEEAAAASSEEEE make a patch for 2006 OS, final version.  I'd be 
really greatful.  I sold my two 1gb card and got one 2gb card.  Right now I 
can only use the 64mb that came with 770.  And it doesn't seem to work well 
with my card reader even.  I really don't want to have to buy another 1gb card 
so help a guy out.  Thanks a lot in advance.
Comment 5 Giuseppe Merigo 2006-07-03 21:25:15 UTC
I would like to have a patch too. My poor 2GB mmc lies unused on my desktop :)
Comment 6 Mickael Marchand 2006-07-04 12:17:51 UTC
well, I would like to build a new kernel for you, but nokia has not released
sources yet (which is probably against the GPL btw ...)
please free the sources so we can rebuild the kernel

I am quite surprised to see such grave bugs(imho) not being fixed in the
official release (well, there were something like 100-200 bugs opened for beta
2006, it does not look like much of them were fixed before the release ... nice
Comment 7 Maemo QA (deprecated) 2006-07-04 20:00:17 UTC
Thanks for your feedback, and sorry for slow response time.
The issue has been reported to upstream maintainer.
Comment 8 Mickael Marchand 2006-07-07 22:12:43 UTC
have fun guys :
OS2006 patched kernel : http://www.freenux.org/~mm/zImage-su-18-200627

working for me :)

Comment 9 sean darcy 2006-08-23 06:18:05 UTC
What's happening here? We're looking to equip our guys with the 770, but would
really like to use the 2gb mmc cards. Did this patch make it into the 2006
kernel? Will we have to patch each tablet?

Can we expect anything?
Comment 10 brainstorm 2006-09-21 22:20:55 UTC
It did not make it in 2006 kernel, please, patch it on newer official 
firmware :_)
Comment 11 Frantisek Dufka maemo.org 2006-09-25 16:42:15 UTC
Patch just hardcodes block size to 512 (md->block_bits = 9), I added also info
to see what card originally says it can handle

--- drivers/mmc/mmc_block.c.orig        2006-09-25 14:46:30.000000000 +0200
+++ drivers/mmc/mmc_block.c     2006-09-25 15:03:36.000000000 +0200
@@ -367,7 +367,12 @@
                        md->read_only = 1;
+       printk(KERN_INFO "card reports rb%u wb%u rp%u wp%u but we don't believe
it and set rb,wb to 512\n",
+                               1 << card->csd.read_blkbits,
+                               1 << card->csd.write_blkbits,
+                               card->csd.read_partial,
+                               card->csd.write_partial);
+       md->block_bits = 9;
         * Refuse to allow block sizes smaller than 512 bytes.

compiled kernel is here http:// fanoush.webpark.cz/maemo/zimage-su-18-200625-2gb.zip

My Sandisk 1GB reports:
[  305.791748] card reports rb512 wb512 rp1 wp0 but we don't believe it and set
rb,wb to 512
[  305.803039] mmcblk0: mmc0:0001 SDR01G 1003264KiB
[  305.803405]  mmcblk0: p1 p2

My new Kingston 2gb mmcmobile reports:
[  361.527740] card reports rb1024 wb1024 rp1 wp0 but we don't believe it and
set rb,wb to 512
[  361.539398] mmcblk0: mmc0:0001 MMCm   2039296KiB
[  361.539794]  mmcblk0: p1

Looks like 1GB reports 512bytes but 2gb reports 1kb which apparently does not
work. I wonder if card lies about its features or there is some problem with 1kb
blocks in linux mmc driver. But hopefully using blocksize 512 does not cause
noticeable slowdown so this patch is good enough.
Comment 12 Oscar Simmons 2006-09-26 09:57:05 UTC
(In reply to comment #10)
> It did not make it in 2006 kernel, please, patch it on newer official 
> firmware :_) 

The Nokia 770 is an impressive hand held with it's large screen, out of the box .pdf reader, and low 
cost.  I am advocating it as an individualized learning tablet for my warfare component in the US Navy, 
including over 3000 personnel.  However, 2GB is the required to hold the professional material we wish 
to distribute.
Developers, I'm requesting information on time of release for the patch to correct this deficiency.  While 
I can't guarantee the sale of 3000 units (more if the bigger Navy sees success with our learning tablets), 
I can guarantee there won't be a sale if this is not resolved soon.  Please contact me directly when the 
patch is made available.

LT Oscar Simmons
Comment 13 Maemo QA (deprecated) 2006-09-26 17:19:19 UTC
(In reply to comment #12)
> Developers, I'm requesting information on time of release for the patch to
correct this deficiency.  

I have forwarded your information to marketing, who should contact you, but
unfortunately we cannot give any information re future releases.
Comment 14 Paul Sjoberg 2006-10-22 14:50:07 UTC
Maybe the following is clear to most people already, but since it's not 
explicitly stated:

1) MSDOS partition table describes partitions using sector counts. The sector 
size used is supposed to be the hardware block size according to kernel source 
code. For my 1 GB card this is 512 bytes, for (atleast mine) 2 GB cards it's 
1024 bytes. So if the partition table for the 2 GB card really uses 512 bytes 
as the sector size, the kernel will think partitions are twice their actual 
size and start at a position twice the actual.

2) The logical sector size used by the FAT filesystem must be atleast as big as 
the hardware block size for the kernel FAT driver to work. I think most FAT 
filesystems are formatted to use 512 byte logical sectors. For 2 GB cards they 
should be formatted to have atleast 1024 bytes (e.g. mkfs.vfat -S 1024 /dev/

3) The kernel g_file_storage module uses 512-byte block size (hardcoded 
apparently). I haven't really looked into the workings of this at all, but I 
assume that when the MMC is accessed via USB the computer software reads the 
MMC card's partition table too. Since g_file_storage uses 512-byte blocks the 
partition table should use 512-byte blocks as well.

The attached patch just makes the N770 kernel use 512 byte sectors for the MMC 
card partition table. The FAT filesystem must be formatted with (atleast) 1024 
byte logical sector size for 2 GB cards. Note that the N770 File Manager will 
use 512 byte sector sizes for both the partition table and the filesystem 
logical sector size. So you'll need to apply mkfs.vfat -S 1024 afterwards.
Comment 15 Paul Sjoberg 2006-10-22 14:53:32 UTC
Created an attachment (id=120) [details]
Set the partition table sector size to 512 bytes for N770 MMC device
Comment 16 Paul Sjoberg 2006-10-29 13:18:48 UTC
Created an attachment (id=124) [details]
Make g_file_storage.ko able to use block sizes greater than 512 bytes

The original g_file_storage uses hardcoded 512 byte sector/block sizes. This
patch uses the block size given by the device (MMC card). For my 2 GB MMC card,
this is 1024 bytes.

The previous patch I offered wouldn't work with Windows XP, because it requires
that FAT logical sector size is equal to the hardware sector size. With the
present patch Windows XP will partition and format file systems correctly
(using 1024 byte sectors.) The Nokia 770 IT2006 release kernel requires no
patching other than the present g_file_storage patch.

Note that on my PC (Debian Sarge, 2.4 kernel) the kernel doesn't properly
refresh the partition table of the USB mass storage device (/dev/sda). It
doesn't read the hardware sector size either and just assumes 512 bytes
(Windows XP works properly though). A workaround is to issue the command
"sfdisk /dev/sda" followed by ctrl-c (or some similar command), which refreshes
the partition table and reads the sector size (via READ CAPACITY scsi command).
I don't know if this bug is fixed in 2.6 kernels.
Comment 17 Simon80 2006-11-01 19:12:23 UTC
magic numbers are bad... :)
Comment 18 Sebastian Spaeth 2006-11-09 13:07:32 UTC
As of 2.2006 2GB mmc cards should work, shouldn't they? Is this bug still valid
Comment 19 Giuseppe Merigo 2006-11-09 13:17:49 UTC
(In reply to comment #18)
> As of 2.2006 2GB mmc cards should work, shouldn't they? Is this bug still valid
> then?

It works flawlessly for me (tm) :-)
Comment 20 Mike Lococo 2007-01-27 19:06:44 UTC
Closing this bug.  It's been fixed: