2009-07-20 10:57:05     ST M25P128 chip support

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

2009-07-20 10:57:05     ST M25P128 chip support

Peter Gombos (HUNGARY)

Message: 77735   

 

Hi,

 

My own custom board has M25P128 chip. I use u-boot 2009R1.

 

It seems the sf erase command calculates the address wrong. This flash has 256k sectors instead of the usual 64k.

 

in file drivers/mtd/spi/stmicro.c  around line 286

 

The original line is:

 

cmd[1] = (offset / sector_size) + actual;

 

If the sector size is 64k, the calculation is right. But in my case cmd[1] contains the sector number which should be erased but the flash chip requires the physical address of the sector.

 

My solution is to change the line:

 

cmd[1] = offset>>16;

 

It works with 64k and 256k flash chips too.

 

As far as I see the other manufacturers (winbond, spansion) do the same calculation.

QuoteReplyEditDelete

 

 

2009-07-20 14:22:25     Re: ST M25P128 chip support

Mike Frysinger (UNITED STATES)

Message: 77754   

 

your proposed change looks correct to me.  i think i have a board with that chip on it to double check.

QuoteReplyEditDelete

 

 

2009-07-21 16:31:41     Re: ST M25P128 chip support

Peter Gombos (HUNGARY)

Message: 77789   

 

The right line is:

 

cmd[1] = (offset + actual * sector_size)>>16;

 

because it is inside of a for cycle... sorry

QuoteReplyEditDelete

 

 

2009-07-21 16:42:33     Re: ST M25P128 chip support

Peter Gombos (HUNGARY)

Message: 77790   

 

Additionaly I did some modification to be able erase any size of a memory pool before update linux in SPI

 

My update script is the following:

 

sf probe 1;tftp $(loadaddr) $(linux_image);sf erase $(storeaddr) $(filesize);sf write $(loadaddr) $(storeaddr) $(filesize);set image_length $(filesize);save;

 

Boot script:

 

sf probe 1;sf read $(loadaddr) $(storeaddr) $(image_length);bootm;

 

In the original code the sf erase is refused because the erase length is not on sector boundary. I should erase the whole chip but it takes more time.

 

Any opinion?

QuoteReplyEditDelete

 

 

2009-07-21 17:32:58     Re: ST M25P128 chip support

Mike Frysinger (UNITED STATES)

Message: 77791   

 

since entire sectors need to be erased, there is no avoiding that.  so you should dedicate an entire sector or two for u-boot and then use those hardcoded sizes to erase.  the write can still use $(filesize) of course.

 

there is plans to add support for +len syntax, but it wont be worked on for a while.

Attachments

    Outcomes