sdhc card / usb mass storage device problem

Started by "Tim...@sabretechnology.co.uk [lpc2000]" July 2, 2014
Hi, I've made a little SD card audio playback board for someone using LPC1754. It all works fine and will play from any type and size of card.

The board can be connected as a USB mass storage device. However on Windows 7 only, some SD cards are not readable by the PC.

After much trawling through USB packets it appears that Windows is asking for the wrong sector when it requests the boot sector.
On a working card, Windows requests Sector 0 (the partition table) lots of times, then it requests 0x2000 bytes of data starting at the boot sector address which it gets from the partition table. My working card has 0x0083 as the boot sector address.
On a non working card, the boot sector start address is 0x0200, but when windows requests the 0x2000 bytes of data it asks for sector 0x0000 again rather than 0x0200.
So it seems like Windows is not reading the higher byte of the start address.

This works fine on XP. Don't have any other windows versions to try. Anyone have any further knowledge on this?

--
Tim Mitchell
Sabre Technology (Hull) Ltd
http://www.sabretechnology.co.uk
t:01482 800981 f:01482 801078


Posted by: Tim Mitchell



An Engineer's Guide to the LPC2100 Series

Il 02/07/2014 11:24, Tim Mitchell t...@sabretechnology.co.uk [lpc2000] ha
scritto:
>
>
> Hi, I've made a little SD card audio playback board for someone using
> LPC1754. It all works fine and will play from any type and size of card.
>
> The board can be connected as a USB mass storage device. However on
> Windows 7 only, some SD cards are not readable by the PC.
>
> After much trawling through USB packets it appears that Windows is
> asking for the wrong sector when it requests the boot sector.
> On a working card, Windows requests Sector 0 (the partition table)
> lots of times, then it requests 0x2000 bytes of data starting at the
> boot sector address which it gets from the partition table. My working
> card has 0x0083 as the boot sector address.
> On a non working card, the boot sector start address is 0x0200, but
> when windows requests the 0x2000 bytes of data it asks for sector
> 0x0000 again rather than 0x0200.
> So it seems like Windows is not reading the higher byte of the start
> address.
>
> This works fine on XP. Don't have any other windows versions to try.
> Anyone have any further knowledge on this?
>
XP had no driver for SDHC so it always suppose to have SD card
interfaced, Win7 and Win8 have the SDHC driver. May you try with
different card models and sizes? You should try with a normal SD (an 8GB
card) and with a SDHC (32GB for instance) and see the difference.
Also knowing what stack you are using helps, I suppose you are using
that on LpcOpen.
About boot sectors and partitions:
The first partition table entry starts at 0x1be and is 16 bytes long
(there are places for three more entries)

So your table entry is

00 00 03 01 0b 2e ee e7 00 20 00 00 00 d8 7a 00

decoding that according to the table at we get

00: non bootable partition
00 03 01: chs start of partition, you can ignore this and use the LBA values
0b: parition type: "fat32 with CHS addressing"
2e ee e7 : chs end of partition again you can ignore this
00 20 00 00: start LBA sector of partition = sector 0x2000 = byte offset
0x400000
00 d8 7a 00: length of partition = 0x7ad800 sectors = 0xF5B00000 bytes
http://en.wikipedia.org/wiki/Master_boot_record
> --
> Tim Mitchell
> Sabre Technology (Hull) Ltd
> http://www.sabretechnology.co.uk
> t:01482 800981 f:01482 801078
>
>
>
>
>
> Questa e-mail è priva di virus e malware perché è attiva la protezione
> avast! Antivirus .

logo
*

Massimo Manca*/, Micron Engineering/
via della Ferriera, 48 33170 Pordenone PN ITALIA
Tel: 39 0434 1856131| Mobile: 39 349 4504979
www.micronengineering.it

Twitter

LinkedIn

SlideShare

Contact me: Skype micron.engineering
Designed with WiseStamp -
Get
yours

---
Questa e-mail è priva di virus e malware perché è attiva la protezione avast! Antivirus.
http://www.avast.com
[Non-text portions of this message have been removed]


Posted by: "M. Manca"



VGhhbmtzIGZvciB0aGUgcmVwbHkuDQoNCkknbSB1c2luZyBOWFAncyBTRCBjYXJkIGxpYnJh
cnkgKGl0J3Mgbm90IGFjdHVhbGx5IGZyb20gTHBjT3BlbiwgYnV0IGEgcHJldmlvdXMgdmVy
c2lvbiB0aGV5IHByb3ZpZGVkIHdoaWNoIEkgdXNlZCBzdWNjZXNzZnVsbHkgaW4gYW4gZWFy
bGllciBkZXZpY2UpLCBhbmQgRmF0RnMgdG8gYWN0dWFsbHkgcmVhZCB0aGUgRkFUIHRob3Vn
aCBvYnZpb3VzbHkgdGhpcyBoYXMgbm8gcGFydCBpbiB0aGUgbWFzcyBzdG9yYWdlIG9wZXJh
dGlvbi4NCg0KSSBoYXZlIHRyaWVkIGEgcmFuZ2Ugb2YgY2FyZHMgYW5kIGFsbCB0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S0tLS0tLS0tLS0tLS0tLS0tLS0t
LS0tLS0tLS0tCgoKLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tCgpZYWhv
byBHcm91cHMgTGlua3MKCjwqPiBUbyB2aXNpdCB5b3VyIGdyb3VwIG9uIHRoZSB3ZWIsIGdv
IHRvOgogICAgaHR0cDovL2dyb3Vwcy55YWhvby5jb20vZ3JvdXAvbHBjMjAwMC8KCjwqPiBZ
b3VyIGVtYWlsIHNldHRpbmdzOgogICAgSW5kaXZpZHVhbCBFbWFpbCB8IFRyYWRpdGlvbmFs
Cgo8Kj4gVG8gY2hhbmdlIHNldHRpbmdzIG9ubGluZSBnbyB0bzoKICAgIGh0dHA6Ly9ncm91
cHMueWFob28uY29tL2dyb3VwL2xwYzIwMDAvam9pbgogICAgKFlhaG9vISBJRCByZXF1aXJl
ZCkKCjwqPiBUbyBjaGFuZ2Ugc2V0dGluZ3MgdmlhIGVtYWlsOgogICAgbHBjMjAwMC1kaWdl
c3RAeWFob29ncm91cHMuY29tIAogICAgbHBjMjAwMC1mdWxsZmVhdHVyZWRAeWFob29ncm91
cHMuY29tCgo8Kj4gVG8gdW5zdWJzY3JpYmUgZnJvbSB0aGlzIGdyb3VwLCBzZW5kIGFuIGVt
YWlsIHRvOgogICAgbHBjMjAwMC11bnN1YnNjcmliZUB5YWhvb2dyb3Vwcy5jb20KCjwqPiBZ
b3VyIHVzZSBvZiBZYWhvbyBHcm91cHMgaXMgc3ViamVjdCB0bzoKICAgIGh0dHBzOi8vaW5m
by55YWhvby5jb20vbGVnYWwvdXMveWFob28vdXRvcy90ZXJtcy8KCg=
Just to add, I have a USB card reader on the Win7 machine and that can read both cards fine.

So it seems like the USB card reader must not be using the same driver as my board - I wonder if there is a way of tricking windows to use that driver for my board?

--
Tim Mitchell
Sabre Technology (Hull) Ltd
http://www.sabretechnology.co.uk
t:01482 800981 f:01482 801078


Posted by: Tim Mitchell