MTD on MBX860
Hi,
I am using linuxppc_2_4 (2.4.6) with current mtd support from cvs tree. The board is with JEDEC AMD 29F016 x4 flash chips (8M Flash space). Map file which I use for this board is attached (I use rpxlite.c and tqm8xxl.c (for partitioning) as reference).
The problem I found is that mtd says:
"mtd: Failed. Cannot handle unsymetric banking"
I enabled some debug info in jedec.c (uncommenting some printks and add some) and found that it is looking for banked and find bank[0] is 8M bank[1] is 0M
- realy unsymetric :)
but I think it is linear flash.
I worarounded it commentig one condition:
jedec.c Tue Jul 10 10:07:41 2001 renamed from jedec.c.orig Tue Jul 10 10:06:41 2001 +1 -1
@@ -159,7 +159,7 @@ are empty banks. Note, the last bank does not count here, only the first banks are important. Holes on non-bank boundaries can not exist due to the way the detection algorithm works. */ - if (priv.size < my_bank_size) +/* if (priv.size < my_bank_size) */ my_bank_size = priv.size; priv.is_banked = 0; //printk("priv.size is %x, my_bank_size is %x\n",priv.size,my_bank_size);
but I think it is not the right action ...
now flash and partitioning(I think ) is working:
fromm booting kernel:
<>
Motorola MBX flash device: 800000 at fe000000
MTD Part: MBX flash 4*[AMD Am29F016]
MTD->erasesize is 40000MTD->size is 800000
mtd: Giving out device 0 to MBX flash
Creating 3 MTD partitions on "MBX flash":
0x00000000-0x00080000 : "MBX flash BOOT partition"
mtd: Giving out device 1 to MBX flash BOOT partition 0x00080000-0x00600000 : "MBX flash DATA partition"
mtd: Giving out device 2 to MBX flash DATA partition 0x00600000-0x00800000 : "MBX flash APPLICATION partition"
mtd: Giving out device 3 to MBX flash APPLICATION partition <>
sh-2.03# ./mtd_debug info /dev/mtd0
mtd.type = MTD_NORFLASH
mtd.flags = MTD_CAP_NORFLASH
mtd.size = 8388608 (8M)
mtd.erasesize = 262144 (256K)
mtd.oobblock = 0
mtd.oobsize = 0
mtd.ecctype = MTD_ECC_NONE
regions = 0
sh-2.03# ./mtd_debug info /dev/mtd1
mtd.type = MTD_NORFLASH
mtd.flags = MTD_CAP_NORFLASH
mtd.size = 524288 (512K)
mtd.erasesize = 262144 (256K)
mtd.oobblock = 0
mtd.oobsize = 0
mtd.ecctype = MTD_ECC_NONE
regions = 0
sh-2.03# ./mtd_debug info /dev/mtd2
mtd.type = MTD_NORFLASH
mtd.flags = MTD_CAP_NORFLASH
mtd.size = 5767168 (5M)
mtd.erasesize = 262144 (256K)
mtd.oobblock = 0
mtd.oobsize = 0
mtd.ecctype = MTD_ECC_NONE
regions = 0
sh-2.03# ./mtd_debug info /dev/mtd3
mtd.type = MTD_NORFLASH
mtd.flags = MTD_CAP_NORFLASH
mtd.size = 2097152 (2M)
mtd.erasesize = 262144 (256K)
mtd.oobblock = 0
mtd.oobsize = 0
mtd.ecctype = MTD_ECC_NONE
regions = 0
I managed to mount /dev/mtdblock3 as jffs and can create and delete files there.
My question is why jedec driver find it as banked?
maybe it is my fault in mbx860.c map file?
My patch is not the right solution curently I will add some ifdefs to comment patched line when I am using MBX board.
also I found that the einfo utility is not working on this board it says:
<>
sh-2.03# ./einfo /dev/mtd0
Device /dev/mtd0 has 0 erase regions
<>
but mtd_debug util is working ass seen above.
I have RPX Classic board with CFI AMD flash and same binary is working.
comments?
Best Regards,
Anton Todorov
Emness Technology
/*
* $Id: mbx.c,v 1.0 2001/06/18 15:40:23 anton Exp $ *
* Handle mapping of the flash on MBX boards */
#include <linux/module.h>
#include <linux/types.h>
#include <linux/kernel.h>
#include <asm/io.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/map.h>
#include <linux/mtd/partitions.h>
#define WINDOW_ADDR 0xfe000000
#define WINDOW_SIZE 0x00200000
/* Flash / Partition sizing */
#define MAX_SIZE_KiB 8192
#define BOOT_PARTITION_SIZE_KiB 512
#define KERNEL_PARTITION_SIZE_KiB 5632
#define APP_PARTITION_SIZE_KiB 2048
#define NUM_PARTITIONS 3
/* partition_info gives details on the logical partitions that the split the
* single flash device into. If the size if zero we use up to the end of the
* device. */
static struct mtd_partition partition_info[]={
{ name: "MBX flash BOOT partition",
offset: 0,
size: BOOT_PARTITION_SIZE_KiB*1024 },
{ name: "MBX flash DATA partition",
offset: BOOT_PARTITION_SIZE_KiB*1024,
size: (KERNEL_PARTITION_SIZE_KiB)*1024 },
{ name: "MBX flash APPLICATION partition",
offset: (BOOT_PARTITION_SIZE_KiB+KERNEL_PARTITION_SIZE_KiB)*1024 }
};static struct mtd_info *mymtd;
__u8 mbx_read8(struct map_info *map, unsigned long ofs)
{
return readb(map->map_priv_1 + ofs);
}__u16 mbx_read16(struct map_info *map, unsigned long ofs)
{
return readw(map->map_priv_1 + ofs);
}__u32 mbx_read32(struct map_info *map, unsigned long ofs)
{
return readl(map->map_priv_1 + ofs);
}void mbx_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len)
{
memcpy_fromio(to, (void *)(map->map_priv_1 + from), len);
}void mbx_write8(struct map_info *map, __u8 d, unsigned long adr)
{
writeb(d, map->map_priv_1 + adr);
}void mbx_write16(struct map_info *map, __u16 d, unsigned long adr)
{
writew(d, map->map_priv_1 + adr);
}void mbx_write32(struct map_info *map, __u32 d, unsigned long adr)
{
writel(d, map->map_priv_1 + adr);
}void mbx_copy_to(struct map_info *map, unsigned long to, const void *from, ssize_t len)
{
memcpy_toio((void *)(map->map_priv_1 + to), from, len);
}struct map_info mbx_map = {
name: "MBX flash",
size: WINDOW_SIZE,
buswidth: 4,
read8: mbx_read8,
read16: mbx_read16,
read32: mbx_read32,
copy_from: mbx_copy_from,
write8: mbx_write8,
write16: mbx_write16,
write32: mbx_write32,
copy_to: mbx_copy_to
};#if LINUX_VERSION_CODE < 0x20212 && defined(MODULE) #define init_mbx init_module
#define cleanup_mbx cleanup_module
#endif
int __init init_mbx(void)
{
printk(KERN_NOTICE "Motorola MBX flash device: %x at %x\n", WINDOW_SIZE*4, WINDOW_ADDR);
mbx_map.map_priv_1 = (unsigned long)ioremap(WINDOW_ADDR, WINDOW_SIZE * 4);
if (!mbx_map.map_priv_1) {
printk("Failed to ioremap\n");
return -EIO;
}
mymtd = do_map_probe("jedec", &mbx_map);
if (mymtd) {
mymtd->module = THIS_MODULE;
add_mtd_device(mymtd);
add_mtd_partitions(mymtd, partition_info, NUM_PARTITIONS);
return 0;
}
iounmap((void *)mbx_map.map_priv_1);
return -ENXIO;
}static void __exit cleanup_mbx(void)
{
if (mymtd) {
del_mtd_device(mymtd);
map_destroy(mymtd);
}
if (mbx_map.map_priv_1) {
iounmap((void *)mbx_map.map_priv_1);
mbx_map.map_priv_1 = 0;
}
}module_init(init_mbx);module_exit(cleanup_mbx);
Quoted 8 lines
I am using
linuxppc_2_4(2.4.6) with current mtd support from cvs tree. The board is with JEDEC AMD 29F016 x4 flash chips (8M Flash space). Map file which I use for this board is attached (I userpxlite.candtqm8xxl.c(for partitioning) as reference). The problem I found is that mtd says:"mtd: Failed. Cannot handle unsymetric banking"
Did you mean AMD29F160 (instead of AMD29F016)? If so, I have a data sheet on my desk here that shows block sizes of:
#1 8K #2 4K #3 4K #4 16K #5 32K
....
#35 32K
--------------
Quoted 112 lines · Anton Todorov
Hi,
I am using
linuxppc_2_4(2.4.6) with current mtd support from cvs tree. The board is with JEDEC AMD 29F016 x4 flash chips (8M Flash space). Map file which I use for this board is attached (I userpxlite.candtqm8xxl.c(for partitioning) as reference).
The problem I found is that mtd says:"mtd: Failed. Cannot handle unsymetric banking"
I enabled some debug info in
jedec.c(uncommenting some printks and add some) and found that it is looking for banked and find bank[0] is 8M bank[1] is 0M
- realy unsymetric :)
but I think it is linear flash.
I worarounded it commentig one condition:jedec.c Tue Jul 10 10:07:41 2001 renamed from jedec.c.orig Tue Jul 10 10:06:41 2001 +1
-1@@ -159,7 +159,7 @@ are empty banks. Note, the last bank does not count here, only the first banks are important. Holes on non-bank boundaries can not exist due to the way the detection algorithm works. */ - if (priv.size < my_bank_size) +/* if (priv.size < my_bank_size) */ my_bank_size = priv.size; priv.is_banked = 0; //printk("priv.size is %x, my_bank_size is %x\n",priv.size,my_bank_size);but I think it is not the right action ...
now flash and partitioning(I think ) is working:
fromm booting kernel:
<>
Motorola MBX flash device: 800000 atfe000000MTD Part: MBX flash 4*[AMD Am29F016]
MTD->erasesizeis 40000MTD->sizeis 800000
mtd: Giving out device 0 to MBX flash
Creating 3 MTD partitions on "MBX flash":
0x00000000-0x00080000 : "MBX flash BOOT partition"
mtd: Giving out device 1 to MBX flash BOOT partition 0x00080000-0x00600000 : "MBX flash DATA partition"
mtd: Giving out device 2 to MBX flash DATA partition 0x00600000-0x00800000 : "MBX flash APPLICATION partition"
mtd: Giving out device 3 to MBX flash APPLICATION partition <>
sh-2.03# ./mtd_debug info/dev/mtd0
mtd.type =MTD_NORFLASH
mtd.flags =MTD_CAP_NORFLASH
mtd.size = 8388608 (8M)
mtd.erasesize = 262144 (256K)
mtd.oobblock = 0
mtd.oobsize = 0
mtd.ecctype =MTD_ECC_NONE
regions = 0sh-2.03# ./mtd_debug info
/dev/mtd1
mtd.type =MTD_NORFLASH
mtd.flags =MTD_CAP_NORFLASH
mtd.size = 524288 (512K)
mtd.erasesize = 262144 (256K)
mtd.oobblock = 0
mtd.oobsize = 0
mtd.ecctype =MTD_ECC_NONE
regions = 0sh-2.03# ./mtd_debug info
/dev/mtd2
mtd.type =MTD_NORFLASH
mtd.flags =MTD_CAP_NORFLASH
mtd.size = 5767168 (5M)
mtd.erasesize = 262144 (256K)
mtd.oobblock = 0
mtd.oobsize = 0
mtd.ecctype =MTD_ECC_NONE
regions = 0sh-2.03# ./mtd_debug info
/dev/mtd3
mtd.type =MTD_NORFLASH
mtd.flags =MTD_CAP_NORFLASH
mtd.size = 2097152 (2M)
mtd.erasesize = 262144 (256K)
mtd.oobblock = 0
mtd.oobsize = 0
mtd.ecctype =MTD_ECC_NONE
regions = 0I managed to mount
/dev/mtdblock3as jffs and can create and delete files there.My question is why jedec driver find it as banked?
maybe it is my fault inmbx860.cmap file?
My patch is not the right solution curently I will add some ifdefs to comment patched line when I am using MBX board.
also I found that the einfo utility is not working on this board it says:
<>
sh-2.03# ./einfo/dev/mtd0
Device/dev/mtd0has 0 erase regions
<>
butmtd_debugutil is working ass seen above.
I have RPX Classic board with CFI AMD flash and same binary is working.comments?
Best Regards,
Anton Todorov
Emness Technology------------------------------------------------------------------------
Name: mbx860.c
mbx860.cType: text/x-c
Encoding: base64
Quoted 12 lines · you
Quoted 8 lines
I am using
linuxppc_2_4(2.4.6) with current mtd support from cvs tree. The board is with JEDEC AMD 29F016 x4 flash chips (8M Flash space). Map file which I use for this board is attached (I userpxlite.candtqm8xxl.c(for partitioning) as reference). The problem I found is that mtd says:"mtd: Failed. Cannot handle unsymetric banking"
Did you mean AMD29F160 (instead of AMD29F016)? If so, I have a data sheet on my desk here that shows block sizes of:
Quoted 8 lines
#1 8K #2 4K #3 4K #4 16K #5 32K....
#35 32K
no. iIt is exactly AM29F016B-90EC and is only JEDEC compatible.
Regards,
Anton Todorov
Emness Technology
Help: MTD & SmartMedia
In reply to Anton TodorovHelp -- what is the best MTD approach for a guy who wants r/w ability of an embedded SmartMedia slot of a Linux device, but also wants the media readable/writable when taken to a desktop Windows box?
Should I use this combination?
vfat + MTD + nftl("user") + nand.c("driver")
Thanks!
Steve Kranz <[email protected]>
RidgeRun, Inc.
Re: Help: MTD & SmartMedia
Quoted 2 lines · [email protected] said:
Should I use this combination?
vfat + MTD +nftl("user")+nand.c("driver")
Using nand.c as the driver is correct. However, the SmartMedia format is not NFTL. It looks like there's sufficient information at
http://www.ssfdc.or.jp/spec/english/ to implement the appropriate translation layer code.
--
dwmw2
Quoted 5 lines · [email protected] said:
I am using
linuxppc_2_4(2.4.6) with current mtd support from cvs
tree. The board is with JEDEC AMD 29F016 x4 flash chips (8M Flash space). Map file which I use for this board is attached (I userpxlite.candtqm8xxl.c(for partitioning) as reference). The problem I found is that mtd says:
Thanks. May I add that map driver to CVS?
You should hopefully now find that the new jedec_probe stuff will work for your chips, and you don't have to use the old jedec code.
--
dwmw2
Quoted 8 lines · you
Quoted 5 lines · [email protected] said:
I am using
linuxppc_2_4(2.4.6) with current mtd support from cvs
tree. The board is with JEDEC AMD 29F016 x4 flash chips (8M Flash space). Map file which I use for this board is attached (I userpxlite.candtqm8xxl.c(for partitioning) as reference). The problem I found is that mtd says:Thanks. May I add that map driver to CVS?
Yes it is under GPL !
I am attaching another one with more descriptive header :)
Quoted 3 lines
You should hopefully now find that the new
jedec_probestuff will work for your chips, and you don't have to use the old jedec code.
I hope it works but for the moment my work on ppc based boards is suspended, but I hope soon to came back to it.
Quoted 2 lines
--
dwmw2
Best Regards,
Anton Todorov
Emness Technology
http://www.emness.com
/*
* $Id: mbx860.c,v 1.1 2001/08/11 10:43:37 anton Exp $
*
* Handle mapping of the flash on MBX860 boards
*
* Author: Anton Todorov
* Copyright: (C) 2001 Emness Technology
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
*/
#include <linux/module.h>
#include <linux/types.h>
#include <linux/kernel.h>
#include <asm/io.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/map.h>
#include <linux/mtd/partitions.h>
#define WINDOW_ADDR 0xfe000000
#define WINDOW_SIZE 0x00200000
/* Flash / Partition sizing */
#define MAX_SIZE_KiB 8192
#define BOOT_PARTITION_SIZE_KiB 512
#define KERNEL_PARTITION_SIZE_KiB 5632
#define APP_PARTITION_SIZE_KiB 2048
#define NUM_PARTITIONS 3
/* partition_info gives details on the logical partitions that the split the
* single flash device into. If the size if zero we use up to the end of the
* device. */
static struct mtd_partition partition_info[]={
{ name: "MBX flash BOOT partition",
offset: 0,
size: BOOT_PARTITION_SIZE_KiB*1024 },
{ name: "MBX flash DATA partition",
offset: BOOT_PARTITION_SIZE_KiB*1024,
size: (KERNEL_PARTITION_SIZE_KiB)*1024 },
{ name: "MBX flash APPLICATION partition",
offset: (BOOT_PARTITION_SIZE_KiB+KERNEL_PARTITION_SIZE_KiB)*1024 }
};static struct mtd_info *mymtd;
__u8 mbx_read8(struct map_info *map, unsigned long ofs)
{
return readb(map->map_priv_1 + ofs);
}__u16 mbx_read16(struct map_info *map, unsigned long ofs)
{
return readw(map->map_priv_1 + ofs);
}__u32 mbx_read32(struct map_info *map, unsigned long ofs)
{
return readl(map->map_priv_1 + ofs);
}void mbx_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len)
{
memcpy_fromio(to, (void *)(map->map_priv_1 + from), len);
}void mbx_write8(struct map_info *map, __u8 d, unsigned long adr)
{
writeb(d, map->map_priv_1 + adr);
}void mbx_write16(struct map_info *map, __u16 d, unsigned long adr)
{
writew(d, map->map_priv_1 + adr);
}void mbx_write32(struct map_info *map, __u32 d, unsigned long adr)
{
writel(d, map->map_priv_1 + adr);
}void mbx_copy_to(struct map_info *map, unsigned long to, const void *from, ssize_t len)
{
memcpy_toio((void *)(map->map_priv_1 + to), from, len);
}struct map_info mbx_map = {
name: "MBX flash",
size: WINDOW_SIZE,
buswidth: 4,
read8: mbx_read8,
read16: mbx_read16,
read32: mbx_read32,
copy_from: mbx_copy_from,
write8: mbx_write8,
write16: mbx_write16,
write32: mbx_write32,
copy_to: mbx_copy_to
};#if LINUX_VERSION_CODE < 0x20212 && defined(MODULE) #define init_mbx init_module
#define cleanup_mbx cleanup_module
#endif
int __init init_mbx(void)
{
printk(KERN_NOTICE "Motorola MBX flash device: %x at %x\n", WINDOW_SIZE*4, WINDOW_ADDR);
mbx_map.map_priv_1 = (unsigned long)ioremap(WINDOW_ADDR, WINDOW_SIZE * 4);
if (!mbx_map.map_priv_1) {
printk("Failed to ioremap\n");
return -EIO;
}
mymtd = do_map_probe("jedec", &mbx_map);
if (mymtd) {
mymtd->module = THIS_MODULE;
add_mtd_device(mymtd);
add_mtd_partitions(mymtd, partition_info, NUM_PARTITIONS);
return 0;
}
iounmap((void *)mbx_map.map_priv_1);
return -ENXIO;
}static void __exit cleanup_mbx(void)
{
if (mymtd) {
del_mtd_device(mymtd);
map_destroy(mymtd);
}
if (mbx_map.map_priv_1) {
iounmap((void *)mbx_map.map_priv_1);
mbx_map.map_priv_1 = 0;
}
}module_init(init_mbx);module_exit(cleanup_mbx);