DHCP报错ffffffff,可能是因为内存不足?[WIFI-2436]

XHYZN_Marshall
Posts: 35
Joined: Mon May 25, 2020 2:12 am

DHCP报错ffffffff,可能是因为内存不足?[WIFI-2436]

Postby XHYZN_Marshall » Mon May 25, 2020 2:23 am

020-05-23 22:19:04:795-< [0;32mI (13998124) Wi-Fi: heap_size=118816[0m

2020-05-23 22:19:05:043-< I (13998334) wifi: new:<1,1>, old:<1,1>, ap:<1,1>, sta:<1,1>, prof:1
I (13998334) wifi: station: c8:2b:96:b9:7a:3c join, AID=1, bgn, 40U
D (13998344) event: SYSTEM_EVENT_AP_STACONNECTED, mac:c8:2b:96:b9:7a:3c, aid:1[0m
[0;32mI (13998344) Wi-Fi:
*********SYSTEM_EVENT_AP_STACONNECTED*********
[0m
[0;32mI (13998354) Wi-Fi: station:c8:2b:96:b9:7a:3c join, AID=1[0m

2020-05-23 22:19:05:164-< dhcps: handle_dhcp-> receive a packet
dhcps: handle_dhcp malloc_len=548 rx_len=308dhcps: handle_dhcp-> p->tot_len = 308
dhcps: handle_dhcp-> p->len = 308
01 01 06 00 cc c7 c6 a4 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 c8 2b 96 b9
7a 3c 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 63 82 53 63
35 01 01 39 02 05 dc 0c 09 65 73 70 72 65 73 73
69 66 37 0c 01 03 1c 06 0f 2c 2e 2f 1f 21 79 2b
ff 00 00 00 00 00
2020-05-23 22:19:05:320-< 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 dhcps: handle_dhcp-> parse_msg(p)
dhcps: len = 68
dhcps: (s16_t)*optptr = 53
dhcps: (s16_t)*optptr = 57
dhcps: (s16_t)*optptr = 12
dhcps: (s16_t)*optptr = 55
dhcps: (s16_t)*optptr = 255
dhcps: DHCPD_STATE_OFFER
dhcps: return s.state = 1
dhcps: xid changed
dhcps: client_address.addr = 20aa8c0
dhcps: handle_dhcp-> DHCPD_STATE_OFFER
udhcp: send_offer>>p->ref = 1
dhcps: send_offer>>pbuf_alloc succeed
dhcps: send_offer>>p->tot_len = 548
dhcps: send_offer>>p->len = 548
02 01 06 00 cc c7 c6 a4 00 00 80 00 00 00 00 00
c0 a8 0a 02 00 00 00 00 00 00 00 00 c8 2b 96 b9
7a 3c 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 63 82 53 63
35 01 02 01 04 ff ff ff 00 33 04 00 06 97 80 36
04 c0 a8 0a 01 03 04 c0 a8 0a 01 06 04 c0 a8 0a
01 1c 04 c0 a8 0a ff 1a 02 05 dc 1f 01 00 2b 06
01 04 00 00 00 02 ff 00 00 00 00 00 00 00 00 00
00 00 0
2020-05-23 22:19:05:467-< 0 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 [0;32mI (13998604) UART1: ESP->MCU:Get Date_time
[0m
dhcps: send_offer>>udp_sendto result ffffffff
udhcp: send_offer>>free pbuf

当前模式是STA+AP模式。

上面是Debug,可见在第二个步骤OFFER时,通过UDP发送提示udp_sendto result ffffffff

值得注意的是,出现此现象的时候,heap的大小仍有118816字节;并且在此过程中,还有另外一个UDP正在向外广播数据,并且UDP偶尔报错 errno 12。

这种现象导致了其他STA再也无法连接上这个AP了,只有重启才能够重新连接上。

此现象的复现过程是:这个ESP32频繁连接断开一个目标路由器,并且有另一个STA频繁连接断开这个STA。

问题:1、出现这个问题的可能原因有哪些?2、heap空间大小是足够的,但是UDP偶尔报错12提示内存不足,是否是因为heap分为了几个区域,虽然总的大小有118816字节,但是实际上留给UDP或者DHCP使用的已经不足?

问题困扰多时,影响项目进度,感谢支持!

XHYZN_Marshall
Posts: 35
Joined: Mon May 25, 2020 2:12 am

Re: DHCP报错ffffffff,可能是因为内存不足?

Postby XHYZN_Marshall » Wed Jun 03, 2020 2:47 am

Can any body help me?

ESP_Alvin
Posts: 129
Joined: Thu May 17, 2018 2:26 am

Re: DHCP报错ffffffff,可能是因为内存不足?[WIFI-2436]

Postby ESP_Alvin » Wed Jun 03, 2020 2:56 am

Moderator's note: edit the topic title for issue tracking, thanks for reporting.

ESP_Alvin
Posts: 129
Joined: Thu May 17, 2018 2:26 am

Re: DHCP报错ffffffff,可能是因为内存不足?[WIFI-2436]

Postby ESP_Alvin » Wed Jun 03, 2020 2:58 am

Hi XHYZN_Marshall

感谢反馈,是否可以提供下 elf, sdk configuration, backtrace, log outputs, commit ID, hardware 等信息,以便我们能够解决问题,谢谢。

XHYZN_Marshall
Posts: 35
Joined: Mon May 25, 2020 2:12 am

Re: DHCP报错ffffffff,可能是因为内存不足?[WIFI-2436]

Postby XHYZN_Marshall » Wed Jun 03, 2020 3:12 am

ESP_Alvin wrote:
Wed Jun 03, 2020 2:58 am
Hi XHYZN_Marshall

感谢反馈,是否可以提供下 elf, sdk configuration, backtrace, log outputs, commit ID, hardware 等信息,以便我们能够解决问题,谢谢。
感谢回复。后来经我们追踪,发现根源在于以下函数返回了-1.
int esp_wifi_internal_tx(wifi_interface_t wifi_if, void *buffer, uint16_t len);

这个函数是UDP的发送函数send_to()最终调用的最底层的函数,我们无法看到函数的定义,无法看到具体实现过程。我们想知道,为什么它会返回-1呢?很关键的一个信息是,整个测试过程我们每1秒都会打印一次heap的可用size,每次都有100+KB可用。

xiehang
Posts: 26
Joined: Mon Mar 18, 2019 8:57 am

Re: DHCP报错ffffffff,可能是因为内存不足?[WIFI-2436]

Postby xiehang » Wed Jun 03, 2020 7:48 am

int esp_wifi_internal_tx(wifi_interface_t wifi_if, void *buffer, uint16_t len);
这个函数返回 -1 有两种情况:
1, tx data 类型的 buf 申请失败。(剩余内存不够 或者 tx data 类型的buf 配置的最大数目 buf 都被使用了)
2,txq 为空。
请告知我一下信息,以方便我分析处理这问题:
1,你使用的 IDF 版本号 和 WiFi firmware version
2,提供一份 完整的 log
3,sdkconfig
4,复现方法

XHYZN_Marshall
Posts: 35
Joined: Mon May 25, 2020 2:12 am

Re: DHCP报错ffffffff,可能是因为内存不足?[WIFI-2436]

Postby XHYZN_Marshall » Wed Jun 03, 2020 9:35 am

xiehang wrote:
Wed Jun 03, 2020 7:48 am
int esp_wifi_internal_tx(wifi_interface_t wifi_if, void *buffer, uint16_t len);
这个函数返回 -1 有两种情况:
1, tx data 类型的 buf 申请失败。(剩余内存不够 或者 tx data 类型的buf 配置的最大数目 buf 都被使用了)
2,txq 为空。
请告知我一下信息,以方便我分析处理这问题:
1,你使用的 IDF 版本号 和 WiFi firmware version
2,提供一份 完整的 log
3,sdkconfig
4,复现方法
1.IDF V3.3.1。WiFi firmware version应该如何查看?

2.请详见附件

3.请详见附件
Log开启了IP DEBUG和PBUF DEBUG 以及UDP DEBUG。 在第283371行(运行了132分钟时),开始出现UDP报errno 12.在290699行(运行了136分钟时),最后一次成功为STA分配IP地址。 从292595行开始,被其他STA连接后都无法正常分配IP地址。在本帖子的正文中有出现过“dhcps: send_offer>>udp_sendto result ffffffff”的LOG,在这份LOG被关闭了DHCP DEBUG。但是现象复现时,确实会持续显“dhcps: send_offer>>udp_sendto result ffffffff”

4.复现方法:需要两个ESP32,其中一个称为ESP32_SERVER,另一个称为ESP32_CLIENT。出现问题的是ESP32_SERVER。ESP32_SERVER开启AP+STA模式并且稳定通电。ESP32_SERVER作为STA的角色,连接一个路由器,此路由器会65秒开10秒关循环,用于测试断网重连功能;同时ESP32_SERVER作为AP的角色,被ESP32_CLIENT的STA连接,ESP32_CLIENT是50秒开10关循环,ESP32_CLIENT每次上电会自动连接ESP32_SERVER的AP。在整个过程中,ESP32_SERVER一直通电,并且会以2.5秒的频率向外UDP广播一个16字节的数据包。大约90分钟后开始出现问题。



另外关于返回-1的原因, tx data 类型的 buf 申请失败(剩余内存不够),这里的内存是指stack还是heap?如果是heap的话,现象复现时heap的可用大小仍有100+KB。

再次感谢!
Attachments
20200528135607-Log.txt
(9.5 MiB) Downloaded 377 times
sdkconfig.txt
sdkconfig
(17.34 KiB) Downloaded 388 times

xiehang
Posts: 26
Joined: Mon Mar 18, 2019 8:57 am

Re: DHCP报错ffffffff,可能是因为内存不足?[WIFI-2436]

Postby xiehang » Wed Jun 03, 2020 12:43 pm

感谢您的反馈,请在提供一份 ESP32 clien 端的log 给我。
我想确定下 ESP32 softap 是其他设备在也连接不上,还是 其他设备连接上之后获取不到 ip 地址。

如果是 其他设备连接上之后获取不到 ip 地址,可以给我提供一份打开 DHCP DEBUG 的log 吗?

XHYZN_Marshall
Posts: 35
Joined: Mon May 25, 2020 2:12 am

Re: DHCP报错ffffffff,可能是因为内存不足?[WIFI-2436]

Postby XHYZN_Marshall » Thu Jun 04, 2020 1:52 am

xiehang wrote:
Wed Jun 03, 2020 12:43 pm
感谢您的反馈,请在提供一份 ESP32 clien 端的log 给我。
我想确定下 ESP32 softap 是其他设备在也连接不上,还是 其他设备连接上之后获取不到 ip 地址。

如果是 其他设备连接上之后获取不到 ip 地址,可以给我提供一份打开 DHCP DEBUG 的log 吗?
你好,是连接上之后获取不到IP,且此时拿其他手机去连接,也连接不上一直卡在正在获取IP。并且除非ESP32 SoftAP重启,否则将会一直无法分配IP给STA。

这个问题在论坛其他人也有遇到过,viewtopic.php?f=13&t=15907

附件1.ESP32 client的log(注意这份Log里面的DHCP Debug是DHCP Server的debug)在146485行(22:28:05)的连接就开始无法获取到IP了。
20200523182631-LogClient.txt
(7.29 MiB) Downloaded 375 times
附件2.ESP32 Server的含有DHCP DEBUG的log,但没有UDP Debug和PBUF Debug等。在144375行开始的连接就无法分配IP了。
20200523182625-Log_ServerDHCPDebug.txt
(5.91 MiB) Downloaded 394 times

xiehang
Posts: 26
Joined: Mon Mar 18, 2019 8:57 am

Re: DHCP报错ffffffff,可能是因为内存不足?[WIFI-2436]

Postby xiehang » Thu Jun 04, 2020 8:59 am

我在申请内存的地方添加了一些打印,你可以帮我在复现下这个问题吗
使用方法:
把 2020-06-04_164108.zip 解压,把 2020-06-04_164108/esp32 目录下所有 .a 文件放到 esp-idf/components/esp32/lib 目录下就可以。
Attachments
2020-06-04_164108.zip
(961.57 KiB) Downloaded 371 times
2020-06-04_164108.zip
(961.57 KiB) Downloaded 349 times
2020-06-04_164108.zip
(961.57 KiB) Downloaded 360 times

Who is online

Users browsing this forum: No registered users and 5 guests