Skip to contentSkip to conversation

Smartmedia block mapping

DISCUSSION Holly Gates 5 participants 9 messages Jul 22, 2003 – Jul 25, 2003 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

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

#1 lore raw
Quoted 45 lines · Holly Gates

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.

Quoted 4 lines

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.

Signature · 5 lines
Thomas
________________________________________________________________________
linutronix - competence in embedded & realtime linux
http://www.linutronix.de
mail: [email protected]
#2 lore raw
In reply to Holly Gates
Quoted 2 lines · Holly Gates

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.

Quoted 3 lines

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.

Quoted 4 lines

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.

Signature · 1 line
dwmw2
#3 lore raw
Quoted 8 lines · David Woodhouse
Quoted 2 lines · Holly Gates

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.

Quoted 7 lines
Quoted 2 lines

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.

Quoted 9 lines
Quoted 2 lines

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

#4 lore raw
Quoted 8 lines · Holly Gates
Quoted 6 lines · David Woodhouse
Quoted 2 lines · Holly Gates

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.

Quoted 8 lines

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.

Quoted 4 lines

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.

Quoted 16 lines
Quoted 8 lines
Quoted 4 lines

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.

Quoted 5 lines
Quoted 4 lines

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...

Quoted 8 lines
Quoted 5 lines

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

#5 lore raw

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
Quoted 100 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]]On Behalf Of Charles Manning
Sent: Thursday, July 24, 2003 3:28 PM
To: Holly Gates
Cc: [email protected]
Subject: Re: Smartmedia block mapping

Quoted 6 lines · Holly Gates
Quoted 5 lines · David Woodhouse
Quoted 2 lines · Holly Gates

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 --

Quoted 3 lines
Quoted 1 line

see the SmartMedia specs for details.

Right, I sort of got a bit of that by reading docs at

samsung's website.

Quoted 1 line

It seems like the logical block number is stored in the

out of band area

Quoted 1 line

of the physical block. But it seems to me that if this

was the only

Quoted 1 line

place it was stored, then when you plug in the card, the

card reader

Quoted 1 line

would have to read the out of band area for all the

blocks on the card

Quoted 1 line

and make a table in RAM. At least on my card reader, it

is only a little

Quoted 1 line

ASIC on the board. I would be surprised to find a few

hundred K of RAM

Quoted 1 line

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.

Quoted 2 lines

By the way, any idea where to get the SM spec? I can't

seem to find it

Quoted 1 line

anywhere that I don't need to sign and NDA or pay

hundreds of dollars

Quoted 1 line

for it.

You can get it from the samsung flash www.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

but ideally I could just write the binary file to the sectors in true, physical, incrementing order. Anyone know of a

utility I could

Quoted 4 lines
Quoted 4 lines
Quoted 1 line

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

Quoted 5 lines
Quoted 1 line

for you and hence you don't get this option.

Hmm. OK. Thats too bad.

Quoted 1 line
Quoted 1 line

I suppose I could build a parallel port adapter and

write some software

Quoted 1 line
Quoted 1 line
Quoted 1 line

or something, but that is annoying since I know the

computer is capable

Quoted 1 line
Quoted 1 line
Quoted 1 line

of doing what I want if I could get at the right layer

of the driver

Quoted 3 lines
Quoted 3 lines
Quoted 1 line

stack...

No, it's not. Your USB card reader doesn't let you have

access to the

Quoted 4 lines
Quoted 4 lines

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.

Quoted 2 lines

Dang! Oh well, thanks for the advice. I'll get out the

soldering iron I

Quoted 1 line

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/

#6 lore raw
Quoted 8 lines · Matthew Dharm

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!

Quoted 2 lines

Matt

#7 lore raw

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
Quoted 31 lines

-----Original Message-----
From: Charles Manning [mailto:[email protected]]
Sent: Thursday, July 24, 2003 3:47 PM
To: Matthew Dharm; Holly Gates
Cc: [email protected]
Subject: Re: Smartmedia block mapping

Quoted 1 line · Matthew Dharm

The sddr09 driver in linux/usb/drivers/storage/ actually

contains a

Quoted 2 lines

software implementation of the block-mapping needed. The SDDR-09 actually forces the host to do this instead of making the

device do

Quoted 4 lines

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

Quoted 1 line

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!

Quoted 2 lines

Matt

#8 lore raw
Quoted 3 lines · Matthew Dharm

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.

Signature · 1 line
dwmw2