用jlink 调试h750 (400Mhz版本)+ uCOSIII + spi nand flash,主频设置为400MHz,在调试过程中,经常会发生变量的值被意外修改,ucosIII经常会检测到任务栈溢出。但实际上栈区的空间占用很少,并未用完而溢出,而好像是栈指针意外被更改所致。将主频降到200MHz,直接在AXI RAM中运行,程序一切都正常;(主频200MHz调试也不正常);主频400MHz连续运行,也不正常,总是会引起变量被修改。整个现象就像是CPU读写内存不稳定一样,经常数据不对。请教大家帮忙分析一下,是哪里的问题? 目前移植yaffs2 200Mhz主频,新建一个文件写入55KB数据,然后再读出对比数据与源数据是否相符,如此反复连续运行。连续运行56万个循环未出错一次。 MPU 配置如下: void MPU_Config(void ) { #if ( __DCACHE_PRESENT == 1) MPU_Region_InitTypeDef MPU_InitStruct; /* 禁用MPU */ HAL_MPU_Disable(); /* 配置AXI RAM 属性*/ MPU_InitStruct.Enable = MPU_REGION_ENABLE; MPU_InitStruct.BaseAddress = 0x24000000; //区域基地址。 MPU_InitStruct.Size = MPU_REGION_SIZE_512KB; //要配置的区域的区域大小。 MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS; //数据访问权限 MPU_InitStruct.IsBufferable = MPU_ACCESS_BUFFERABLE; //区域是可缓冲 MPU_InitStruct.IsCacheable = MPU_ACCESS_CACHEABLE; //区域是否可缓存 MPU_InitStruct.IsShareable = MPU_ACCESS_NOT_SHAREABLE; //是否共享。 MPU_InitStruct.Number = MPU_REGION_NUMBER0; //区域保护。 MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL1; // MPU_InitStruct.SubRegionDisable = 0x00; //子区域禁用字段。 MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_ENABLE; //指令访问禁用位。 HAL_MPU_ConfigRegion(&MPU_InitStruct); /* 配置ITCM RAM 属性*/ MPU_InitStruct.Number = MPU_REGION_NUMBER1; MPU_InitStruct.BaseAddress = 0x00000000; //区域基地址。 MPU_InitStruct.Size = MPU_REGION_SIZE_64KB; //要配置的区域的区域大小。 HAL_MPU_ConfigRegion(&MPU_InitStruct); /* 配置DTCM RAM 属性*/ MPU_InitStruct.Number = MPU_REGION_NUMBER2; MPU_InitStruct.BaseAddress = 0x20000000; //区域基地址。 MPU_InitStruct.Size = MPU_REGION_SIZE_128KB; //要配置的区域的区域大小。 HAL_MPU_ConfigRegion(&MPU_InitStruct); /* 配置外设区域 属性*/ MPU_InitStruct.BaseAddress = 0x40000000; MPU_InitStruct.Size = MPU_REGION_SIZE_256MB; MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE; MPU_InitStruct.Number = MPU_REGION_NUMBER3; MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0; HAL_MPU_ConfigRegion(&MPU_InitStruct); /* 启用MPU */ HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT); #endif } 内存配置如下: /*###ICF### Section handled by ICF editor, don't touch! ****/ /*-Editor annotation file-*/ /* IcfEditorFile="$TOOLKIT_DIR$\config\linker\ST\IcfEditor\stm32h7xx.xml" */ /*-Specials-*/ define symbol __ICFEDIT_intvec_start__ = 0x20000000; /*-Memory Regions-*/ define symbol __ICFEDIT_region_FLASH1_start__ = 0x08000000; define symbol __ICFEDIT_region_FLASH1_end__ = 0x080FFFFF; define symbol __ICFEDIT_region_ITCMR_start__ = 0x00000000;//64KB define symbol __ICFEDIT_region_ITCMR_end__ = 0x0000FFFF; define symbol __ICFEDIT_region_DTCMR1_start__ = 0x20000400;//64KB define symbol __ICFEDIT_region_DTCMR1_end__ = 0x2000FFFF; define symbol __ICFEDIT_region_DTCMR2_start__ = 0x20010000;//64KB define symbol __ICFEDIT_region_DTCMR2_end__ = 0x2001FFFF; define symbol __ICFEDIT_region_AXISR1_start__ = 0x24000000; //D1:512KB 分成两段,24000000-2403FFFF:作为动态内存区域 define symbol __ICFEDIT_region_AXISR1_end__ = 0x2403FFFF; define symbol __ICFEDIT_region_AXISR_start__ = 0x24040000; //D1:512KB 分成两段,24040000-2407FFFF:程序运行区 define symbol __ICFEDIT_region_AXISR_end__ = 0x2407FFFF; /*-Sizes-*/ define symbol __ICFEDIT_size_cstack__ = 0x2000; define symbol __ICFEDIT_size_heap__ = 0x1000; /**** End of ICF editor section. ###ICF###*/ define memory mem with size = 4G; define region FLASH_region = mem:[from __ICFEDIT_region_FLASH1_start__ to __ICFEDIT_region_FLASH1_end__] | mem:[from __ICFEDIT_region_FLASH2_start__ to __ICFEDIT_region_FLASH2_end__]; define region ITCMR_region = mem:[from __ICFEDIT_region_ITCMR_start__ to __ICFEDIT_region_ITCMR_end__ ]; define region DTCMR_region = mem:[from __ICFEDIT_region_DTCMR1_start__ to __ICFEDIT_region_DTCMR1_end__] | mem:[from __ICFEDIT_region_DTCMR2_start__ to __ICFEDIT_region_DTCMR2_end__]; define region AXISR_region = mem:[from __ICFEDIT_region_AXISR_start__ to __ICFEDIT_region_AXISR_end__ ]; define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { }; define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { }; initialize by copy { readwrite }; if (isdefinedsymbol(__USE_DLIB_PERTHREAD)) { initialize by copy with packing = none { section __DLIB_PERTHREAD }; } do not initialize { section .noinit }; place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec }; place in AXISR_region { readonly}; place in ITCMR_region { section .textrw }; place in DTCMR_region { readwrite, block CSTACK,block HEAP}; |
建议用简单的代码测试一下芯片高速运行时RAM的数据是否正常。 同时建议使用正版的ST-LINK调试,看看是否是工具影响,并且官方的ST-LINK 很便宜。 另外也要注意检查一下你用的这个版本是不是Y版本,对照勘误手册看一下。 |