Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed WiFi Manual Connection Crash LoadStoreErrorCause #345

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SergeiSovik
Copy link

libnet80211.a has wrong data placing in section .irom.text, which causes a critical error LoadStoreErrorCause, followed by a exception restart. This fix forces the linker to place data to the DRAM memory and completely eliminates the problem of starting WiFi in manual mode

@kriegste
Copy link

When exactly does this problem occur?

@SergeiSovik
Copy link
Author

SergeiSovik commented Jun 20, 2021

This problem happens on manual wifi_station_connect.
Inside libnet80211.a object file ieee80211_phy.o contains variables ieee80211_11b_table_74 and ieee80211_11g_table_75 defined in wrong section .irom.text. According ESP8266_NONOS_SDK/ld/eagle.app.v6.ld all .irom.text section mapped to flash memory irom0_0_seg (0x40200000+). This memory can be accessed only with 4 byte size and 4 byte aligned read operations. When first manual wifi connect happens, ieee80211_setup_ratetable get called, inside this function at offset 0x37 invalid instruction l8ui a7, a5, 0 (0x72 0x05 0x00) produces crash, by trying to read one byte from ieee80211_11b_table_74.

P.S. Without having source files from libnet80211 this is only one simple way to fix an error

@kriegste
Copy link

Occasionally, I get a LoadProhibited in libphy, but never after wifi_station_connect. I can do wifi_station_connect all day long and nothing bad happens.
Do you have an idea why this happens on some projects and not on others?

@SergeiSovik
Copy link
Author

Because libmain.a setup exception handlers to ignore this kind of fatal errors, as result returns 0 value on read. I'm using custom exception interrupts on my projects.
I think it is not right to ignore such exceptions, because the part of the code conceived by their creators stops working. This means that the functionality is being cut. By handling all exceptions, it becomes possible to detect such bugs and find solutions to fix them.

@kriegste
Copy link

Ok, thanks. I had trouble compiling (section did not fit). Then I used ar to move the .o file you mentioned from libnet to libphy. The stuff in there has to be in RAM anyway. So no touching of the linker files required. Compile was fine and according to nm there are now three new functions in RAM: ieee80211_phy_init, ieee80211_setup_ratetable and ieee80211_phy_type_get. The bin starts, connects und runs ok for hours now. Heap usage is ok. Let's see what happens.

@kriegste
Copy link

Do you know whether the lastest update fixes this problem? libnet80211 was changed and the comment mentions "ratetable".
7a1c97f
Or is your workaround still needed?

@SergeiSovik
Copy link
Author

Do you know whether the lastest update fixes this problem? libnet80211 was changed and the comment mentions "ratetable".
7a1c97f
Or is your workaround still needed?

According to libnet80211 disassembly:

Disassembly of section .irom.text:

00000000 <ieee80211_11b_table_74>:
   0:	0004 0000 0000 0000 0000 0000 0000 0000     ................
	...
  18:	157c 0000 0204 018b 00df 007f 0000 0000     |...............
  28:	2af8 0000 0304 0196 00d5 0075 0000 0000     .*........u.....
  38:	03e8 0000 0000 0082 013a 013a 0000 0000     ........:.:.....
  48:	07d0 0000 0104 0184 0102 00a2 0000 0000     ................
	...

000000d4 <ieee80211_11g_table_75>:
  d4:	000c 0000 0000 0000 0000 0000 0000 0000     ................
	...
  ec:	157c 0000 0204 028b 00df 007f 0000 0000     |...............
  fc:	2af8 0000 0304 0396 00d5 0075 0000 0000     .*........u.....
 10c:	03e8 0000 0000 0082 013a 013a 0000 0000     ........:.:.....
 11c:	07d0 0000 0104 0184 0102 00a2 0001 0000     ................
 12c:	1770 0000 0b00 040c 003c 003c 0001 0000     p.......<.<.....
 13c:	2ee0 0000 0a00 0618 0030 0030 0001 0000     ........0.0.....
 14c:	5dc0 0000 0900 0830 002c 002c 0001 0000     .]....0.,.,.....
 15c:	bb80 0000 0800 0860 002c 002c 0001 0000     ......`.,.,.....
 16c:	d2f0 0000 0c00 086c 002c 002c 0001 0000     ......l.,.,.....
 17c:	2328 0000 0f00 0412 003c 003c 0001 0000     (#......<.<.....
 18c:	4650 0000 0e00 0624 0030 0030 0001 0000     PF....$.0.0.....
 19c:	8ca0 0000 0d00 0848 002c 002c 0000 0000     ......H.,.,.....
 1ac:	0000 0000                                   ....

000001b0 <mem_debug_file_76>:
 1b0:	6569 6565 3038 3132 5f31 6870 2e79 0063     ieee80211_phy.c.

Data objects still sits in wrong place .irom.text
So answering yours question: Yes, its still required

@kriegste
Copy link

Thanks much for the quick reply!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants