-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
samd: Support WiFi using external esp32 based modules. #11219
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
Conversation
Code size report:
|
The Wifi support by MicroPython is in PR micropython#11219. The board files can be used for both Adafruit Metro M4 variants.
Codecov Report
@@ Coverage Diff @@
## master #11219 +/- ##
=======================================
Coverage 98.38% 98.38%
=======================================
Files 158 158
Lines 20900 20900
=======================================
Hits 20563 20563
Misses 337 337 |
The Wifi support by MicroPython is in PR micropython#11219. The board files can be used for both Adafruit Metro M4 variants.
db45d14
to
ea84b9c
Compare
The Wifi support by MicroPython is in PR micropython#11219. The board files can be used for both Adafruit Metro M4 variants.
fa3dea3
to
6556485
Compare
@dpgeorge I hope I have implemented all of your suggestions right. The last commit tries to add variant support. Although it's SSL which weighs a lot. |
The Wifi support by MicroPython is in PR micropython#11219. The board files can be used for both Adafruit Metro M4 variants.
The Wifi support by MicroPython is in PR micropython#11219. The board files can be used for both Adafruit Metro M4 variants.
179bb9e
to
6109903
Compare
The Wifi support by MicroPython is in PR micropython#11219. The board files can be used for both Adafruit Metro M4 variants.
689bf70
to
62c95f0
Compare
@dpgeorge I reordered the commits into generic and samd-specific ones. |
40a92a9
to
9f059e0
Compare
Rebased to the actual master with external flash support. There is just one variant now, |
Just a rebase and update after modules lost their "u". |
Yes and with same results more or less, enabling IRQ on both pins at this point just results in more unnecessary polling. |
OK, For MIMXRT and SAMD it makes a big difference, so I keep it there. The amount of unneccessary polling seems minor. But there are sequence where several SPI tansfers happen with dataready low. I kept the periodic polling at 128ms, since for any immediate response polling is triggered by the IRQ. I do not know if you changed the polling time. |
Those are all of the changes I have here #12490
If there's anything to read DATAREADY will be high already and spi_transfer will reschedule the poll as long as it's high. |
With all relevant changes from #12490 to esp_hosted_hal.c applied, the figures are the same as with the dual IRQ, under the varying environmental situation. The traffic pattern at the wires looks comparable. I did not lower the polling rate. I see that you still have support for a WiFi LED, if enabled. |
Yes it should be the same, but this doesn't require configuring the second pin. I think this is the max it can do, I'm running the SPI clock at 25MHz, unless there's something to optimize at the firmware side.
Yes it's a very good indicator, it blinks much faster when running iperf, also the IRQ pin is now configured in board config files. |
After some testing I made a small change to
|
Yes I noticed it needs a small delay when doing repeated transfers, but I feel those minor fixes here and there will only get us so far, there's a bottleneck somewhere that's capping the TCP performance. |
This change is not about speed, it is about reliability. In my local LAN, ping should always succeed with a small variation of response times. That's what troubled me. The other figures are fine. 10µs delay: Ping times ~10ms to sometimes >500ms, ~2% loss. |
No problem, I can add it to the PR. |
On a related topic: reducing the wait time in the polling loops of |
Feel free to fix it in your PR 👍🏼 |
Of course. I'm still not sure whether I should keep the new NINAW10 interface or just require the wiring to be fixed in the respective mpconfigboard.h files. |
I did, but changed the approach using the esp_hosted style of esp_hosted_hal.c, by declaring the functions in nina_wifi_bsp.c as |
Those are good changes, thank you! |
BTW was able to get a higher throughput by increasing lwip's memory (SND_BUF etc..) but it takes a lot of memory:
The thing to note is, seems the cap is ~8 Mbits/sec. |
I know that the LWIP settings are a dial to turn, but the increase is slow. You spend a lot of memory for a little bit higher speed. For the 8Mbit limit you should look into the net SPI transfer pattern. At the SAMD51 I see a short break between blocks of each 3 bytes, reducing already the net SPI transfer speed e.g. from 8Mbit to ~5.5MBit. |
Actually I see significant throughput increase with bigger SND_BUF + MTU etc.. even with CYW43, the defaults in MicroPython are too low and cause a lot of fragmentation (I guess the assumption is you wouldn't be sending large packets normally like iperf does). BTW I also tested CYW43/RPI Pico_W (SPI mode) with the same LWIP config I use in my PR, and receiving is very good:
For some reason the esp_hosted RX is always half the TX. |
From what I observed, it's a matter of the MCU type. For SAMD and MIMXRT I have ports with both NINAW10 and esp_hosted. With SAMD, RX is the same as TX, with MIMXRT RX is half of TX, no matter whether the NINA or esp_hosted variant runs. I do not know why. |
Good Morning Ibrahim. Since your changes to esp_hosted are now merged, I try to pull up the respective SAMD and MIMXRT branches. There seems to be a problem with calling esp_hosted_hal_deinit(), which is called with esp_hosted_hal_init(), but not on a soft reset, unless bluetooth was enabled. But calling esp_hosted_hal_deinit() is required to call esp_hosted_wifi_deinit(). I used to have that in main.c, but it is not called in the C33 main.c. Edit: b.t.w. At the end of your esp_hosted_hal.c, it still reads: |
I'm not sure I fully understand the issue, in C33 WiFi is not deinitialized on soft-reset, unless Bluetooth was used, in that case BTW, did you manage to build the esp_hosted firmware ? If you did, can you please share steps to building the firmware ? I saw some recent changes that may improve the performance, but also wanted to try to increase SPI TX/RX buffers see if it helps. I have IDF 5+ and tried to build it, but I think our sdkconfig.defaults is not actually a defaults file, and the build just keeps reverting to default sdkconfig (with |
I have to disable WiFi, because otherwise there are some dangling net events which cannot be handled since SPI is gone. No problem. I have indeed built the esp_hosted firmware to change the pins for the interface signals. I went through the IDF-config session using |
Will give it a try, thank you! |
b.t.w: I made a small change to mp_bluetooth_hci_controller_init() to shorten the BLE start-up time. Nothing urgen or ciritcal t, so it can wait until the support for the respective port is merged, or if there are anyhow changes to be made.
|
Actually I think this was required because the bootloader's verbose debugging is enabled (at least in the firmware that ships with C33), which is very annoying. |
The esp_hosted variant works very well now. With the combination of a Teensy 4.0 and a Adafruit ESP32 breakout board I get with iperf3 3.4 MBit/s for TCP and 6.2 MBit/s for UDP, with SPI at 8Mbit/s! |
That's great news, close to the official benchmarks on ESP32. |
I have a question about the macro |
The CS pin, you asked for this pin to not be changed on deinit. |
Such like the u.blox W102, Adafruit Airlift products or just any ESP32 based hardware. The ESP32-WROOM with at least 2MB flash module is sufficient. The actual firmware support full WiFi with SSL on boards with a SAMD51x19 MCU external flash and basic WiFi without SSL for SAMD51x19 boards with the file system in internal flash. SAMD21x18 boards with external flash could as well provide basic WiFi.
The build was tested using the test script and performs identical to the Arduino Nano 2040 connect, which is not a surprise. The PR includes documentation.
For providing the firmware binaries requires required for the ESP32 modules I have made PR to micropython-lib in the espflash path. It seemed to be the best place for it.
This extension is based on the great work of @iabdalkader with the network_ninaw10 package and his support during the implementation.