This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

LAUNCHXL-CC1310: CC1310 + TI15.4 如何提高堆栈空间大小

Part Number: LAUNCHXL-CC1310

TTI大神,你好!

   问题描述:

           我在设计程序中 有接口需要多次申请空间(用Csf_malloc()申请),程序运行中 总在确定的第N次调用Csf_malloc()时出错,最终报  MAIN_ASSERT_HWI_TIRTOS错误。

问提分析:

1、          目前怀疑任务运行空间不够而缠身该问题,进而将  任务堆栈大小( APP_TASK_STACK_SIZE)修改到3000左右,问题依然存在 (问题出现推后一些,例如第N+L次调用Csf_malloc()),但是串口应用报错,怀疑是由于任务堆栈太大  占用了该部分内容。
        

2、根据其他帖子相关问题,尝试修改CMD文件,好像没有效果(没有实际修改)。

/* Retain interrupt vector table variable                                    */
--retain=g_pfnVectors
/* Override default entry point.                                             */
--entry_point ResetISR
/* Allow main() to take args                                                 */
--args 0x8

/* Suppress warnings and errors:                                             */
/* - 10063: Warning about entry point not being _c_int00                     */
/* - 16011, 16012: 8-byte alignment errors. Observed when linking in object  */
/*   files compiled using Keil (ARM compiler)                                */
--diag_suppress=10063,16011,16012

/* The following command line options are set as part of the CCS project.    */
/* If you are building using the command line, or for some reason want to    */
/* define them here, you can uncomment and modify these lines as needed.     */
/* If you are using CCS for building, it is probably better to make any such */
/* modifications in your CCS project and leave this file alone.              */
/*                                                                           */
/* --heap_size=0                                                             */
/* --stack_size=256                                                          */
/* --library=rtsv7M3_T_le_eabi.lib                                           */

--heap_size=1024
--stack_size=1256


/* The starting address of the application.  Normally the interrupt vectors  */
/* must be located at the beginning of the application.                      */

#define FLASH_BASE              0x00000000
#ifdef ONE_PAGE_NV
#define FLASH_SIZE              0x1E000
#define FLASH_NV_BASE           0x1E000
#define FLASH_NV_SIZE           0x1000
#else
#define FLASH_SIZE              0x1D000
#define FLASH_NV_BASE           0x1D000
#define FLASH_NV_SIZE           0x2000
#endif
#define FLASH_LAST_BASE         0x1F000
#define FLASH_LAST_SIZE         0x1000
#define RAM_BASE                0x20000000
#define RAM_SIZE                0x5000


/* System memory map */

MEMORY
{
    /* Application stored in and executes from internal flash */
    FLASH (RX) : origin = FLASH_BASE, length = FLASH_SIZE
    /* FLASH NV */
    FLASH_NV (RWX) : origin = FLASH_NV_BASE, length = FLASH_NV_SIZE
    /* Last flash page */
    FLASH_LAST (RX) : origin = FLASH_LAST_BASE, length = FLASH_LAST_SIZE
    /* Application uses internal RAM for data */
    SRAM (RWX) : origin = RAM_BASE, length = RAM_SIZE
}

/* Section allocation in memory */

SECTIONS
{
    .intvecs        :   > FLASH_BASE
/*
    flash_last_text
    {
        nvocop.obj(.text)
        macTask.obj(.text)
    } > FLASH_LAST
*/
    .text           :   >> FLASH_LAST | FLASH

    config_const { mac_user_config.obj(.const) } > FLASH

    .const          :   > FLASH
    .constdata      :   > FLASH
    .rodata         :   > FLASH
    .cinit          :   > FLASH
    .pinit          :   > FLASH
    .init_array     :   > FLASH
    .emb_text       :   > FLASH
    .ccfg           :   > FLASH_LAST (HIGH)

    GROUP > SRAM
    {
        .data
        .bss
        .vtable
        .vtable_ram
         vtable_ram
        .sysmem
        .nonretenvar
    } LOAD_END(heapStart)

    .stack          :   >  SRAM (HIGH) LOAD_START(heapEnd)
}

/* Create global constant that points to top of stack */
/* CCS: Change stack size under Project Properties    */
__STACK_TOP = __stack + __STACK_SIZE;

求助:

