RT1021 FlexSPI 操作(读,写,檫除)整个代码死机

cancel
Showing results for 
Search instead for 
Did you mean: 

RT1021 FlexSPI 操作(读,写,檫除)整个代码死机

108 Views
zhude_111
Contributor I

你好!

      我遇到一个奇怪的问题,在RT1021开发板上,对FlexSPI进行读写操作,发现整个代码会挂掉,卡住不运行也不知道问题出在哪里,XIP模式下。用的函数是ROM-API的函数。

现象:在0x40000的位置写入400个数据,然后读出来直接卡死,代码不动。

void test123(void)
{
int ch;
uint32_t status=0;
uint32_t srcBuf[100];
//==========================================
portDISABLE_INTERRUPTS();


status=g_bootloaderTree->flexSpiNorDriver->erase(instance, &zgmconfig, 0x40000, 0x1000);
PRINTF("status1=%d.\r\n",status);

for(ch=0;ch<100;ch++){
srcBuf[ch]=ch;
}

status=g_bootloaderTree->flexSpiNorDriver->program(instance, &zgmconfig,0x40000, srcBuf);
PRINTF("status2=%d.\r\n",status);
status=g_bootloaderTree->flexSpiNorDriver->program(instance, &zgmconfig,0x40000+256, &srcBuf[64]);
PRINTF("status3=%d.\r\n",status);
for(ch=0;ch<100;ch++){
PRINTF(" Buf[%d]=%d",ch,*(uint32_t*)(0x60000000+0x40000+ch*4));
}
PRINTF("\r\n");
portENABLE_INTERRUPTS() ;
}

串口打印如下然后不动了。

zhude_111_0-1602901331085.png

但如果我把

#if 0
status=g_bootloaderTree->flexSpiNorDriver->program(instance, &zgmconfig,0x40000+256, &srcBuf[64]);
PRINTF("status3=%d.\r\n",status);

#endif

屏蔽掉又好了。因为我写入的是400个字节,大于256,所以我分包做了2次写

 

 

void test123(void)
{
int ch;
uint32_t status=0;
uint32_t srcBuf[100];
//==========================================
portDISABLE_INTERRUPTS();


status=g_bootloaderTree->flexSpiNorDriver->erase(instance, &zgmconfig, 0x40000, 0x1000);
PRINTF("status1=%d.\r\n",status);

for(ch=0;ch<100;ch++){
srcBuf[ch]=ch;
}

status=g_bootloaderTree->flexSpiNorDriver->program(instance, &zgmconfig,0x40000, srcBuf);
PRINTF("status2=%d.\r\n",status);

#if 0
status=g_bootloaderTree->flexSpiNorDriver->program(instance, &zgmconfig,0x40000+256, &srcBuf[64]);
PRINTF("status3=%d.\r\n",status);

#endif
for(ch=0;ch<100;ch++){
PRINTF(" Buf[%d]=%d",ch,*(uint32_t*)(0x60000000+0x40000+ch*4));
}
PRINTF("\r\n");
portENABLE_INTERRUPTS() ;
}

 

打印就正常,不死机,好奇怪

 
 

 

0 Kudos
2 Replies

89 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi zhude_111,

   楼主你好!

   你用的板子是NXP 官方的MIMXRT1020-EVK 板子吗?还是你自己的板子?

   你第一次用:

status=g_bootloaderTree->flexSpiNorDriver->program(instance, &zgmconfig,0x40000, srcBuf);

之后,然后你看看从0x40000+256开始,是否有数据了?

确保你第一次写的数据不会和你第二次操作的区域有重叠了。

你读出来看看呢。可以直接debug看。

如果debug的话,看看代码死哪里了。

 

Wish it helps you!

If you still have questions about it, please kindly let me know!

Best Regards,

Kerry

-------------------------------------------------------------------------------

Note:

- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored

Please open a new thread and refer to the closed one, if you have a related question at a later point in time.

-----------------------------------------------------------------------------

0 Kudos

106 Views
zhude_111
Contributor I

zhude_111_0-1602901952632.png

打印信息是这样的

Buf[0]=0 Buf[1]=1 Buf[2]=2 Buf[3]=3 Buf[4]=4 Buf[5]=5 Buf[6]=6 Buf[7]=7 Buf[8]=8 Buf[9]=9 Buf[10]=10 Buf[11]=11 Buf[12]=12 Buf[13]=13 Buf[14]=14 Buf[15]=15 Buf[16]=16 Buf[17]=17 Buf[18]=18 Buf[19]=19 Buf[20]=20 Buf[21]=21 Buf[22]=22 Buf[23]=23 Buf[24]=24 Buf[25]=25 Buf[26]=26 Buf[27]=27 Buf[28]=28 Buf[29]=29 Buf[30]=30 Buf[31]=31 Buf[32]=32 Buf[33]=33 Buf[34]=34 Buf[35]=35 Buf[36]=36 Buf[37]=37 Buf[38]=38 Buf[39]=39 Buf[40]=40 Buf[41]=41 Buf[42]=42 Buf[43]=43 Buf[44]=44 Buf[45]=45 Buf[46]=46 Buf[47]=47 Buf[48]=48 Buf[49]=49 Buf[50]=50 Buf[51]=51 Buf[52]=52 Buf[53]=53 Buf[54]=54 Buf[55]=55 Buf[56]=56 Buf[57]=57 Buf[58]=58 Buf[59]=59 Buf[60]=60 Buf[61]=61 Buf[62]=62 Buf[63]=63 Buf[64]=1 Buf[65]=1 Buf[66]=1 Buf[67]=1 Buf[68]=1 Buf[69]=1 Buf[70]=1 Buf[71]=1 Buf[72]=1 Buf[73]=1 Buf[74]=1 Buf[75]=1 Buf[76]=1 Buf[77]=1 Buf[78]=1 Buf[79]=1 Buf[80]=1 Buf[81]=1 Buf[82]=1 Buf[83]=1 Buf[84]=1 Buf[85]=1 Buf[86]=1 Buf[87]=1 Buf[88]=1 Buf[89]=1 Buf[90]=1 Buf[91]=1 Buf[92]=1 Buf[93]=1 Buf[94]=1 Buf[95]=1 Buf[96]=1 Buf[97]=1 Buf[98]=1 Buf[99]=1
TX MSG: fe 6 1 0 0 f9

 

但还有一点,只有前面256个数据有用,后面的应该是0XFFFFFF才对,怎么会是1呢,因为在写之前我已经檫除掉FLASH了

0 Kudos