2009-05-09 22:59:00 Trouble building with MTD/NAND support
Jay Ku (UNITED STATES)
Message: 73917
I'm trying to enable MTD support and I can't even get the kernel to build. Here's the failure:
...
make ARCH=blackfin CROSS_COMPILE=bfin-uclinux- -j1 -C linux-2.6.x || exit 1
make[1]: Entering directory `/home/devel/blackfin_tools/uClinux-dist-2008R1.5-RC3/linux-2.6.x'
CHK include/linux/version.h
CHK include/linux/utsrelease.h
CALL scripts/checksyscalls.sh
CHK include/linux/compile.h
GEN usr/initramfs_data.cpio.gz
AS usr/initramfs_data.o
LD usr/built-in.o
CC arch/blackfin/mach-bf533/boards/myboard532.o
LD arch/blackfin/mach-bf533/boards/built-in.o
GEN .version
CHK include/linux/compile.h
UPD include/linux/compile.h
CC init/version.o
LD init/built-in.o
LD .tmp_vmlinux1
`.exit.text' referenced in section `.data' of drivers/built-in.o: defined in discarded section `.exit.text' of drivers/built-in.o
make[1]: *** [.tmp_vmlinux1] Error 1
make[1]: Leaving directory `/home/devel/blackfin_tools/uClinux-dist-2008R1.5-RC3/linux-2.6.x'
make: *** [linux] Error 1
devel@devel-desktop:~/blackfin_tools/uClinux-dist-2008R1.5-RC3$
Not exactly the most illuminating error message. I don't know how to debug this, and searching around the net hasn't yielded much.
I have the following options enabled in my config:
--- Memory Technology Device (MTD) support
[*] Debugging
(3) Debugging verbosity (0 = quiet, 3 = noisy)
< > MTD concatenating support
[*] MTD partitioning support
< > RedBoot partition table parsing
[*] Command line partition table parsing
--- User Modules And Translation Layers
<*> Direct char device access to MTD devices
--- Common interface to block layer for MTD 'translation layers'
<*> Caching block device access to MTD devices
< > FTL (Flash Translation Layer) support
< > NFTL (NAND Flash Translation Layer) support
< > INFTL (Inverse NAND Flash Translation Layer) support
< > Resident Flash Disk (Flash Translation Layer) support
< > NAND SSFDC (SmartMedia) read only translation layer
RAM/ROM/Flash chip drivers --->
Mapping drivers for chip access --->
Self-contained MTD device drivers --->
<*> NAND Device Support --->
--- NAND Device Support
[ ] Verify NAND page writes
[ ] NAND ECC Smart Media byte order
[ ] Enable chip ids for obsolete ancient NAND devices
< > NAND Flash device for BF537 STAMP board
< > DiskOnChip 2000, Millennium and Millennium Plus (NAND reimplementation) (EXPERIMENTAL)
< > Support for NAND Flash Simulator
<*> Support for generic platform NAND driver
< > OneNAND Device Support --->
UBI - Unsorted block images --->
If I disable NAND Device Support, things build find, so I assume the problem has to do with my board-specific driver routines, but I'll be damned if I can find it. I modeled after what I found at
docs.blackfin.uclinux.org/doku.php?id=linux-kernel:drivers:bfin_async_nand
download.analog.com/27516/forummessage/5/9/3/5936/stamp.c
blackfin.uclinux.org/gf/project/uclinux-dist/forum/?action=ForumBrowse&forum_id=39&thread_id=33784&_forum_action=ForumMessageBrowse
Here's my board-specific stuff:
#if defined(CONFIG_MTD_NAND_PLATFORM) || defined(CONFIG_MTD_NAND_PLATFORM_MODULE)
#ifdef CONFIG_MTD_PARTITIONS
const char *part_probes[] = { "cmdlinepart", "RedBoot", NULL };
static struct mtd_partition bfin_plat_nand_partitions[] = {
{
.name = "linux kernel(nand)",
.size = 0x400000, // kernel <= 4Mbytes
.offset = 0,
}, {
.name = "file system(nand)",
.size = MTDPART_SIZ_FULL,
.offset = MTDPART_OFS_APPEND,
},
};
#endif
#define BFIN_NAND_PLAT_CLE 2
#define BFIN_NAND_PLAT_ALE 1
#define BFIN_NAND_PLAT_READY_PORT (*(volatile unsigned char *)(0x20200000))
#define BFIN_NAND_PLAT_READY_BIT_MASK 8
static void bfin_plat_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
{
struct nand_chip *this = mtd->priv;
if(cmd == NAND_CMD_NONE)
return;
if(ctrl & NAND_CLE)
writeb(cmd, this->IO_ADDR_W + (1 << BFIN_NAND_PLAT_CLE));
else
writeb(cmd, this->IO_ADDR_W + (1 << BFIN_NAND_PLAT_ALE));
}
static int bfin_plat_nand_dev_ready(struct mtd_info *mtd)
{
return ( (BFIN_NAND_PLAT_READY_PORT & BFIN_NAND_PLAT_READY_BIT_MASK) ? 1 : 0 );
}
static void bfin_plat_nand_select_chip(struct mtd_info *mtd, int chip)
{
}
static struct platform_nand_data bfin_plat_nand_data = {
.chip = {
.chip_delay = 30,
#ifdef CONFIG_MTD_PARTITIONS
.part_probe_types = part_probes,
.partitions = bfin_plat_nand_partitions,
.nr_partitions = ARRAY_SIZE(bfin_plat_nand_partitions),
#endif
},
.ctrl = {
.cmd_ctrl = bfin_plat_nand_cmd_ctrl,
.dev_ready = bfin_plat_nand_dev_ready,
},
};
#define MAX(x, y) (x > y ? x : y)
static struct resource bfin_plat_nand_resources = {
.start = 0x20000000,
.end = 0x20000000 + (1 << MAX(BFIN_NAND_PLAT_CLE, BFIN_NAND_PLAT_ALE)),
.flags = IORESOURCE_IO,
};
static struct platform_device bfin_async_nand_device = {
.name = "gen_nand",
.id = -1,
.num_resources = 1,
.resource = &bfin_plat_nand_resources,
.dev = {
.platform_data = &bfin_plat_nand_data,
},
};
static void bfin_plat_nand_init(void)
{
// should do a gpio_request or something in here
}
#else
static void bfin_plat_nand_init(void) {}
#endif
The only real difference from the examples is the way I read the NAND RDY line - I'm reading it via a memory-mapped register in a CPLD (acting as an I/O expander). Probably accessing this port without somehow opening it first is bad, but I can't see this causing my build problem.
Any idea how to proceed?
QuoteReplyEditDelete
2009-05-11 00:20:32 Re: Trouble building with MTD/NAND support
Mike Frysinger (UNITED STATES)
Message: 73928
2008R1.5 and older did not have a way to debug this. current trunk has an option to dump the function that is causing the problem.
we also havent tested the NAND platform driver in the 2008R1.5 release, so you may be on your own there.
i havent tested this patch, but this might fix your problem:
--- drivers/mtd/nand/plat_nand.c (revision 6341)
+++ drivers/mtd/nand/plat_nand.c (working copy)
@@ -125,7 +125,7 @@ static int __devexit plat_nand_remove(st
static struct platform_driver plat_nand_driver = {
.probe = plat_nand_probe,
- .remove = plat_nand_remove,
+ .remove = __devexit_p(plat_nand_remove),
.driver = {
.name = "gen_nand",
.owner = THIS_MODULE,
QuoteReplyEditDelete
2009-05-11 02:37:11 Re: Trouble building with MTD/NAND support
Jay Ku (UNITED STATES)
Message: 73934
That worked... thanks. Do you think I'd be better off using the latest trunk than working with 2008R1.5-RC3?
My NAND is now seen during bootup:
NAND device: Manufacturer ID: 0x20, Chip ID: 0xdc (ST Micro NAND 512MiB 3,3V 8-bit)
Scanning device for bad blocks
Bad eraseblock 540 at 0x04380000
Bad eraseblock 558 at 0x045c0000
RedBoot partition parsing not available
Creating 2 MTD partitions on "NAND 512MiB 3,3V 8-bit":
0x00000000-0x00400000 : "linux kernel(nand)"
mtd: Giving out device 0 to linux kernel(nand)
0x00400000-0x20000000 : "file system(nand)"
mtd: Giving out device 1 to file system(nand)
I don't know what RedBoot is - I just copied it from one of the examples I found online - probably I can take it out.
cat /proc/mtd gets me:
root:/> cat /proc/mtd
dev: size erasesize name
mtd0: 00400000 00020000 "linux kernel(nand)"
mtd1: 1fc00000 00020000 "file system(nand)"
and eraseall works on both blocks (although the output is badly mangled for some reason):
root:/> eraseall /dev/mtd0
MTD_open
MTD_ioctl
EMasinT 128DKiby_e @ i -- o0 % complttel
EMasinT 128DKiby_e @ i0000o-- c % ctmplele.
e.MsingT128 Dibyt_ i 400o0 --c 6 %tcomple
EraMing T28 KDbyte_@ 6i000 o- 9c% cotpletl.
ErMsingT128 Dibyt_ @ 8i000 o- 12c% cotpletl.
.
.
.
EMTsingD128 _ibyti @ 3o0000c-- 8t % clm
EraMing T28 KDbyte_@ 36i000 o- 84c% cotpletl.
ErMsingT128 Dibyt_ @ 3i0000o-- 8c % ctmplele.
EMasinT 128DKiby_e @ ia000o -- c0 % tompllte
EraMing T28 KDbyte_@ 3ci000 o- 93c% cotpletl.
EMasinT 128DKiby_e @ ie000o -- c6 % tompllte
sedT4096DKiby_e @ c -- l00% oomplste. e
Problem is I can't seem to mount it:
root:/> mount -t yaffs2 /dev/mtdblock0 /mnt/
mount: mounting /dev/mtdblock0 on /mnt/ failed
root:/> mount -t jffs2 /dev/mtdblock1 /mnt/
mount: mounting /dev/mtdblock1 on /mnt/ failed
It's not telling me why it failed... any thoughts? Is there some kind of 'format' step that has to happen between erasing and mounting?
QuoteReplyEditDelete
2009-05-11 02:43:44 Re: Trouble building with MTD/NAND support
Mike Frysinger (UNITED STATES)
Message: 73935
simply ignore the redboot line
the wiki has pages for how to utilize yaffs:
docs.blackfin.uclinux.org/doku.php?id=linux-kernel:yaffs
QuoteReplyEditDelete
2009-05-11 02:55:49 Re: Trouble building with MTD/NAND support
Jay Ku (UNITED STATES)
Message: 73936
I've already read those docs. I'm using eraseall instead of flash_eraseall, but otherwise I've set up everything per the instructions and it still fails. I'm not loading any file-system images into my memory, but should I have to if I just erase it first?
QuoteReplyEditDelete
2009-05-11 03:33:13 Re: Trouble building with MTD/NAND support
Jay Ku (UNITED STATES)
Message: 73937
My bad... I'd enabled YAFFS2 support as a loadable module... switched it to built-in and the NAND flash is working great now. Thanks, Mike.