-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
RP2: Add ublox Nina-W10 WiFi/BT module driver. #7668
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
d37baa4
to
840bae9
Compare
Thanks for this, there's a lot of work here and it's a really good addition. Some initial questions:
|
Yes this is 100% written from scratch all of it,
I thought about that initially too, it may be able to support something like a bypass mode but I think it will require a different firmware to so. That said, this driver is mainly for the Nano RP2040 which ships with this firmware which is also used by other Arduino boards (and I think some of Adafruits boards use it as well not sure) so this driver is needed for these boards to support WiFi out of the box. Maybe at some point in the future we can add support for lwip firmware too and make it configurable. |
Renamed all constants in question to their actual respective functions, and removed some unused ones. |
Codecov Report
@@ Coverage Diff @@
## master #7668 +/- ##
==========================================
- Coverage 98.25% 98.25% -0.01%
==========================================
Files 154 154
Lines 20071 20071
==========================================
- Hits 19721 19720 -1
- Misses 350 351 +1
Continue to review full report at Codecov.
|
ff7cff7
to
cb8a125
Compare
Cleaned up and rebased also moved RP2 port support to this PR since it was labeled port-rp2. |
cb8a125
to
d916943
Compare
@dpgeorge Hello, this been ready for a while. |
It would be good to add the new driver code introduced here to the code formatting, like this: --- a/tools/codeformat.py
+++ b/tools/codeformat.py
@@ -35,6 +35,7 @@ import subprocess
# Relative to top-level repo dir.
PATHS = [
# C
+ "drivers/ninaw10/*.[ch]",
"extmod/*.[ch]",
"extmod/btstack/*.[ch]",
"extmod/nimble/*.[ch]", |
I see that the Nina-W10 contains an ESP32 for the WiFi and BT. As such, could the driver here be considered as a generic ESP32
8000
WiFi-BT-coprocessor driver? Eg if I took an ESP32 board and installed the Well, I don't really want to suggest to rename this driver to |
Regarding licensing: I see that https://github.com/arduino/nina-fw is LGPL. So it's really important that no code at all has been taken/copied/adapted from that driver to make the driver here. |
@dpgeorge updated the PR to address all the requested changes.
Yes it should, STM or any other MCU just need to implement the BSP layer. The firmware just turns the ESP32 into an SPI WIFI module (like the WINC1500).
No it's written completely from scratch and has nothing to do with the LGPL driver (which is C++ btw) but it's also not a port in fact it takes a very different approach to how the protocol and var args/values are handled, and it's much more efficient and maintains a higher datarate than the LGPL driver.
Done. |
afb76ae
to
e8b65c2
Compare
* Add WiFi/BT drivers for ublox Nina-W10 (esp32 based) module. * Add ublox Nina-W10 Python module in extmod.
I loaded the Arduino NINA.bin to a generic ESP32, connected it (for simplicity) to a RP2040 Pico with networking enabled, tried WiFi and it works. Thanks to @iabdalkader for making the driver so clean. There is a little bit of confusion between versions. The one from Arduino is 1.4.8, Adafruit points at a version 1.7.4. Both variants are available as source code (GPL 2.1) and binaries. |
I think the firmware from Adafruit is a fork with a (likely) compatible API/protocol. What I know for sure is 1.4.8 fixes a bug in send/recv and that's what you should be using or higher. |
The Arduino Version 1.4.8 works in the same way as with the Arduino Nano connect, which runs art 1.4.5. But using it with my standard set of test programs fails. socket.settimeout(n) responds with |
Yes it may look the same but 1.4.8 fixes a very subtle issue that breaks internal socket state when used in a tight send/recv loop.
The
I run standard basic tests, send/recv, http client, ntp etc... |
I made all further tests with 1.4.8. Some of the trouble comes from trying to use a SOCK_RAW type socket, which seems to be supported by the lwip stack in the NINA firmware, but not in the driver. I tried timeout on a SOCK_DGRAM type socket, which so far worked fine on other ports. Maybe it was simply ignored.
|
Yes lwip stack supports it, but does the firmware allow creating raw sockets ? I'd have to check, but if there's a command to create them we can add support for it, if needed.
I think this behavior is not documented anywhere (I could be wrong), the CYW driver works like that, but right now in my driver in make_new I reset the active flag, so this is intended. I could fix if it's the expected behavior.
This is actually a bug, I can fix it, I return a different error number for time so upper layers fail to detect it, please open issues for this or any other bug/feature mention me and I may have some time to update the driver. |
RAW sockets can be used in all other ports with socket support.
The ESP drivers work that way as well. It may be documented there. I will make further tests and report. Yesterday I had trouble with that litte script below for getting ntptime, which I use since early ESP8266 time on all ports. It fails at least at three steps:
I shortened the initial script a little bit, leaving out the part which sets the RTC. The error comes up when calling ntptime.time()
|
Again to be very clear, in order for me to support RAW socks in this driver, it must be supported by the firmware running on the Nina/ESP32, which does Not seem to provide any commands to handle raw socks. I'd raise this issue with Arduino/Adafruit.
I'm not sure if it's intended that WLAN maintains its state or they just assume you'd call it once, either way is fine by me. You can send a PR to fix that if you like and we'll discuss it there. This line just needs to be removed: https://github.com/micropython/micropython/blob/master/extmod/network_ninaw10.c#L66 and line 74 where autobind state is reset.
Try this script, it works flawlessly, and it uses a domain name with |
This script works only if the wifi connection happens within the script. If I take that out and connect in a separate script, it fails. So it is related to the other aspect of handling the state of the WiFi connection by instance and not global. In my opinion it is a global property. The need to connect in each module which wants to use WiFi seems strange. And, b.t.w. connecting more than once failed sometimes, sometimes it works. You can try by putting the content of your sample script into a function and calling that repeatedly. As for recv() and recvfrom(). I looked up at various sources. Even if is seems suggested to use recvfrom() with UDP sockets, I found no place mandating it. Since recvfrom() works, it is more a matter of inconsistency between the various MicroPython ports. |
Alright I'll send a PR to address all these issue. |
Thank you very much. |
Keep in mind that my NTP script in a loop will fail anyway due to this issue: arduino/nina-fw#72 EDIT: The workaround is to not bind the socket at all, and just let the driver auto-bind it for you. |
That's fine. The connection to an AP should happen only once and should be usable until a disconnect. |
document going directly to display with ondiskgif
No description provided.