2009-03-05 14:32:53     MTD Partitions (bf537, JFFS2, Flash=S25FL128P)

Document created by Aaronwu Employee on Aug 14, 2013
Version 1Show Document
  • View in full screen mode

2009-03-05 14:32:53     MTD Partitions (bf537, JFFS2, Flash=S25FL128P)

Steven Vacca (UNITED STATES)

Message: 70466   


Hi all,


I am having trouble creating MTD partitons.  I want to have a Bootloader partiton, followed by a Kernel partition, followed  by a JFFS2 filesystem partition.


I am using uClinux-dist-2008R1.5-RC3.


I have a custom development bd based on the bf537-STAMP, and it has the bf537 chip and Spansion SPI Flash chip, S25FL128P (16Meg).


I'm currently am able to produce a uImage which contains the kernel, and also my custom app file (with threads) located in the /mnt of the resulting romfs. I'm able to ICE-Bear the boot loader and my kernel to the bd, have the kernel

boot-up, and execute my app, with threads ablazin'.


But, I need to implement an MTD/JFFS2 filesystem, in which to place my apps and other files, which will be updated occasionally via FTP.


When the kernel boots-up, I see no print msgs stating anything about the MTD partitions.  Once I can get the MTD partitions incorporated, I can then FTP the produced rootfs.jffs2 file (produced when compiling the uImage) to the 3rd partition.


BTW, my make syntax for the FLAT file is:


   make CROSS=bfin-uclinux- -Wl,-elf2flt


In my menuconfig, I have the following pertinent settings:



  Analog Devices/BF537-STAMP



  Device Drivers:

    MTD Support:

      Y MTD partitioning support

      N Commandline partition table parsing

      Y Direct char device access to MTD devices

      Y Caching block device access to MTD devices


      RAM/ROM/Flash chip drivers

        N Detect flash chips by CFI probe

        Y Detect non-CFI AMD/JEDEC-compatible flash chips


      Mapping drivers for chip access

        Y Support non-linear mappings of flash chips

        N CFI flash device in physical memory map

        N Generic uClinux RAM/ROM filesystem support


      (NOTE: There no Self-contained MTD device drivers for the S25FL128P Flash chip.)


  File systems:

    N JFS filesystem support


    Miscellaneous filesystems:

      Y Journalling Flash File System v2 (JFFS2) support

      2 JFFS2 debugging verbosity

      Y JFFS2 write-buffering support




When I do: </proc cat mtd>   all I get is  <dev:  size  erasesize  name>

So, there are apparently no MTD partitions getting created.


When the kernel is booting, all I see is some mention of JFFS2:


  JFFS2 version 2.2. (NAND)  (SUMMARY)   2001-2006 Red Hat, Inc.

  JFFS2: default compression mode: priority




In linux-2.6.x/arch/blackfin/mach-bf537/boards/stamp.c, I added the following:



/* all SPI peripherals info goes here */


//!!! My additions !!!:


static struct mtd_partition bfin_spi_flash_partitions[] =



.name   = "bootloader",

.size   = 0x00040000,

.offset  = 0,     //Offset from FLASH addr 0x0000.0000.

.mask_flags = MTD_CAP_ROM



.name   = "kernel",

.size   = 0x600000,

.offset     = MTDPART_OFS_APPEND //Append after bootloader section.



.name   = "file system",

.size   = MTDPART_SIZ_FULL,  //Occupy rest of FLASH.

.offset     = MTDPART_OFS_APPEND //Append after kernel section.





static struct flash_platform_data bfin_spi_flash_data =


  .name = "S25FL128P",

  .parts = bfin_spi_flash_partitions,

  .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),

  .type = "S25FL128P"




//SPI flash chip (S25FL128P)

static struct bfin5xx_spi_chip spi_flash_chip_info =


  .enable_dma = 0,             //Use DMA transfer with this chip.

  .bits_per_word = 8,






//I also added this, but am not sure if it's proper (as I based it on the nearby CONFIG_MTD_M25P80 section.



#if 1


/* the modalias must be the same as spi device driver name */

.modalias = "s25fl128", /* Name of spi_driver for this device */

