Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
20 years ago

MTD do_write_oneword fails

Hi

I'm having some trouble with writing to a flash partition on our board running Microtronix 1.4 uclinux 2.6

We have 5 partitions on our flash:

static struct mtd_partition microtronix_partitions = {
    {
  .name =  "romfs/jffs2",
  .size =  0x160000,
  .offset =    0x190000,
    },{
  .name =  "loader/kernel",
  .size =  0x190000,
  .offset =    0,
    }, {
  .name =  "HMConfig",
  .size =  0x010000,
  .offset =    0x1F0000,
    }, {
  .name =  "User configuration",
  .size =  0x080000,
  .offset =    0x300000,
    }, {
  .name =  "safe configuration",
  .size =  0x080000,
  .offset =    0x380000,
    }
};

for the sake of testing , we have made an ext2 fs image, which is downloaded to the "User configuration" partition,

and mounted this on a /mnt/rwfs dev.

We are now able to see the files on the mounted partion (those that were already on the image), but we are not able to write anything to the partition.

Whenever we copy a file to the partition, it fails with a "MTD do_write_oneword(): software timeout" when the cache is flushed.

The error seems to be on random sectors and not all sectors.

The Flash is OK, because we are able to load the entire partiton with the ext2 fs image, through the Flash-Programmer.

We have even tried to make a image with 0x55 pattern to make sure that the entire partition is written physically and this is working when using the Flash-Programmer.

Does anyone have an idea, as to why we are have this problem?

2 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Your flash is write only.

    Writting to flash is not just a matter of writing to flash. In order to write to a flash, you must firt erase the "sector," then write to it. Your data is contiguous on the flash. So, to insert a new bit of information, you need to "push" the rest of the information towards the end of the flash.

    With that in mind. Look at the paragraph above. Replace "Writting to flash is not just........." with "Writting to your flash is not just............" In order to insert the "your," you must copy the entire section of code from flash, store it in some place like RAM, erase some number of "sectors" depending on the code size, insert "your", then write it all back to flash.

    Take a look at your flash data sheet, it will give you a better idea of what is done during a flash write.

    Doug
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    You are correct about the part where the sectors need to be erased - this is done by the MTD.

    The MTD reads the sector involved (places this in a RAM buffer), erases the correct sector, places

    the new file values in the RAM buffer and then commits this to the erased sector.

    If it was a problem with the Flash not being erased before writing, then the failure would not be random,

    but rather it would fail at the same addresses each time, as they were not erased.

    I'll try to see if I can narrow down the problem by enabling the MTD debug.