mirror of
https://github.com/DigitalDevices/dddvb.git
synced 2023-10-10 13:37:43 +02:00
support Winbond flash
This commit is contained in:
parent
67f0820a53
commit
e11c70c118
@ -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);
|
||||
@ -1315,6 +1328,10 @@ int read_id(int dev, int argc, char* argv[], uint32_t Flags)
|
||||
|
||||
|
||||
switch(Flash) {
|
||||
case WINBOND_W25Q16JV:
|
||||
read_winbd(dev, Id);
|
||||
len = 8;
|
||||
break;
|
||||
case SPANSION_S25FL116K:
|
||||
case SPANSION_S25FL132K:
|
||||
case SPANSION_S25FL164K:
|
||||
|
@ -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");
|
||||
|
Loading…
Reference in New Issue
Block a user