jffs2+mtd+big endian problem

Li Yang leoli at motorola.com
Wed Feb 4 03:11:23 EST 2004


On Tue, 2004-01-20 at 15:32, David Woodhouse wrote:
> On Tue, 2004-01-20 at 12:20 +0800, Li Yang wrote:
> > > This sounds like you're using byte-swapping operations in your map
> > > driver. You should be using __raw_write*() not write*(). You said you
> > > were 'at the very beginning'... are you still doing that now?
> > 
> > I have verified my maps/ file.  I'm using __raw_write*() now.  Here is
> > part of my maps file, I don't know if the memcpy_toio() matters.
> 
> It doesn't -- it'll never get used. All you need are read32, write32 and
> copy_from. Try this...
>                                                                       
> __u32 ads_read32(struct map_info *map, unsigned long ofs)
> {
>         return *(volatile __u32 *)(map->map_priv_1 + ofs);
> }
>                                                                                                        
> void ads_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len)
> {
>         memcpy(to, (void *)(map->map_priv_1 + from), len);
> }
>                                                                                                        
> void ads_write32(struct map_info *map, __u32 d, unsigned long adr)
> {
>         *(volatile __u32 *)(map->map_priv_1 + adr) = d;
>         mb();
> }
>  
> 
> Did you try reading and writing chunks of 1, 2 and 4 bytes directly
> to/from /dev/mtd0?

It's very strange even when I use the complex mapping as you given above
the write is still 32bit swapped.  And I tried writing 1, 2 and 4 bytes
using cp.  For block device, write is successful but still swapped.  For
char device, the following error message is given.

# cp u16 /dev/mtd1
MTD_open
MTD_ioctl
Invalid ioctl 402c7413 (MEMGETINFO = 40204d01)
MTD_write
MTD_close
# cp u16 /dev/mtdblock1
mtdblock_open
ok
mtdblock: read on "JFFS" at 0x0, size 0x200
mtdblock: write on "JFFS" at 0x0, size 0x200
mtdblock_release
mtdblock: writing cached data for "JFFS" at 0x0, size 0x40000
ok
#


-- 
Li Yang <leoli at motorola.com>
Metrowerks




More information about the linux-mtd mailing list