All of lore.kernel.org
 help / color / mirror / Atom feed
* Smartmedia block mapping
@ 2003-07-22 20:05 Holly Gates
  2003-07-22 20:17 ` David Woodhouse
  2003-07-22 21:11 ` Thomas Gleixner
  0 siblings, 2 replies; 9+ messages in thread
From: Holly Gates @ 2003-07-22 20:05 UTC (permalink / raw)
  To: linux-mtd

Hello all, I'm hoping someone can give me some advice on a smartmedia 
issue. Here is the deal: I'm working on a display controller based on an 
FPGA, some lookup table data is stored on a smartmedia card. The FPGA 
just pulls data from the card sector by sector in incrementing order.

The cards I am using are samsung 32MB, and I was kind of hoping to find 
some cards with no bad blocks in the area I care about, but we could 
write VHDL to skip bad blocks if need be.

I've been writing the card using a linux laptop running redhat with a 
PQI USB smartmedia adapter which just worked when I plugged it in, by 
executing:

sh> dd if=table.bin of=/dev/sda bs=512c count=64000

When I read back the card using dd, all the data is in order. However 
the problem comes when I read the card with the FPGA. First I noticed 
that my binary file didn't show up until about sector 0x42, and also 
occasionally data would come out that was supposed to be written 
thousands of sectors away. Same thing happens if I do the 
writing/reading using a PCMCIA/smartmedia adapter.

Having done all the work so far with just the data sheet, I started 
poking around the web and it seems like I am running into the 
logical->physical mapping inherent in most uses of smartmedia. However I 
don't want this mapping since it would be a major pain in the ass to 
build and maintain a RAM translation table in the FPGA part of the 
system. I'm still not sure exactly how the translation table is made and 
stored either; is it on the card somewhere? Maybe in those first 0x42 
sectors?

Maybe I could see using the mapping table if it was on the card 
somewhere, but ideally I could just write the binary file to the sectors 
in true, physical, incrementing order. Anyone know of a utility I could 
use to do this?

One thing I tried already was using the "raw" utility:

sh> raw /dev/raw/raw1 /dev/sda

and then using a C program to read out the sectors, however the raw 
utility must be plugging in to a level that is above the mapping since 
when I watch what sectors the computer requests from the card on a logic 
analyzer, it still just jumps around for no apparent reason.

I suppose I could build a parallel port adapter and write some software 
or something, but that is annoying since I know the computer is capable 
of doing what I want if I could get at the right layer of the driver 
stack...

Thanks for any help! (Please cc me on any reply since I am not subscribed)

-Holly Gates

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Smartmedia block mapping
  2003-07-22 20:05 Smartmedia block mapping Holly Gates
@ 2003-07-22 20:17 ` David Woodhouse
  2003-07-22 20:34   ` Holly Gates
  2003-07-22 21:11 ` Thomas Gleixner
  1 sibling, 1 reply; 9+ messages in thread
From: David Woodhouse @ 2003-07-22 20:17 UTC (permalink / raw)
  To: Holly Gates; +Cc: linux-mtd

On Tue, 2003-07-22 at 16:05, Holly Gates wrote:
> Maybe I could see using the mapping table if it was on the card 
> somewhere,

It is. It's in the 'out of band' area of the data blocks I believe --
see the SmartMedia specs for details.

>  but ideally I could just write the binary file to the sectors 
> in true, physical, incrementing order. Anyone know of a utility I could 
> use to do this?

You need special hardware which gives you access to the raw flash
without doing the translation _for_ you. Most 'card readers' will do it
for you and hence you don't get this option.

> I suppose I could build a parallel port adapter and write some software 
> or something, but that is annoying since I know the computer is capable 
> of doing what I want if I could get at the right layer of the driver 
> stack...

No, it's not. Your USB card reader doesn't let you have access to the
raw flash; it has the translation built-in. 

Either implement the full SMTL in your FPGA, or make sure you use
hardware which accesses the flash directly, when writing to the device.

-- 
dwmw2

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Smartmedia block mapping
  2003-07-22 20:17 ` David Woodhouse
