libretiny-eu / libretiny

PlatformIO development platform for IoT modules
http://docs.libretiny.eu/
MIT License
382 stars 55 forks source link

LT 1.5.0 crashes with "RTL8195A Hard Fault Error" after WiFi scan #257

Closed hn closed 4 months ago

hn commented 4 months ago

LT 1.5.0 crashes on EMW3080 (RTL8710BN clone) as reported here: https://github.com/hn/ginlong-solis/issues/22

LT 1.4.1 works fine on this MCU.

The crash is caused by https://github.com/libretiny-eu/libretiny/commit/1d80b5fff72cc31cba49f54fe7dd56357842031a from https://github.com/libretiny-eu/libretiny/pull/226 (checked by adding (cherry-picking) only this patch to 1.4.1 -> MCU crashes).

kuba2k2 commented 4 months ago

@szupi-ipuzs Something broke, I think. I will try to find the source of the issue.

kuba2k2 commented 4 months ago

Here is the modified Realtek WiFi code. It seems that scanAlloc() returns the amount of allocated items, then the Realtek code tries to assign to the last item. The index in [] is wrong though, it tries to assign to one item past the last one.

Can you try adding last--; right after the if() that checks if the allocation succeeded? That should fix the issue.

hn commented 4 months ago
rtl87xx:
  board: generic-rtl8710bx-4mb-980k
  framework:
    version: 0.0.0
    source: https://github.com/hn/libretiny#fix-257-wifi-scan

Et voilà ... it works :) MCU boots flawlessly with Version: v1.5.0+sha.72d46c9 on generic-rtl8710bx-4mb-980k

kuba2k2 commented 4 months ago

PRs are welcome :)

Also, since you're using the generic BX version in your project, we can add that EMW board natively to LibreTiny. It could even have its own flash layout and pinout drawing to best match that board.