@@ -219,7 +219,7 @@ static void flash_erase(uint32_t addr, uint8_t byte) {
219219 }
220220
221221 uint32_t num_sectors = flash_num_sectors ();
222- for (uint32_t i = 0 ; i < num_sectors ; i ++ ) {
222+ for (uint32_t i = 1 ; i < num_sectors ; i ++ ) {
223223 if ((mem .flash .sector [i ].ipb & mem .flash .sector [i ].dpb ) == 1 ) {
224224 memset (& mem .flash .block [i * SIZE_FLASH_SECTOR_64K ], 0xFF , SIZE_FLASH_SECTOR_64K );
225225 }
@@ -293,7 +293,7 @@ static void flash_erase_ipb(uint32_t addr, uint8_t byte) {
293293 }
294294
295295 uint32_t num_sectors = flash_num_sectors ();
296- for (uint32_t i = 0 ; i < num_sectors ; i ++ ) {
296+ for (uint32_t i = 1 ; i < num_sectors ; i ++ ) {
297297 mem .flash .sector [i ].ipb = 1 ;
298298 }
299299
@@ -511,19 +511,40 @@ static uint8_t mem_read_flash_parallel(uint32_t addr) {
511511 }
512512 break ;
513513 case FLASH_READ_CFI :
514- if (addr >= 0x20 && addr <= 0x2A ) {
515- static const uint8_t id [7 ] = { 0x51 , 0x52 , 0x59 , 0x02 , 0x00 , 0x40 , 0x00 };
516- value = id [(addr - 0x20 ) / 2 ];
517- } else if (addr >= 0x36 && addr <= 0x50 ) {
518- static const uint8_t id [] = {
514+ if (!(addr & 1 ) && addr >= 0x20 && addr <= 0xA0 ) {
515+ /* W29GL032CB7S */
516+ static const uint8_t id_4mb [] = {
517+ /* Identification */
518+ 0x51 , 0x52 , 0x59 , 0x02 , 0x00 , 0x40 , 0x00 , 0x00 ,
519+ 0x00 , 0x00 , 0x00 ,
520+ /* System Interface Data */
519521 0x27 , 0x36 , 0x00 , 0x00 , 0x03 , 0x04 , 0x08 , 0x0E ,
520- 0x03 , 0x05 , 0x03 , 0x03 , 0x16 , 0x02 , 0x00 , 0x05 ,
521- 0x00 , 0x01 , 0x08 , 0x00 , 0x00 , 0x3F , 0x00 , 0x00 ,
522- 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
523- 0x00 , 0x00 , 0x50 , 0x52 , 0x49 , 0x31 , 0x33 , 0x0C ,
524- 0x02 , 0x01 , 0x00 , 0x08 , 0x00 , 0x00 , 0x02 , 0x95 ,
525- 0xA5 , 0x02 , 0x01 };
526- value = id [(addr - 0x36 ) / 2 ];
522+ 0x03 , 0x05 , 0x03 , 0x03 ,
523+ /* Device Geometry */
524+ 0x16 , 0x02 , 0x00 , 0x05 , 0x00 , 0x02 , 0x07 , 0x00 ,
525+ 0x20 , 0x00 , 0x3E , 0x00 , 0x00 , 0x01 , 0x00 , 0x00 ,
526+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
527+ /* Vendor-Specific */
528+ 0x50 , 0x52 , 0x49 , 0x31 , 0x33 , 0x0C , 0x02 , 0x01 ,
529+ 0x00 , 0x08 , 0x00 , 0x00 , 0x02 , 0x95 , 0xA5 , 0x02 ,
530+ 0x01 };
531+ /* W29GL064CB7S */
532+ static const uint8_t id_8mb [] = {
533+ /* Identification */
534+ 0x51 , 0x52 , 0x59 , 0x02 , 0x00 , 0x40 , 0x00 , 0x00 ,
535+ 0x00 , 0x00 , 0x00 ,
536+ /* System Interface Data */
537+ 0x27 , 0x36 , 0x00 , 0x00 , 0x03 , 0x04 , 0x08 , 0x0E ,
538+ 0x03 , 0x05 , 0x03 , 0x03 ,
539+ /* Device Geometry */
540+ 0x17 , 0x02 , 0x00 , 0x05 , 0x00 , 0x02 , 0x07 , 0x00 ,
541+ 0x20 , 0x00 , 0x7E , 0x00 , 0x00 , 0x01 , 0x00 , 0x00 ,
542+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
543+ /* Vendor-Specific */
544+ 0x50 , 0x52 , 0x49 , 0x31 , 0x33 , 0x0C , 0x02 , 0x01 ,
545+ 0x00 , 0x08 , 0x00 , 0x00 , 0x02 , 0x95 , 0xA5 , 0x02 ,
546+ 0x01 };
547+ value = (mem .flash .size == SIZE_FLASH_MIN ? id_4mb : id_8mb )[(addr - 0x20 ) / 2 ];
527548 }
528549 break ;
529550 case FLASH_DEEP_POWER_DOWN :
0 commit comments