@ 2003-07-22 20:34   ` Holly Gates
  2003-07-24 22:27     ` Charles Manning
  0 siblings, 1 reply; 9+ messages in thread
From: Holly Gates @ 2003-07-22 20:34 UTC (permalink / raw)
  To: David Woodhouse; +Cc: linux-mtd



David Woodhouse wrote:

>On Tue, 2003-07-22 at 16:05, Holly Gates wrote:
>
>>Maybe I could see using the mapping table if it was on the card 
>>somewhere,
>>
>
>It is. It's in the 'out of band' area of the data blocks I believe --
>see the SmartMedia specs for details.
>
Right, I sort of got a bit of that by reading docs at samsung's website. 
It seems like the logical block number is stored in the out of band area 
of the physical block. But it seems to me that if this was the only 
place it was stored, then when you plug in the card, the card reader 
would have to read the out of band area for all the blocks on the card 
and make a table in RAM. At least on my card reader, it is only a little 
ASIC on the board. I would be surprised to find a few hundred K of RAM 
on that ASIC, which is what you might want for a table on the larger cards.

By the way, any idea where to get the SM spec? I can't seem to find it 
anywhere that I don't need to sign and NDA or pay hundreds of dollars 
for it.

>> but ideally I could just write the binary file to the sectors 
>>in true, physical, incrementing order. Anyone know of a utility I could 
>>use to do this?
>>
>
>You need special hardware which gives you access to the raw flash
>without doing the translation _for_ you. Most 'card readers' will do it
>for you and hence you don't get this option.
>
Hmm. OK. Thats too bad.

>>I suppose I could build a parallel port adapter and write some software 
>>or something, but that is annoying since I know the computer is capable 
>>of doing what I want if I could get at the right layer of the driver 
>>stack...
>>
>
>No, it's not. Your USB card reader doesn't let you have access to the
>raw flash; it has the translation built-in. 
>
>Either implement the full SMTL in your FPGA, or make sure you use
>hardware which accesses the flash directly, when writing to the device.
>
Dang! Oh well, thanks for the advice. I'll get out the soldering iron I 
guess...

-Holly

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Smartmedia block mapping
  2003-07-22 20:05 Smartmedia block mapping Holly Gates
  2003-07-22 20:17 ` David Woodhouse
@ 2003-07-22 21:11 ` Thomas Gleixner
  1 sibling, 0 replies; 9+ messages in thread
From: Thomas Gleixner @ 2003-07-22 21:11 UTC (permalink / raw)
  To: Holly Gates, linux-mtd

On Tuesday 22 July 2003 22:05, Holly Gates wrote:
> Hello all, I'm hoping someone can give me some advice on a smartmedia
> issue. Here is the deal: I'm working on a display controller based on an
> FPGA, some lookup table data is stored on a smartmedia card. The FPGA
> just pulls data from the card sector by sector in incrementing order.
>
> The cards I am using are samsung 32MB, and I was kind of hoping to find
> some cards with no bad blocks in the area I care about, but we could
> write VHDL to skip bad blocks if need be.
>
> I've been writing the card using a linux laptop running redhat with a
> PQI USB smartmedia adapter which just worked when I plugged it in, by
> executing:
>
> sh> dd if=table.bin of=/dev/sda bs=512c count=64000
>
> When I read back the card using dd, all the data is in order. However
> the problem comes when I read the card with the FPGA. First I noticed
> that my binary file didn't show up until about sector 0x42, and also
> occasionally data would come out that was supposed to be written
> thousands of sectors away. Same thing happens if I do the
> writing/reading using a PCMCIA/smartmedia adapter.
>
> Having done all the work so far with just the data sheet, I started
> poking around the web and it seems like I am running into the
> logical->physical mapping inherent in most uses of smartmedia. However I
> don't want this mapping since it would be a major pain in the ass to
> build and maintain a RAM translation table in the FPGA part of the
> system. I'm still not sure exactly how the translation table is made and
> stored either; is it on the card somewhere? Maybe in those first 0x42
> sectors?
>
> Maybe I could see using the mapping table if it was on the card
> somewhere, but ideally I could just write the binary file to the sectors
> in true, physical, incrementing order. Anyone know of a utility I could
> use to do this?
>
> One thing I tried already was using the "raw" utility:
>
> sh> raw /dev/raw/raw1 /dev/sda
>
> and then using a C program to read out the sectors, however the raw
> utility must be plugging in to a level that is above the mapping since
> when I watch what sectors the computer requests from the card on a logic
> analyzer, it still just jumps around for no apparent reason.
>
> I suppose I could build a parallel port adapter and write some software
> or something, but that is annoying since I know the computer is capable
> of doing what I want if I could get at the right layer of the driver
> stack...

