SPI_FLASH_INSTRUCTION_CODE ( 0x4B ) for get the UID 64 Bit MAC of Winbond

User avatar
rudi
Posts: 197
Joined: Fri Oct 24, 2014 7:55 pm

SPI_FLASH_INSTRUCTION_CODE ( 0x4B ) for get the UID 64 Bit MAC of Winbond

Postby rudi » Thu Aug 20, 2015 11:15 pm

hi espressif

have we an official api for comunicate with the SPI_FLASH?
i mean not the read, write function to a SPI_FLASH to store or read bytes.

right, we have an api command to read the manufacturer id

spi_flash_get_id()

but i mean, is there an official api to send instruction code to the SPI FLASH
example :
to read the SPI_FLASH MAC ID - i mean the uinique id ( 64 Bit )

read Winbond - instruction code byte is : 0x4B


there is a unique 64bit MAC/ID at address 0X4B on the flash chip.
this could be very useful in uniquely identifying flash ic in a large manufacturer
and history database for firmware / updates.


the UID number can be used in conjunction with user software methods
to help prevent copying or cloning of a system.


linked to a pdf ( example the W25Q64CV )
because file is too big for upload.

Code: Select all

 
https://www.winbond.com/resource-files/w25q64cv_revh_052214[2].pdf


please have a look to side 55
point : 7.2.3.4 Read Unique ID Number (4BH)

please support this as an api instruction.
please support to can send other instruction code too.

example: 7.2.39 Read Security Registers ( 48h )

there are more interesst instruction code

i have write/request this more as one time i know -


please support this in an api command official


thank you!
best wishes
rudi ;-)

-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪

User avatar
rudi
Posts: 197
Joined: Fri Oct 24, 2014 7:55 pm

Re: SPI_FLASH_INSTRUCTION_CODE ( 0x4B ) for get the UID 64 Bit MAC of Winbond

Postby rudi » Sun Sep 20, 2015 10:55 am

push #

-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪

User avatar
rudi
Posts: 197
Joined: Fri Oct 24, 2014 7:55 pm

Re: SPI_FLASH_INSTRUCTION_CODE ( 0x4B ) for get the UID 64 Bit MAC of Winbond

Postby rudi » Tue Sep 22, 2015 2:53 am

Solved and DONE

got my new flash ic's just in time- so i have a short try with this 32Mbit,
and runs like clockwork in my code - i solved this now- and can go next step to make fw better proteced.

if you can support this in your api too - would be fine step -

the UID number can be used in conjunction with user software methods
to help prevent copying or cloning of a system.


"Thanks for your interest in this...
Attachments
bbs.png
ready ;-) .jpg

-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪

lihwarlee
Posts: 1
Joined: Sat Jan 16, 2016 9:07 am

Re: SPI_FLASH_INSTRUCTION_CODE ( 0x4B ) for get the UID 64 Bit MAC of Winbond

Postby lihwarlee » Sat Jan 16, 2016 9:15 am

Do you have any sample code about reading Unique ID of W25Q32 ?

Pls send the SAMPLE CODE to me, E-mail: 64569224@qq.com

Thank you.


I have use your SPI driver to debug this, but it is NOT success.

void ReadFlashID(BYTE *pManuId, BYTE *pDevId)
{
BYTE tmp;

spi_master_init(0);

spi_mast_byte_write(0, 0x90);
// spi_byte_write_espslave(0, 0x90);
os_delay_us(200);
// SPI_REG8(PUB_SPICMD_WR_BYTE, 0x90);
spi_mast_byte_write(0, 0x00);
// spi_byte_write_espslave(0, 0x00);

os_delay_us(200);
// SPI_REG8(PUB_SPICMD_WR_BYTE, 0x00);
spi_mast_byte_write(0, 0x00);
// spi_byte_write_espslave(0, 0x00);
os_delay_us(200);
// SPI_REG8(PUB_SPICMD_WR_BYTE, 0x00);
spi_mast_byte_write(0, 0x00);
// spi_byte_write_espslave(0, 0x00);
os_delay_us(200);
// SPI_REG8(PUB_SPICMD_WR_BYTE, 0x00);

// spi_mast_byte_write(0, 0x00);
// spi_byte_write_espslave(0, 0x00);
os_delay_us(200);
// SPI_REG8(PUB_SPICMD_RD_BYTE, 0x00); //read the last byte
spi_byte_read_espslave(0, &tmp);
*pManuId = tmp;
os_delay_us(200);
spi_byte_read_espslave(0, &tmp);
// SPI_REG8(PUB_SPICMD_RD_LASTBYTE, 0x00); //read the last byte
*pDevId = tmp;
}

User avatar
rudi
Posts: 197
Joined: Fri Oct 24, 2014 7:55 pm

Re: SPI_FLASH_INSTRUCTION_CODE ( 0x4B ) for get the UID 64 Bit MAC of Winbond

