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.

[参考译文] CC1312R:堆跟踪

Guru**** 2551230 points
Other Parts Discussed in Thread: CC1312R, SYSCONFIG

请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/wireless-connectivity/sub-1-ghz-group/sub-1-ghz/f/sub-1-ghz-forum/984795/cc1312r-heap-track

器件型号:CC1312R
Thread 中讨论的其他器件: SysConfig

您好!

我正在尝试在 定制硬件上使用 simplelink_cc13x2_26x2_SDK_4_30_00_54收集器示例来获取 CC1312R 上的运行时堆统计信息、因此没有像 ROV 这样的调试。

在 app.cfg 中:

*通过将 HEAPMGR_CONFIG 设置为相应的值来选择要使用的堆管理器(见下面)
* 0 = osal 堆管理器、大小是静态的。
* 0x80 = osal 堆管理器、具有自动大小:剩余的 RAM (系统未使用)将完全分配给堆。
* 1 = HeapMem、静态大小
* 0x81 = HeapMem、带自动调整大小。 剩余的 RAM (系统未使用)将被完全分配给堆。
* 2 =带固定尺寸的 HeapTrack (带 HeapMem)
* 0x82 = HeapTrack (带 HeapMem)、具有自动大小:剩余的 RAM (系统未使用)将完全分配给堆。

项目正在使用0x80。 因此、我从这里读取堆统计数据不可用。 我只是在等待用于观察资源的堆大小或可用内存。

但是、如果我选择0x82、那么 IAR 中的项目构建失败。

有没有其他方法可以获得系统使用的堆的大小?

谢谢、