You cannot access the layer, as this is all faked stuff. The smartmedia 
adaptor has some firmware, which does all the sector translation. The first 
two sectors are reserved anyway for FAT.

The nand support in Linux gives you access to raw sectors. So build a adaptor 
for the parallel port and  write a small board driver, then you can do what 
you want. 

-- 
Thomas
________________________________________________________________________
linutronix - competence in embedded & realtime linux
http://www.linutronix.de
mail: tglx@linutronix.de

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Smartmedia block mapping
  2003-07-22 20:34   ` Holly Gates
@ 2003-07-24 22:27     ` Charles Manning
  2003-07-24 22:33       ` Matthew Dharm
  0 siblings, 1 reply; 9+ messages in thread
From: Charles Manning @ 2003-07-24 22:27 UTC (permalink / raw)
  To: Holly Gates; +Cc: linux-mtd

On Wednesday 23 July 2003 08:34, Holly Gates wrote:
> David Woodhouse wrote:
> >On Tue, 2003-07-22 at 16:05, Holly Gates wrote:
> >>Maybe I could see using the mapping table if it was on the card
> >>somewhere,
> >
> >It is. It's in the 'out of band' area of the data blocks I believe --
> >see the SmartMedia specs for details.
>
> Right, I sort of got a bit of that by reading docs at samsung's website.
> It seems like the logical block number is stored in the out of band area
> of the physical block. But it seems to me that if this was the only
> place it was stored, then when you plug in the card, the card reader
> would have to read the out of band area for all the blocks on the card
> and make a table in RAM. At least on my card reader, it is only a little
> ASIC on the board. I would be surprised to find a few hundred K of RAM
> on that ASIC, which is what you might want for a table on the larger cards.

SmartMedia does require the logical to physical mapping to be held in RAM 
(well for any acceptable performance anyway). This is not much 2 bytes of RAM 
per block of 16kB ie. ony about 32kB of RAM data for a 256MB card (isn't that 
the biggest?). 

As others have noted, if the device is using the USB mass storage driver then 
it is doing all this internally and you can't get at the low levels.

>
> By the way, any idea where to get the SM spec? I can't seem to find it
> anywhere that I don't need to sign and NDA or pay hundreds of dollars
> for it.

You can get it from the samsung flash www.
>
> >> but ideally I could just write the binary file to the sectors
> >>in true, physical, incrementing order. Anyone know of a utility I could
> >>use to do this?
> >
> >You need special hardware which gives you access to the raw flash
> >without doing the translation _for_ you. Most 'card readers' will do it
> >for you and hence you don't get this option.
>
> Hmm. OK. Thats too bad.
>
> >>I suppose I could build a parallel port adapter and write some software
> >>or something, but that is annoying since I know the computer is capable
> >>of doing what I want if I could get at the right layer of the driver
> >>stack...
> >
> >No, it's not. Your USB card reader doesn't let you have access to the
> >raw flash; it has the translation built-in.
> >
> >Either implement the full SMTL in your FPGA, or make sure you use
> >hardware which accesses the flash directly, when writing to the device.
>
> Dang! Oh well, thanks for the advice. I'll get out the soldering iron I
> guess...

You can get NAND eval boards from Samsung etc that will give you low level 
access. 

-- CHarles

^ permalink raw reply	[flat|nested] 9+ messages in thread

* RE: Smartmedia block mapping
  2003-07-24 22:27     ` Charles Manning
@ 2003-07-24 22:33       ` Matthew Dharm
  2003-07-24 22:47         ` Charles Manning
  0 siblings, 1 reply; 9+ messages in thread
