u-boot_mod icon indicating copy to clipboard operation
u-boot_mod copied to clipboard

Firmware uploading is interrupted randomly by some packets

Open matlinuxer2 opened this issue 2 years ago • 4 comments

Descriptions:

Model: Tube-E4G (code base could be different than the latest upstream) Model info

When I uploaded a firmware smaller than 8MB(ex: Openwrt Tube-E4G image ), the process finished smoothly. But when I tried a larger firmware (ex: Alternative Image listed in ALFA docs site , 8.5MB) It failed often, around 80% failed.

Collected information:

I captured the packets logs with the wireshark. The log file is

2022-05-09_uboot-tube-e4g_analysis.log.pcapng.zip

I attach some screenshots for comparison here:

Failed case: reflash_failed

Success case: reflash_success

It looks like some TCP Dup ACK packets interrupt the process, but don't know what's cause this issue in the background. In my debug instance, the failed case's process didn't enter the block here: https://github.com/pepe2k/u-boot_mod/blob/ad5a2135bdba57454c1fb9fe4d8efd7b04d0cfe5/u-boot/httpd/httpd.c#L497

So far these are all clues I can get for now.

matlinuxer2 avatar May 12 '22 10:05 matlinuxer2

After trace the issue more deeply, I found the root cause is not TCP Dup ACK but the http request length calculation issue. In some cases, it could be hs->upload is greater than hs->upload_total but the http request still not end.

https://github.com/pepe2k/u-boot_mod/blob/ad5a2135bdba57454c1fb9fe4d8efd7b04d0cfe5/u-boot/httpd/httpd.c#L568

The webfailsafe_post_done change and http_state_reset are trigged before the last packet arrived, which blocks the whole process.

To fix this issue, I add a patch to detect the http request end based on Content-Length parameter: https://github.com/matlinuxer2/u-boot_mod/commit/0c655af7bd502f186438ce891a559c95491303aa

I tested it with Tube-E4G and chrome on Linux, not sure it apply to other cases yet. Hope it helps

matlinuxer2 avatar May 17 '22 11:05 matlinuxer2

@matlinuxer2 please, share the binary U-Boot image.

pepe2k avatar May 17 '22 13:05 pepe2k

Hi @pepe2k I attached the tested bootloader below:

bootloader_binaries.zip

I also split my changes into 3 commits, which could be easier to review and filter debug-only parts, commits are here:

https://github.com/matlinuxer2/u-boot_mod/tree/fix_web_failsafe_stall

The captured logs I upload below:

success_firefox.zip failed_firefox.zip patched_firefox.zip failed_chrome.zip success_chrome.zip failed_curl.zip success_curl.zip

matlinuxer2 avatar May 18 '22 21:05 matlinuxer2

I am having problems with connection getting reset, with8MB [1] I can get it working, but with official gl.inet images 50MB it always resets.

Slate AX

[1] https://github.com/coolsnowwolf/openwrt-gl-ax1800

slandden avatar Aug 28 '22 19:08 slandden

Sorry but this project is no longer maintained.

pepe2k avatar Oct 13 '22 10:10 pepe2k