返回该小组首页 回复主题
jack_chang

jack_chang

小组等级:     E币:393  (E币换礼)

#1楼主:我在调试USART1的时出现的一个运行错误

文章发表于:2008-05-15 08:04

    我在对STM32F10x进行USART调试的时候出现了下面的运行错误:堆栈已经充满了,我该如何修改?

    Thu May 15 07:56:05 2008: The stack 'CSTACK' is filled to 100% (8192 bytes used out of 8192). The warning threshold is set to 90.%

jizzll

   小组等级:    E币:3775  (E币换礼)

#2

文章发表于:2008-05-15 23:59

不懂,等人来huid

STM32

   小组等级:    E币:3329  (E币换礼)

#3

文章发表于:2008-05-16 11:13

请参考你使用的编译链接软件的手册,把堆栈扩大。

STM32

   小组等级:    E币:3329  (E币换礼)

#4

文章发表于:2008-05-16 12:06

如果你使用的是IAR软件,可以在它的链接文件中修改堆栈设置。

一般有两个链接文件,lnkarm_flash.xcl用于产生Flash中调试运行的代码,lnkarm_ram.xcl用于产生RAM中调试运行的代码;在IAR EWARM的IDE中,点击Project\Options...\Linker\Config,在Linker Command file下可以看见你使用的是哪个链接文件。

打开你使用的链接文件,找到-D_CSTACK_SIZE=????并修改堆栈大小,等号后面是16进制表示的堆栈尺寸。

如果使用的是Keil软件,可以打开STM32F10x.s并修改Stack_Size一行。

jack_chang

   小组等级:    E币:393  (E币换礼)

#5

文章发表于:2008-05-16 18:24

  按照STM32大哥的提示,去修改了_D_STACK_SIZE参数,但是故障依然;

图一:运行时的故障

jack_chang

   小组等级:    E币:393  (E币换礼)

#6

文章发表于:2008-05-16 18:35

  按照STM32大哥的提示,去修改了_D_STACK_SIZE参数,但是故障依然;

图一:运行时的故障

点击看大图

图二:将Debuger的驱动修改为:simulator,进入PC完全模拟调试,正常!

点击看大图

图三:将Debuger的驱动修改为:Third_Party后,打开在Linker Command file的设置,是否是在这个位置设置_D_STACK_SIZE参数???如果是,如何设置?我尝试多种设置都无效!

点击看大图

图四:也尝试直接打开“链接文件”的文件“xxxx_lnk.xcl",并修改这个堆栈参数,故障也是依然,不知是否我设置的不对?请提示输入值。谢谢

点击看大图

STM32

   小组等级:    E币:3329  (E币换礼)

#7

文章发表于:2008-05-16 22:07

我说的是修改lnkarm_flash.xcl或lnkarm_ram.xcl文件,可你却修改xxxx_lnk.xcl文件,这显然不是同一个文件,你修改的文件是一个临时产生的文件,链接完毕就没有用了,下次还会从新生成,手工修改它根本不解决问题。

下面是lnkarm_flash.xcl文件的内容,红色标出的那行才是要修改的地方,请试试:

/*;******************** (C) COPYRIGHT 2007 STMicroelectronics ******************
;* File Name          : lnkarm_flash.xcl
;* Author             : MCD Application Team
;* Version            : V1.0
;* Date               : 10/08/2007
;* Description        : XLINK command file template for EWARM/ICCARM
;* Usage              : xlink  -f lnkarm 
;*                    :-s  
;*******************************************************************************
; THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
; WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
; AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
; INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
; CONTENT OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
; INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
;******************************************************************************/

// Code memory in FLASH
-DROMSTART=0x8000000
-DROMEND=0x801FFFF

// Data in RAM
-DRAMSTART=0x20000000
-DRAMEND=0x20004FFF

//*************************************************************************
// -------------
// Code segments - may be placed anywhere in memory.
// -------------
//
//   INTVEC     -- Exception vector table.
//   SWITAB     -- Software interrupt vector table.
//   ICODE      -- Startup (cstartup) and exception code.
//   DIFUNCT    -- Dynamic initialization vectors used by C++.
//   CODE       -- Compiler generated code.
//   CODE_I     -- Compiler generated code declared __ramfunc (executes in RAM)
//   CODE_ID    -- Initializer for CODE_I (ROM).
//
// -------------
// Data segments - may be placed anywhere in memory.
// -------------
//
//   CSTACK      -- The stack used by C/C++ programs (system and user mode).
//   HEAP       -- The heap used by malloc and free in C and new and
//                 delete in C++.
//   INITTAB    -- Table containing addresses and sizes of segments that
//                 need to be initialized at startup (by cstartup).
//   CHECKSUM   -- The linker places checksum byte(s) in this segment,
//                 when the -J linker command line option is used.
//   DATA_y     -- Data objects.
//
// Where _y can be one of:
//
//   _AN        -- Holds uninitialized located objects, i.e. objects with
//                 an absolute location given by the @ operator or the
//                 #pragma location directive. Since these segments
//                 contain objects which already have a fixed address,
//                 they should not be mentioned in this linker command
//                 file.
//   _C         -- Constants (ROM).
//   _I         -- Initialized data (RAM).
//   _ID        -- The original content of _I (copied to _I by cstartup) (ROM).
//   _N         -- Uninitialized data (RAM).
//   _Z         -- Zero initialized data (RAM).
//
// Note:  Be sure to use end values for the defined address ranges.
//        Otherwise, the linker may allocate space outside the
//        intended memory range.
//*************************************************************************