From: Matthew Dharm @ 2003-07-24 22:33 UTC (permalink / raw)
  To: manningc2, Holly Gates; +Cc: linux-mtd

The sddr09 driver in linux/usb/drivers/storage/ actually contains a
software implementation of the block-mapping needed.  The SDDR-09
actually forces the host to do this instead of making the device do
it.

If you can find an SDDR-09 device, and are willing to re-write the
driver (it currently does not support any sort of raw access), then
you could do what you're trying to do.

Matt

--
Matthew D. Dharm                            Senior Software Designer
Momentum Computer Inc.                      1815 Aston Ave.  Suite 107
(760) 431-8663 X-115                        Carlsbad, CA 92008-7310
Momentum Works For You                      www.momenco.com

> -----Original Message-----
> From: linux-mtd-bounces@lists.infradead.org
> [mailto:linux-mtd-bounces@lists.infradead.org]On Behalf Of Charles
> Manning
> Sent: Thursday, July 24, 2003 3:28 PM
> To: Holly Gates
> Cc: linux-mtd@lists.infradead.org
> Subject: Re: Smartmedia block mapping
>
>
> On Wednesday 23 July 2003 08:34, Holly Gates wrote:
> > David Woodhouse wrote:
> > >On Tue, 2003-07-22 at 16:05, Holly Gates wrote:
> > >>Maybe I could see using the mapping table if it was on the card
> > >>somewhere,
> > >
> > >It is. It's in the 'out of band' area of the data blocks
> I believe --
> > >see the SmartMedia specs for details.
> >
> > Right, I sort of got a bit of that by reading docs at
> samsung's website.
> > It seems like the logical block number is stored in the
> out of band area
> > of the physical block. But it seems to me that if this
> was the only
> > place it was stored, then when you plug in the card, the
> card reader
> > would have to read the out of band area for all the
> blocks on the card
> > and make a table in RAM. At least on my card reader, it
> is only a little
> > ASIC on the board. I would be surprised to find a few
> hundred K of RAM
> > on that ASIC, which is what you might want for a table on
> the larger cards.
>
> SmartMedia does require the logical to physical mapping to
> be held in RAM
> (well for any acceptable performance anyway). This is not
> much 2 bytes of RAM
> per block of 16kB ie. ony about 32kB of RAM data for a
> 256MB card (isn't that
> the biggest?).
>
> As others have noted, if the device is using the USB mass
> storage driver then
> it is doing all this internally and you can't get at the low levels.
>
> >
> > By the way, any idea where to get the SM spec? I can't
> seem to find it
> > anywhere that I don't need to sign and NDA or pay
> hundreds of dollars
> > for it.
>
> You can get it from the samsung flash www.
> >
> > >> but ideally I could just write the binary file to the sectors
> > >>in true, physical, incrementing order. Anyone know of a
> utility I could
> > >>use to do this?
> > >
> > >You need special hardware which gives you access to the raw flash
> > >without doing the translation _for_ you. Most 'card
> readers' will do it
> > >for you and hence you don't get this option.
> >
> > Hmm. OK. Thats too bad.
> >
> > >>I suppose I could build a parallel port adapter and
> write some software
> > >>or something, but that is annoying since I know the
> computer is capable
> > >>of doing what I want if I could get at the right layer
> of the driver
> > >>stack...
> > >
> > >No, it's not. Your USB card reader doesn't let you have
> access to the
> > >raw flash; it has the translation built-in.
> > >
> > >Either implement the full SMTL in your FPGA, or make sure you use
> > >hardware which accesses the flash directly, when writing
> to the device.
> >
> > Dang! Oh well, thanks for the advice. I'll get out the
> soldering iron I
> > guess...
>
> You can get NAND eval boards from Samsung etc that will
> give you low level
> access.
>
> -- CHarles
>
> ______________________________________________________
> Linux MTD discussion mailing list
> http://lists.infradead.org/mailman/listinfo/linux-mtd/
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Smartmedia block mapping
  2003-07-24 22:33       ` Matthew Dharm
@ 2003-07-24 22:47         ` Charles Manning
  2003-07-24 22:57           ` Matthew Dharm
  0 siblings, 1 reply; 9+ messages in thread
From: Charles Manning @ 2003-07-24 22:47 UTC (permalink / raw)
  To: Matthew Dharm, Holly Gates; +Cc: linux-mtd

On Friday 25 July 2003 10:33, Matthew Dharm wrote:
> The sddr09 driver in linux/usb/drivers/storage/ actually contains a
> software implementation of the block-mapping needed.  The SDDR-09
> actually forces the host to do this instead of making the device do
> it.
>
> If you can find an SDDR-09 device, and are willing to re-write the
> driver (it currently does not support any sort of raw access), then
> you could do what you're trying to do.

Thanx for that info Matt.

This would indicate that the SDDR-09 would allow you to use YAFFS and JFFS2 
too!


>
> Matt

^ permalink raw reply	[flat|nested] 9+ messages in thread

* RE: Smartmedia block mapping
  2003-07-24 22:47         ` Charles Manning