Postby rudi » Mon Jan 25, 2016 4:21 am

lihwarlee wrote:
Do you have any sample code about reading Unique ID of W25Q32 ?

Pls send the SAMPLE CODE to me, E-mail: 64569224@qq.com

Thank you.


I have use your SPI driver to debug this, but it is NOT success.

void ReadFlashID(BYTE *pManuId, BYTE *pDevId)
{
BYTE tmp;

spi_master_init(0);

spi_mast_byte_write(0, 0x90);
// spi_byte_write_espslave(0, 0x90);
os_delay_us(200);
// SPI_REG8(PUB_SPICMD_WR_BYTE, 0x90);
spi_mast_byte_write(0, 0x00);
// spi_byte_write_espslave(0, 0x00);

os_delay_us(200);
// SPI_REG8(PUB_SPICMD_WR_BYTE, 0x00);
spi_mast_byte_write(0, 0x00);
// spi_byte_write_espslave(0, 0x00);
os_delay_us(200);
// SPI_REG8(PUB_SPICMD_WR_BYTE, 0x00);
spi_mast_byte_write(0, 0x00);
// spi_byte_write_espslave(0, 0x00);
os_delay_us(200);
// SPI_REG8(PUB_SPICMD_WR_BYTE, 0x00);

// spi_mast_byte_write(0, 0x00);
// spi_byte_write_espslave(0, 0x00);
os_delay_us(200);
// SPI_REG8(PUB_SPICMD_RD_BYTE, 0x00); //read the last byte
spi_byte_read_espslave(0, &tmp);
*pManuId = tmp;
os_delay_us(200);
spi_byte_read_espslave(0, &tmp);
// SPI_REG8(PUB_SPICMD_RD_LASTBYTE, 0x00); //read the last byte
*pDevId = tmp;
}


hi
how you have "connect" the spi_master_init(0); by pins to your flash chip ?
do you connect a second spi flash or will you read from boot flash as connected is Quad?
be sure you have read the datasheet, there are Standard, Dual and Quad Instructions.

uid_esp.png


try to read the modes are can used:
http://www.winbond-usa.com/resource-fil ... 202015.pdf

examples
side 61, 62, 63
and then you know how you must handle UID:
side 64
and jedec ( manufacturer )
side 65

btw, jedec is supported in last Flash Tool, the src is in the folder too.
viewtopic.php?f=5&t=433

Code: Select all


..

 def get_flash_id(self):
   try:
       self.flash_begin(0,0)
       self.write_reg(self.ESP_DATA_ADDR, 0 , 0 , 0 )
       time.sleep(0.01)
       self.write_reg(self.ESP_CMD_ADDR , self.ESP_CMD_RDID , self.ESP_CMD_RDID , 0 )
       time.sleep(0.01)
       flash_id = self.read_reg(self.ESP_DATA_ADDR)
       print "get flash id : 0x%08x"%flash_id
       self.flash_manufacturer_id = flash_id&0xff
       self.flash_device_id = ((flash_id>>16)&0xff | (flash_id &( 0xff<<8)))
       print " manufacturer_id: 0x%x\r\n"%self.flash_manufacturer_id
       print " device_id: 0x%x\r\n"%self.flash_device_id
       return True
   except:
       print "get flash id error"
       return False
   
   #self.mp.textCtrl_BinPath3.AppendText("\r\nFLASH:\r\n")
   #self.mp.textCtrl_BinPath3.AppendText("manufacturer_id: %xh\r\n"%manufacturer_id)
   #self.mp.textCtrl_BinPath3.AppendText("device_id:%xh\r\n"%device_id)

..




best wishes
rudi ;-)

-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪

User avatar
rudi
Posts: 197
Joined: Fri Oct 24, 2014 7:55 pm

Re: SPI_FLASH_INSTRUCTION_CODE ( 0x4B ) for get the UID 64 Bit MAC of Winbond

Postby rudi » Mon Jan 25, 2016 9:15 am

hint

UID = only in SPI MODE
JEDEC = SPI & QPI Mode

hope now is clear:
and why we have no SDK_API for the Quad connected Flash
if you want read the UID from Quad connected Flash
you must overlap a user SPI Mode. ( use bitbanged mode, its the easiest way for his )
search.php?keywords=overlap+spi


JEDEC_SPI_QPI.png


hope this helps

best wishes
rudi ;-)

-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪

adhopraz
Posts: 1
Joined: Sat Nov 24, 2018 4:30 pm

Re: SPI_FLASH_INSTRUCTION_CODE ( 0x4B ) for get the UID 64 Bit MAC of Winbond

Postby adhopraz » Tue Nov 27, 2018 4:45 pm

Tks Rudy, It's work for me :D

Who is online

Users browsing this forum: No registered users and 13 guests