Other Parts Discussed in Thread: Z-STACK
Hi
I instrumented the ZNP code to detect buffer overruns on the ZNP. See OSAL_Memory.c in the attached ZIP file for the code.
To know when it happens, put a breakpoint on i++ as shown in the screenshot.
The screenshot shows where it happens through the Call stack.
The memory capture shown can also help understand which Zigbee communication caused this, together with the sniffer log.
The serial log is also attached, the serial communication stopped in the extract below:
[2020-11-24 15:27:46.805410] > [ZDO/AREQ] **END_DEVICE_ANNCE_IND** <132F-000d6f000e8a756f> Src:132F (SYS:5/TYPE:40/CMD:C1) ( 18)::fe 0d 45 c1 2f 13 2f 13 6f 75 8a 0e 00 6f 0d 00 80 f5 [2020-11-24 15:27:46.807380] > [ZDO/AREQ] **END_DEVICE_ANNCE_IND** <132F-000d6f000e8a756f> Src:132F (SYS:5/TYPE:40/CMD:C1) ( 18)::fe 0d 45 c1 2f 13 2f 13 6f 75 8a 0e 00 6f 0d 00 80 f5 [2020-11-24 15:27:46.809369] > [ZDO/AREQ] **MSG_CB_INCOMING** (SYS:5/TYPE:40/CMD:FF) ( 25)::fe 14 45 ff 2f 13 01 13 00 00 b2 00 00 2f 13 6f 75 8a 0e 00 6f 0d 00 80 72 [2020-11-24 15:27:46.812482] > [ZDO/AREQ] **MSG_CB_INCOMING** (SYS:5/TYPE:40/CMD:FF) ( 25)::fe 14 45 ff 2f 13 01 13 00 00 b3 00 00 2f 13 6f 75 8a 0e 00 6f 0d 00 80 73 [2020-11-24 15:27:47.691534] 3217 0x132f → 0x0000 IEEE 802.15.4 12 Data Request^M
And the last packet sent by the ZNP heppened somewhat later:
[2020-11-24 15:27:56.758657] 3282 → IEEE 802.15.4 5 Ack^M [2020-11-24 15:27:57.060278] 3283 0xc9a3 → 0x0000 IEEE 802.15.4 12 Data Request^M [2020-11-24 15:27:57.060760] 3284 → IEEE 802.15.4 5 Ack^M [2020-11-24 15:27:57.750243] 3285 0x132f → 0x0000 IEEE 802.15.4 12 Data Request^M [2020-11-24 15:27:57.750741] 3286 → IEEE 802.15.4 5 Ack^M [2020-11-24 15:27:57.759978] 3287 0x0000 → 0x132f ZigBee ZDP 57 Extended Address Response, Status: Success, Nwk Addr: 0x0000 = TexasIns_00:10:22:82:77^M [2020-11-24 15:27:57.760107] 3288 → IEEE 802.15.4 5 Ack^M [2020-11-24 15:27:57.768251] 3289 0x132f → 0x0000 ZigBee ZDP 58 Extended Address Request, Nwk Addr: 0x0000^M [2020-11-24 15:27:57.768373] 3290 → IEEE 802.15.4 5 Ack^M [2020-11-24 15:27:57.772629] 3291 0x132f → 0x0000 ZigBee ZDP 58 Extended Address Request, Nwk Addr: 0x0000^M [2020-11-24 15:27:57.772752] 3292 → IEEE 802.15.4 5 Ack^M [2020-11-24 15:27:57.776888] 3293 0x132f → 0x0000 ZigBee 45 APS: Ack, Dst Endpt: 0, Src Endpt: 0^M [2020-11-24 15:27:57.778522] 3294 → IEEE 802.15.4 5 Ack^M [2020-11-24 15:27:58.756343] 3295 0x132f → 0x0000 IEEE 802.15.4 12 Data Request^M
The ZNP stopped communicating because of the breakpoint.
The method for detecting the overflow/overrun is the following:
1. In osal_mem_alloc reserve 1 extra byte and put a known value in the last byte of the buffer.
2. In osal_mem_free, check the last byte of the buffer. Enter an infinite loop if the value is not the expected value.
I encourage you to do further tests using this method ;-) , and of course share the fixes as soon as possible.