@ 2003-07-24 22:57           ` Matthew Dharm
  2003-07-25  0:26             ` David Woodhouse
  0 siblings, 1 reply; 9+ messages in thread
From: Matthew Dharm @ 2003-07-24 22:57 UTC (permalink / raw)
  To: manningc2, Holly Gates; +Cc: linux-mtd

Well, in theory, yes.....

But the current code just makes the media look like traditional
block-media via the usb-storage driver.  You would need to do some
significant hacking to expose the low-level interface.

Matt

--
Matthew D. Dharm                            Senior Software Designer
Momentum Computer Inc.                      1815 Aston Ave.  Suite 107
(760) 431-8663 X-115                        Carlsbad, CA 92008-7310
Momentum Works For You                      www.momenco.com

> -----Original Message-----
> From: Charles Manning [mailto:manningc2@actrix.gen.nz]
> Sent: Thursday, July 24, 2003 3:47 PM
> To: Matthew Dharm; Holly Gates
> Cc: linux-mtd@lists.infradead.org
> Subject: Re: Smartmedia block mapping
>
>
> On Friday 25 July 2003 10:33, Matthew Dharm wrote:
> > The sddr09 driver in linux/usb/drivers/storage/ actually
> contains a
> > software implementation of the block-mapping needed.  The SDDR-09
> > actually forces the host to do this instead of making the
> device do
> > it.
> >
> > If you can find an SDDR-09 device, and are willing to re-write the
> > driver (it currently does not support any sort of raw
> access), then
> > you could do what you're trying to do.
>
> Thanx for that info Matt.
>
> This would indicate that the SDDR-09 would allow you to use
> YAFFS and JFFS2
> too!
>
>
> >
> > Matt
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* RE: Smartmedia block mapping
  2003-07-24 22:57           ` Matthew Dharm
@ 2003-07-25  0:26             ` David Woodhouse
  0 siblings, 0 replies; 9+ messages in thread
From: David Woodhouse @ 2003-07-25  0:26 UTC (permalink / raw)
  To: Matthew Dharm; +Cc: manningc2, linux-mtd, Holly Gates

On Thu, 2003-07-24 at 18:57, Matthew Dharm wrote:
> But the current code just makes the media look like traditional
> block-media via the usb-storage driver.  You would need to do some
> significant hacking to expose the low-level interface.

I suspect it's worth doing. There are plenty of 'raw' SmartMedia
adapters out there, which want plugging into the MTD core as normal NAND
devices -- and we only want one implementation of SMTL.

-- 
dwmw2

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2003-07-25  0:26 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-22 20:05 Smartmedia block mapping Holly Gates
2003-07-22 20:17 ` David Woodhouse
2003-07-22 20:34   ` Holly Gates
2003-07-24 22:27     ` Charles Manning
2003-07-24 22:33       ` Matthew Dharm
2003-07-24 22:47         ` Charles Manning
2003-07-24 22:57           ` Matthew Dharm
2003-07-25  0:26             ` David Woodhouse
2003-07-22 21:11 ` Thomas Gleixner

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.