Index: ./packages/devs/flash/intel/28fxxx//current/ChangeLog =================================================================== RCS file: /cvs/ecos/ecos/packages/devs/flash/intel/28fxxx/current/ChangeLog,v retrieving revision 1.11 diff -c -u -r1.11 ChangeLog --- ./packages/devs/flash/intel/28fxxx//current/ChangeLog 12 Dec 2002 21:15:26 -0000 1.11 +++ ./packages/devs/flash/intel/28fxxx//current/ChangeLog 16 Apr 2003 21:05:18 -0000 @@ -1,3 +1,10 @@ +2003-04-15 Michael Checky + + * include/flash_28fxxx.inl: In 'flash_erase_block()', made sure + CYGHWR_FLASH_WRITE_DISABLE() is called before returning. Changed + timeout code in 'flash_erase_block()' and 'flash_program_buf()' + to be more robust under the GCC optimizer. + 2002-12-12 Gary Thomas 2002-12-12 Patrick Doyle Index: ./packages/devs/flash/intel/28fxxx//current/include/flash_28fxxx.inl =================================================================== RCS file: /cvs/ecos/ecos/packages/devs/flash/intel/28fxxx/current/include/flash_28fxxx.inl,v retrieving revision 1.8 diff -c -u -r1.8 flash_28fxxx.inl --- ./packages/devs/flash/intel/28fxxx//current/include/flash_28fxxx.inl 12 Dec 2002 21:15:27 -0000 1.8 +++ ./packages/devs/flash/intel/28fxxx//current/include/flash_28fxxx.inl 16 Apr 2003 21:05:19 -0000 @@ -297,9 +297,12 @@ ROM[0] = FLASH_Block_Erase; *b_v = FLASH_Confirm; - timeout = 5000000; - while(((stat = ROM[0]) & FLASH_Status_Ready) != FLASH_Status_Ready) { - if (--timeout == 0) break; + // can take up to five seconds + for (timeout = 0; timeout < 5000000; ++timeout) + { + stat = ROM[0]; + if ((stat & FLASH_Status_Ready) == FLASH_Status_Ready) + break; } // Restore ROM to "normal" mode @@ -324,7 +327,7 @@ if (*b_v != FLASH_BlankValue ) { // Only update return value if erase operation was OK if (FLASH_ERR_OK == res) res = FLASH_ERR_DRV_VERIFY; - return res; + goto flash_erase_block_exit; } len -= sizeof(*b_p); } @@ -333,6 +336,7 @@ len = flash_dev_info->bootblocks[len_ix++]; } +flash_erase_block_exit: CYGHWR_FLASH_WRITE_DISABLE(); return res; @@ -409,13 +413,21 @@ addr_v = FLASH_P2V(addr_p++); ROM[0] = FLASH_Program; *addr_v = *data_p; - timeout = 5000000; - while(((stat = ROM[0]) & FLASH_Status_Ready) != FLASH_Status_Ready) { - if (--timeout == 0) { - res = FLASH_ERR_DRV_TIMEOUT; - goto bad; - } + + // can take up to 185 usec + for (timeout = 0; timeout < 5000000; ++timeout) + { + stat = ROM[0]; + if ((stat & FLASH_Status_Ready) == FLASH_Status_Ready) + break; + } + + // did we timeout ? + if (timeout >= 5000000) { + res = FLASH_ERR_DRV_TIMEOUT; + break; } + if (stat & FLASH_ErrorMask) { if (!(stat & FLASH_ErrorProgram)) res = FLASH_ERR_HWR; // Unknown error @@ -439,7 +451,6 @@ } // Restore ROM to "normal" mode - bad: ROM[0] = FLASH_Reset; CYGHWR_FLASH_WRITE_DISABLE();