//************************************************
// Inform the linker about the CPU family used.
//************************************************

-carm

//*************************************************************************
// Segment placement - General information
//
// All numbers in the segment placement command lines below are interpreted
// as hexadecimal unless they are immediately preceded by a '.', which
// denotes decimal notation.
//
// When specifying the segment placement using the -P instead of the -Z
// option, the linker is free to split each segment into its segment parts
// and randomly place these parts within the given ranges in order to
// achieve a more efficient memory usage. One disadvantage, however, is
// that it is not possible to find the start or end address (using
// the assembler operators .sfb./.sfe.) of a segment which has been split
// and reformed.
//
// When generating an output file which is to be used for programming
// external ROM/Flash devices, the -M linker option is very useful
// (see xlink.pdf for details).
//*************************************************************************


//*************************************************************************
// Read-only segments mapped to ROM.
//*************************************************************************

//************************************************
// Address range for reset and exception
// vectors (INTVEC).
//************************************************

-Z(CODE)INTVEC=ROMSTART-ROMEND

//************************************************
// Startup code and exception routines (ICODE).
//************************************************

-Z(CODE)ICODE,DIFUNCT=ROMSTART-ROMEND
-Z(CODE)SWITAB=ROMSTART-ROMEND

//************************************************
// Code segments may be placed anywhere.
//************************************************

-Z(CODE)CODE=ROMSTART-ROMEND

//************************************************
// Original ROM location for __ramfunc code copied
// to and executed from RAM.
//************************************************

-Z(CONST)CODE_ID=ROMSTART-ROMEND

//************************************************
// Various constants and initializers.
//************************************************

-Z(CONST)INITTAB,DATA_ID,DATA_C=ROMSTART-ROMEND
-Z(CONST)CHECKSUM=ROMSTART-ROMEND


//*************************************************************************
// Read/write segments mapped to RAM.
//*************************************************************************

//************************************************
// Data segments.
//************************************************

-Z(DATA)DATA_I,DATA_Z,DATA_N=RAMSTART-RAMEND

//************************************************
// __ramfunc code copied to and executed from RAM.
//************************************************

-Z(DATA)CODE_I=RAMSTART-RAMEND

//************************************************
// ICCARM produces code for __ramfunc functions in
// CODE_I segments. The -Q XLINK command line
// option redirects XLINK to emit the code in the
// CODE_ID segment instead, but to keep symbol and
// debug information associated with the CODE_I
// segment, where the code will execute.
//************************************************

-QCODE_I=CODE_ID

//*************************************************************************
// Stack and heap segments.
//*************************************************************************

-D_CSTACK_SIZE=400
-D_HEAP_SIZE=200

-Z(DATA)CSTACK+_CSTACK_SIZE=RAMSTART-RAMEND
-Z(DATA)HEAP+_HEAP_SIZE=RAMSTART-RAMEND

//*************************************************************************
// ELF/DWARF support.
//
// Uncomment the line "-Felf" below to generate ELF/DWARF output.
// Available format specifiers are:
//
//   "-yn": Suppress DWARF debug output
//   "-yp": Multiple ELF program sections
//   "-yas": Format suitable for debuggers from ARM Ltd (also sets -p flag)
//
// "-Felf" and the format specifiers can also be supplied directly as
// command line options, or selected from the Xlink Output tab in the
// IAR Embedded Workbench.
//*************************************************************************

// -Felf

 

jack_chang

   小组等级:    E币:393  (E币换礼)

#8

文章发表于:2008-05-17 09:15

  编译器显示CSTACK的范围是:0x200002d~0x20004fff,但是我无论如何修改_D_STACK_SIZE的值(或增,或减),故障依然,不得已我将程序打包了,请STM32大哥帮我一下。谢谢!点击下载USART Example

jack_chang

   小组等级:    E币:393  (E币换礼)

#9

文章发表于:2008-05-19 11:32

  顶!不能沉呀!初学者有很大借鉴意义!

STM32

   小组等级:    E币:3329  (E币换礼)

#10

文章发表于:2008-05-19 12:27

我的调试器有点问题还不能用。但我发现你的链接文件中有个严重的错误,你把RAM的地址范围定义错了,请看下面这里,你少写了一个0,这会造成什么都不能工作,请改正后试试:

// Data in RAM
-DRAMSTART=0x20000000
-DRAMEND=0x20004FFF

jack_chang

   小组等级:    E币:393  (E币换礼)

#11

文章发表于:2008-05-19 15:05

  楼上的大哥,我已经改了,但是故障亦然,有如下报警:

Mon May 19 15:03:24 2008: The stack pointer for stack 'CSTACK' (currently 0x00102010) is outside the stack range (0x20000034 to 0x20001534)
点击看大图

不知道有是否有其他设置问题?

2【下一页】总共 , 当前 /

快速回复主题--如果想加入编辑器功能,建议使用 [高级回复]

您目前还不是小组成员,请先加入

回复贴子区

用户名:    您没有注册?

密码:    忘记了密码?

内容:

  • DesignDesign
  • HTMLHTML

浏览该小组的用户还看过...

设计资源与分销