CH563Q IAP FLASH_ROM_WRITE 问题。

你好, 我司ch563q的案子,目前正参考/exam/IAP_DEMO 在做 软件升级功能,

数据是从主板(usb host)传送到ch563(usb device), 每次数据长度是500 Bytes,

FLASH_ROM_ERASE是没问题的,但是第一个FLASH_ROM_WRITE就一直是返回 0xFC,

不晓得这个返回值是什么意思 ?  麻烦帮忙看下,谢谢。


以下是我们代码和打印信息:

{
   STEBMSG_IAP_PROM *p = (STEBMSG_IAP_PROM *)pstMsg->pBuf;
   unsigned int nSz = pstMsg->stHdr.nSz - MAX_EXBRD_HDR - 4;
   UINT32 nAddr;
   int i;
   char nChkSum = 0;

   for(i=0;i < nSz;i++)
   {
      nChkSum += p->pData[i];
   }
   if(nChkSum != p->nChkSum)
   {
      gstRespMsg.stHdr.nMsgId = pstMsg->stHdr.nMsgId;
   }
   else
   {
      nAddr = (p->pAddr[0] | ((UINT32)p->pAddr[1] << 8) | ((UINT32)p->pAddr[2] << 16));
      i = FLASH_ROM_WRITE(nAddr, (PVOID)&p->pData[0], nSz);
      if(i  !=  0)
      {
         gstRespMsg.stHdr.nMsgId = pstMsg->stHdr.nMsgId;
      }
   }
   printf("[test]IAPPGM i:0x%X, nSz:%d, Sum:0x%02X, 0x%02X, nAddr:%d, MsgId:0x%02X\n", i, nSz, nChkSum,    p->nChkSum, nAddr, gstRespMsg.stHdr.nMsgId);
}


打印信息:

[test]IAPPGM i:0xFC, nSz:500, Sum:0x3E, 0x3E, nAddr:0, MsgId:0xD0
RMsgId:0xD0
[test]IAPPGM i:0xFC, nSz:500, Sum:0x3E, 0x3E, nAddr:0, MsgId:0xD0
RMsgId:0xD0
[test]IAPPGM i:0xFC, nSz:500, Sum:0x3E, 0x3E, nAddr:0, MsgId:0xD0
RMsgId:0xD0
[test]IAPPGM i:0xFC, nSz:500, Sum:0x3E, 0x3E, nAddr:0, MsgId:0xD0
RMsgId:0xD0
[test]IAPPGM i:0xFC, nSz:500, Sum:0x3E, 0x3E, nAddr:0, MsgId:0xD0
RMsgId:0xD0
[test]IAPPGM i:0xFC, nSz:500, Sum:0x3E, 0x3E, nAddr:0, MsgId:0xD0
RMsgId:0xD0
[test]IAPPGM i:0xFC, nSz:500, Sum:0x3E, 0x3E, nAddr:0, MsgId:0xD0
RMsgId:0xD0
[test]IAPPGM i:0xFC, nSz:500, Sum:0x3E, 0x3E, nAddr:0, MsgId:0xD0

一直重复.

在执行写操作之前时候有FLASH_LOCK的相关动作?确保在操作flash的时候flash处于解锁状态。


你好,

FLASH_ROM_ERASE代码段如下:

FLASH_ROM_LOCK(0x00);
if(FLASH_ROM_ERASE(0, Length *1024) != 0)
{
    FLASH_ROM_LOCK(FLASH_ROM_LOCK_AUTO);
    gstRespMsg.stHdr.nMsgId = pstMsg->stHdr.nMsgId;
}


FLASH_ROM_ERASE是没问题的,  先做了erase, 之后才调用的 FLASH_ROM_WRITE,

从打印信息看传入的参数应该没问题啊,但始终是返回 0xFC,

FLASH_ROM_WRITE 的调用是你们封装的 ISPXT56X.O, 应该能看到为什么返回这个(0xFC代表什么意义)?



在实际实现IAP功能的时候,建议保留第一个4K不要擦除来实现。

参考以下代码:http://www.wch.cn/bbs/thread-71433-1.html


参考 CH563-IAP-1v1, 功能已经实现了,谢谢。


只有登录才能回复,可以选择微信账号登录