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.

[参考译文] CC1312R7:IRQ 硬故障:强制:使用:在 WiSun 风扇代码 SDK 6.40.00.13的 macAllocTxBuffer 中未对齐

Guru**** 2482225 points
Other Parts Discussed in Thread: SYSBIOS, CC1312R7

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

https://e2e.ti.com/support/wireless-connectivity/sub-1-ghz-group/sub-1-ghz/f/sub-1-ghz-forum/1215577/cc1312r7-irq-hard-fault-forced-usage-unaligned-in-macalloctxbuffer-from-wisun-fan-code-sdk-6-40-00-13

器件型号:CC1312R7
Thread 中讨论的其他器件:SYSBIOS

大家好

更新以更新:上一个陈述错误。 它会在禁用安全性的情况下崩溃。 但是,如果有一个正在运行的 WiSun 网络与边界路由器,则会出现*仅*例外。 因此、如果网络代码未看到无线网络、则不会出现异常。

我们正在上述函数中获得 HWI 异常(更符合 exceptionInfo 中的 SP、LR、PC 寄存器)

如何解决此问题?

根据调试器堆栈跟踪:

德州仪器(TI) XDS110 USB 调试探针/Cortex_M4_0 (已暂停)    
   macAllocTxBuffer () at mac_hl_patch.c:1 690 0x00048A76    
   macBuildCommonReq () at mac_hl_patch.c:2 739 0x00033B1E    
   macRadioSendEnhanck (),Mac_RADIO_TX.c:1 179 0x0007B402    
   rxFcsIsr ()在 mac_rx.c:1 331 0x0001524A    
   rxPayloadIsr ()、位于 mac_rx.c:1 052 0x00015024    
   rxStartIsr()位于 mac_rx.c:0 0x0000B590    
   macRxFrameIsr () at mac_rx.c:400 0x0000B2FE    
   macRxCbSubG () at mac.c:0 0x00021E3C    
   macRxCb()在 mac.c:546 0x00021E1C 处    
   RFCC26X2_MULTIPLE.c:2 947 0x00039496处的 RF_radioOpDoneCb ()    
   rf_fsmActiveState ()位于 List.h:155 0x0000E9AC    
   TI_SysBIOS_KNL_Swi_run ()、位于 Swi.c:185 0x0006994A    
   TI_SysBIOS_KNL_Swi_restoreHwi ()位于 Swi.c:440 0x0005538A    
   TI_SysBIOS_family_arm_m3_Hwi_doSwiRestore ()、位于 Hwi.c:1 754 0x0008A7FA    
   TI_SysBIOS_family_arm_m3_Hwi_dischat + 0xb0 ()

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

    大家好、

    您的项目所基于的项目是什么? 这是开箱即用的 Wi-SUN 项目吗?

    请说明您在哪里使用此函数?  

    此致、

    SID  

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

    是的、它基于 SDK 中的 ns_CoAP_node_src_LP_CC1312R7_tirtos7_ticlang。
    我们未使用该函数、该函数是网络堆栈的一部分、并从 IRQ 调用。

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

    此外、mbed 端口中存在许多不一致之处:

    指定 mbed_config.h 产生的
    #define mbed_CONF_NANOSTACK_HAL_CRITICAL_SECTION_USABLE_FROM_INTERRUPT       0
    据推测应该告知代码关键段在中断中*不*可用。

    不过、 arm_hal_timer.c 仅检查 Mbed_CONF_NANOSTACK_HAL_CRITICAL_SECTION_USABLE_FROM_INTERRUPT 已定义、而不是设置为什么。
    这会生成不正确的代码吗?

    我已尝试取消定义 mbed_CONF_NANOSTACK_HAL_CRITICAL_SECTION_USABLE_FROM_INTERRUPT 、但我们仍得到相同的异常。

    mbid_CONF_NANOSTACK_HAL_EVENT_LOOP_THREADY_STACK_SIZE 也有两种不同的冲突设置
    在 mbed_config.h 中、该值在 mbed_config_中设置为6144 app.h 它设置为3800。 这是编译使用的最后一个定义。

    哪个是堆栈事件循环的正确 statck 大小?

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

    好的、我们

    typedef struct {
        const char *uri;
        uint8_t methods;
        coap_service_request_recv_cb *callback;
    } servicetable_t;
    
    #define NUMBEROFSERVICES 6
    
    servicetable_t servicetable[NUMBEROFSERVICES ] =
    {
     { "option"
       , COAP_SERVICE_ACCESS_GET_ALLOWED | COAP_SERVICE_ACCESS_PUT_ALLOWED | COAP_SERVICE_ACCESS_DELETE_ALLOWED
       , node_option_cb
     }
     ,{ "group"
        , COAP_SERVICE_ACCESS_GET_ALLOWED | COAP_SERVICE_ACCESS_PUT_ALLOWED | COAP_SERVICE_ACCESS_DELETE_ALLOWED
        , group_option_cb
     }
     ,{ "trig"
        , COAP_SERVICE_ACCESS_PUT_ALLOWED
        , trig_cb
     }
     ,{ "ping"
        , COAP_SERVICE_ACCESS_PUT_ALLOWED
        , dummy_cb
     }
     ,{ "req"                          
        , COAP_SERVICE_ACCESS_PUT_ALLOWED
        , req_cb
     }
     ,{ "Dummy"                          // TODO: Remove
        , COAP_SERVICE_ACCESS_GET_ALLOWED | COAP_SERVICE_ACCESS_PUT_ALLOWED | COAP_SERVICE_ACCESS_DELETE_ALLOWED
        , dummy_cb
     }
    
    // ,{ "cal"
    //    , COAP_SERVICE_ACCESS_GET_ALLOWED
    //        | COAP_SERVICE_ACCESS_PUT_ALLOWED
    //        | COAP_SERVICE_ACCESS_DELETE_ALLOWED
    //        | COAP_SERVICE_ACCESS_POST_ALLOWED
    //    , cal_cb
    // }
    // ,{ "reboot"
    //    , COAP_SERVICE_ACCESS_PUT_ALLOWED
    //    , reboot_cb
    // }
    // ,{ "debug"
    //    , COAP_SERVICE_ACCESS_GET_ALLOWED | COAP_SERVICE_ACCESS_PUT_ALLOWED
    //    , debug_cb
    // }
    //
    };
    
    已找到触发网络堆栈异常的原因。 表初始化过大似乎会导致损坏。 因此、具有以下代码的固件在阵列大小设置为6时能够完美地工作。 如果我们将数组大小增加到7、则会在 macAllocTxBuffer 中获得异常。

    请注意异常会发生 *在触摸表之前 ,macAllocTxBuffer 会在 WiSun-network 连接之前以及任何 CoAP 回调注册之前引起异常。

    因此、我不知道网络堆栈为什么会由此损坏。 编译器是否生成错误的结构内联来覆盖纳瓦级联数据结构?
    有什么建议吗?

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

    您可以对使用数组大小6和数组大小7生成的两个映射文件进行比较、以查看是否有明显的变化。 是否可以通过 OOB 示例轻松重现此问题?  

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

    我找到了产生误差的原因。 在函数内部具有静态缓冲区会导致 TI 无线电堆栈崩溃、但存在上述例外情况。
    这看起来绝对类似于代码生成或链接器错误。 也许是时候将其升级为工程设计了?

    //The follwing code causes the TI radio stack to crash.
    // Note that the stack crashes before this code runs, or the buffer is touched in any way.
    // The exceptiopn occures before any coap handler have been registered
    int cal_cb         (int8_t service_id, uint8_t source_address[static 16], uint16_t source_port, sn_coap_hdr_s *request_ptr) {
        DebugWriteUart0 ("\r\ncal_cb: ");
        DebugPrintCoap (request_ptr);
    
        const char *reply= NULL;    // NULL indicates no error message
        coapQuery_t optionQuery;
        int numberOfQueryOptions=0;
    
    #define CALOUTBUFSIZE   255
        static unsigned char buf[CALOUTBUFSIZE];  // TODO: Is this the thing that crashes TIs stack when static?
    
    //////////////////////////////////////////////////////////////////////////
    // The following code *works* flawlessly. No other changes whatsoever:
    int cal_cb         (int8_t service_id, uint8_t source_address[static 16], uint16_t source_port, sn_coap_hdr_s *request_ptr) {
        DebugWriteUart0 ("\r\ncal_cb: ");
        DebugPrintCoap (request_ptr);
    
        const char *reply= NULL;    // NULL indicates no error message
        coapQuery_t optionQuery;
        int numberOfQueryOptions=0;
    
    #define CALOUTBUFSIZE   255
        unsigned char buf[CALOUTBUFSIZE];  
    

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

    更新:请查看上一问题的单独备注以了解真正原因。
    问题不在于 CoAP 方法表、而是函数内的静态分配关键字会导致编译器和/或链接器生成错误的代码(或可能在 TI 无线电堆栈中发生一些无法预见的交互)。 如果我们更改服务表、会发生崩溃的原因是、如果表中未引用 cal_cb 函数、则链接器不会链接该函数。

    这是一个开始的分歧,和智慧的部分。 左侧是工作固件的映射、右侧是导出硬件异常的固件。
    那么、您能从中看出什么呢?

    4c4
    < >> Linked Mon Apr 17 09:56:49 2023
    ---
    > >> Linked Mon Apr 17 11:17:45 2023
    7c7
    < ENTRY POINT SYMBOL: "ResetISR"  address: 0008e31b
    ---
    > ENTRY POINT SYMBOL: "ResetISR"  address: 0008e633
    14c14
    <   FLASH                 00000000   000ae000  00092a20  0001b5e0  R  X
    ---
    >   FLASH                 00000000   000ae000  00092d54  0001b2ac  R  X
    16c16
    <   SRAM                  20000000   00024000  0001100e  00012ff2  RW X
    ---
    >   SRAM                  20000000   00024000  00011125  00012edb  RW X
    23c23
    < 00000000    00000000    0008e52c   0008e52c    r-x
    ---
    > 00000000    00000000    0008e848   0008e848    r-x
    25,30c25,30
    <   00000040    00000040    00006474   00006474    r-- .rodata
    <   000064b8    000064b8    00088074   00088074    r-x .text.1
    < 0008e52c    0008e52c    00000008   00000008    rw-
    <   0008e52c    0008e52c    00000008   00000008    rw- .args
    < 0008e534    0008e534    000004f4   000004f4    r--
    <   0008e534    0008e534    000004f4   000004f4    r-- .cinit
    ---
    >   00000040    00000040    000064a4   000064a4    r-- .rodata
    >   000064e8    000064e8    00088360   00088360    r-x .text.1
    > 0008e848    0008e848    00000008   00000008    rw-
    >   0008e848    0008e848    00000008   00000008    rw- .args
    > 0008e850    0008e850    0000050c   0000050c    r--
    >   0008e850    0008e850    0000050c   0000050c    r-- .cinit
    47c47
    < 20001860    20001860    0000f173   00000000    rw-
    ---
    > 20001860    20001860    0000f28b   00000000    rw-
    49,50c49,50
    <   20001870    20001870    0000df73   00000000    rw- .bss.3
    <   2000f7e8    2000f7e8    000011eb   00000000    rw- .data
    ---
    >   20001870    20001870    0000e072   00000000    rw- .bss.3
    >   2000f8e8    2000f8e8    00001203   00000000    rw- .data
    67c67
    < .rodata    0    00000040    00006474
    ---
    > .rodata    0    00000040    000064a4
    72,363c72,363
    [non wisun deleted]
    <                   00002eda    00000237     wisun_tasklet.o (.rodata.WISUN_CLIENT_CERTIFICATE)
    <                   00003561    000001e1     wisun_tasklet.o (.rodata.WISUN_ROOT_CERTIFICATE)
    <                   00003f81    00000003     kde_helper.o (.rodata.wisun_oui)
    <                   0000436c    000000e7     wisun_tasklet.o (.rodata.WISUN_CLIENT_KEY)
    <                   0000628c    0000000f     wisun_tasklet.o (.rodata.str1.1)
    <                   000062b4    0000000c     wisun_tasklet.o (.rodata..L__const.wisun_tasklet_configure_and_connect_to_network.own_cert)
    <                   000062c0    0000000c     wisun_tasklet.o (.rodata..L__const.wisun_tasklet_configure_and_connect_to_network.trusted_cert)
    >                   00002f0a    00000237     wisun_tasklet.o (.rodata.WISUN_CLIENT_CERTIFICATE)
    >                   00003591    000001e1     wisun_tasklet.o (.rodata.WISUN_ROOT_CERTIFICATE)
    >                   00003fb1    00000003     kde_helper.o (.rodata.wisun_oui)
    >                   0000439c    000000e7     wisun_tasklet.o (.rodata.WISUN_CLIENT_KEY)
    >                   000062bc    0000000f     wisun_tasklet.o (.rodata.str1.1)
    >                   000062e4    0000000c     wisun_tasklet.o (.rodata..L__const.wisun_tasklet_configure_and_connect_to_network.own_cert)
    >                   000062f0    0000000c     wisun_tasklet.o (.rodata..L__const.wisun_tasklet_configure_and_connect_to_network.trusted_cert)
    <                   0002b7e0    000001c6     wisun_tasklet.o (.text.wisun_tasklet_configure_and_connect_to_network)
    <                   0003f20a    0000012a     application.o (.text.nanostack_wisunInterface_configure)
    <                   00043824    00000112     wisun_tasklet.o (.text.wisun_tasklet_clear_stored_certificates)
    <                   000477ee    000000fe     wisun_tasklet.o (.text.wisun_tasklet_add_stored_certificates)
    <                   00049638    000000f6     wisun_tasklet.o (.text.wisun_tasklet_parse_network_event)
    <                   0004a292    000000f2     wisun_tasklet.o (.text.wisun_tasklet_connect)
    <                   00069924    0000007e     wisun_tasklet.o (.text.wisun_tasklet_main)
    <                   000699a2    0000007e     wisun_tasklet.o (.text.wisun_tasklet_statistics_do_start)
    <                   0007217c    00000066     wisun_tasklet.o (.text.wisun_tasklet_statistics_start)
    <                   000731e0    00000062     icmpv6.o (.text.icmpv6_na_wisun_aro_handler)
    <                   000739ea    00000062     wisun_tasklet.o (.text.wisun_tasklet_network_init)
    <                   000762fe    0000005a     application.o (.text.nanostack_wisunInterface_connect)
    <                   0007b192    0000004e     application.o (.text.nanostack_wisunInterface_bringup)
    <                   00082bc8    0000003c     wisun_tasklet.o (.text.wisun_tasklet_init)
    <                   000862ac    00000030     wisun_tasklet.o (.text.wisun_tasklet_network_state_changed)
    >                   0002ba00    000001c6     wisun_tasklet.o (.text.wisun_tasklet_configure_and_connect_to_network)
    >                   0003f42a    0000012a     application.o (.text.nanostack_wisunInterface_configure)
    >                   00043a44    00000112     wisun_tasklet.o (.text.wisun_tasklet_clear_stored_certificates)
    >                   00047a0e    000000fe     wisun_tasklet.o (.text.wisun_tasklet_add_stored_certificates)
    >                   00049858    000000f6     wisun_tasklet.o (.text.wisun_tasklet_parse_network_event)
    >                   0004a4b2    000000f2     wisun_tasklet.o (.text.wisun_tasklet_connect)
    >                   00069bfc    0000007e     wisun_tasklet.o (.text.wisun_tasklet_main)
    >                   00069c7a    0000007e     wisun_tasklet.o (.text.wisun_tasklet_statistics_do_start)
    >                   00072454    00000066     wisun_tasklet.o (.text.wisun_tasklet_statistics_start)
    >                   000734b8    00000062     icmpv6.o (.text.icmpv6_na_wisun_aro_handler)
    >                   00073cc2    00000062     wisun_tasklet.o (.text.wisun_tasklet_network_init)
    >                   000765d6    0000005a     application.o (.text.nanostack_wisunInterface_connect)
    >                   0007b46a    0000004e     application.o (.text.nanostack_wisunInterface_bringup)
    >                   00082ea0    0000003c     wisun_tasklet.o (.text.wisun_tasklet_init)
    >                   00086584    00000030     wisun_tasklet.o (.text.wisun_tasklet_network_state_changed)
    <                   200108ec    00000004     wisun_tasklet.o (.data.mac_api)
    <                   20010950    00000004     wisun_tasklet.o (.data.statistics)
    <                   20010960    00000004     wisun_tasklet.o (.data.wisun_certificates_ptr)
    <                   20010964    00000004     wisun_tasklet.o (.data.wisun_tasklet_data_ptr)
    <                   200109c6    00000001     wisun_tasklet.o (.data.statistics_started)
    >                   20010a04    00000004     wisun_tasklet.o (.data.mac_api)
    >                   20010a68    00000004     wisun_tasklet.o (.data.statistics)
    >                   20010a78    00000004     wisun_tasklet.o (.data.wisun_certificates_ptr)
    >                   20010a7c    00000004     wisun_tasklet.o (.data.wisun_tasklet_data_ptr)
    >                   20010ade    00000001     wisun_tasklet.o (.data.statistics_started)
    < 00002eda  WISUN_CLIENT_CERTIFICATE
    < 0000436c  WISUN_CLIENT_KEY
    < 00003561  WISUN_ROOT_CERTIFICATE
    > 00002f0a  WISUN_CLIENT_CERTIFICATE
    > 0000439c  WISUN_CLIENT_KEY
    > 00003591  WISUN_ROOT_CERTIFICATE
    < 0007b193  nanostack_wisunInterface_bringup
    < 0003f20b  nanostack_wisunInterface_configure
    < 000762ff  nanostack_wisunInterface_connect
    > 0007b46b  nanostack_wisunInterface_bringup
    > 0003f42b  nanostack_wisunInterface_configure
    > 000765d7  nanostack_wisunInterface_connect
    < 00003f81  wisun_oui
    < 0004a293  wisun_tasklet_connect
    < 00082bc9  wisun_tasklet_init
    < 000739eb  wisun_tasklet_network_init
    < 0007217d  wisun_tasklet_statistics_start
    > 00003fb1  wisun_oui
    > 0004a4b3  wisun_tasklet_connect
    > 00082ea1  wisun_tasklet_init
    > 00073cc3  wisun_tasklet_network_init
    > 00072455  wisun_tasklet_statistics_start
    < 00002eda  WISUN_CLIENT_CERTIFICATE
    < 00003561  WISUN_ROOT_CERTIFICATE
    < 00003f81  wisun_oui
    < 0000436c  WISUN_CLIENT_KEY
    < 0003f20b  nanostack_wisunInterface_configure
    < 0004a293  wisun_tasklet_connect
    < 0007217d  wisun_tasklet_statistics_start
    < 000739eb  wisun_tasklet_network_init
    < 000762ff  nanostack_wisunInterface_connect
    < 0007b193  nanostack_wisunInterface_bringup