请问有什么其他办法可以解决该问题吗,

  • 那位TI大神给支个招

  • 您好,我们已收到您的问题并升级到英文论坛,如有答复将尽快回复您。谢谢!

  • 您好,如果是在分配了一定数量后获取到main_asson_HWI_TIRTOS ,那么可能会从可用的heap memory中丢失。 使用 csf_malloc 分配内存时,不再需要内存时,需要取消分配。

    这是通过 csf_free() 完成的。 增加堆栈大小对问题没有什么帮助。

    该功能在csf.h file中有具体描述:

    https://dev.ti.com/tirex/nodeContent?node=AFxsKMWQaK7Gn6aujsKElg__eCfARaV__LATEST

  • 不是 这个原因  ,申请空间使用完后都会csf_free()的

  • 帮您跟进给工程师问下哈,尽快给到您答复。

  • 您好,您能否提供下app.cfg file?

  • 好的收到,发送给工程师了,有答复尽快给您。

  • 您好,建议您试下用ROV和 Heap Track来调试。

    要使能heaptrack,请在 .cfg文件中做如下更改:

    var HEAPMGR_CONFIG = 0x82; // instead of 0x80

    并注释掉以下几行:

    // var ROM = xdc.useModule('ti.sysbios.rom.ROM');
    // ROM.romName = ROM.CC1350;

    然后重新构建下,再使用CCS中的Runtime Object View查看HeapMeM 和 HeapTrack 模块。

    https://dev.ti.com/tirex/explore/node?node=AG2SLewG5xZ3UgWI-gK8cg__FUz-xrs__LATEST

  • 根据建议,完成修改,其中
    var HEAPMGR_CONFIG = 0x82
    导致编译时LINK错误

    making ../src/sysbios/sysbios.aem3 ...
    gmake[2]: Nothing to be done for 'all'.
    Building target: "collector_CC1310_LAUNCHXL_tirtos_ccs.out"
    Invoking: Arm Linker
    "C:/ti/ccs1100/ccs/tools/compiler/ti-cgt-arm_20.2.5.LTS/bin/armcl" --cmd_file="D:/Xiang_he/Documents/workspace_v11-sdk_4_20_00_05-PortB-TaskDTU_v0.1-ATE/collector_CC1310_LAUNCHXL_tirtos_ccs/Application/Defines/collector.opts"  -mv7M3 --code_state=16 --float_support=none -me -O4 --opt_for_speed=0 --define=RESET_ASSERT- --define=Board_EXCLUDE_NVS_EXTERNAL_FLASH- --define=DeviceFamily_CC13X0 --define=SET_CCFG_BL_CONFIG_BL_LEVEL=0x00 --define=SET_CCFG_BL_CONFIG_BL_ENABLE=0xC5 --define=SET_CCFG_BL_CONFIG_BL_PIN_NUMBER=0x0D --define=SET_CCFG_BL_CONFIG_BOOTLOADER_ENABLE=0xC5 --define=CCFG_FORCE_VDDR_HH=1 -g --c99 --plain_char=unsigned --diag_warning=225 --diag_warning=255 --diag_wrap=off --display_error_number --gen_func_subsections=on --embedded_constants=on --unaligned_access=on --enum_type=packed --wchar_t=16 --common=on --fp_reassoc=off --sat_reassoc=off -z -m"collector_CC1310_LAUNCHXL_tirtos_ccs.map" -i"C:/ti/ccs1100/ccs/tools/compiler/ti-cgt-arm_20.2.5.LTS/lib" --reread_libs --define=ONE_PAGE_NV --diag_wrap=off --display_error_number --warn_sections --xml_link_info="collector_CC1310_LAUNCHXL_tirtos_ccs_linkInfo.xml" --rom_model --unused_section_elimination=on -o "collector_CC1310_LAUNCHXL_tirtos_ccs.out" "./CC1310_LAUNCHXL.obj" "./CC1310_LAUNCHXL_fxns.obj" "./ccfg.obj" "./Application/LaunchPad/board_gpio.obj" "./Application/LaunchPad/board_key.obj" "./Application/LaunchPad/board_lcd.obj" "./Application/LaunchPad/board_led.obj" "./Application/MAC/HAL/common/hal_appasrt.obj" "./Application/MAC/HAL/target/dbg.obj" "./Application/MAC/HAL/target/hal_aes.obj" "./Application/MAC/HAL/target/hal_ccm.obj" "./Application/MAC/HAL/target/hal_flash_wrapper.obj" "./Application/MAC/HAL/target/hal_rtc_wrapper.obj" "./Application/MAC/HAL/target/hal_trng_wrapper.obj" "./Application/MAC/HAL/target/pwrmon.obj" "./Application/MAC/HighLevel/mac_cfg.obj" "./Application/MAC/LowLevel/mac_settings.obj" "./Application/PALNA/board_palna.obj" "./Application/Services/nvocop.obj" "./Application/Services/nvoctp.obj" "./Application/Services/saddr.obj" "./Application/api_mac.obj" "./Application/cllc.obj" "./Application/collector.obj" "./Application/csf.obj" "./Application/macTask.obj" "./Application/mac_user_config.obj" "./Application/mac_util.obj" "./Application/main.obj" "./Application/uart_printf.obj" "./Application/util_timer.obj" "./Application/osal_port/osal_port.obj" "./Application/osal_port/osal_port_timers.obj" "./Application/protobuf-c/mimoiot.pb-c.obj" "./Application/protobuf-c/protobuf-c.obj" "../cc13x0lp.cmd" -l"configPkg/linker.cmd"  -l"C:/ti/simplelink_cc13x0_sdk_4_20_00_05/source/ti/ti154stack/library/tirtos/ccs/bin/maclib_secure_cc13x0.a" -l"C:/ti/simplelink_cc13x0_sdk_4_20_00_05/source/ti/display/lib/display.aem3" -l"C:/ti/simplelink_cc13x0_sdk_4_20_00_05/source/ti/grlib/lib/ccs/m3/grlib.a" -l"C:/ti/simplelink_cc13x0_sdk_4_20_00_05/source/ti/drivers/rf/lib/rf_multiMode_cc13x0.aem3" -l"C:/ti/simplelink_cc13x0_sdk_4_20_00_05/source/ti/drivers/lib/drivers_cc13x0.aem3" -l"C:/ti/simplelink_cc13x0_sdk_4_20_00_05/kernel/tirtos/packages/ti/dpl/lib/dpl_cc13x0.aem3" -l"C:/ti/simplelink_cc13x0_sdk_4_20_00_05/source/ti/devices/cc13x0/driverlib/bin/ccs/driverlib.lib" -llibc.a 
    <Linking>
    "../cc13x0lp.cmd", line 121: error #10099-D: program will not fit into available memory, or the section contains a call site that requires a trampoline that can't be generated for this section. placement with alignment fails for section ".cinit" size 0x452.  Available memory ranges:
       FLASH        size: 0x1e000      unused: 0x2f2        max hole: 0x2f0     
    error #10010: errors encountered during linking; "collector_CC1310_LAUNCHXL_tirtos_ccs.out" not built
     
    >> Compilation failure
    makefile:202: recipe for target 'collector_CC1310_LAUNCHXL_tirtos_ccs.out' failed
    gmake[1]: *** [collector_CC1310_LAUNCHXL_tirtos_ccs.out] Error 1
    makefile:198: recipe for target 'all' failed
    gmake: *** [all] Error 2

    其中cc13x0lp.cmd文件如下:

    /******************************************************************************
    
     @file  cc13x0lp.cmd
    
     @brief Linker configuration file for MAC on CC13x0 LaunchPad
    
     Group: WCS LPC
     Target Device: cc13x0
    
     ******************************************************************************
     
     Copyright (c) 2016-2021, Texas Instruments Incorporated
     All rights reserved.
    
     Redistribution and use in source and binary forms, with or without
     modification, are permitted provided that the following conditions
     are met:
    
     *  Redistributions of source code must retain the above copyright
        notice, this list of conditions and the following disclaimer.
    
     *  Redistributions in binary form must reproduce the above copyright
        notice, this list of conditions and the following disclaimer in the
        documentation and/or other materials provided with the distribution.
    
     *  Neither the name of Texas Instruments Incorporated nor the names of
        its contributors may be used to endorse or promote products derived
        from this software without specific prior written permission.
    
     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    
     ******************************************************************************
     
     
     *****************************************************************************/
    
    /* Retain interrupt vector table variable                                    */
    --retain=g_pfnVectors
    /* Override default entry point.                                             */
    --entry_point ResetISR
    /* Allow main() to take args                                                 */
    --args 0x8
    /* Suppress warnings and errors:                                             */
    /* - 10063: Warning about entry point not being _c_int00                     */
    /* - 16011, 16012: 8-byte alignment errors. Observed when linking in object  */
    /*   files compiled using Keil (ARM compiler)                                */
    --diag_suppress=10063,16011,16012
    
    /* The following command line options are set as part of the CCS project.    */
    /* If you are building using the command line, or for some reason want to    */
    /* define them here, you can uncomment and modify these lines as needed.     */
    /* If you are using CCS for building, it is probably better to make any such */
    /* modifications in your CCS project and leave this file alone.              */
    /*                                                                           */
    /* --heap_size=0                                                             */
    /* --stack_size=256                                                          */
    /* --library=rtsv7M3_T_le_eabi.lib                                           */
    
    /* The starting address of the application.  Normally the interrupt vectors  */
    /* must be located at the beginning of the application.                      */
    
    #define FLASH_BASE              0x00000000
    #ifdef ONE_PAGE_NV
    #define FLASH_SIZE              0x1E000
    #define FLASH_NV_BASE           0x1E000
    #define FLASH_NV_SIZE           0x1000
    #else
    #define FLASH_SIZE              0x1D000
    #define FLASH_NV_BASE           0x1D000
    #define FLASH_NV_SIZE           0x2000
    #endif
    #define FLASH_LAST_BASE         0x1F000
    #define FLASH_LAST_SIZE         0x1000
    #define RAM_BASE                0x20000000
    #define RAM_SIZE                0x5000
    
    
    /* System memory map */
    
    MEMORY
    {
        /* Application stored in and executes from internal flash */
        FLASH (RX) : origin = FLASH_BASE, length = FLASH_SIZE
        /* FLASH NV */
        FLASH_NV (RWX) : origin = FLASH_NV_BASE, length = FLASH_NV_SIZE
        /* Last flash page */
        FLASH_LAST (RX) : origin = FLASH_LAST_BASE, length = FLASH_LAST_SIZE
        /* Application uses internal RAM for data */
        SRAM (RWX) : origin = RAM_BASE, length = RAM_SIZE
    }
    
    /* Section allocation in memory */
    
    SECTIONS
    {
        .intvecs        :   > FLASH_BASE
    /*
        flash_last_text
        {
            nvocop.obj(.text)
            macTask.obj(.text)
        } > FLASH_LAST
    */
        .text           :   >> FLASH_LAST | FLASH
    
        config_const { mac_user_config.obj(.const) } > FLASH
    
        .const          :   > FLASH
        .constdata      :   > FLASH
        .rodata         :   > FLASH
        .cinit          :   > FLASH
        .pinit          :   > FLASH
        .init_array     :   > FLASH
        .emb_text       :   > FLASH
        .ccfg           :   > FLASH_LAST (HIGH)
    
        GROUP > SRAM
        {
            .data
            .bss
            .vtable
            .vtable_ram
             vtable_ram
            .sysmem
            .nonretenvar
        } LOAD_END(heapStart)
    
        .stack          :   >  SRAM (HIGH) LOAD_START(heapEnd)
    }
    
    /* Create global constant that points to top of stack */
    /* CCS: Change stack size under Project Properties    */
    __STACK_TOP = __stack + __STACK_SIZE;
    

  • 好的已经反馈给工程师了哈。

  • 您好,应该是闪存不够大的问题,导致无法在您的应用中使用heap tracker的功能。

    您可以手动检查存储器的浏览器。 启动debug session并在内存浏览器窗口中查找地址 heapStart 和 heapEnd。 如果是重复模式或充满数据,您可以在这两个地址之间进行检查,以及它在每个 malloc 之后的变化。 在最后一次分配失败之前以及在最后分配失败之后,在内存浏览器中特别要检查下这些位置。

  • 这个调试过程我明白,但是 现在编译不通过,也没办法调试啊

  • 您好,您可以恢复 app.cfg 更改并进行编译。 在以上调试步骤中不需要heap tracker。