-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
ports/mimxrt: Add CYW43 WiFi/BT support. #11397
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
6305b1e
to
3ef81e6
Compare
bce47d4
to
5be548e
Compare
@dpgeorge WiFi is almost ready I think, most of the networking tests pass, however it doesn't seem to work very well with OOB IRQ ( However I'm more concerned with Bluetooth, it doesn't work at all because Unrelated question, why is the ticks management in this port so complex ? Why use a GPT timer at all to manage ticks, delay etc.. and not just use the systick like in Networking tests (note this port doesn't have cert validity checks):
|
That's a question for @robert-hh |
I had seen the question but thought it was about the STM32 port. If we are talking about ticks.c: that existed when Philipp and me started with the MIMXRT port, and I kept is as it is. But it is a good timing source for µs resolution. It is well made (by @dpgeorge, as git tells), not overly complicated. The calls to the NXP lib look a little bit bulky. |
Yes I was referring to |
systick is not suitable for the ticks_us() part, because it has just a ms resolution. ticks.c could be simplified. The ticks_delay_us64() with ticks_wake_after_us32() part may not be needed. But it's working, and as such it follows the rule "if it ain't broken, don't fix it". The GPT timers are not used for anything else. I used them initially for the timer class, but moved that to SoftTimer. |
I was not going to try to fix anything, just pointing out that there's room for improvement, I'm mainly concerned with WiFi/BT support right now, but you know that rule doesn't really apply here, code changes all the time to improve time/space complexity, even if it's to save a few bytes. |
@dpgeorge I think the bluetooth issue might actually be faulty hardware or a power supply issue with the evk/breakout I'm using, I will get prototypes of the actual hardware next week and will retest Bluetooth. In the meantime, I think Regarding the OOB issue, it was actually one of those reads failing and locking up the bus, I've now added code to clear the error after failure, and it works normally now just like the SDIO interrupt mode. Just a thought, it might be valuable to write a porting guide for the driver at some point. static void cyw43_kso_set(cyw43_int_t *self, int value) {
// these can fail and it's still ok
cyw43_write_reg_u8(self, BACKPLANE_FUNCTION, SDIO_SLEEP_CSR, write_value);
cyw43_write_reg_u8(self, BACKPLANE_FUNCTION, SDIO_SLEEP_CSR, write_value);
`` |
48ef7e6
to
88d5ac3
Compare
@dpgeorge Do we have to switch the CTS pin to GPIO in One more question, I tested WiFi with a 25MHz initial clock and enumeration, firmware loading etc.. everything seems to work fine at 25MHz, I'm wondering if the initial 400KHz clock is really required ? It makes a big difference in boot time. |
0a96558
to
0748f0f
Compare
@robert-hh I noticed that the processor doesn't wake up from cyw43_do_ioctl (self=self@entry=0x2000779c <cyw43_state>, kind=kind@entry=2, cmd=cmd@entry=263, len=len@entry=1560,
buf=buf@entry=0x200077d4 <cyw43_state+56> "clmload", iface=iface@entry=0) at ../../lib/cyw43-driver/src/cyw43_ll.c:1223
1223 CYW43_DO_IOCTL_WAIT; |
You may have found the reason for a long standing issue in the mimxrt port, in that WFI() was not interrupted by systick. That may have been one reason why ticks.c was implemented this way with the compare IRQ on the GPT. The other reason is µs-precision for delays. Just the ticks_ms_upper counter & handling is a little bit of over-engineering. |
Yeah but I had to get a few things in order first, mainly |
b.t.w. Which board do you use for testing? I looked back into the various PR about the WFI()/WFE() topic, and it seems only remained for the 117x MCU. |
MIMXRT1060-EVKB |
607597d
to
d076e70
Compare
Final update, WiFi and Bluetooth are both working fine now, see test results below, although for BT nothing above 115200 is reliable, since there's no hardware flow control support in Bluetooth
WiFi
|
d076e70
to
5f30732
Compare
@dpgeorge Maybe this one can be merged too ? Possibly after the next release, but it's not as invasive as it seems. |
04f2d4e
to
1778e27
Compare
523c534
to
ea55695
Compare
Are we any closer to resolving the pending conversations here ? |
ea55695
to
c474158
Compare
c474158
to
e4bfc88
Compare
I tested this on PYBD-SF2/SF6 with the BLE multitests, and it works. |
Add portable pin config macros to mphalport.h. And add a function to configure pins with more pin options such as alt function, pull, speed, drive, interrupt mode, etc. Note: this new `machine_pin_config()` function can replace `machine_pin_set_mode()`, but the latter is left as-is to avoid breaking anything. Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
This is a basic SDIO driver for the mimxrt port, that was added mainly to support the CYW43 WiFi driver, and as such it only supports the commands required by the CYW43 driver (but more commands can be added easily). The driver performs non-blocking DMA transfers, and can detect and recover from errors. Note: because the mimxrt port is missing static alternate functions, named pins and other pin related functions, currently the alternate functions for USDHC 1 and 2 are hard-coded in the driver. Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
This commit adds the necessary configuration and hooks to get the CYW43 driver working with the mimxrt port. Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
This commit adds the necessary functions to get NimBLE working with the mimxrt port. Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
This commit allows other ports to reuse the CYW43 HCI driver, by replacing all Bluetooth UART and control named pins with defines in config files and using `mpbthci` abstract functions (i.e. `mp_bluetooth_hci_*`) instead of the STM32 specific UART functions. Note: the function `cywbt_wait_cts_low` does not need to switch the CTS pin from alternate function to GPIO to read it. At least on stm32, mimxrt it's possible to just read the pin input. For example, see the STM32F7 RM0410 section 6.3.11, and the `SION` for IMXRT. So this function can also be available for other ports if the pin mode switching is removed. Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
Following other ports, IRQ priorities and related functions are moved to their own header, to simplify mpconfigport.h. Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
e4bfc88
to
3f5976e
Compare
@iabdalkader I agree these points can be improved (but they were not necessary to get this PR merged). Feel free to have a go at fixing them, otherwise I'll eventually get to them. |
Well at least now the driver is usable by other ports so it should be fine for now, but may get around to it. For the first point, adding Are there any plans (or reasons not) to move |
We can do that. It changes the licensing but I don't think there's really a problem with that. Would be neater to keep everything in lib/cyw43-driver. (Also rp2 uses a completely different BT backend, but again that doesn't impact moving this file there.) |
Following-up on this, I moved |
This is a work in progress, attempt at adding CYW43 WiFi/BT support to
ports/mimxrt
, starting with WiFi first and Bluetooth will follow when this is working.