VoCore: SPI Flash Unique ID

SPI microSD is not done yet 🙂 Just finish an easy driver patch.
This patch is used to get unique id from flash chip. That id is also VoCore Unique ID(unless you change the flash chip). It will be used to get back factory setting(include mac address, wifi parameter, etc.) If you change the flash partition “factory”(512 bytes) and want to change it back. That factory setting can be downloaded from this site by this VoCore Unique ID.

Download new driver file m25p80.c

diff the origin m25p80.c and my m25p80.c

< /* Used for Winbond flashes only. */
< #define OPCODE_WINBOND_ID    0x4b    /* Get flash unique id */
< /* flash unique id probe */
< static int unique_id_prob(struct spi_device *spi, u8 *id)
< {
<     int			tmp;
<     u8			code[5];
<     code[0] = OPCODE_WINBOND_ID;
<     tmp = spi_write_then_read(spi, &code, 5, id, 8);
<     if (tmp < 0) {
<         pr_debug("%s: error %d reading UNIQUE ID\n",
<                 dev_name(&spi->dev), tmp);
<         return tmp;
<     }
<     return 0;
< }
<     /* show unique id in kernel debug log for w25q64 or w25q128. */
<     if(info->jedec_id == 0xef4017 || info->jedec_id == 0xef4018) {
<         u8 unique_id[8];
<         if(!unique_id_prob(spi, unique_id)) {
<             dev_warn(&spi->dev, "flash id: %02x%02x%02x%02x%02x%02x%02x%02x\n",
<                     unique_id[7], unique_id[6], unique_id[5], unique_id[4],
<                     unique_id[3], unique_id[2], unique_id[1], unique_id[0]);
<         } else {
<             dev_warn(&spi->dev, "failed to get flash unique id.\n");
<         }
<     }

Part of bootup log:
This is tested by using winbond flash, but from read other chip datasheet, this is supported too.

Now the openwrt is compiled under mac 🙂 I do not have to use linux vm anymore. This makes the process a little faster. Thanks Markus Z for the tip, http://vocore.freshdesk.com/support/discussions/topics/1000033335

PS: there is a small bug in m25p80.c, jedec id of s25fl064k and w25q64 are same. w25q64(Winbond) jedec id is correct, so s25fl064k(Spansion) has a wrong id in the source. Is there anybody know its real jedec id? We should fix that little bug in linux kernel.

2 thoughts on “VoCore: SPI Flash Unique ID

    1. vongervonger Post author

      That code will conflict with the exists Spansion flash…
      What I do in the new patch is to move Winbond data in front of Spansion flash, so driver will search w25q64 first.

Comments are closed.