Andy

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 Andy:  

    您应该能够检查.map 文件并计算堆的大小。  

    谢谢、  
    ELIN

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、Elin、

    感谢您的回复。 是的、选中.map 文件会告诉我已分配给堆的 RAM 数量。 它是在进行静态分配后剩余的 RAM 数量。 但是、我正在尝试获取用作项目分配的堆内存的数量、并释放内存。 其主要目的是实现了碎片化数据消息、这些数据消息使用保存到堆存储器的 malloc 进行保存。 与此一起、我尝试将收集器可以拥有的子设备数量从50个增加到50个。 要了解可能的最大值(有一些余量)、最好知道堆内存的使用百分比。 我想分配的最大值是理想的。 然后、我可以在长期测试中运行我的系统并监控堆资源。

    我尝试使用堆统计数据没有成功、现在开始得出结论、这是不可能的。 我需要使用具有跟踪功能的不同堆管理器、但在 app.cfg 中简单地切换到该堆(0x82)会导致 IAR 编译器在 app.cfg 文件处停止。

    接下来、我是否需要在 app.cfg 中设置0x82? 如果是这样、更改堆管理器会产生什么后果?

    非常感谢、

    Andy

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

     尊敬的 Andy:  

    感谢您的耐心等待。  

    将 HEAPMGR_metrics 添加到预定义后、您将公开跟踪运行时堆指标的结构。 因此、如果您已经定义了 HEAPMGR_metrics、您应该能够看到例如显示存储器使用情况的 HEAPMGR_MEMAX。 但您也可以检查其他指标、以下是 rtos_heaposal.h 中的代码片段、其中显示了定义  HEAPMGR_MEASICEs,您可以访问的指标。

    #ifdef HEAPMGR_METRICS
    hmU32_t HEAPMGR_BLKMAX  = 0; // Max cnt of all blocks ever seen at once.
    hmU32_t HEAPMGR_BLKCNT  = 0; // Current cnt of all blocks.
    hmU32_t HEAPMGR_BLKFREE = 0; // Current cnt of free blocks.
    hmU32_t HEAPMGR_MEMALO  = 0; // Current total memory allocated.
    hmU32_t HEAPMGR_MEMMAX  = 0; // Max total memory ever allocated at once.
    hmU32_t HEAPMGR_MEMUB   = 0; // Upper-bound of memory usage
    hmU16_t HEAPMGR_MEMFAIL = 0; // Memory allocation failure count
    #endif // HEAPMGR_METRICS

    谢谢、  
    ELIN  

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好!

    我在 IAR 中创建了一个完全新鲜的收集器项目、该项目没有以任何方式进行修改。 好消息是、我遇到的错误与我自己的严重修改项目相同、因此似乎我没有做任何事情来阻止 MEAPMGR_MEDIMENUARICESS_BUARTICESS_BUARTICESD 的工作。 坏消息是、我仍然遇到错误。

    rtos_heaposal.h 似乎需要包含在项目中,以便我可以使用 HEAPMGR_GETMETRICS();

    但是、包括会直接导致许多编译问题。

    我需要了解的是:

    1) 1) HEAPMGR_metrics 是否与  app.cfg 中设置的0x80 = osal 堆管理器兼容?

    * The heap manager to use is selected by setting HEAPMGR_CONFIG to the corresponding value (see below)
    * 0 = osal Heap manager, size is static.
    * 0x80 = osal Heap manager, with auto-size: The remainning RAM (not used by the system) will be fully assign to the Heap.
    * 1 = HeapMem with Static size
    * 0x81 = HeapMem with auto-size. The remainning RAM (not used by the system) will be fully assign to the Heap.
    * 2 = HeapTrack (with HeapMem) with fixe size
    * 0x82 = HeapTrack (with HeapMem) with auto-size: The remainning RAM (not used by the system) will be fully assign to the Heap.

    从 osal_port.c 获取的代码段似乎建议这么做(此处的第51行)、但 osal_port.c 似乎未在我的项目中使用。

    /***** Private function definitions *****/
    
    // DMM currently uses ICall Heap
    #ifdef USE_DMM
    extern void *ICall_heapMalloc(uint32_t size);
    extern void *ICall_heapRealloc(void *blk, uint32_t size);
    extern void ICall_heapFree(void *blk);
    
    #define OsalPort_heapMalloc ICall_heapMalloc
    #define OsalPort_heapRealloc ICall_heapRealloc
    #define OsalPort_heapFree ICall_heapFree
    #else
    /***** Public function definitions *****/
    /* Implementing a simple heap using heapmgr.h template.
    * This simple heap depends on critical section implementation
    * and hence the template is used after critical section definition. */
    static void *OsalPort_heapMalloc(uint32_t size);
    static void *OsalPort_heapRealloc(void *blk, uint32_t size);
    static void OsalPort_heapFree(void *blk);
    
    #define HEAPMGR_INIT OsalPort_heapInit
    #define HEAPMGR_MALLOC OsalPort_heapMalloc
    #define HEAPMGR_FREE OsalPort_heapFree
    #define HEAPMGR_REALLOC OsalPort_heapRealloc
    #define HEAPMGR_GETSTATS OsalPort_heapGetStats
    #define HEAPMGR_MALLOC_LIMITED OsalPort_heapMallocLimited
    
    #ifdef HEAPMGR_METRICS
    void OsalPort_heapMgrGetMetrics(uint32_t *pBlkMax,
    uint32_t *pBlkCnt,
    uint32_t *pBlkFree,
    uint32_t *pMemAlo,
    uint32_t *pMemMax,
    uint32_t *pMemUB);
    
    #define HEAPMGR_GETMETRICS OsalPort_heapMgrGetMetrics
    #endif
    
    #define HEAPMGR_LOCK() \
    do { OsalPort_heapCSState = OsalPort_enterCS(); } while (0)
    #define HEAPMGR_UNLOCK() \
    do { OsalPort_leaveCS(OsalPort_heapCSState); } while (0)
    #define HEAPMGR_IMPL_INIT()
    
    /* Note that a static variable can be used to contain critical section
    * state since heapmgr.h template ensures that there is no nested
    * lock call. */
    static uint32_t OsalPort_heapCSState;
    
    #if defined(HEAPMGR_CONFIG) && ((HEAPMGR_CONFIG == 0) || (HEAPMGR_CONFIG == 0x80))
    #include <rtos_heaposal.h>
    #elif defined(HEAPMGR_CONFIG) && ( (HEAPMGR_CONFIG == 1) || (HEAPMGR_CONFIG == 0x81))
    #include <rtos_heapmem.h>
    #elif defined(HEAPMGR_CONFIG) && ( (HEAPMGR_CONFIG == 2) || (HEAPMGR_CONFIG == 0x82))
    #include <rtos_heaptrack.h>
    #else
    #include <rtos_heaposal.h>
    #endif
    #endif // USE_DMM

    2) 2)堆管理使用哪些文件? 我在 rtos_heaposal.h、iCall.c 和 osal_port.c 之间感到困惑 这些文件与我的项目有何关系? 什么是 osal_port? iCall 是否已弃用?

    很抱歉所有问题、但我认为理解这里的文件结构将有助于我使堆统计工作。

    非常感谢、

    Andy

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 Andy:  

    感谢您的耐心等待、我将深入研究并尽快返回给您。 请注意、我下周外出度假、因此预计两周内会收到回复。  

    谢谢、  
    ELIN  

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好!

    有没有关于这方面的新闻? 我真的可以让它正常工作。

    对于您的网络用户:单击"我的配置文件"后、我在"活动"中回复了此消息。  每次我在键入时按 Return 键时、都会发布回复、结果有点奇怪。

    此致、

    Andy

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 Andy:  

    对延误表示歉意,再次感谢您的耐心。

     遗憾 的是、由于 SDK 4.30、HEAPMGR_METERIN评估 定义不再与开箱即用示例项目兼容。 原因是 osal 实用程序函数现在包含在单独的库中(maclib_osal_tirtos_cc13x2_26x2.a)、其中项目定义如 HEAPMGR_metrics 不会影响库代码。

    但是、您仍然可以通过从示例工程中删除 osal 库并直接包含 SDK 中的文件来启用堆跟踪。 您可以通过以下方式执行此操作:

    a. 使用默认堆管理器(osal 堆管理器)构建收集器示例项目
    b. 在 SysConfig 中,导航到“生成的文件”按钮,并从“包含在构建中”列表中禁用 ti_utils_build_linker.cmd.genlibs 文件
    c. 打开 ti_utils_build_linker.cmd.genlibs 并删除库包含行:"ti/ti154stack/library/tirtos/IAR/bin/maclib_osal_tirtos_cc13x2_26x2.a"
    d. 将以下文件添加到工程中(software_stack/ti15_rstack/osal):

     -"C:\ti\simplelink_cc13x2_26x2_sdk_4_30_00_54\sources\ti154stack\common\osal_port\osal_port_tirtos\osal_port.c"

    -"C:\ti\simplelink_cc13x2_26x2_sdk_4_30_00_54\sources\ti154stack\common\osal_port\osal_port_tirtos\osal_port_timers.c"

    -"C:\ti\simplelink_cc13x2_26x2_sdk_4_30_00_54\source\ti154stack\console\util\mac_util.c"
    e. 添加 HEAPMGR_metrics define 并在需要时调用 OsalPort_heapMgrGetMetrics 以查看堆管理器指标

    2. 在 app.cfg 文件中配置的堆管理器决定项目中包含哪个堆管理器:

     

    #if defined(HEAPMGR_CONFIG) && ((HEAPMGR_CONFIG == 0) || (HEAPMGR_CONFIG == 0x80))
    #include <rtos_heaposal.h>
    #elif defined(HEAPMGR_CONFIG) && ( (HEAPMGR_CONFIG == 1) || (HEAPMGR_CONFIG == 0x81))
    #include <rtos_heapmem.h>
    #elif defined(HEAPMGR_CONFIG) && ( (HEAPMGR_CONFIG == 2) || (HEAPMGR_CONFIG == 0x82))
    #include <rtos_heaptrack.h>
    

    OSAL_port 类似于在 TI-RTOS 上运行的传统轻量级 RTOS 库。 堆栈代码库主要用于尚未迁移到 TI-RTOS 的区域。

    间接调用(ICALL)是一种过时的功能、未在13x2/26x2 SimpleLink SDK 中使用。 当 TI 15.4堆栈支持分离映像应用/堆栈配置时、这是为传统器件提供的框架。 13x2/26x2器件目前不支持分离应用/堆栈映像配置。

    谢谢、  
    ELIN

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    感谢您的观看。 我现在正在尝试、并将发布回来。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、Elin、

    我有两个问题、请参阅下面的5)和6)。

    我有堆指标、我对此非常满意、非常感谢。 某些要点可能会对其他要点有所帮助、尽管这是在修改后的非标准收集器项目上、但它可能仍适用于标准版本:

    1) 1)我还必须包含 util_timer.c

    2) 2)我使用的是 SysConfig 1.6.0、它没有禁用生成的文件的选项、因此我更新为1.0.0。

    3) 3)我从 osal_port.c 中删除了声明、并将其移动到 osal_port.h:

    #ifdef HEAPMGR_METRICS
    void OsalPort_heapMgrGetMetrics(uint32_t *pBlkMax,
                                 uint32_t *pBlkCnt,
                                 uint32_t *pBlkFree,
                                 uint32_t *pMemAlo,
                                 uint32_t *pMemMax,
                                 uint32_t *pMemUB);
    
    #define HEAPMGR_GETMETRICS      OsalPort_heapMgrGetMetrics
    #endif

    然后将#include osal_port.h 添加到我需要堆指标的文件中。 我想我本可以改用'extern '。

    4) 4)以下是我调用度量函数的方法:

    /**
     * @brief   obtain heap usage metrics
     * @param   pBlkMax   pointer to a variable to store max cnt of all blocks ever seen at once
     * @param   pBlkCnt   pointer to a variable to store current cnt of all blocks
     * @param   pBlkFree  pointer to a variable to store current cnt of free blocks
     * @param   pMemAlo   pointer to a variable to store current total memory allocated
     * @param   pMemMax   pointer to a variable to store max total memory ever allocated at once
     * @param   pMemUB    pointer to a variable to store the upper bound of memory usage
     */
        
         uint32_t BlkMax;
         uint32_t BlkCnt;
         uint32_t BlkFree;
         uint32_t MemAlo;
         uint32_t MemMax;
         uint32_t MemUB;
        
         HEAPMGR_GETMETRICS(&BlkMax, &BlkCnt, &BlkFree, &MemAlo, &MemMax, &MemUB);

    5) 5)我的网络有问题、我试图跟踪并使堆指标有效将会大有帮助。 但是、在使其正常工作时、我意识到由于迁移堆栈版本、.syscfg 文件仍然引用了旧堆栈:

    /**
     * These arguments were used when this file was generated. They will be automatically applied on subsequent loads
     * via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments.
     * @cliArgs --board "/ti/boards/CC1312R1_LAUNCHXL" --product "simplelink_cc13x2_26x2_sdk@4.10.00.78"
     * @versions {"data":"2021031521","timestamp":"2021031521","tool":"1.8.0+1863","templates":null}
     */

    我已将版本更改为我正在使用的堆栈、但我的问题是、这会影响任何内容、是否会因此出现问题?

    6) 6)以类似的方式5)可以将 SysConfig 从1.6.0升级到1.8.0、这会对我的网络产生任何影响、还是仅在 GUI 中进行更改?

    非常感谢、

    Andy