.max_speed_hz = 25000000,     /* max spi clock (SCK) speed in HZ */

.bus_num = 0, /* Framework bus number */

.chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/

.platform_data = &bfin_spi_flash_data,

.controller_data = &spi_flash_chip_info,

.mode = SPI_MODE_3,







I assume that with the bf537 and SPI Flash, I don't use the Physical Mapping, physmap.c.  It also appears that selecting bf537 (instead of the bf533), the file bf5xx_flash.c doesn't get compiled, which may be correct.


After some debugging, I don't think add_mtd_partitions() in mtdpart.c is getting called, especially since bf5xx_flash.c isn't getting invoked. It appears that the bf537 isn't supposed to invoke it, but if set for the bf533, it does.











2009-03-05 15:19:18     Re: MTD Partitions (bf537, JFFS2, Flash=S25FL128P)

Mike Frysinger (UNITED STATES)

Message: 70467   


have you reviewed the mtd documentation ?






2009-03-05 15:40:23     Re: MTD Partitions (bf537, JFFS2, Flash=S25FL128P)

Steven Vacca (UNITED STATES)

Message: 70472   


Yes, I have read that numerous times, and it is chock-full of great info. But I'm not sure

what I'm missing.  Areas of interest are the sections which state the drivers are in mtd/maps,

the Partitioning section.  I'm confused about the drivers, and should I be using command line










2009-03-05 15:50:17     Re: MTD Partitions (bf537, JFFS2, Flash=S25FL128P)

Mike Frysinger (UNITED STATES)

Message: 70474   


the document also talks about enabling a chip driver for spi flashes which you didnt show in the summary of options you enabled ... that's why i asked if you read the document


now that i think about it some more, the spi flash driver in the 2008R1.5 release did not support for any S25FL parts.  the latest driver in trunk does.




2009-03-05 15:57:48     Re: MTD Partitions (bf537, JFFS2, Flash=S25FL128P)

Steven Vacca (UNITED STATES)

Message: 70476   


OK, let me check into that.  Thanks.




2009-03-06 10:43:27     Re: MTD Partitions (bf537, JFFS2, Flash=S25FL128P)

Steven Vacca (UNITED STATES)

Message: 70533   


I downloaded the uclinux-dist-trunk-svn.src tarfile from the Nightly Snapshots. The only pertinent driver I see is the m25p80.c file in the ~/drivers/mtd/devices folder.


In m25p80, it shows:


/* NOTE: double check command sets and memory organization when you add

* more flash chips.  This current list focusses on newer chips, which

* have been converging on command sets which including JEDEC ID.


static struct flash_info __devinitdata m25p_data [] = {




/* Spansion -- single (large) sector size only, at least

  * for the chips listed here (without boot sectors).


{ "s25sl004a", 0x010212, 0, 64 * 1024, 8, },

{ "s25sl008a", 0x010213, 0, 64 * 1024, 16, },

{ "s25sl016a", 0x010214, 0, 64 * 1024, 32, },

{ "s25sl032a", 0x010215, 0, 64 * 1024, 64, },

{ "s25sl064a", 0x010216, 0, 64 * 1024, 128, },

        { "s25sl12800", 0x012018, 0x0300, 256 * 1024, 64, },

{ "s25sl12801", 0x012018, 0x0301, 64 * 1024, 256, },







This is for something called an s25slxxx, not an s25flxxx. Is this the same thing?

Can't find any info on the net regarding an "sl".


Anyway, to implement the driver, should I configure for the m25p80 in menuconfig?









2009-03-06 13:31:16     Re: MTD Partitions (bf537, JFFS2, Flash=S25FL128P)

Mike Frysinger (UNITED STATES)

Message: 70538   


afaik, it's the same thing




2009-03-09 16:28:47     Re: MTD Partitions (bf537, JFFS2, Flash=S25FL128P)

Steven Vacca (UNITED STATES)

Message: 70623   




The hardware guys here gave me a bf537 dev bd and some schematcs.  The schematics say the FLASH chip is an s25fl128.  Guess what?  The dev bd actually has an m25p128 FLASH chip on it.  I've already scooped-up off the floor all the hair I pulled out of my head.  :>)   Thanks for the help, anyway.