From e11c70c118467344d421376626b7c4fafd5b1453 Mon Sep 17 00:00:00 2001 From: Ralph Metzler Date: Thu, 10 Jan 2019 17:11:55 +0100 Subject: [PATCH 1/2] support Winbond flash --- apps/octonet/ddtest.c | 23 ++++++++++++++++++++--- apps/octonet/flash.c | 11 +++++++++++ 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/apps/octonet/ddtest.c b/apps/octonet/ddtest.c index b1b46c6..e0626bd 100644 --- a/apps/octonet/ddtest.c +++ b/apps/octonet/ddtest.c @@ -43,7 +43,7 @@ int ReadFlash(int ddb, int argc, char *argv[], uint32_t Flags) Start = strtoul(argv[0],NULL,16); Len = strtoul(argv[1],NULL,16); if (argc == 3) { - fd = open(argv[2], O_WRONLY | O_CREAT | O_TRUNC); + fd = open(argv[2], O_WRONLY | O_CREAT | O_TRUNC, S_IRWXU); if (fd < 0) { printf("Could not open file %s\n", argv[2]); return -1; @@ -402,6 +402,7 @@ int FlashProg(int dev,int argc, char* argv[],uint32_t Flags) case SPANSION_S25FL116K: SectorSize = 4096; FlashSize = 0x200000; break; case SPANSION_S25FL132K: SectorSize = 4096; FlashSize = 0x400000; break; case SPANSION_S25FL164K: SectorSize = 4096; FlashSize = 0x800000; break; + case WINBOND_W25Q16JV: SectorSize = 4096; FlashSize = 0x200000; break; } if (SectorSize == 0) return 0; @@ -571,6 +572,7 @@ int FlashProg(int dev,int argc, char* argv[],uint32_t Flags) case SPANSION_S25FL116K: case SPANSION_S25FL132K: case SPANSION_S25FL164K: + case WINBOND_W25Q16JV: err = FlashWritePageMode(dev,FlashOffset,Buffer,BufferSize,0x1C); break; } @@ -1284,7 +1286,7 @@ int lic_erase(int dev, int argc, char* argv[], uint32_t Flags) static int read_sfpd(int dev, uint8_t adr, uint8_t *val) { - uint8_t cmd[5] = { 0x5a, 0, 0, adr, 00 }; + uint8_t cmd[5] = { 0x5a, 0, 0, adr, 0 }; int r; r = flashio(dev, cmd, 5, val, 1); @@ -1306,6 +1308,17 @@ static int read_sst_id(int dev, uint8_t *id) return 0; } +static int read_winbd(int dev, uint8_t *val) +{ + uint8_t cmd[5] = { 0x4b, 0, 0, 0, 0 }; + int r; + + r = flashio(dev, cmd, 5, val, 8); + if (r < 0) + return r; + return 0; +} + int read_id(int dev, int argc, char* argv[], uint32_t Flags) { int Flash = FlashDetect(dev); @@ -1313,8 +1326,12 @@ int read_id(int dev, int argc, char* argv[], uint32_t Flags) uint8_t Id[8]; uint32_t len, i, adr; - + switch(Flash) { + case WINBOND_W25Q16JV: + read_winbd(dev, Id); + len = 8; + break; case SPANSION_S25FL116K: case SPANSION_S25FL132K: case SPANSION_S25FL164K: diff --git a/apps/octonet/flash.c b/apps/octonet/flash.c index 7ccfb61..82621d7 100644 --- a/apps/octonet/flash.c +++ b/apps/octonet/flash.c @@ -7,6 +7,7 @@ enum { SPANSION_S25FL116K = 5, SPANSION_S25FL132K = 6, SPANSION_S25FL164K = 7, + WINBOND_W25Q16JV = 8, }; static uint32_t linknr = 0; @@ -47,6 +48,8 @@ int FlashDetect(int dev) r = SPANSION_S25FL164K; else if ( Id[0] == 0x1F && Id[1] == 0x28) r = ATMEL_AT45DB642D; + else if ( Id[0] == 0xef && Id[1] == 0x40 && Id[2] == 0x15 ) + r = WINBOND_W25Q16JV; else r = UNKNOWN_FLASH; @@ -75,6 +78,9 @@ int FlashDetect(int dev) case SPANSION_S25FL164K : printf("Flash: SPANSION S25FL164K 64 MBit\n"); break; + case WINBOND_W25Q16JV : + printf("Flash: Winbond W25Q16JV 16 MBit\n"); + break; } return r; } @@ -120,6 +126,11 @@ static int flashdetect(int fd, uint32_t *sector_size, uint32_t *flash_size) printf("Flash: SPANSION S25FL164K 64 MBit\n"); *sector_size = 4096; *flash_size = 0x800000; + } else if (id[0] == 0xef && id[1] == 0x40 && id[2] == 0x15) { + flash_type = WINBOND_W25Q16JV; + printf("Flash: Winbond 16 MBit\n"); + *sector_size = 4096; + *flash_size = 0x200000; } else if (id[0] == 0x1F && id[1] == 0x28) { flash_type = ATMEL_AT45DB642D; printf("Flash: Atmel AT45DB642D 64 MBit\n"); From a783a0267944f02e4693d86d2481a0d536c41df6 Mon Sep 17 00:00:00 2001 From: Ralph Metzler Date: Thu, 10 Jan 2019 17:48:00 +0100 Subject: [PATCH 2/2] support Winbond flash --- apps/flashprog.c | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/flashprog.c b/apps/flashprog.c index a13f9e2..a770b6c 100644 --- a/apps/flashprog.c +++ b/apps/flashprog.c @@ -339,6 +339,7 @@ int main(int argc, char **argv) break; case SPANSION_S25FL116K: case SPANSION_S25FL164K: + case WINBOND_W25Q16JV: err = FlashWritePageMode(ddb,FlashOffset,buffer,BufferSize,0x1C); break; }