LibFlash and W25X10BV

Technical questions regarding the XTC tools and programming with XMOS.
Post Reply
User avatar
rp181
Respected Member
Posts: 395
Joined: Tue May 18, 2010 12:25 am
Contact:

LibFlash and W25X10BV

Post by rp181 »

I am having a strange problem with libflash and a W25X10BV.

If I flash the chip with an image with a boot partition size (so there is a data partition), everything completes successfully. When I run as an XCore application, it works once. When I run again, the data partition size is showing as 0. In effect, I have to re-flash it before every run. I thought that the problem may be the flash device so I wrote a configuration file, but I am not quite sure how to actually use it. The file:

Code: Select all

10, 								/* 1. libflash device ID */
256, 								/* 2. Page size */
512, 								/* 3. Number of pages */
3, 									/* 4. Address size */
4, 									/* 5. Clock divider */
0x9f, 								/* 6. RDID cmd */
0, 									/* 7. RDID dummy bytes */
3, 									/* 8. RDID data size in bytes */
0x103011,	 						/* 9. RDID manufacturer ID */
0x20, 								/* 10. SE cmd */
0, 									/* 11. SE full sector erase */
0x06, 								/* 12. WREN cmd */
0x04, 								/* 13. WRDI cmd */
PROT_TYPE_SR,						/* 14. Protection type */
{{0x0c,0x0},{0,0}}, 				/* 15. SR protect and unprotect cmds */
0x02, 								/* 16. PP cmd */
0x0b, 								/* 17. READ cmd */
1, 									/* 18. READ dummy bytes */
SECTOR_LAYOUT_REGULAR, 				/* 19. Sector layout */
{32768,{0,{0}}}, 					/* 20. Sector sizes */
0x05, 								/* 21. RDSR cmd */
0x01, 								/* 22. WRSR cmd */
0x01, 								/* 23. WIP bit mask */
This file is in the same directory as the source files with name w25x10bv. In the code, I do:

Code: Select all

fl_DeviceSpec W25X10BV[] = {
	{
	#include "w25x10bv"
	}
	};

r = fl_connectToDevice(flashSPI, W25X10BV,1);
However, this causes an exception:

Code: Select all

xrun: Program received signal ET_LOAD_STORE, Memory access exception.
      [Switching to stdcore[0] hwthread 4]


MaxFlashrom
Experienced Member
Posts: 82
Joined: Fri Nov 05, 2010 2:59 pm

Post by MaxFlashrom »

I have in C:

Code: Select all


fl_DeviceSpec flash_devices[] = {
  { 
#include "flashspec1.spec" // see tools guide for format
  },

  {
#include "flashspec2.spec"
  }

};


fl_PortHolderStruct p_flash = {
    XS1_PORT_1A,
    XS1_PORT_1B,
    XS1_PORT_1C,
    XS1_PORT_1D,
    XS1_CLKBLK_1
};

result = fl_connectToDevice(&p_flash, flash_devices, sizeof(flash_devices)/sizeof(fl_DeviceSpec));
Note the first parameter is passed as a pointer to the struct(or a reference in XC) in the call to fl_connectToDevice. Your example was not clear on this. This may be causing your problem. I have not checked all your custom fields for your W25X10BV, but the general format looks OK.
Multiple custom flash devices can be supported.

I would recommend that you always use --spi-spec <myflash.spec> when calling xflash and also do not use

Code: Select all

int fl_connect(fl_SPIPorts& SPI)
: pass in your own list of supported devices. You can use the #defines included from SpecMacros.h, if you need to.

Hope this helps
Max.
MaxFlashrom
Experienced Member
Posts: 82
Joined: Fri Nov 05, 2010 2:59 pm

Post by MaxFlashrom »

XMOS currently defines this in SpecMacros.h (for the 11.2.2 tools)
This differs from yours in some fields. Check that what you have makes sense.

Code: Select all

#define FL_DEVICE_WINBOND_W25X10 \
{ \
    WINBOND_W25X10, \
    256,                    /* page size */ \
    512,                    /* num pages */ \
    3,                      /* address size */ \
    8,                      /* log2 clock divider */ \
    0x9f,                   /* SPI_RDID */ \
    0,                      /* id dummy bytes */ \
    3,                      /* id size in bytes */ \
    0xef3011,               /* device id */ \
    0x20,                   /* SPI_SSE */ \
    0,                      /* full sector erase */ \
    0x06,                   /* SPI_WREN */ \
    0x04,                   /* SPI_WRDI */ \
    PROT_TYPE_SR,           /* protection through status reg */ \
    {{0x1c,0x00},{0,0}},    /* no values */ \
    0x02,                   /* SPI_PP */ \
    0x0b,                   /* SPI_READFAST */ \
    1,                      /* 1 read dummy byte */ \
    SECTOR_LAYOUT_REGULAR,  /* sane sectors */ \
    {4096,{0,{0}}},         /* regular sector size */ \
    0x05,                   /* SPI_RDSR */ \
    0x01,                   /* SPI_WRSR */ \
    0x01,                   /* SPI_WIP_BIT_MASK */ \
}
Max.
Post Reply