580
« on: May 06, 2020, 04:56:18 PM »
Hello,
Can you try flushing the co-pro buffer and double checking the REG_CMD_READ and REG_CMD_WRITE pointers are equal before issuing the flash read command as per the below example?
bool_t AppFlashErase(void)
{
/* Erase the flash */
uint8_t status = Gpu_Hal_Rd8(g_phost, REG_FLASH_STATUS);
#ifdef _DEBUG
printf("\nFlash status %d (%s)\n", status, flash_status[status]);
#endif
if (status == FLASH_STATUS_DETACHED)
{
Gpu_CoCmd_FlashAttach(g_phost);
App_Flush_Co_Buffer(g_phost);
Gpu_Hal_WaitCmdfifo_empty(g_phost);
status = Gpu_Hal_Rd8(g_phost, REG_FLASH_STATUS);
#ifdef _DEBUG
printf("Flash status %d (%s)\n", status, flash_status[status]);
#endif
if (FLASH_STATUS_BASIC != status)
{
printf("Error, Flash is not able to attach\n");
return FALSE;
}
}
printf("Erasing Flash...\n");
Gpu_CoCmd_FlashErase(g_phost);
App_Flush_Co_Buffer(g_phost);
Gpu_Hal_WaitCmdfifo_empty(g_phost);
/* Check first 4KB */
uint8_t *p_flashbuf = (uint8_t *)calloc(4 * 1024, sizeof(uint8_t));
Gpu_CoCmd_FlashHelper_Read(g_phost, 0, 0, 4 * 1024, p_flashbuf);
for (int i = 0; i < 4 * 1024; i++)
{
if (*(p_flashbuf++) != 0xFF)
{
return FALSE;
}
}
return TRUE;
}
Best Regards,
BRT Communnity