"Erase-all" fails with 10.4 XFLASH

Technical questions regarding the XTC tools and programming with XMOS.
Post Reply
va3ttn
Member
Posts: 12
Joined: Sat Jul 03, 2010 1:46 pm

"Erase-all" fails with 10.4 XFLASH

Post by va3ttn »

Using XC-1 with AMIC A25L80P flash.
Have 3 chips. All behave the same.
Chips program fine on the first attempt and CPU boots correctly.

It's impossible to program the chip for the second time,
the programmer starts, then hangs up upon reaching the address 0x000c00.
Putting in new chip repeats the same: first attempt OK, then hang up at 0x000c00.

With 10.4 I tried the --erase-all option and got the following:

Code: Select all

F:\XMOS Projects\Graphics2\Debug>xflash --id 0 --target-file XC-1.xn --spi-spec A25L80P.txt --erase-all
  --device option is deprecated, use --id
Error: F03075 Failed to execute flash erasure app.
What is the "flash erasure app"?
Is there something missing from my 10.4?

For reference, here's my specification file for A25L80P flash:

Code: Select all

    24,                      /*  flash id = value returned by fl_getFlashType                */
    256,                     /*  page size in bytes                                          */
    4096,                    /*  number of pages                                             */
    3,                       /*  number of address bytes to send                             */
    8,                       /*  divider to generate the SPI clock from the reference clock  */
    0x9f,                    /*  command to read the device ID                               */
    1,                       /*  number of dummy bytes returned before the ID                */
    3,                       /*  ID size in bytes                                            */
    0x372014,                /*  expected device ID                                          */
    0xd8,                    /*  command to erase all or part of a sector                    */
    0,                       /*  number of bytes erased by sector erase;  0 = entire sector  */
    0x06,                    /*  command to write-enable the device                          */
    0x04,                    /*  command to write-disable the device                         */
    SEC_PROT_NONE,           /*  protection type;  PROT_TYPE_NONE = no protection            */
    {{0,0},{0,0}},           /*  description of the device protection                        */
    0x02,                    /*  command to program a page                                   */
    0x03,                    /*  command to read data                                        */
    0,                       /*  number of dummy bytes returned before the data              */
    SECTOR_LAYOUT_REGULAR,   /*  sector layout; SECTOR_LAYOUT_REGULAR=all sectors same size  */
    {65536,{0,{0}}},         /*  sector sizes                                                */
    0x05,                    /*  command to read  the status register                        */
    0x01,                    /*  command to write the status register                        */
    0x01,                    /*  bit mask for the Write In Progress bit                      */


m_y
Experienced Member
Posts: 69
Joined: Mon May 17, 2010 10:19 am

Post by m_y »

The "flash erasure app" is the program created by xflash which runs on the target and does the erasing. It's failing, at least in part, because there's is a bug in 10.4. The --spi-spec options doesn't work with --read-all, --write-all, and --erase-all.

Here's an XC erase-all program into which you can drop your own spi-spec. As it stands it works on the XK-1 borard.

Code: Select all

#include <platform.h>
#include <flashlib.h>
#include <print.h>

fl_PortHolderStruct portHolder =
{
  PORT_SPI_MISO,
  PORT_SPI_SS,
  PORT_SPI_CLK,
  PORT_SPI_MOSI,
  on stdcore[0]: XS1_CLKBLK_1
};

fl_DeviceSpec deviceSpecs[] =
{
  {
    42,
    256,
    512,
    3,
    8,
    0x9F,
    0,
    3,
    0x1f6601,
    0xD8,
    0,
    0x06,
    0x04,
    PROT_TYPE_SR,
    {{0x0c,0x02},{0,0}},
    0x02,
    0x0B,
    1,
    SECTOR_LAYOUT_REGULAR,
    {32768,{0,{0}}},
    0x05,
    0x01,
    0x01
  }
};

int main()
{
  par
  {
    on stdcore[0]:
    {
      if( 0 == fl_connectToDevice( portHolder, deviceSpecs, 1 ) )
      {
        fl_setProtection(0);
        fl_eraseAll();
        fl_disconnect();
      }
      else
      {
        printstr("Error: Failed to connect to flash device.\n");
      }
    }
  }
  return(0);
}
m_y
Experienced Member
Posts: 69
Joined: Mon May 17, 2010 10:19 am

Post by m_y »

va3ttn wrote:Using XC-1 with AMIC A25L80P flash.
Have 3 chips. All behave the same.
Chips program fine on the first attempt and CPU boots correctly.
I've not enountered this chip before. Will find the datasheet and see if there's something obvious which would cause this.
m_y
Experienced Member
Posts: 69
Joined: Mon May 17, 2010 10:19 am

Post by m_y »

I've had a look through the datasheet and the spispec. There is no obvious cause for the hang. I expect that it's spinning waiting for the WIP bit to go low, but this isn't happening for some reason.

I've made a couple of changes to the SPI spec which might help: protection (from PROT_TYPE_NONE to PROT_TYPE_SR), sector layout (from SECTOR_LAYOUT_REGULAR to SECTOR_LAYOUT_IRREGULAR, added layout information). I don't have this chip available for testing here so I haven't be able to verify.

Code: Select all

    24,                      /*  flash id = value returned by fl_getFlashType                */
    256,                     /*  page size in bytes                                          */
    4096,                    /*  number of pages                                             */
    3,                       /*  number of address bytes to send                             */
    8,                       /*  divider to generate the SPI clock from the reference clock  */
    0x9f,                    /*  command to read the device ID                               */
    1,                       /*  number of dummy bytes returned before the ID                */
    3,                       /*  ID size in bytes                                            */
    0x372014,                /*  expected device ID                                          */
    0xd8,                    /*  command to erase all or part of a sector                    */
    0,                       /*  number of bytes erased by sector erase;  0 = entire sector  */
    0x06,                    /*  command to write-enable the device                          */
    0x04,                    /*  command to write-disable the device                         */
    PROT_TYPE_SR,           /*  protection type;  PROT_TYPE_NONE = no protection            */
    {{0x1e,0x02},{0,0}},           /*  description of the device protection                        */
    0x02,                    /*  command to program a page                                   */
    0x03,                    /*  command to read data                                        */
    0,                       /*  number of dummy bytes returned before the data              */
    SECTOR_LAYOUT_IRREGULAR,   /*  sector layout; SECTOR_LAYOUT_IRREGULAR  */
    {0,{20,{4,4,5,6,7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8}}},         /*  sector sizes                               */
    0x05,                    /*  command to read  the status register                        */
    0x01,                    /*  command to write the status register                        */
    0x01,                    /*  bit mask for the Write In Progress bit                      */
User avatar
jonathan
Respected Member
Posts: 377
Joined: Thu Dec 10, 2009 6:07 pm
Contact:

Post by jonathan »

Can we have the source for xflash library (libflash.a) please? It's impossible to debug SPI Flash problems without it.
Image
Post Reply